Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
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.cxx
39 parFvFieldDistributor.txx
40 parFvFieldDistributorFields.cxx
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
53namespace Foam
54{
55
56// Forward Declarations
59class IOobjectList;
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
97public:
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)
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>
218 const IOobjectList& objects,
219 const wordRes& selectedFields = wordRes()
220 ) const;
221};
222
223
224// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226} // End namespace Foam
227
228// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229
230#ifdef NoRepository
231# include "parFvFieldDistributor.txx"
232#endif
233
234// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236#endif
237
238// ************************************************************************* //
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-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. Implemented as a HashTable,...
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition Switch.H:81
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
Class containing processor-to-processor mapping information.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
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.
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > distributeSurfaceField(const IOobject &fieldObject) const
Read and distribute surface field.
void operator=(const parFvFieldDistributor &)=delete
No copy assignment.
label distributeVolumeFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, redistribute and write all/selected volume fields.
parFvFieldDistributor(const fvMesh &srcMesh, fvMesh &tgtMesh, const mapDistributePolyMesh &distMap, const bool isWriteProc)
Construct from components.
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.
parFvFieldDistributor(const parFvFieldDistributor &)=delete
No copy construct.
void distributeAllFields(const IOobjectList &objects, const wordRes &selectedFields) const
Distribute all fields for known field types.
parFvFieldDistributor(const fvMesh &srcMesh, fvMesh &tgtMesh, const mapDistributePolyMesh &distMap, refPtr< fileOperation > &writeHandler)
Construct from components.
void reconstructPoints()
Helper: reconstruct and write mesh points.
A class for managing references or pointers (no reference counting).
Definition refPtr.H:54
A class for managing temporary objects.
Definition tmp.H:75
A List of wordRe with additional matching capabilities.
Definition wordRes.H:56
Namespace for OpenFOAM.