Loading...
Searching...
No Matches
faMeshReconstructor.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) 2021-2024 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::faMeshReconstructor
28
29Description
30 A bare-bones reconstructor for finiteArea meshes when processor
31 meshes are available (in parallel) but an equivalent serial faMesh
32 is needed for reconstruction or decomposition.
33 In these situations, a serial version of the faMesh is needed,
34 but preferably without reconstructing the entire volume mesh.
35
36 It uses the finiteVolume faceProcAddressing in addition to
37 the geometric information available from the underlying polyMesh.
38
39 The resulting equivalent faMesh can be used for basic operations,
40 but caution should be exercised before attempting large operations.
41
42SourceFiles
43 faMeshReconstructor.cxx
44
45\*---------------------------------------------------------------------------*/
46
47#ifndef Foam_faMeshReconstructor_H
48#define Foam_faMeshReconstructor_H
49
50#include "faMesh.H"
51#include "primitivePatch.H"
52
53// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54
55namespace Foam
56{
57
58// Forward Declarations
59class Time;
61/*---------------------------------------------------------------------------*\
62 Class faMeshReconstructor Declaration
63\*---------------------------------------------------------------------------*/
64
65class faMeshReconstructor
66{
67 // Private Data
68
69 //- The processor-specific faMesh
70 const faMesh& procMesh_;
71
72 // Flags
73
74 //- Problems encountered during construction?
75 int errors_;
76
77
78 // Addressing
79
80 //- Processor face addressing, derived from finite volume information
81 labelList faFaceProcAddr_;
82
83 //- Processor boundary addressing
84 labelList faBoundaryProcAddr_;
85
86 //- Processor point addressing
87 labelList faPointProcAddr_;
88
89 //- Processor edge addressing
90 labelList faEdgeProcAddr_;
91
92
93 // Equivalent surface information
94
95 //- Faces labels for a single patch
96 labelList singlePatchFaceLabels_;
97
98 //- Faces for a single patch
99 faceList singlePatchFaces_;
100
101 //- Support points for a single patch
102 pointField singlePatchPoints_;
103
104 //- Lists of edge-labels (per edge patch) for the single patch
105 labelListList singlePatchEdgeLabels_;
106
107
108 // Demand-driven data
109
110 //- Primitive patch
111 mutable autoPtr<primitivePatch> serialPatchPtr_;
112
113 //- Time database for serial meshes
114 autoPtr<Time> serialRunTime_;
115
116 //- Dummy volume mesh, used for serial area mesh
117 autoPtr<polyMesh> serialVolMesh_;
118
119 //- Equivalent serial area mesh
120 autoPtr<faMesh> serialAreaMesh_;
121
122
123 // Private Member Functions
124
125 //- Calculate all addressing, using finiteVolume faceProcAddressing
126 void calcAddressing(const labelUList& fvFaceProcAddr);
127
128 //- Set primitive patch, removing any old one
129 void initPatch() const;
130
131 //- Create the serial geometry
132 void createMesh();
133
134 //- No copy construct
135 faMeshReconstructor(const faMeshReconstructor&) = delete;
136
137 //- No copy assignment
138 void operator=(const faMeshReconstructor&) = delete;
139
140
141public:
142
143 //- Debug flag
144 static int debug;
145
146
147 // Constructors
148
149 //- Construct from components
150 explicit faMeshReconstructor
151 (
152 const faMesh& procMesh,
153 IOobjectOption::readOption readVolProcAddr =
155 );
156
157 //- Construct from components
158 faMeshReconstructor
159 (
160 const faMesh& procMesh,
161 const labelUList& fvFaceProcAddressing
162 );
163
164
165 //- Destructor
167
168 void clearGeom();
169
170
171 // Member Functions
172
173 //- True if no construct errors encountered
174 bool good() const noexcept { return !errors_; }
175
176 //- Processor point addressing
177 const labelList& pointProcAddressing() const noexcept
178 {
179 return faPointProcAddr_;
180 }
181
182 //- Processor edge addressing
184 {
185 return faEdgeProcAddr_;
186 }
188 //- Processor face addressing
190 {
191 return faFaceProcAddr_;
192 }
193
194 //- Processor boundary addressing
196 {
197 return faBoundaryProcAddr_;
198 }
199
200
201 //- Serial equivalent patch
202 const primitivePatch& patch() const;
203
204 //- Serial equivalent patch
206
207 //- Serial equivalent faMesh
208 const faMesh& mesh() const;
210
211 // Write
212
213 //- Write proc addressing
214 static void writeAddressing
215 (
216 const IOobject& io,
217 const labelUList& faBoundaryProcAddr,
218 const labelUList& faFaceProcAddr,
219 const labelUList& faPointProcAddr,
220 const labelUList& faEdgeProcAddr
221 );
223 //- Write proc addressing at the polyMesh faceInstances time
224 void writeAddressing() const;
225
226 //- Write proc addressing at the given time
227 void writeAddressing(const word& timeName) const;
228
229 //- Write mesh information
230 static void writeMesh
231 (
232 const word& timeName,
233 const faMesh& fullMesh,
234 const labelUList& singlePatchFaceLabels
235 );
236
237 //- Write equivalent mesh information at the polyMesh faceInstances time
238 void writeMesh() const;
239
240 //- Write equivalent mesh information at the given time
241 void writeMesh(const word& timeName) const;
242};
243
244
245// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247} // End namespace Foam
248
249// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250
251#endif
252
253// ************************************************************************* //
readOption
Enumeration defining read preferences.
@ MUST_READ
Reading required.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static void writeMesh(const word &timeName, const faMesh &fullMesh, const labelUList &singlePatchFaceLabels)
Write mesh information.
const labelList & boundaryProcAddressing() const noexcept
Processor boundary addressing.
faMeshReconstructor(const faMesh &procMesh, const labelUList &fvFaceProcAddressing)
Construct from components.
~faMeshReconstructor()
Destructor.
bool good() const noexcept
True if no construct errors encountered.
primitivePatch & patch()
Serial equivalent patch.
static void writeAddressing(const IOobject &io, const labelUList &faBoundaryProcAddr, const labelUList &faFaceProcAddr, const labelUList &faPointProcAddr, const labelUList &faEdgeProcAddr)
Write proc addressing.
faMeshReconstructor(const faMesh &procMesh, IOobjectOption::readOption readVolProcAddr=IOobjectOption::MUST_READ)
Construct from components.
void writeMesh() const
Write equivalent mesh information at the polyMesh faceInstances time.
const labelList & faceProcAddressing() const noexcept
Processor face addressing.
const labelList & pointProcAddressing() const noexcept
Processor point addressing.
void writeAddressing() const
Write proc addressing at the polyMesh faceInstances time.
const faMesh & mesh() const
Serial equivalent faMesh.
void writeMesh(const word &timeName) const
Write equivalent mesh information at the given time.
static int debug
Debug flag.
const primitivePatch & patch() const
Serial equivalent patch.
const labelList & edgeProcAddressing() const noexcept
Processor edge addressing.
void writeAddressing(const word &timeName) const
Write proc addressing at the given time.
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition faMesh.H:140
A class for handling words, derived from Foam::string.
Definition word.H:66
const auto & io
word timeName
Definition getTimeIndex.H:3
Namespace for OpenFOAM.
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field.
List< face > faceList
List of faces.
Definition faceListFwd.H:41
const direction noexcept
Definition scalarImpl.H:265
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
Definition UList.H:75