faMeshDistributor.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 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::faMeshDistributor
28 
29 Description
30  Holds a reference to the original mesh (the baseMesh)
31  and optionally to a subset of that mesh (the subMesh)
32  with mapping lists for points, faces, and cells.
33 
34 SourceFiles
35  faMeshDistributor.C
36  faMeshDistributorNew.C
37  faMeshDistributorTemplates.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef Foam_faMeshDistributor_H
42 #define Foam_faMeshDistributor_H
43 
44 #include "faMesh.H"
45 #include "mapDistributePolyMesh.H"
46 #include "areaFieldsFwd.H"
47 #include "edgeFieldsFwd.H"
48 #include "Switch.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward Declarations
56 class IOobjectList;
57 
58 /*---------------------------------------------------------------------------*\
59  Class faMeshDistributor Declaration
60 \*---------------------------------------------------------------------------*/
61 
63 {
64  // Private Data
65 
66  //- The source mesh reference
67  const faMesh& srcMesh_;
68 
69  //- The destination mesh reference
70  const faMesh& tgtMesh_;
71 
72  //- Distribution map reference (faMesh)
73  const mapDistributePolyMesh& distMap_;
74 
75  //- Internal edge mapper
76  mutable std::unique_ptr<mapDistributeBase> internalEdgeMapPtr_;
77 
78  //- Patch edge mappers
79  mutable PtrList<mapDistributeBase> patchEdgeMaps_;
80 
81  //- Storage for dummy handler (when using bool control)
82  refPtr<fileOperation> dummyHandler_;
83 
84  //- Write control via a file handler
85  refPtr<fileOperation>& writeHandler_;
86 
87  //- Write control as a bool
88  Switch isWriteProc_;
89 
90 
91  // Private Member Functions
92 
93  //- Construct internal edge mapping
94  void createInternalEdgeMap() const;
95 
96  //- Construct per-patch edge mapping
97  void createPatchMaps() const;
98 
99  //- Debug: check addressing
100  void checkAddressing() const;
101 
102  //- Construct reconstruct mapping
103  static mapDistributePolyMesh createReconstructMap
104  (
105  const faMesh& mesh,
106  const autoPtr<faMesh>& baseMeshPtr,
107  const labelUList& faceProcAddr,
108  const labelUList& edgeProcAddr,
109  const labelUList& pointProcAddr,
110  const labelUList& boundaryProcAddr
111  );
112 
113 
114 public:
115 
116  //- Output verbosity when writing
117  static int verbose_;
118 
119 
120  // Generated Methods
121 
122  //- No copy construct
123  faMeshDistributor(const faMeshDistributor&) = delete;
124 
125  //- No copy assignment
126  void operator=(const faMeshDistributor&) = delete;
127 
128 
129  // Constructors
130 
131  //- Construct from components, using bool to control writing
133  (
134  const faMesh& srcMesh,
135  const faMesh& tgtMesh,
136  const mapDistributePolyMesh& faDistMap,
137  const bool isWriteProc
138  );
139 
140  //- Construct from components, using file handler to control writing
142  (
143  const faMesh& srcMesh,
144  const faMesh& tgtMesh,
145  const mapDistributePolyMesh& faDistMap,
146  refPtr<fileOperation>& writeHandler
147  );
148 
149 
150  // Static Methods
151 
152  //- Distribute mesh according to the given (volume) mesh distribution.
153  // Uses 'tgtPolyMesh' for the new mesh
155  (
156  const faMesh& oldMesh,
157  const mapDistributePolyMesh& distMap,
158  const polyMesh& tgtPolyMesh,
159  autoPtr<faMesh>& newMeshPtr
160  );
161 
162  //- Distribute mesh according to the given (volume) mesh distribution.
163  // Re-uses polyMesh from oldMesh for the new mesh
165  (
166  const faMesh& oldMesh,
167  const mapDistributePolyMesh& distMap,
168  autoPtr<faMesh>& newMeshPtr
169  );
170 
171 
172  // Member Functions
173 
174  // Field Mapping
175 
176  //- Read, distribute and write all/selected point field types
177  //- (scalar, vector, ... types)
178  label distributeAllFields
179  (
180  const IOobjectList& objects,
181  const wordRes& selectedFields = wordRes()
182  ) const;
183 
184  //- Distribute area field
185  template<class Type>
188  (
190  ) const;
191 
192  //- Distribute edge field
193  template<class Type>
196  (
198  ) const;
199 
200  //- Read and distribute area field
201  template<class Type>
204  (
205  const IOobject& fieldObject
206  ) const;
207 
208  //- Read and distribute edge field
209  template<class Type>
212  (
213  const IOobject& fieldObject
214  ) const;
215 
216  //- Read, distribute and write all/selected area fields
217  template<class Type>
219  (
220  const IOobjectList& objects,
221  const wordRes& selectedFields = wordRes()
222  ) const;
223 
224  //- Read, distribute and write all/selected area fields
225  template<class Type>
227  (
228  const IOobjectList& objects,
229  const wordRes& selectedFields = wordRes()
230  ) const;
231 };
232 
233 
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 
236 } // End namespace Foam
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 
241 #ifdef NoRepository
243 #endif
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #endif
248 
249 // ************************************************************************* //
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:133
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
faMeshDistributor(const faMeshDistributor &)=delete
No copy construct.
label distributeEdgeFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, distribute and write all/selected area fields.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
Definition: IOobjectList.H:55
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, any/none. Also accepts 0/1 as a string and shortcuts t/f, y/n.
Definition: Switch.H:77
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Generic GeometricField class.
tmp< GeometricField< Type, faePatchField, edgeMesh > > distributeEdgeField(const IOobject &fieldObject) const
Read and distribute edge field.
A class for managing references or pointers (no reference counting)
Definition: HashPtrTable.H:49
Forwards for edge field types.
dynamicFvMesh & mesh
static int verbose_
Output verbosity when writing.
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
label distributeAllFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, distribute and write all/selected point field types (scalar, vector, ... types) ...
void operator=(const faMeshDistributor &)=delete
No copy assignment.
label distributeAreaFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, distribute and write all/selected area fields.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:54
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:75
A class for managing temporary objects.
Definition: HashPtrTable.H:50
tmp< GeometricField< Type, faPatchField, areaMesh > > distributeField(const GeometricField< Type, faPatchField, areaMesh > &fld) const
Distribute area field.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:180
tmp< GeometricField< Type, faPatchField, areaMesh > > distributeAreaField(const IOobject &fieldObject) const
Read and distribute area field.
static mapDistributePolyMesh distribute(const faMesh &oldMesh, const mapDistributePolyMesh &distMap, const polyMesh &tgtPolyMesh, autoPtr< faMesh > &newMeshPtr)
Distribute mesh according to the given (volume) mesh distribution.
Forwards and collection of common area field types.
Namespace for OpenFOAM.