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-2022 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 
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  //- Do I need to write (eg, master only for reconstruct)
81  bool isWriteProc_;
82 
83 
84  // Private Member Functions
85 
86  //- Construct per-patch addressing
87  void createPatchFaceMaps();
88 
89  //- No copy construct
91 
92  //- No copy assignment
93  void operator=(const parFvFieldDistributor&) = delete;
94 
95 
96 public:
97 
98  //- Output verbosity when writing
99  static int verbose_;
100 
101 
102  // Constructors
103 
104  //- Construct from components
105  //
106  // \param srcMesh The source mesh (eg, processor)
107  // \param tgtMesh The target mesh (eg, reconstructed)
108  // \param distMap The distribution map
109  // \param isWriteProc Tagged for output writing (on this proc)
111  (
112  const fvMesh& srcMesh,
113  fvMesh& tgtMesh,
114  const mapDistributePolyMesh& distMap,
115  const bool isWriteProc
116  );
117 
118 
119  // Member Functions
120 
121  //- Get status of write enabled (on this proc)
122  bool isWriteProc() const noexcept
123  {
124  return isWriteProc_;
125  }
126 
127  //- Change status of write enabled (on this proc)
128  bool isWriteProc(const bool on) noexcept
129  {
130  bool old(isWriteProc_);
131  isWriteProc_ = on;
132  return old;
133  }
134 
135 
136  //- Helper: reconstruct and write mesh points
137  // (note: should be moved to something like processorMeshes class)
138  void reconstructPoints();
139 
140  //- Distribute all fields for known field types
142  (
143  const IOobjectList& objects,
144  const wordRes& selectedFields
145  ) const;
146 
147  //- Redistribute volume internal field
148  template<class Type>
151  (
153  ) const;
154 
155  //- Read and distribute volume internal field
156  template<class Type>
158  distributeInternalField(const IOobject& fieldObject) const;
159 
160 
161  //- Redistribute volume field
162  template<class Type>
165  (
167  ) const;
168 
169  //- Read and distribute volume field
170  template<class Type>
172  distributeVolumeField(const IOobject& fieldObject) const;
173 
174 
175  //- Redistribute surface field
176  template<class Type>
179  (
181  ) const;
182 
183  //- Read and distribute surface field
184  template<class Type>
186  distributeSurfaceField(const IOobject& fieldObject) const;
187 
188 
189  //- Read, redistribute and write all/selected volume internal fields
190  template<class Type>
192  (
193  const IOobjectList& objects,
194  const wordRes& selectedFields = wordRes()
195  ) const;
196 
197  //- Read, redistribute and write all/selected volume fields
198  template<class Type>
200  (
201  const IOobjectList& objects,
202  const wordRes& selectedFields = wordRes()
203  ) const;
204 
205  //- Read, reconstruct and write all/selected surface fields
206  template<class Type>
208  (
209  const IOobjectList& objects,
210  const wordRes& selectedFields = wordRes()
211  ) const;
212 };
213 
214 
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 
217 } // End namespace Foam
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 #ifdef NoRepository
223 #endif
224 
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 #endif
228 
229 // ************************************************************************* //
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > distributeSurfaceField(const IOobject &fieldObject) const
Read and distribute surface field.
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.
Definition: areaFieldsFwd.H:50
label distributeInternalFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, redistribute and write all/selected volume internal fields.
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:47
const direction noexcept
Definition: Scalar.H:258
bool isWriteProc() const noexcept
Get status of write enabled (on this proc)
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
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:79
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:166
label distributeSurfaceFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, reconstruct and write all/selected surface fields.
Namespace for OpenFOAM.