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> internalEdgeMap_;
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  static mapDistributePolyMesh createReconstructMap
103  (
104  const faMesh& mesh,
105  const autoPtr<faMesh>& baseMeshPtr,
106  const labelUList& faceProcAddr,
107  const labelUList& edgeProcAddr,
108  const labelUList& pointProcAddr,
109  const labelUList& boundaryProcAddr
110  );
111 
112 
113 public:
114 
115  //- Output verbosity when writing
116  static int verbose_;
117 
118 
119  // Generated Methods
120 
121  //- No copy construct
122  faMeshDistributor(const faMeshDistributor&) = delete;
123 
124  //- No copy assignment
125  void operator=(const faMeshDistributor&) = delete;
126 
127 
128  // Constructors
129 
130  //- Construct from components, using bool to control writing
132  (
133  const faMesh& srcMesh,
134  const faMesh& tgtMesh,
135  const mapDistributePolyMesh& faDistMap,
136  const bool isWriteProc
137  );
138 
139  //- Construct from components, using file handler to control writing
141  (
142  const faMesh& srcMesh,
143  const faMesh& tgtMesh,
144  const mapDistributePolyMesh& faDistMap,
145  refPtr<fileOperation>& writeHandler
146  );
147 
148 
149  // Static Methods
150 
151  //- Distribute mesh according to the given (volume) mesh distribution.
152  // Uses 'tgtPolyMesh' for the new mesh
154  (
155  const faMesh& oldMesh,
156  const mapDistributePolyMesh& distMap,
157  const polyMesh& tgtPolyMesh,
158  autoPtr<faMesh>& newMeshPtr
159  );
160 
161  //- Distribute mesh according to the given (volume) mesh distribution.
162  // Re-uses polyMesh from oldMesh for the new mesh
164  (
165  const faMesh& oldMesh,
166  const mapDistributePolyMesh& distMap,
167  autoPtr<faMesh>& newMeshPtr
168  );
169 
170 
171  // Member Functions
172 
173  // Field Mapping
174 
175  //- Read, distribute and write all/selected point field types
176  //- (scalar, vector, ... types)
177  label distributeAllFields
178  (
179  const IOobjectList& objects,
180  const wordRes& selectedFields = wordRes()
181  ) const;
182 
183  //- Distribute area field
184  template<class Type>
187  (
189  ) const;
190 
191  //- Distribute edge field
192  template<class Type>
195  (
197  ) const;
198 
199  //- Read and distribute area field
200  template<class Type>
203  (
204  const IOobject& fieldObject
205  ) const;
206 
207  //- Read and distribute edge field
208  template<class Type>
211  (
212  const IOobject& fieldObject
213  ) const;
214 
215  //- Read, distribute and write all/selected area fields
216  template<class Type>
218  (
219  const IOobjectList& objects,
220  const wordRes& selectedFields = wordRes()
221  ) const;
222 
223  //- Read, distribute and write all/selected area fields
224  template<class Type>
226  (
227  const IOobjectList& objects,
228  const wordRes& selectedFields = wordRes()
229  ) const;
230 };
231 
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 } // End namespace Foam
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 
240 #ifdef NoRepository
242 #endif
243 
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 
246 #endif
247 
248 // ************************************************************************* //
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:87
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.
Definition: areaFieldsFwd.H:50
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:55
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:74
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:172
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.