Loading...
Searching...
No Matches
faMeshDistributor.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) 2022-2025 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::faMeshDistributor
28
29Description
30 Holds a reference to the original mesh (the baseMesh)
31 and optionally to a subset of that mesh (the subMesh)
32 with mapping lists for points, faces, and cells.
33
34SourceFiles
35 faMeshDistributor.cxx
36 faMeshDistributor.txx
37 faMeshDistributorNew.cxx
38
39\*---------------------------------------------------------------------------*/
40
41#ifndef Foam_faMeshDistributor_H
42#define Foam_faMeshDistributor_H
43
44#include "faMesh.H"
46#include "areaFieldsFwd.H"
47#include "edgeFieldsFwd.H"
48#include "Switch.H"
49
50// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51
52namespace Foam
53{
54
55// Forward Declarations
56class IOobjectList;
58/*---------------------------------------------------------------------------*\
59 Class faMeshDistributor Declaration
60\*---------------------------------------------------------------------------*/
61
63{
64 // Private Data
65
66 //- The source mesh reference
67 const faMesh& srcMesh_;
68
69 //- The destination mesh reference
70 const faMesh& tgtMesh_;
71
72 //- Distribution map reference (faMesh)
73 const mapDistributePolyMesh& distMap_;
74
75 //- Internal edge mapper
76 mutable std::unique_ptr<mapDistributeBase> internalEdgeMapPtr_;
77
78 //- Patch edge mappers
79 mutable PtrList<mapDistributeBase> patchEdgeMaps_;
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 internal edge mapping
94 void createInternalEdgeMap() const;
95
96 //- Construct per-patch edge mapping
97 void createPatchMaps() const;
98
99 //- Debug: check addressing
100 void checkAddressing() const;
101
102 //- Construct reconstruct mapping
103 static mapDistributePolyMesh createReconstructMap
104 (
105 const faMesh& mesh,
106 const autoPtr<faMesh>& baseMeshPtr,
107 const labelUList& faceProcAddr,
108 const labelUList& edgeProcAddr,
109 const labelUList& pointProcAddr,
110 const labelUList& boundaryProcAddr
111 );
112
113
114public:
115
116 //- Output verbosity when writing
117 static int verbose_;
118
119
120 // Generated Methods
121
122 //- No copy construct
123 faMeshDistributor(const faMeshDistributor&) = delete;
124
125 //- No copy assignment
126 void operator=(const faMeshDistributor&) = delete;
127
128
129 // Constructors
130
131 //- Construct from components, using bool to control writing
133 (
134 const faMesh& srcMesh,
135 const faMesh& tgtMesh,
136 const mapDistributePolyMesh& faDistMap,
137 const bool isWriteProc
138 );
139
140 //- Construct from components, using file handler to control writing
142 (
143 const faMesh& srcMesh,
144 const faMesh& tgtMesh,
145 const mapDistributePolyMesh& faDistMap,
147 );
148
149
150 // Static Methods
152 //- Distribute mesh according to the given (volume) mesh distribution.
153 // Uses 'tgtPolyMesh' for the new mesh
155 (
156 const faMesh& oldMesh,
157 const mapDistributePolyMesh& distMap,
158 const polyMesh& tgtPolyMesh,
159 autoPtr<faMesh>& newMeshPtr
160 );
161
162 //- Distribute mesh according to the given (volume) mesh distribution.
163 // Re-uses polyMesh from oldMesh for the new mesh
165 (
166 const faMesh& oldMesh,
167 const mapDistributePolyMesh& distMap,
168 autoPtr<faMesh>& newMeshPtr
169 );
171
172 // Member Functions
173
174 // Field Mapping
175
176 //- Read, distribute and write all/selected point field types
177 //- (scalar, vector, ... types)
179 (
180 const IOobjectList& objects,
181 const wordRes& selectedFields = wordRes()
182 ) const;
183
184 //- Distribute area field
185 template<class Type>
188 (
190 ) const;
191
192 //- Distribute edge field
193 template<class Type>
196 (
198 ) const;
200 //- Read and distribute area field
201 template<class Type>
204 (
205 const IOobject& fieldObject
206 ) const;
207
208 //- Read and distribute edge field
209 template<class Type>
212 (
213 const IOobject& fieldObject
214 ) const;
216 //- Read, distribute and write all/selected area fields
217 template<class Type>
219 (
220 const IOobjectList& objects,
221 const wordRes& selectedFields = wordRes()
222 ) const;
223
224 //- Read, distribute and write all/selected area fields
225 template<class Type>
227 (
228 const IOobjectList& objects,
229 const wordRes& selectedFields = wordRes()
230 ) const;
231};
232
233
234// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235
236} // End namespace Foam
237
238// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239
240
241#ifdef NoRepository
242# include "faMeshDistributor.txx"
243#endif
244
245// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247#endif
248
249// ************************************************************************* //
Forwards and collection of common area field types.
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))
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
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
label distributeAllFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, distribute and write all/selected point field types (scalar, vector, ... types).
void operator=(const faMeshDistributor &)=delete
No copy assignment.
faMeshDistributor(const faMesh &srcMesh, const faMesh &tgtMesh, const mapDistributePolyMesh &faDistMap, refPtr< fileOperation > &writeHandler)
Construct from components, using file handler to control writing.
tmp< GeometricField< Type, faPatchField, areaMesh > > distributeAreaField(const IOobject &fieldObject) const
Read and distribute area field.
tmp< GeometricField< Type, faPatchField, areaMesh > > distributeField(const GeometricField< Type, faPatchField, areaMesh > &fld) const
Distribute area field.
faMeshDistributor(const faMeshDistributor &)=delete
No copy construct.
static int verbose_
Output verbosity when writing.
static mapDistributePolyMesh distribute(const faMesh &oldMesh, const mapDistributePolyMesh &distMap, const polyMesh &tgtPolyMesh, autoPtr< faMesh > &newMeshPtr)
Distribute mesh according to the given (volume) mesh distribution.
static mapDistributePolyMesh distribute(const faMesh &oldMesh, const mapDistributePolyMesh &distMap, autoPtr< faMesh > &newMeshPtr)
Distribute mesh according to the given (volume) mesh distribution.
tmp< GeometricField< Type, faePatchField, edgeMesh > > distributeEdgeField(const IOobject &fieldObject) const
Read and distribute edge field.
tmp< GeometricField< Type, faePatchField, edgeMesh > > distributeField(const GeometricField< Type, faePatchField, edgeMesh > &fld) const
Distribute edge field.
label distributeEdgeFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, distribute and write all/selected area fields.
label distributeAreaFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, distribute and write all/selected area fields.
faMeshDistributor(const faMesh &srcMesh, const faMesh &tgtMesh, const mapDistributePolyMesh &faDistMap, const bool isWriteProc)
Construct from components, using bool to control writing.
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition faMesh.H:140
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
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
dynamicFvMesh & mesh
Forwards for edge field types.
Namespace for OpenFOAM.
UList< label > labelUList
A UList of labels.
Definition UList.H:75