OpenLB 1.7
Loading...
Searching...
No Matches
superCommunicator.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2020 Adrian Kummerlaender
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef SUPER_COMMUNICATOR_H
25#define SUPER_COMMUNICATOR_H
26
27#include <set>
28#include <vector>
29#include <algorithm>
30
31#include "mpiManager.h"
32#include "loadBalancer.h"
33#include "blockCommunicator.h"
37
38namespace olb {
39
40
42
52template <typename T, typename SUPER>
54private:
55 SUPER& _super;
56
57#ifdef PARALLEL_MODE_MPI
59 MPI_Comm _neighborhoodComm;
60 MPI_Comm _communicatorComm;
61#endif
62
64 std::vector<std::unique_ptr<BlockCommunicationNeighborhood<T,SUPER::d>>> _blockNeighborhoods;
66 std::vector<std::unique_ptr<BlockCommunicator>> _blockCommunicators;
67
69 std::vector<std::type_index> _fieldsRequested;
71 std::set<int> _remoteCuboidNeighborhood;
72
74 bool _enabled = false;
76 bool _ready = false;
77
78public:
79 SuperCommunicator(SUPER& super);
81
83
87 template <typename FIELD>
88 void requestField() {
89 if (std::find(_fieldsRequested.begin(), _fieldsRequested.end(), typeid(FIELD)) == _fieldsRequested.end()) {
90 _fieldsRequested.emplace_back(typeid(FIELD));
91 for (auto& neighborhood : _blockNeighborhoods) {
92 neighborhood->template requestField<FIELD>();
93 }
94 }
95 }
96
98 template <typename... FIELDS>
100 (requestField<FIELDS>(), ...);
101 }
102
104 void requestCell(LatticeR<SUPER::d+1> latticeR);
106 void requestOverlap(int width);
108 void requestOverlap(int width, FunctorPtr<SuperIndicatorF<T,SUPER::d>>&& indicatorF);
109
111 void clearRequestedCells();
112
114 void exchangeRequests();
115
117 void communicate();
118
120 const std::set<int>& getRemoteCuboids() const;
121
122};
123
124template <typename SUPER>
126
127}
128
129#endif
Smart pointer for managing the various ways of passing functors around.
Definition functorPtr.h:60
Communication-free negotation of unique tags for inter-cuboid communication.
Generic communicator for overlaps between blocks of SUPER.
void communicate()
Perform communication.
void requestFields()
Convenience method for requesting multiple FIELDS in one call.
void requestOverlap(int width)
Request all cells in overlap of width for communication.
const std::set< int > & getRemoteCuboids() const
Returns set of non-local neighborhood cuboid indices.
void clearRequestedCells()
Remove all requested cells.
void requestField()
Request FIELD for communication.
void exchangeRequests()
Exchange requests between processes.
void requestCell(LatticeR< SUPER::d+1 > latticeR)
Request single cell in the padding area for communication.
Plain old scalar vector.
Definition vector.h:47
Wrapper functions that simplify the use of MPI.
Top level namespace for all of OpenLB.
SuperCommunicator(SUPER &) -> SuperCommunicator< typename SUPER::value_t, SUPER >
std::conditional_t< D==2, SuperIndicatorF2D< T >, SuperIndicatorF3D< T > > SuperIndicatorF
Definition aliases.h:208