parFvFieldDistributor.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) 2015 OpenFOAM Foundation
9  Copyright (C) 2018-2026 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::parFvFieldDistributor
29 
30 Description
31  Finite volume reconstructor for volume and surface fields.
32 
33  Runs in parallel.
34  Reconstructs/redistributes from procMesh to baseMesh.
35  baseMesh is non-zero cells on processor0 only.
36 
37 SourceFiles
38  parFvFieldDistributor.cxx
39  parFvFieldDistributor.txx
40  parFvFieldDistributorFields.cxx
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef Foam_parFvFieldDistributor_H
45 #define Foam_parFvFieldDistributor_H
46 
47 #include "fvMesh.H"
48 #include "PtrList.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward Declarations
56 class mapDistributePolyMesh;
57 class mapDistributeBase;
58 class IOobjectList;
59 
60 /*---------------------------------------------------------------------------*\
61  Class parFvFieldDistributor Declaration
62 \*---------------------------------------------------------------------------*/
63 
65 {
66  // Private Data
67 
68  //- Processor mesh reference (source mesh)
69  const fvMesh& srcMesh_;
70 
71  //- Destination mesh reference (eg, reconstructed mesh)
72  fvMesh& tgtMesh_;
73 
74  //- Distribution map reference
75  const mapDistributePolyMesh& distMap_;
76 
77  //- Patch mappers
78  PtrList<mapDistributeBase> patchFaceMaps_;
79 
80  //- Storage for unused handler (when using bool control)
81  const refPtr<fileOperation> noHandler_;
82 
83  //- Write control via a file handler
84  const refPtr<fileOperation>& writeHandler_;
85 
86  //- Write control as a bool (instead of via file handler)
87  bool isWriteProc_;
88 
89 
90  // Private Member Functions
91 
92  //- Construct per-patch addressing
93  void createPatchFaceMaps();
94 
95  //- Write using writeHandler_ or isWriteProc_ to guide the output
96  template<class FieldType>
97  void writeField(const FieldType& fld) const;
98 
99 
100 public:
101 
102  //- Output verbosity when writing
103  static int verbose_;
104 
105 
106  // Generated Methods
107 
108  //- No copy construct
110 
111  //- No copy assignment
112  void operator=(const parFvFieldDistributor&) = delete;
113 
114 
115  // Constructors
116 
117  //- Construct from components
119  (
121  const fvMesh& srcMesh,
123  fvMesh& tgtMesh,
125  const mapDistributePolyMesh& distMap,
127  const bool isWriteProc = true
128  );
129 
130  //- Construct from components
132  (
134  const fvMesh& srcMesh,
136  fvMesh& tgtMesh,
138  const mapDistributePolyMesh& distMap,
140  const refPtr<fileOperation>& writeHandler
141  );
142 
143 
144  // Member Functions
145 
146  //- The source mesh
147  const fvMesh& sourceMesh() const noexcept { return srcMesh_; }
148 
149  //- Helper: reconstruct and write mesh points
150  // (note: should be moved to something like processorMeshes class)
151  void reconstructPoints();
152 
153  //- Distribute all fields for known field types
155  (
156  const IOobjectList& objects,
157  const wordRes& selectedFields
158  ) const;
159 
160  //- Redistribute volume internal field
161  template<class Type>
164  (
166  ) const;
167 
168  //- Read and distribute volume internal field
169  template<class Type>
171  distributeInternalField(const IOobject& fieldObject) const;
173 
174  //- Redistribute volume field
175  template<class Type>
178  (
180  ) const;
181 
182  //- Read and distribute volume field
183  template<class Type>
185  distributeVolumeField(const IOobject& fieldObject) const;
186 
187 
188  //- Redistribute surface field
189  template<class Type>
192  (
194  ) const;
195 
196  //- Read and distribute surface field
197  template<class Type>
199  distributeSurfaceField(const IOobject& fieldObject) const;
200 
201 
202  //- Read, redistribute and write all/selected volume internal fields
203  template<class Type>
205  (
206  const IOobjectList& objects,
207  const wordRes& selectedFields = wordRes()
208  ) const;
209 
210  //- Read, redistribute and write all/selected volume fields
211  template<class Type>
213  (
214  const IOobjectList& objects,
215  const wordRes& selectedFields = wordRes()
216  ) const;
217 
218  //- Read, reconstruct and write all/selected surface fields
219  template<class Type>
221  (
222  const IOobjectList& objects,
223  const wordRes& selectedFields = wordRes()
224  ) const;
225 };
226 
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 } // End namespace Foam
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
234 #ifdef NoRepository
235 # include "parFvFieldDistributor.txx"
236 #endif
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 #endif
241 
242 // ************************************************************************* //
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > distributeSurfaceField(const IOobject &fieldObject) const
Read and distribute surface field.
void operator=(const parFvFieldDistributor &)=delete
No copy assignment.
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
static int verbose_
Output verbosity when writing.
label distributeVolumeFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, redistribute and write all/selected volume fields.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Generic GeometricField class.
label distributeInternalFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, redistribute and write all/selected volume internal fields.
A class for managing references or pointers (no reference counting)
Definition: HashPtrTable.H:49
Finite volume reconstructor for volume and surface fields.
void distributeAllFields(const IOobjectList &objects, const wordRes &selectedFields) const
Distribute all fields for known field types.
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
const fvMesh & sourceMesh() const noexcept
The source mesh.
const direction noexcept
Definition: scalarImpl.H:265
tmp< DimensionedField< Type, volMesh > > distributeInternalField(const IOobject &fieldObject) const
Read and distribute volume internal field.
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))
tmp< DimensionedField< Type, volMesh > > distributeField(const DimensionedField< Type, volMesh > &) const
Redistribute volume internal field.
tmp< GeometricField< Type, fvPatchField, volMesh > > distributeVolumeField(const IOobject &fieldObject) const
Read and distribute volume field.
void reconstructPoints()
Helper: reconstruct and write mesh points.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: PtrList.H:56
parFvFieldDistributor(const parFvFieldDistributor &)=delete
No copy construct.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:188
label distributeSurfaceFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, reconstruct and write all/selected surface fields.
Namespace for OpenFOAM.