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-2023 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.C
39  parFvFieldDistributorFields.C
40  parFvFieldDistributorTemplates.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef Foam_parFvFieldDistributor_H
45 #define Foam_parFvFieldDistributor_H
46 
47 #include "PtrList.H"
48 #include "fvMesh.H"
49 #include "Switch.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 // Forward Declarations
57 class mapDistributePolyMesh;
58 class mapDistributeBase;
59 class IOobjectList;
60 
61 /*---------------------------------------------------------------------------*\
62  Class parFvFieldDistributor Declaration
63 \*---------------------------------------------------------------------------*/
64 
66 {
67  // Private Data
68 
69  //- Processor mesh reference (source mesh)
70  const fvMesh& srcMesh_;
71 
72  //- Destination mesh reference (eg, reconstructed mesh)
73  fvMesh& tgtMesh_;
74 
75  //- Distribution map reference
76  const mapDistributePolyMesh& distMap_;
77 
78  //- Patch mappers
79  PtrList<mapDistributeBase> patchFaceMaps_;
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 per-patch addressing
94  void createPatchFaceMaps();
95 
96 
97 public:
98 
99  //- Output verbosity when writing
100  static int verbose_;
101 
102 
103  // Generated Methods
104 
105  //- No copy construct
107 
108  //- No copy assignment
109  void operator=(const parFvFieldDistributor&) = delete;
110 
111 
112  // Constructors
114  //- Construct from components
115  //
116  // \param srcMesh The source mesh (eg, processor)
117  // \param tgtMesh The target mesh (eg, reconstructed)
118  // \param distMap The distribution map
119  // \param isWriteProc Tagged for output writing (on this proc)
121  (
122  const fvMesh& srcMesh,
123  fvMesh& tgtMesh,
124  const mapDistributePolyMesh& distMap,
125  const bool isWriteProc
126  );
127 
128  //- Construct from components
129  //
130  // \param srcMesh The source mesh (eg, processor)
131  // \param tgtMesh The target mesh (eg, reconstructed)
132  // \param distMap The distribution map
133  // \param writeHandler Handler for output writing (on this proc)
135  (
136  const fvMesh& srcMesh,
137  fvMesh& tgtMesh,
138  const mapDistributePolyMesh& distMap,
139  refPtr<fileOperation>& writeHandler
140  );
141 
142 
143  // Member Functions
144 
145  //- Helper: reconstruct and write mesh points
146  // (note: should be moved to something like processorMeshes class)
147  void reconstructPoints();
148 
149  //- Distribute all fields for known field types
151  (
152  const IOobjectList& objects,
153  const wordRes& selectedFields
154  ) const;
155 
156  //- Redistribute volume internal field
157  template<class Type>
160  (
162  ) const;
163 
164  //- Read and distribute volume internal field
165  template<class Type>
167  distributeInternalField(const IOobject& fieldObject) const;
168 
169 
170  //- Redistribute volume field
171  template<class Type>
174  (
176  ) const;
177 
178  //- Read and distribute volume field
179  template<class Type>
181  distributeVolumeField(const IOobject& fieldObject) const;
182 
183 
184  //- Redistribute surface field
185  template<class Type>
188  (
190  ) const;
191 
192  //- Read and distribute surface field
193  template<class Type>
195  distributeSurfaceField(const IOobject& fieldObject) const;
196 
197 
198  //- Read, redistribute and write all/selected volume internal fields
199  template<class Type>
201  (
202  const IOobjectList& objects,
203  const wordRes& selectedFields = wordRes()
204  ) const;
205 
206  //- Read, redistribute and write all/selected volume fields
207  template<class Type>
209  (
210  const IOobjectList& objects,
211  const wordRes& selectedFields = wordRes()
212  ) const;
213 
214  //- Read, reconstruct and write all/selected surface fields
215  template<class Type>
217  (
218  const IOobjectList& objects,
219  const wordRes& selectedFields = wordRes()
220  ) const;
221 };
222 
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 } // End namespace Foam
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 #ifdef NoRepository
232 #endif
233 
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 
236 #endif
237 
238 // ************************************************************************* //
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.
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
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.
Definition: areaFieldsFwd.H:50
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
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: List.H:55
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...
Definition: areaFieldsFwd.H:42
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:172
label distributeSurfaceFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, reconstruct and write all/selected surface fields.
Namespace for OpenFOAM.