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 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 // Forward Declarations
55 class IOobjectList;
56 
57 /*---------------------------------------------------------------------------*\
58  Class faMeshDistributor Declaration
59 \*---------------------------------------------------------------------------*/
60 
62 {
63  // Private Data
64 
65  //- The source mesh reference
66  const faMesh& srcMesh_;
67 
68  //- The destination mesh reference
69  const faMesh& tgtMesh_;
70 
71  //- Distribution map reference (faMesh)
72  const mapDistributePolyMesh& distMap_;
73 
74  //- Internal edge mapper
75  mutable std::unique_ptr<mapDistributeBase> internalEdgeMap_;
76 
77  //- Patch edge mappers
78  mutable PtrList<mapDistributeBase> patchEdgeMaps_;
79 
80  //- Do I need to write (eg, master only for reconstruct)
81  bool isWriteProc_;
82 
83 
84  // Private Member Functions
85 
86  //- Construct internal edge mapping
87  void createInternalEdgeMap() const;
88 
89  //- Construct per-patch edge mapping
90  void createPatchMaps() const;
91 
92  static mapDistributePolyMesh createReconstructMap
93  (
94  const faMesh& mesh,
95  const autoPtr<faMesh>& baseMeshPtr,
96  const labelUList& faceProcAddr,
97  const labelUList& edgeProcAddr,
98  const labelUList& pointProcAddr,
99  const labelUList& boundaryProcAddr
100  );
101 
102  //- No copy construct
103  faMeshDistributor(const faMeshDistributor&) = delete;
104 
105  //- No copy assignment
106  void operator=(const faMeshDistributor&) = delete;
107 
108 
109 public:
110 
111  //- Output verbosity when writing
112  static int verbose_;
113 
114 
115  // Constructors
116 
117  //- Construct from components
119  (
120  const faMesh& srcMesh,
121  const faMesh& tgtMesh,
122  const mapDistributePolyMesh& faDistMap,
123  const bool isWriteProc = false
124  );
125 
126 
127  // Static Methods
128 
129  //- Distribute mesh according to the given (volume) mesh distribution.
130  // Uses 'tgtPolyMesh' for the new mesh
132  (
133  const faMesh& oldMesh,
134  const mapDistributePolyMesh& distMap,
135  const polyMesh& tgtPolyMesh,
136  autoPtr<faMesh>& newMeshPtr
137  );
138 
139  //- Distribute mesh according to the given (volume) mesh distribution.
140  // Re-uses polyMesh from oldMesh for the new mesh
142  (
143  const faMesh& oldMesh,
144  const mapDistributePolyMesh& distMap,
145  autoPtr<faMesh>& newMeshPtr
146  );
147 
148 
149  // Member Functions
150 
151  //- Get status of write enabled (on this proc)
152  bool isWriteProc() const noexcept
153  {
154  return isWriteProc_;
155  }
156 
157  //- Change status of write enabled (on this proc)
158  bool isWriteProc(const bool on) noexcept
159  {
160  bool old(isWriteProc_);
161  isWriteProc_ = on;
162  return old;
163  }
164 
165 
166  // Field Mapping
167 
168  //- Read, distribute and write all/selected point field types
169  //- (scalar, vector, ... types)
170  label distributeAllFields
171  (
172  const IOobjectList& objects,
173  const wordRes& selectedFields = wordRes()
174  ) const;
175 
176  //- Distribute area field
177  template<class Type>
178  tmp<GeometricField<Type, faPatchField, areaMesh>>
180  (
182  ) const;
183 
184  //- Distribute edge field
185  template<class Type>
188  (
190  ) const;
191 
192  //- Read and distribute area field
193  template<class Type>
196  (
197  const IOobject& fieldObject
198  ) const;
199 
200  //- Read and distribute edge field
201  template<class Type>
204  (
205  const IOobject& fieldObject
206  ) const;
207 
208  //- Read, distribute and write all/selected area fields
209  template<class Type>
211  (
212  const IOobjectList& objects,
213  const wordRes& selectedFields = wordRes()
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 
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 } // End namespace Foam
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 
233 #ifdef NoRepository
235 #endif
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 #endif
240 
241 // ************************************************************************* //
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:88
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
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
bool isWriteProc() const noexcept
Get status of write enabled (on this proc)
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.
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:47
label distributeAllFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, distribute and write all/selected point field types (scalar, vector, ... types) ...
const direction noexcept
Definition: Scalar.H:258
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:73
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:166
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.