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-------------------------------------------------------------------------------
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::faMeshSubset
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
34Caution
35 Currently not really functional for subsetting beyond handling
36 a simple zero-sized mesh.
37
38SourceFiles
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
56namespace Foam
57{
58
59// Forward Declarations
60class mapDistributePolyMesh;
61
62/*---------------------------------------------------------------------------*\
63 Class faMeshSubset Declaration
64\*---------------------------------------------------------------------------*/
66class 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
98protected:
99
100 // Protected Member Functions
101
102 //- FatalError if subset has not been performed
103 bool checkHasSubMesh() const;
104
105 //- No copy construct
106 faMeshSubset(const faMeshSubset&) = delete;
107
108 //- No copy assignment
109 void operator=(const faMeshSubset&) = delete;
110
111
112public:
113
114 // Static Data Members
115
116 //- Name for exposed internal edges (default: oldInternalEdges)
117 static word exposedPatchName;
118
119
120 // Constructors
121
122 //- Construct using the entire mesh (no subset)
123 explicit faMeshSubset(const faMesh& baseMesh);
124
125 //- Construct a zero-sized subset mesh, non-processor patches only
126 faMeshSubset(const faMesh& baseMesh, const Foam::zero);
127
128
129 // Member Functions
130
131 // Access
132
133 //- Original mesh
134 inline const faMesh& baseMesh() const noexcept;
135
136 //- Return baseMesh or subMesh, depending on the current state.
137 inline const faMesh& mesh() const noexcept;
138
139 //- Have subMesh?
140 inline bool hasSubMesh() const noexcept;
141
142 //- Return reference to subset mesh
143 inline const faMesh& subMesh() const;
144
145 //- Return reference to subset mesh
146 inline faMesh& subMesh();
147
148 //- Return point map
149 inline const labelList& pointMap() const;
150
151 //- Return face map
152 inline const labelList& faceMap() const;
153
154 //- Return edge map with sign to encode flipped edges
155 inline const labelList& edgeFlipMap() const;
156
157 //- Return cell map
158 inline const labelList& cellMap() const;
159
160 //- Return patch map
161 inline const labelList& patchMap() const;
162
163
164 // Edit
165
166 //- Reset subMesh and all maps
167 void clear();
168
169 //- Reset subMesh and all maps. Same as clear()
170 void reset();
171
172 //- Reset to a zero-sized subset mesh, non-processor patches only
173 void reset(const Foam::zero);
174
175
176 // Field Mapping (static functions)
177
178 //- Map area field.
179 // Optionally allow unmapped faces not to produce a warning
180 template<class Type>
183 (
184 const GeometricField<Type, faPatchField, areaMesh>&,
185 const faMesh& sMesh,
186 const bool allowUnmapped = false
187 );
188
189 //- Map edge field.
190 // Optionally allow unmapped faces not to produce a warning
191 template<class Type>
194 (
196 const faMesh& sMesh
197 );
198
199
200 // Field Mapping
201
202 //- Map area field.
203 // Optionally allow unmapped faces not to produce a warning
204 template<class Type>
207 (
208 const GeometricField<Type, faPatchField, areaMesh>&,
209 const bool allowUnmapped = false
210 ) const;
211
212 //- Map edge field.
213 template<class Type>
216 (
218 const bool allowUnmapped = false
219 ) const;
220};
221
222
223// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224
225} // End namespace Foam
226
227// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228
229#include "faMeshSubsetI.H"
230
231// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232
233#ifdef NoRepository
234 #include "faMeshSubsetTemplates.C"
235#endif
236
237// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238
239#endif
240
241// ************************************************************************* //
Generic GeometricField class.
Mesh data needed to do the Finite Area discretisation.
Definition: areaFaMesh.H:56
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Mesh data needed to do the Finite Area discretisation.
Definition: edgeFaMesh.H:56
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
Definition: faMeshSubset.H:66
faMeshSubset(const faMeshSubset &)=delete
No copy construct.
const labelList & faceMap() const
Return face map.
Definition: faMeshSubsetI.H:72
void operator=(const faMeshSubset &)=delete
No copy assignment.
const labelList & cellMap() const
Return cell map.
Definition: faMeshSubsetI.H:91
const faMesh & mesh() const noexcept
Return baseMesh or subMesh, depending on the current state.
Definition: faMeshSubsetI.H:36
bool checkHasSubMesh() const
FatalError if subset has not been performed.
Definition: faMeshSubset.C:42
const faMesh & subMesh() const
Return reference to subset mesh.
Definition: faMeshSubsetI.H:48
const labelList & patchMap() const
Return patch map.
Definition: faMeshSubsetI.H:99
static word exposedPatchName
Name for exposed internal edges (default: oldInternalEdges)
Definition: faMeshSubset.H:116
const labelList & pointMap() const
Return point map.
Definition: faMeshSubsetI.H:64
void clear()
Reset subMesh and all maps.
Definition: faMeshSubset.C:81
bool hasSubMesh() const noexcept
Have subMesh?
Definition: faMeshSubsetI.H:42
void reset()
Reset subMesh and all maps. Same as clear()
Definition: faMeshSubset.C:93
static tmp< GeometricField< Type, faPatchField, areaMesh > > interpolate(const GeometricField< Type, faPatchField, areaMesh > &, const faMesh &sMesh, const bool allowUnmapped=false)
Map area field.
const labelList & edgeFlipMap() const
Return edge map with sign to encode flipped edges.
Definition: faMeshSubsetI.H:80
const faMesh & baseMesh() const noexcept
Original mesh.
Definition: faMeshSubsetI.H:30
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:100
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: faPatchField.H:82
faePatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cove...
Definition: faePatchField.H:83
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:63
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223