Loading...
Searching...
No Matches
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-2023 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.cxx
50 parPointFieldDistributor.txx
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#include "Switch.H"
61
62// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63
64namespace Foam
65{
66
67// Forward Declarations
70class IOobjectList;
72/*---------------------------------------------------------------------------*\
73 Class parPointFieldDistributor Declaration
74\*---------------------------------------------------------------------------*/
75
77{
78 // Private Data
79
80 //- The source mesh reference
81 const pointMesh& srcMesh_;
82
83 //- Number of points in the old (source) mesh
84 const label nOldPoints_;
85
86 //- The pointPatch mesh points
87 PtrList<labelList> patchMeshPoints_;
88
89 //- The target (destination) mesh reference
90 refPtr<pointMesh> tgtMeshRef_;
91
92 //- Distribution map reference
94
95 //- Point patch mappers
96 PtrList<mapDistributeBase> patchPointMaps_;
97
98 //- Storage for dummy handler (when using bool control)
99 refPtr<fileOperation> dummyHandler_;
100
101 //- Write control via a file handler
102 refPtr<fileOperation>& writeHandler_;
103
104 //- Write control as a bool
105 Switch isWriteProc_;
106
107
108public:
109
110 //- Output verbosity when writing
111 static int verbose_;
112
113
114 // Generated Methods
115
116 //- No copy construct
118
119 //- No copy assignment
120 void operator=(const parPointFieldDistributor&) = delete;
121
122
123 // Constructors
124
125 //- Basic construction
126 //
127 // \param srcMesh The source pointMesh
128 // \param savePoints Call saveMeshPoints() immediately
129 // \param isWriteProc Tagged for output writing (on this proc)
131 (
132 const pointMesh& srcMesh,
133 const bool savePoints, // normally false
134 const bool isWriteProc
135 );
136
137 //- Basic construction
138 //
139 // \param srcMesh The source pointMesh
140 // \param savePoints Call saveMeshPoints() immediately
141 // \param writeHandler Valid for output writing (on this proc)
143 (
144 const pointMesh& srcMesh,
145 const bool savePoints, // normally false
146 refPtr<fileOperation>& writeHandler
147 );
148
149 //- Full construction of source/target
150 //
151 // \param srcMesh The source pointMesh
152 // \param tgtMesh The target pointMesh
153 // \param distMap The distribution map
154 // \param savePoints Call saveMeshPoints() immediately
155 // \param isWriteProc Tagged for output writing (on this proc)
157 (
158 const pointMesh& srcMesh,
159 const pointMesh& tgtMesh,
160 const mapDistributePolyMesh& distMap,
161 const bool savePoints, // normally false
162 const bool isWriteProc
163 );
164
165 //- Full construction of source/target
166 //
167 // \param srcMesh The source pointMesh
168 // \param tgtMesh The target pointMesh
169 // \param distMap The distribution map
170 // \param savePoints Call saveMeshPoints() immediately
171 // \param writeHandler Valid for output writing (on this proc)
173 (
174 const pointMesh& srcMesh,
175 const pointMesh& tgtMesh,
176 const mapDistributePolyMesh& distMap,
177 const bool savePoints, // normally false
178 refPtr<fileOperation>& writeHandler
179 );
180
181
182 // Member Functions
183
184 //- True if meshPoints (per boundary) for the source mesh
185 //- have been saved
186 bool hasMeshPoints() const;
187
188 //- True if patch maps (per boundary) exist
189 bool hasPatchPointMaps() const;
190
191 //- True if a target mesh/distribution map has been attached
192 bool hasTarget() const;
193
194 //- Clear out meshPoints (per boundary) for the source mesh
195 void clearMeshPoints();
196
197 //- Clear out patch maps (per boundary)
198 void clearPatchPointMaps();
199
200 //- Create/recreate meshPoints (per boundary) for the source mesh
201 void saveMeshPoints();
202
203 //- Construct per-patch addressing
205
206 //- Clear target mesh / distribution map
207 void resetTarget();
208
209 //- Reset target mesh / distribution map
210 void resetTarget
211 (
212 const pointMesh& tgtMesh,
213 const mapDistributePolyMesh& distMap
214 );
215
216
217 // Field Mapping
218
219 //- Read, distribute and write all/selected point field types
220 //- (scalar, vector, ... types)
222 (
223 const IOobjectList& objects,
224 const wordRes& selectedFields = wordRes()
225 ) const;
226
227
228 //- Distribute point field
229 template<class Type>
232 (
234 ) const;
235
236 //- Read and distribute point field
237 template<class Type>
240 (
241 const IOobject& fieldObject
242 ) const;
243
244 //- Read, distribute and write all/selected point fields
245 template<class Type>
247 (
248 const IOobjectList& objects,
249 const wordRes& selectedFields = wordRes()
250 ) const;
251
252 //- Distributed each (unregistered!) point field
253 //- and store the result on its objectRegistry
254 template<class Type>
256 (
258 ) const;
260
261
262// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263
264} // End namespace Foam
265
266// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267
268#ifdef NoRepository
269# include "parPointFieldDistributor.txx"
270#endif
271
272// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273
274#endif
275
276// ************************************************************************* //
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-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. Implemented as a HashTable,...
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition Switch.H:81
Class containing processor-to-processor mapping information.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
label distributeAllFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, distribute and write all/selected point field types (scalar, vector, ... types).
bool hasPatchPointMaps() const
True if patch maps (per boundary) exist.
parPointFieldDistributor(const pointMesh &srcMesh, const bool savePoints, refPtr< fileOperation > &writeHandler)
Basic construction.
parPointFieldDistributor(const parPointFieldDistributor &)=delete
No copy construct.
tmp< GeometricField< Type, pointPatchField, pointMesh > > distributePointField(const IOobject &fieldObject) const
Read and distribute point field.
void distributeAndStore(const PtrList< GeometricField< Type, pointPatchField, pointMesh > > &) const
Distributed each (unregistered!) point field and store the result on its objectRegistry.
void resetTarget()
Clear target mesh / distribution map.
void operator=(const parPointFieldDistributor &)=delete
No copy assignment.
parPointFieldDistributor(const pointMesh &srcMesh, const pointMesh &tgtMesh, const mapDistributePolyMesh &distMap, const bool savePoints, const bool isWriteProc)
Full construction of source/target.
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.
parPointFieldDistributor(const pointMesh &srcMesh, const bool savePoints, const bool isWriteProc)
Basic construction.
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.
bool hasMeshPoints() const
True if meshPoints (per boundary) for the source mesh have been saved.
parPointFieldDistributor(const pointMesh &srcMesh, const pointMesh &tgtMesh, const mapDistributePolyMesh &distMap, const bool savePoints, refPtr< fileOperation > &writeHandler)
Full construction of source/target.
Mesh representing a set of points created from polyMesh.
Definition pointMesh.H:49
A class for managing references or pointers (no reference counting).
Definition refPtr.H:54
A class for managing temporary objects.
Definition tmp.H:75
A List of wordRe with additional matching capabilities.
Definition wordRes.H:56
Namespace for OpenFOAM.
Forwards and collection of common point field types.