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-2022 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::faMeshReconstructor
28 
29 Description
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 
42 SourceFiles
43  faMeshReconstructor.C
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 
55 namespace Foam
56 {
57 
58 // Forward Declarations
59 class Time;
60 
61 /*---------------------------------------------------------------------------*\
62  Class faMeshReconstructor Declaration
63 \*---------------------------------------------------------------------------*/
64 
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 
141 public:
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
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
183  const labelList& edgeProcAddressing() const noexcept
184  {
185  return faEdgeProcAddr_;
186  }
187 
188  //- Processor face addressing
189  const labelList& faceProcAddressing() const noexcept
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;
209 
210 
211  // Write
212 
213  //- Write proc addressing at the polyMesh faceInstances time
214  void writeAddressing() const;
215 
216  //- Write proc addressing at the given time
217  void writeAddressing(const word& timeName) const;
218 
219  //- Write equivalent mesh information at the polyMesh faceInstances time
220  void writeMesh() const;
221 
222  //- Write equivalent mesh information at the given time
223  void writeMesh(const word& timeName) const;
224 };
225 
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 } // End namespace Foam
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232 
233 #endif
234 
235 // ************************************************************************* //
bool good() const noexcept
True if no construct errors encountered.
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:87
void writeMesh() const
Write equivalent mesh information at the polyMesh faceInstances time.
const faMesh & mesh() const
Serial equivalent faMesh.
const labelList & edgeProcAddressing() const noexcept
Processor edge addressing.
static int debug
Debug flag.
A bare-bones reconstructor for finiteArea meshes when processor meshes are available (in parallel) bu...
const primitivePatch & patch() const
Serial equivalent patch.
word timeName
Definition: getTimeIndex.H:3
A class for handling words, derived from Foam::string.
Definition: word.H:63
const labelList & faceProcAddressing() const noexcept
Processor face addressing.
const labelList & boundaryProcAddressing() const noexcept
Processor boundary addressing.
const direction noexcept
Definition: Scalar.H:258
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field...
void writeAddressing() const
Write proc addressing at the polyMesh faceInstances time.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
const labelList & pointProcAddressing() const noexcept
Processor point addressing.
List< label > labelList
A List of labels.
Definition: List.H:62
Namespace for OpenFOAM.
readOption
Enumeration defining read preferences.