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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::parFvFieldDistributor
29
30Description
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
37SourceFiles
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
52namespace Foam
53{
54
55// Forward Declarations
56class mapDistributePolyMesh;
57class mapDistributeBase;
58class IOobjectList;
59
60/*---------------------------------------------------------------------------*\
61 Class parFvFieldDistributor Declaration
62\*---------------------------------------------------------------------------*/
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
96public:
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// ************************************************************************* //
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic GeometricField class.
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:59
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Finite volume reconstructor for volume and surface fields.
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > distributeField(const GeometricField< Type, fvsPatchField, surfaceMesh > &) const
Redistribute surface field.
label distributeInternalFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, redistribute and write all/selected volume internal fields.
tmp< DimensionedField< Type, volMesh > > distributeField(const DimensionedField< Type, volMesh > &) const
Redistribute volume internal field.
label distributeSurfaceFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, reconstruct and write all/selected surface fields.
bool isWriteProc(const bool on) noexcept
Change status of write enabled (on this proc)
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > distributeSurfaceField(const IOobject &fieldObject) const
Read and distribute surface field.
bool isWriteProc() const noexcept
Get status of write enabled (on this proc)
label distributeVolumeFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, redistribute and write all/selected volume fields.
tmp< DimensionedField< Type, volMesh > > distributeInternalField(const IOobject &fieldObject) const
Read and distribute volume internal field.
tmp< GeometricField< Type, fvPatchField, volMesh > > distributeVolumeField(const IOobject &fieldObject) const
Read and distribute volume field.
tmp< GeometricField< Type, fvPatchField, volMesh > > distributeField(const GeometricField< Type, fvPatchField, volMesh > &fld) const
Redistribute volume field.
static int verbose_
Output verbosity when writing.
void distributeAllFields(const IOobjectList &objects, const wordRes &selectedFields) const
Distribute all fields for known field types.
void reconstructPoints()
Helper: reconstruct and write mesh points.
A class for managing temporary objects.
Definition: tmp.H:65
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223