fvMeshSubsetProxy.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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2016-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::fvMeshSubsetProxy
29
30Description
31 Simple proxy for holding a mesh, or mesh-subset.
32 The subMeshes are currently limited to cellSet or cellZone definitions.
33
34SourceFiles
35 fvMeshSubsetProxy.C
36 fvMeshSubsetProxyTemplates.C
37
38\*---------------------------------------------------------------------------*/
39
40#ifndef Foam_fvMeshSubsetProxy_H
41#define Foam_fvMeshSubsetProxy_H
42
43#include "fvMeshSubset.H"
44#include "wordRes.H"
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49namespace Foam
50{
51
52/*---------------------------------------------------------------------------*\
53 Class fvMeshSubsetProxy Declaration
54\*---------------------------------------------------------------------------*/
57{
58public:
59
60 // Data Types
61
62 //- Internal bookkeeping for subset type
63 enum subsetType
64 {
67 ZONE,
69 };
70
71
72private:
73
74 // Private Data
75
76 //- Reference to mesh
77 fvMesh& baseMesh_;
78
79 //- Subsetting engine
80 fvMeshSubset subsetter_;
81
82 //- Patch ID for exposed internal faces
83 label exposedPatchId_;
84
85 //- The subsetting type
86 subsetType type_;
87
88 //- Name of the cellSet/cellZone (or empty)
89 word name_;
90
91 //- Selection for multiple cell zones
92 wordRes names_;
93
94 //- The (cached) cell selection
95 bitSet selectedCells_;
96
97
98 // Private Member Functions
99
100 //- Clear, set to NONE
101 void clearOut();
102
103 //- No copy construct
104 fvMeshSubsetProxy(const fvMeshSubsetProxy&) = delete;
105
106 //- No copy assignment
107 void operator=(const fvMeshSubsetProxy&) = delete;
108
109
110public:
111
112 // Constructors
113
114 //- Construct a pass-through proxy. No correct() invoked or required.
116
117 //- Construct from components
119 (
121 const subsetType type,
122 const word& selectionName,
123 label exposedPatchId = -1
124 );
125
126 //- Construct from components. The subsetType is ZONES.
128 (
130 const wordRes& zoneNames,
131 label exposedPatchId = -1
132 );
133
134 //- Construct from components. The subsetType is ZONES.
136 (
138 wordRes&& zoneNames,
139 label exposedPatchId = -1
140 );
141
142
143 // Member Functions
144
145 // Access
146
147 //- The entire base mesh
148 const fvMesh& baseMesh() const noexcept
149 {
150 return baseMesh_;
151 }
152
153 //- The mesh subsetter
154 const fvMeshSubset& subsetter() const noexcept
155 {
156 return subsetter_;
157 }
158
159 //- The mesh subsetter
161 {
162 return subsetter_;
163 }
164
165 //- True if sub-mesh should be used
166 bool useSubMesh() const noexcept
167 {
168 return type_ != subsetType::NONE;
169 }
170
171 //- Access either base-mesh or sub-mesh
172 inline const fvMesh& mesh() const
173 {
174 if (useSubMesh())
175 {
176 return subsetter_.subMesh();
177 }
178
179 return baseMesh_;
180 }
181
182 //- The associated (set or zone) name if any.
183 const word& name() const noexcept
184 {
185 return name_;
186 }
187
188 //- The current cell selection, when subsetting is active
189 const bitSet& selectedCells() const noexcept
190 {
191 return selectedCells_;
192 }
193
194
195 // Edit
196
197 //- Define the zones selection, subset the mesh accordingly
198 void resetZones(const wordRes& zoneNames);
199
200 //- Update of mesh subset.
201 // Return true if the subset changed from previous call.
202 bool correct(bool verbose = false);
203
204 //- Read mesh. Correct on topo-change
206
207
208 // Fields
209
210 //- Construct volField (with zeroGradient) from an internal field
211 template<class Type>
214 (
216 );
217
218 //- Convert an internal field to a volume field (with zeroGradient)
219 template<class Type>
222 (
223 const fvMeshSubset& subsetter,
225 );
226
227 //- Convert an internal field to a volume field (with zeroGradient)
228 // Currently no proper memory reuse
229 template<class Type>
232 (
233 const fvMeshSubset& subsetter,
235 );
236
237 //- Wrapper for field or the subsetted field.
238 // Pass through or forward to fvMeshSubset::interpolate()
239 template<class GeoField>
241 (
242 const fvMeshSubset& subsetter,
243 const GeoField& fld
244 );
245
246 //- Wrapper for field or the subsetted field.
247 // Pass through or forward to fvMeshSubset::interpolate()
248 template<class GeoField>
250 (
251 const fvMeshSubset& subsetter,
252 const tmp<GeoField>& fld
253 );
254
255
256 // Fields
257
258 //- Convert an internal field to a volume field (with zeroGradient)
259 template<class Type>
262 (
264 ) const;
265
266 //- Convert an internal field to a volume field (with zeroGradient)
267 // Currently no proper memory reuse
268 template<class Type>
271 (
273 ) const;
274
275
276 //- Wrapper for field or the subsetted field.
277 // Pass through or forward to fvMeshSubset::interpolate()
278 template<class GeoField>
279 tmp<GeoField> interpolate(const GeoField& fld) const;
280
281 //- Wrapper for field or the subsetted field.
282 // Pass through or forward to fvMeshSubset::interpolate()
283 template<class GeoField>
285};
286
287
288// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289
290} // End namespace Foam
291
292// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
293
294#ifdef NoRepository
296#endif
297
298#endif
299
300// ************************************************************************* //
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:66
Simple proxy for holding a mesh, or mesh-subset. The subMeshes are currently limited to cellSet or ce...
static tmp< GeometricField< Type, fvPatchField, volMesh > > interpolateInternal(const fvMeshSubset &subsetter, const tmp< DimensionedField< Type, volMesh > > &tdf)
Convert an internal field to a volume field (with zeroGradient)
tmp< GeometricField< Type, fvPatchField, volMesh > > interpolateInternal(const tmp< DimensionedField< Type, volMesh > > &tdf) const
Convert an internal field to a volume field (with zeroGradient)
static tmp< GeoField > interpolate(const fvMeshSubset &subsetter, const GeoField &fld)
Wrapper for field or the subsetted field.
static tmp< GeometricField< Type, fvPatchField, volMesh > > zeroGradientField(const DimensionedField< Type, volMesh > &df)
Construct volField (with zeroGradient) from an internal field.
const fvMesh & baseMesh() const noexcept
The entire base mesh.
tmp< GeometricField< Type, fvPatchField, volMesh > > interpolateInternal(const DimensionedField< Type, volMesh > &df) const
Convert an internal field to a volume field (with zeroGradient)
tmp< GeoField > interpolate(const GeoField &fld) const
Wrapper for field or the subsetted field.
const bitSet & selectedCells() const noexcept
The current cell selection, when subsetting is active.
bool useSubMesh() const noexcept
True if sub-mesh should be used.
void resetZones(const wordRes &zoneNames)
Define the zones selection, subset the mesh accordingly.
const word & name() const noexcept
The associated (set or zone) name if any.
tmp< GeoField > interpolate(const tmp< GeoField > &fld) const
Wrapper for field or the subsetted field.
polyMesh::readUpdateState readUpdate()
Read mesh. Correct on topo-change.
const fvMesh & mesh() const
Access either base-mesh or sub-mesh.
const fvMeshSubset & subsetter() const noexcept
The mesh subsetter.
subsetType
Internal bookkeeping for subset type.
@ ZONES
Subset with multiple cellZones.
@ ZONE
Subset with a cellZone.
@ SET
Subset with a cellSet.
static tmp< GeoField > interpolate(const fvMeshSubset &subsetter, const tmp< GeoField > &fld)
Wrapper for field or the subsetted field.
static tmp< GeometricField< Type, fvPatchField, volMesh > > interpolateInternal(const fvMeshSubset &subsetter, const DimensionedField< Type, volMesh > &df)
Convert an internal field to a volume field (with zeroGradient)
fvMeshSubset & subsetter() noexcept
The mesh subsetter.
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
Definition: fvMeshSubset.H:80
const fvMesh & subMesh() const
Return reference to subset mesh.
Definition: fvMeshSubsetI.H:48
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: polyMesh.H:91
A class for managing temporary objects.
Definition: tmp.H:65
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
A class for handling words, derived from Foam::string.
Definition: word.H:68
thermo correct()
Namespace for OpenFOAM.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
const direction noexcept
Definition: Scalar.H:223