faMeshSubset.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 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::faMeshSubset
28 
29 Description
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 
34 Caution
35  Currently not really functional for subsetting beyond handling
36  a simple zero-sized mesh.
37 
38 SourceFiles
39  faMeshSubset.C
40  faMeshSubsetI.H
41  faMeshSubsetTemplates.C
42 
43 \*---------------------------------------------------------------------------*/
44 
45 #ifndef Foam_faMeshSubset_H
46 #define Foam_faMeshSubset_H
47 
48 #include "areaFaMesh.H"
49 #include "edgeFaMesh.H"
50 #include "GeometricField.H"
51 #include "bitSet.H"
52 #include "HashSet.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 
59 // Forward Declarations
60 class mapDistributePolyMesh;
61 
62 /*---------------------------------------------------------------------------*\
63  Class faMeshSubset Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class faMeshSubset
67 {
68  // Private Data
69 
70  //- The base mesh to subset from
71  const faMesh& baseMesh_;
72 
73  //- Demand-driven subset mesh (pointer)
74  autoPtr<faMesh> subMeshPtr_;
75 
76  //- Optional edge mapping array with flip encoded (-1/+1)
77  mutable autoPtr<labelList> edgeFlipMapPtr_;
78 
79  //- Point mapping array
80  labelList pointMap_;
81 
82  //- Face mapping array
83  labelList faceMap_;
84 
85  //- Cell mapping array
86  labelList cellMap_;
87 
88  //- Patch mapping array
89  labelList patchMap_;
90 
91 
92  // Private Member Functions
93 
94  //- Calculate face flip map
95  void calcEdgeFlipMap() const;
96 
97 
98 protected:
99 
100  // Protected Member Functions
101 
102  //- FatalError if subset has not been performed
103  bool checkHasSubMesh() const;
104 
105 
106 public:
107 
108  // Static Data Members
109 
110  //- Name for exposed internal edges (default: oldInternalEdges)
111  static word exposedPatchName;
112 
113  // Generated Methods
114 
115  //- No copy construct
116  faMeshSubset(const faMeshSubset&) = delete;
117 
118  //- No copy assignment
119  void operator=(const faMeshSubset&) = delete;
120 
121 
122  // Constructors
123 
124  //- Construct using the entire mesh (no subset)
125  explicit faMeshSubset(const faMesh& baseMesh);
127  //- Construct a zero-sized subset mesh, non-processor patches only
128  faMeshSubset(const faMesh& baseMesh, const Foam::zero);
129 
130 
131  // Member Functions
132 
133  // Access
134 
135  //- Original mesh
136  inline const faMesh& baseMesh() const noexcept;
137 
138  //- Return baseMesh or subMesh, depending on the current state.
139  inline const faMesh& mesh() const noexcept;
140 
141  //- Have subMesh?
142  inline bool hasSubMesh() const noexcept;
143 
144  //- Return reference to subset mesh
145  inline const faMesh& subMesh() const;
146 
147  //- Return reference to subset mesh
148  inline faMesh& subMesh();
149 
150  //- Return point map
151  inline const labelList& pointMap() const;
152 
153  //- Return face map
154  inline const labelList& faceMap() const;
155 
156  //- Return edge map with sign to encode flipped edges
157  inline const labelList& edgeFlipMap() const;
158 
159  //- Return cell map
160  inline const labelList& cellMap() const;
161 
162  //- Return patch map
163  inline const labelList& patchMap() const;
164 
165 
166  // Edit
167 
168  //- Reset subMesh and all maps
169  void clear();
170 
171  //- Reset subMesh and all maps. Same as clear()
172  void reset();
173 
174  //- Reset to a zero-sized subset mesh, non-processor patches only
175  void reset(const Foam::zero);
176 
177 
178  // Field Mapping (static functions)
179 
180  //- Map area field.
181  // Optionally allow unmapped faces not to produce a warning
182  template<class Type>
183  static tmp<GeometricField<Type, faPatchField, areaMesh>>
185  (
186  const GeometricField<Type, faPatchField, areaMesh>&,
187  const faMesh& sMesh,
188  const bool allowUnmapped = false
189  );
190 
191  //- Map edge field.
192  // Optionally allow unmapped faces not to produce a warning
193  template<class Type>
194  static tmp<GeometricField<Type, faePatchField, edgeMesh>>
196  (
197  const GeometricField<Type, faePatchField, edgeMesh>&,
198  const faMesh& sMesh
199  );
200 
201 
202  // Field Mapping
203 
204  //- Map area field.
205  // Optionally allow unmapped faces not to produce a warning
206  template<class Type>
209  (
210  const GeometricField<Type, faPatchField, areaMesh>&,
211  const bool allowUnmapped = false
212  ) const;
213 
214  //- Map edge field.
215  template<class Type>
218  (
219  const GeometricField<Type, faePatchField, edgeMesh>&,
220  const bool allowUnmapped = false
221  ) const;
222 };
223 
224 
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 } // End namespace Foam
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 #include "faMeshSubsetI.H"
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 #ifdef NoRepository
236  #include "faMeshSubsetTemplates.C"
237 #endif
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 #endif
242 
243 // ************************************************************************* //
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:133
bool hasSubMesh() const noexcept
Have subMesh?
Definition: faMeshSubsetI.H:35
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
Definition: faMeshSubset.H:61
const labelList & edgeFlipMap() const
Return edge map with sign to encode flipped edges.
Definition: faMeshSubsetI.H:73
Generic GeometricField class.
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:46
const labelList & faceMap() const
Return face map.
Definition: faMeshSubsetI.H:65
void operator=(const faMeshSubset &)=delete
No copy assignment.
const labelList & patchMap() const
Return patch map.
Definition: faMeshSubsetI.H:92
A class for handling words, derived from Foam::string.
Definition: word.H:63
static tmp< GeometricField< Type, faPatchField, areaMesh > > interpolate(const GeometricField< Type, faPatchField, areaMesh > &, const faMesh &sMesh, const bool allowUnmapped=false)
Map area field.
bool checkHasSubMesh() const
FatalError if subset has not been performed.
Definition: faMeshSubset.C:35
const labelList & pointMap() const
Return point map.
Definition: faMeshSubsetI.H:57
void reset()
Reset subMesh and all maps. Same as clear()
Definition: faMeshSubset.C:86
const faMesh & mesh() const noexcept
Return baseMesh or subMesh, depending on the current state.
Definition: faMeshSubsetI.H:29
const faMesh & subMesh() const
Return reference to subset mesh.
Definition: faMeshSubsetI.H:41
const labelList & cellMap() const
Return cell map.
Definition: faMeshSubsetI.H:84
const direction noexcept
Definition: scalarImpl.H:255
faMeshSubset(const faMeshSubset &)=delete
No copy construct.
Mesh data needed to do the Finite Area discretisation.
Definition: edgeFaMesh.H:47
const faMesh & baseMesh() const noexcept
Original mesh.
Definition: faMeshSubsetI.H:23
static word exposedPatchName
Name for exposed internal edges (default: oldInternalEdges)
Definition: faMeshSubset.H:126
Mesh data needed to do the Finite Area discretisation.
Definition: areaFaMesh.H:47
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
faePatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cove...
Definition: edgeFieldsFwd.H:43
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Namespace for OpenFOAM.
void clear()
Reset subMesh and all maps.
Definition: faMeshSubset.C:74