OpenLB 1.7
Loading...
Searching...
No Matches
blockCommunicationNeighborhood.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2020 Adrian Kummerlaender, Mathias J. Krause
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 BLOCK_COMMUNICATION_NEIGHBORHOOD_H
25#define BLOCK_COMMUNICATION_NEIGHBORHOOD_H
26
28#include "core/blockStructure.h"
32#include "utilities/aliases.h"
33
34#include <map>
35#include <memory>
36
37namespace olb {
38
39// *INDENT-OFF*
40
41template<typename T> class SuperCommunicationTagCoordinator;
42
44
47template<typename T, unsigned D>
49private:
50 CuboidGeometry<T,D>& _cuboidGeometry;
51 LoadBalancer<T>& _loadBalancer;
52
53 const int _iC;
54 const int _padding;
55
56 std::vector<std::type_index> _fieldsRequested;
57 cpu::sisd::Column<bool> _fieldsAvailable;
58 std::map<int, std::vector<std::type_index>> _fieldsCommonWith;
59
60 std::map<int, std::vector<CellID>> _cellsInboundFrom;
61 std::map<int, std::vector<CellID>> _cellsOutboundTo;
62 std::map<int, std::vector<CellID>> _cellsRequestedFrom;
63
64#ifdef PARALLEL_MODE_MPI
65 MPI_Comm _neighborhoodComm;
66
67 std::map<int, std::unique_ptr<MpiSendRequest>> _fieldRequests;
68 std::map<int, std::unique_ptr<MpiSendRequest>> _cellsRequests;
69#endif
70
71public:
73 , LoadBalancer<T>& loadBalancer
74 , int iC
75 , int padding
76#ifdef PARALLEL_MODE_MPI
77 , MPI_Comm comm
78#endif
79 );
80
82 template <typename FIELD>
83 void requestField() {
84 if (std::find(_fieldsRequested.begin(), _fieldsRequested.end(), typeid(FIELD)) == _fieldsRequested.end()) {
85 _fieldsRequested.emplace_back(typeid(FIELD));
86 _fieldsAvailable.resize(_fieldsRequested.size());
87 }
88 }
90 void requestCell(LatticeR<D> latticeR);
92 void requestOverlap(int width);
94 void requestOverlap(int width, BlockIndicatorF<T,D>& indicatorF);
95
98
100 void setFieldAvailability(std::type_index field, bool available);
102
105 template <typename BLOCK>
106 void setFieldsAvailability(int iC, BLOCK& block);
107
108 void maintain();
109
110#ifdef PARALLEL_MODE_MPI
113 void wait();
114#endif
115
117 template <typename F>
118 void forNeighbors(F f) const {
119 for (const auto& [iC, _] : _cellsRequestedFrom) {
120 f(iC);
121 }
122 }
123
124 const std::vector<std::type_index>& getFieldsCommonWith(int iC) const;
125
126 const std::vector<CellID>& getCellsOutboundTo(int iC) const;
127 const std::vector<CellID>& getCellsInboundFrom(int iC) const;
128 const std::vector<CellID>& getCellsRequestedFrom(int iC) const;
129
130};
131
132// *INDENT-ON*
133
134}
135
136#endif
Configurable overlap communication neighborhood of a block.
void requestOverlap(int width)
Request all cells in overlap of size width for communication.
const std::vector< CellID > & getCellsRequestedFrom(int iC) const
void requestField()
Request field and provides local availability.
const std::vector< CellID > & getCellsOutboundTo(int iC) const
BlockCommunicationNeighborhood(CuboidGeometry< T, D > &cuboidGeometry, LoadBalancer< T > &loadBalancer, int iC, int padding, MPI_Comm comm)
const std::vector< std::type_index > & getFieldsCommonWith(int iC) const
const std::vector< CellID > & getCellsInboundFrom(int iC) const
void setFieldsAvailability(int iC, BLOCK &block)
Update outbound availabilities for locally available neighbor block.
void receive(SuperCommunicationTagCoordinator< T > &)
void clearRequestedCells()
Remove all requested cells.
void requestCell(LatticeR< D > latticeR)
Request individual cell for communication.
void send(SuperCommunicationTagCoordinator< T > &)
void forNeighbors(F f) const
Calls f(iC) for every neighboring cuboid ID iC.
void setFieldAvailability(std::type_index field, bool available)
Update local availability of previously requested field.
Base class for all LoadBalancer.
Communication-free negotation of unique tags for inter-cuboid communication.
Plain old scalar vector.
Definition vector.h:47
Plain column for SISD CPU targets (default)
Definition column.h:45
void resize(std::size_t count)
Definition column.h:78
Top level namespace for all of OpenLB.
std::conditional_t< D==2, CuboidGeometry2D< T >, CuboidGeometry3D< T > > CuboidGeometry
Definition aliases.h:47
std::conditional_t< D==2, BlockIndicatorF2D< T >, BlockIndicatorF3D< T > > BlockIndicatorF
Definition aliases.h:218