Loading...
Searching...
No Matches
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-2023 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{
77/*---------------------------------------------------------------------------*\
78 Class zoneDistribute Declaration
79\*---------------------------------------------------------------------------*/
80
82:
83 public MeshObject<fvMesh, TopologicalMeshObject, zoneDistribute>
84{
85 // Private Typedefs
86
87 typedef MeshObject
88 <
89 fvMesh,
92 > MeshObject_type;
93
94
95 // Private Data
96
97 //- Reference to the zone stencil
98 zoneCPCStencil& stencil_;
99
100 //- Global number into index of cells/faces
101 const globalIndex& globalNumbering_;
102
103 //- Global cell/face index to send for processor-to-processor comms
104 List<labelList> send_;
105
106 //- Parallel [cache]: send connectivity (true/false)
107 bitSet sendConnections_;
108
109 //- Parallel [cache]: send data to these ranks
110 DynamicList<label> sendProcs_;
111
112 //- Parallel [cache]: recv data from these ranks
113 DynamicList<label> recvProcs_;
114
115 //- Persistent set of exchange buffers
116 PstreamBuffers pBufs_;
117
118 //- Cell labels for all cells with a face on a cyclic boundary
119 bitSet cyclicBoundaryCells_;
120
121 //- Holds for each cell on cyclic patch the centres of the cells in its
122 // point neighbour stencil.
123 // Used in getCyclicPatches to identify neigbhour patch ID of point
124 // neighbours on other side of a processorPolyPatch.
125 autoPtr<Map<vectorField>> cyclicCentres_;
126
127
128 // Private Member Functions
129
130 //- Return local volField value at (cell or face) index
131 template<typename Type>
132 Type getLocalValue
133 (
134 const VolumeField<Type>& phi,
135 const label localIdx
136 ) const;
137
138 //- Gives patchNumber and patchFaceNumber for a given
139 //- Geometric volume field
140 template<typename Type>
141 Type faceValue
142 (
143 const VolumeField<Type>& phi,
144 const label localIdx
145 ) const;
146
147
148public:
149
150 //- Runtime information
151 TypeName("zoneDistribute");
152
153
154 // Constructors
155
156 //- Construct from fvMesh
157 explicit zoneDistribute(const fvMesh&);
158
159 //- Selector
160 static zoneDistribute& New(const fvMesh&);
161
162
163 //- Destructor
164 virtual ~zoneDistribute() = default;
165
166
167 // Member Functions
168
169 //- Update stencil with boolList the size has to match mesh nCells
170 void setUpCommforZone(const boolList& zone, bool updateStencil=true);
172 //- Updates stencil with boolList the size has to match mesh nCells
173 void updateStencil(const boolList& zone);
174
175 //- Stencil reference
177 {
178 return stencil_;
179 }
180
181 //- Addressing reference
183 {
184 return globalNumbering_;
185 }
186
187 //- Finds and returns list of all cyclic patch labels to which celli's
188 // point neighbour cell, globalIdx, belongs. celli and globalIdx touch
189 // in at least one point on these patches. globalIdx typically belongs
190 // to stencil_[celli]. The returned label list is used to transform
191 // positions across cyclic boundaries e.g. to be able to calculate
192 // distances between cell centres and interface centres in plicRDF
193 // across such boundaries.
195 (
196 const label celli,
197 const label globalIdx,
198 const vector globalIdxCellCentre
199 ) const;
200
201 //- Gives patchNumber and patchFaceNumber for a given
202 //- Geometric volume field
203 template<typename Type>
204 Type getValue
205 (
206 const VolumeField<Type>& phi,
207 const Map<Type>& valuesFromOtherProc,
208 const label gblIdx
209 ) const;
210
212 (
213 const VolumeField<vector>& positions,
214 const Map<vector>& valuesFromOtherProc,
215 const label gblIdx,
216 const List<label> cyclicPatchID = List<label>()
217 ) const;
218
219 //- Returns stencil and provides a Map with globalNumbering
220 template<typename Type>
222 (
223 const boolList& zone,
225 );
226
227 //- Returns stencil and provides a Map with globalNumbering
228 // Note: Not used currently (v2412) but needed for future surface
229 // tension modelling.
230 template<typename Type>
232 (
233 const boolList& zone,
234 const VolumeField<Type>& phi,
235 const bool& checkTransformation = false
236 );
237
238 //- Returns stencil and provides a Map with globalNumbering
239 template<typename Type>
241 (
242 const boolList& zone,
244 );
245};
246
247
248// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249
250} // End namespace Foam
251
252// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253
254// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255
256#ifdef NoRepository
257#include "zoneDistributeI.H"
258#endif
259
260// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261
262#endif
263
264// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
A HashTable to objects of type <T> with a label key.
Definition Map.H:54
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition bitSet.H:61
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
Definition globalIndex.H:77
computes a cell point cell stencil in a narrow band. resizes in case of topological change
TypeName("zoneDistribute")
Runtime information.
virtual ~zoneDistribute()=default
Destructor.
const globalIndex & globalNumbering() const noexcept
Addressing reference.
List< label > getCyclicPatches(const label celli, const label globalIdx, const vector globalIdxCellCentre) const
Finds and returns list of all cyclic patch labels to which celli's.
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
Gives patchNumber and patchFaceNumber for a given Geometric volume field.
zoneDistribute(const fvMesh &)
Construct from fvMesh.
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 > > getPositionFields(const boolList &zone, const VolumeField< Type > &phi, const bool &checkTransformation=false)
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.
vector getPosition(const VolumeField< vector > &positions, const Map< vector > &valuesFromOtherProc, const label gblIdx, const List< label > cyclicPatchID=List< label >()) const
Base class for mesh zones.
Definition zone.H:63
Namespace for OpenFOAM.
GeometricField< Type, fvPatchField, volMesh > VolumeField
A volume field for a given type.
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< bool > boolList
A List of bools.
Definition List.H:60
const direction noexcept
Definition scalarImpl.H:265
Vector< scalar > vector
Definition vector.H:57
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68