parPointFieldDistributor.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) 2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::parPointFieldDistributor
28
29Description
30 Distributor/redistributor for point fields,
31 uses a two (or three) stage construction.
32
33 The inconvenient multi-stage construction is needed since the
34 pointMesh is directly associated with a polyMesh, which will probably
35 have changed while creating the target mesh. This means that it is
36 necessary to save the size of the source mesh and all of its
37 patch meshPoints prior to making any changes (eg, creating the target
38 mesh).
39
40 -# Create with specified source mesh
41 -# Save the meshPoints (per boundary) for the source mesh
42 -# Attach a target mesh and mesh distribution
43 -# Map the point fields
44 .
45
46 Runs in parallel. Redistributes from srcMesh to tgtMesh.
47
48SourceFiles
49 parPointFieldDistributor.C
50 parPointFieldDistributorTemplates.C
51
52\*---------------------------------------------------------------------------*/
53
54#ifndef Foam_parPointFieldDistributor_H
55#define Foam_parPointFieldDistributor_H
56
57#include "PtrList.H"
58#include "pointMesh.H"
59#include "pointFieldsFwd.H"
60
61// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62
63namespace Foam
64{
65
66// Forward Declarations
67class mapDistributePolyMesh;
68class mapDistributeBase;
69class IOobjectList;
70
71/*---------------------------------------------------------------------------*\
72 Class parPointFieldDistributor Declaration
73\*---------------------------------------------------------------------------*/
76{
77 // Private Data
78
79 //- The source mesh reference
80 const pointMesh& srcMesh_;
81
82 //- Number of points in the old (source) mesh
83 const label nOldPoints_;
84
85 //- The pointPatch mesh points
86 PtrList<labelList> patchMeshPoints_;
87
88 //- The target (destination) mesh reference
89 refPtr<pointMesh> tgtMeshRef_;
90
91 //- Distribution map reference
93
94 //- Point patch mappers
95 PtrList<mapDistributeBase> patchPointMaps_;
96
97 //- Do I need to write (eg, master only for reconstruct)
98 bool isWriteProc_;
99
100
101 // Private Member Functions
102
103 //- No copy construct
105
106 //- No copy assignment
107 void operator=(const parPointFieldDistributor&) = delete;
108
109
110public:
111
112 //- Output verbosity when writing
113 static int verbose_;
114
115
116 // Constructors
117
118 //- Basic construction
119 //
120 // \param srcMesh The source pointMesh
121 // \param savePoints Call saveMeshPoints() immediately
122 // \param isWriteProc Tagged for output writing (on this proc)
124 (
125 const pointMesh& srcMesh,
126 const bool savePoints = false,
127 const bool isWriteProc = false
128 );
129
130 //- Full construction of source/target
131 //
132 // \param srcMesh The source pointMesh
133 // \param tgtMesh The target pointMesh
134 // \param distMap The distribution map
135 // \param savePoints Call saveMeshPoints() immediately
136 // \param isWriteProc Tagged for output writing (on this proc)
138 (
139 const pointMesh& srcMesh,
140 const pointMesh& tgtMesh,
141 const mapDistributePolyMesh& distMap,
142 const bool savePoints = false,
143 const bool isWriteProc = false
144 );
145
146
147 // Member Functions
148
149 //- True if meshPoints (per boundary) for the source mesh
150 //- have been saved
151 bool hasMeshPoints() const;
152
153 //- True if patch maps (per boundary) exist
154 bool hasPatchPointMaps() const;
155
156 //- True if a target mesh/distribution map has been attached
157 bool hasTarget() const;
158
159 //- Clear out meshPoints (per boundary) for the source mesh
160 void clearMeshPoints();
161
162 //- Clear out patch maps (per boundary)
163 void clearPatchPointMaps();
164
165 //- Create/recreate meshPoints (per boundary) for the source mesh
166 void saveMeshPoints();
167
168 //- Construct per-patch addressing
170
171 //- Clear target mesh / distribution map
172 void resetTarget();
173
174 //- Reset target mesh / distribution map
175 void resetTarget
176 (
177 const pointMesh& tgtMesh,
178 const mapDistributePolyMesh& distMap
179 );
180
181 //- Get status of write enabled (on this proc)
182 bool isWriteProc() const noexcept
183 {
184 return isWriteProc_;
185 }
186
187 //- Change status of write enabled (on this proc)
188 bool isWriteProc(const bool on) noexcept
189 {
190 bool old(isWriteProc_);
191 isWriteProc_ = on;
192 return old;
193 }
194
195
196 // Field Mapping
197
198 //- Read, distribute and write all/selected point field types
199 //- (scalar, vector, ... types)
201 (
202 const IOobjectList& objects,
203 const wordRes& selectedFields = wordRes()
204 ) const;
205
206
207 //- Distribute point field
208 template<class Type>
211 (
213 ) const;
214
215 //- Read and distribute point field
216 template<class Type>
219 (
220 const IOobject& fieldObject
221 ) const;
222
223 //- Read, distribute and write all/selected point fields
224 template<class Type>
226 (
227 const IOobjectList& objects,
228 const wordRes& selectedFields = wordRes()
229 ) const;
230
231 //- Distributed each (unregistered!) point field
232 //- and store the result on its objectRegistry
233 template<class Type>
235 (
237 ) const;
238};
239
240
241// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242
243} // End namespace Foam
244
245// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246
247#ifdef NoRepository
249#endif
250
251// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252
253#endif
254
255// ************************************************************************* //
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Generic GeometricField class.
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:59
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Distributor/redistributor for point fields, uses a two (or three) stage construction.
label distributeAllFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
bool hasPatchPointMaps() const
True if patch maps (per boundary) exist.
tmp< GeometricField< Type, pointPatchField, pointMesh > > distributePointField(const IOobject &fieldObject) const
Read and distribute point field.
void distributeAndStore(const PtrList< GeometricField< Type, pointPatchField, pointMesh > > &) const
void resetTarget()
Clear target mesh / distribution map.
bool isWriteProc(const bool on) noexcept
Change status of write enabled (on this proc)
bool isWriteProc() const noexcept
Get status of write enabled (on this proc)
void clearMeshPoints()
Clear out meshPoints (per boundary) for the source mesh.
void clearPatchPointMaps()
Clear out patch maps (per boundary)
tmp< GeometricField< Type, pointPatchField, pointMesh > > distributeField(const GeometricField< Type, pointPatchField, pointMesh > &fld) const
Distribute point field.
label distributePointFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, distribute and write all/selected point fields.
void saveMeshPoints()
Create/recreate meshPoints (per boundary) for the source mesh.
static int verbose_
Output verbosity when writing.
void resetTarget(const pointMesh &tgtMesh, const mapDistributePolyMesh &distMap)
Reset target mesh / distribution map.
void createPatchPointMaps()
Construct per-patch addressing.
bool hasTarget() const
True if a target mesh/distribution map has been attached.
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:55
A class for managing references or pointers (no reference counting)
Definition: refPtr.H:58
A class for managing temporary objects.
Definition: tmp.H:65
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223
Forwards and collection of common point field types.