zoneDistribute.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2020 DLR
9 Copyright (C) 2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::zoneDistribute
29
30Description
31 Class for parallel communication in a narrow band. It either provides a Map
32 with the neighbouring values of the selected region or returns a Map of the
33 required values in global addressing. Also holds a reference to the stencil
34 Before the data transfer the communication has to be set up:
35 exchangeFields_.setUpCommforZone(interfaceCell_);
36 Is used in the plicRDF
37
38 Original code supplied by Henning Scheufler, DLR (2019)
39
40 Additional optimization of processor communication
41 provided by Tetsuo AOYAGI, RIST (2022), to use a more compact
42 exchange of sizes with an updated version of PstreamBuffers.
43 This optimization uses additional sendTo/recvFrom member data
44 to track the topological connectivity, acting like an on-the-fly
45 sub-communicator, and respects corner connectivity.
46
47 -# Initially topological connections are empty (or all false).
48 -# Scan the stencil global cellIds (active zones only) and split
49 into sub-lists according the originating processor (the sender).
50 -# If an originating processor appears/disappears, need to update
51 the connectivity information (requires an all-to-all).
52 -# When possible, the topological send/recv is used in PstreamBuffers
53 finishedSends (minimizes communication).
54 .
55
56SourceFiles
57 zoneDistributeI.H
58 zoneDistribute.C
59
60\*---------------------------------------------------------------------------*/
61
62#ifndef Foam_zoneDistribute_H
63#define Foam_zoneDistribute_H
64
65#include "fvMesh.H"
66#include "globalIndex.H"
67#include "volFields.H"
68
69#include "zoneCPCStencil.H"
70#include "MeshObject.H"
71
72// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
73
74namespace Foam
75{
76
77/*---------------------------------------------------------------------------*\
78 Class zoneDistribute Declaration
79\*---------------------------------------------------------------------------*/
82:
83 public MeshObject<fvMesh, TopologicalMeshObject, zoneDistribute>
84{
85 // Private Data
86
87 //- Reference to the zone stencil
88 zoneCPCStencil& stencil_;
89
90 //- Global number into index of cells/faces
91 const globalIndex& globalNumbering_;
92
93 //- Global cell/face index to send for processor-to-processor comms
94 List<labelList> send_;
95
96 //- Parallel [cache]: send connectivity (true/false)
97 bitSet sendConnections_;
98
99 //- Parallel [cache]: send data to these ranks
100 DynamicList<label> sendProcs_;
101
102 //- Parallel [cache]: recv data from these ranks
103 DynamicList<label> recvProcs_;
104
105
106 // Private Member Functions
107
108 //- Return local volField value at (cell or face) index
109 template<typename Type>
110 Type getLocalValue
111 (
112 const VolumeField<Type>& phi,
113 const label localIdx
114 ) const;
115
116 //- Gives patchNumber and patchFaceNumber for a given
117 //- Geometric volume field
118 template<typename Type>
119 Type faceValue
120 (
121 const VolumeField<Type>& phi,
122 const label localIdx
123 ) const;
124
125
126public:
127
128 //- Runtime information
129 TypeName("zoneDistribute");
130
131
132 // Constructors
133
134 //- Construct from fvMesh
135 explicit zoneDistribute(const fvMesh&);
136
137 //- Selector
138 static zoneDistribute& New(const fvMesh&);
139
140
141 //- Destructor
142 virtual ~zoneDistribute() = default;
143
144
145 // Member Functions
146
147 //- Update stencil with boolList the size has to match mesh nCells
148 void setUpCommforZone(const boolList& zone, bool updateStencil=true);
149
150 //- Updates stencil with boolList the size has to match mesh nCells
151 void updateStencil(const boolList& zone);
152
153 //- Stencil reference
155 {
156 return stencil_;
157 }
158
159 //- Addressing reference
161 {
162 return globalNumbering_;
163 }
164
165 //- Gives patchNumber and patchFaceNumber for a given
166 //- Geometric volume field
167 template<typename Type>
168 Type getValue
169 (
170 const VolumeField<Type>& phi,
171 const Map<Type>& valuesFromOtherProc,
172 const label gblIdx
173 ) const;
174
175 //- Returns stencil and provides a Map with globalNumbering
176 template<typename Type>
178 (
179 const boolList& zone,
181 );
182
183 //- Returns stencil and provides a Map with globalNumbering
184 template<typename Type>
186 (
187 const boolList& zone,
189 );
190};
191
192
193// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194
195} // End namespace Foam
196
197// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198
199// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200
201#ifdef NoRepository
202#include "zoneDistributeI.H"
203#endif
204
205// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206
207#endif
208
209// ************************************************************************* //
surfaceScalarField & phi
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
Generic GeometricField class.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
A HashTable to objects of type <T> with a label key.
Definition: Map.H:60
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:91
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:66
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:68
computes a cell point cell stencil in a narrow band. resizes in case of topological change
Class for parallel communication in a narrow band. It either provides a Map with the neighbouring val...
TypeName("zoneDistribute")
Runtime information.
virtual ~zoneDistribute()=default
Destructor.
const globalIndex & globalNumbering() const noexcept
Addressing reference.
void updateStencil(const boolList &zone)
Updates stencil with boolList the size has to match mesh nCells.
void setUpCommforZone(const boolList &zone, bool updateStencil=true)
Update stencil with boolList the size has to match mesh nCells.
Type getValue(const VolumeField< Type > &phi, const Map< Type > &valuesFromOtherProc, const label gblIdx) const
static zoneDistribute & New(const fvMesh &)
Selector.
const labelListList & getStencil() noexcept
Stencil reference.
Map< Type > getDatafromOtherProc(const boolList &zone, const VolumeField< Type > &phi)
Returns stencil and provides a Map with globalNumbering.
Map< Field< Type > > getFields(const boolList &zone, const VolumeField< Type > &phi)
Returns stencil and provides a Map with globalNumbering.
Base class for mesh zones.
Definition: zone.H:67
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73