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-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::fvMeshSubsetProxy
29 
30 Description
31  Simple proxy for holding a mesh, or mesh-subset.
32  The subMeshes are currently limited to cellSet or cellZone definitions.
33 
34 SourceFiles
35  fvMeshSubsetProxy.C
36  fvMeshSubsetProxyTemplates.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef fvMeshSubsetProxy_H
41 #define fvMeshSubsetProxy_H
42 
43 #include "wordRes.H"
44 #include "fvMeshSubset.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class fvMeshSubsetProxy Declaration
54 \*---------------------------------------------------------------------------*/
55 
57 {
58 public:
59 
60  // Data Types
61 
62  //- Internal bookkeeping for subset type
63  enum subsetType
64  {
65  NONE,
66  SET,
67  ZONE,
68  ZONES
69  };
70 
71 
72 private:
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  //- No copy construct
101  fvMeshSubsetProxy(const fvMeshSubsetProxy&) = delete;
102 
103  //- No copy assignment
104  void operator=(const fvMeshSubsetProxy&) = delete;
105 
106 
107 public:
108 
109  // Constructors
110 
111  //- Construct a pass-through proxy. No correct() invoked or required.
112  explicit fvMeshSubsetProxy(fvMesh& baseMesh);
113 
114  //- Construct from components
116  (
117  fvMesh& baseMesh,
118  const subsetType type,
119  const word& selectionName,
120  label exposedPatchId = -1
121  );
122 
123  //- Construct from components. The subsetType is ZONES.
125  (
126  fvMesh& baseMesh,
127  const wordRes& zoneNames,
128  label exposedPatchId = -1
129  );
130 
131  //- Construct from components. The subsetType is ZONES.
133  (
134  fvMesh& baseMesh,
135  wordRes&& zoneNames,
136  label exposedPatchId = -1
137  );
138 
139 
140  // Member Functions
141 
142  // Access
143 
144  //- The entire base mesh
145  inline const fvMesh& baseMesh() const
146  {
147  return baseMesh_;
148  }
149 
150  //- The mesh subsetter
151  inline const fvMeshSubset& subsetter() const
152  {
153  return subsetter_;
154  }
155 
156  //- Check if a sub-mesh is being used
157  inline bool useSubMesh() const
158  {
159  return type_ != NONE;
160  }
161 
162  //- Access either base-mesh or sub-mesh
163  inline const fvMesh& mesh() const
164  {
165  if (useSubMesh())
166  {
167  return subsetter_.subMesh();
168  }
169 
170  return baseMesh_;
171  }
172 
173  //- The associated (set or zone) name if any.
174  inline const word& name() const
175  {
176  return name_;
177  }
178 
179  //- The current cell selection, when subsetting is active
180  inline const bitSet& selectedCells() const
181  {
182  return selectedCells_;
183  }
184 
185 
186  // Edit
187 
188  //- Update of mesh subset.
189  // Return true if the subset changed from previous call.
190  bool correct(bool verbose = false);
191 
192  //- Read mesh. Correct on topo-change
194 
195 
196  // Fields
197 
198  //- Construct volField (with zeroGradient) from an internal field
199  template<class Type>
202  (
204  );
205 
206  //- Convert an internal field to a volume field (with zeroGradient)
207  template<class Type>
210  (
211  const fvMeshSubset& subsetter,
213  );
214 
215  //- Convert an internal field to a volume field (with zeroGradient)
216  // Currently no proper memory reuse
217  template<class Type>
220  (
221  const fvMeshSubset& subsetter,
223  );
224 
225  //- Wrapper for field or the subsetted field.
226  // Pass through or forward to fvMeshSubset::interpolate()
227  template<class GeoField>
229  (
230  const fvMeshSubset& subsetter,
231  const GeoField& fld
232  );
233 
234  //- Wrapper for field or the subsetted field.
235  // Pass through or forward to fvMeshSubset::interpolate()
236  template<class GeoField>
238  (
239  const fvMeshSubset& subsetter,
240  const tmp<GeoField>& fld
241  );
242 
243 
244  // Fields
245 
246  //- Convert an internal field to a volume field (with zeroGradient)
247  template<class Type>
250  (
252  ) const;
253 
254  //- Convert an internal field to a volume field (with zeroGradient)
255  // Currently no proper memory reuse
256  template<class Type>
259  (
261  ) const;
262 
263 
264  //- Wrapper for field or the subsetted field.
265  // Pass through or forward to fvMeshSubset::interpolate()
266  template<class GeoField>
267  tmp<GeoField> interpolate(const GeoField& fld) const;
268 
269  //- Wrapper for field or the subsetted field.
270  // Pass through or forward to fvMeshSubset::interpolate()
271  template<class GeoField>
273 };
274 
275 
276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
277 
278 } // End namespace Foam
279 
280 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
281 
282 #ifdef NoRepository
284 #endif
285 
286 #endif
287 
288 // ************************************************************************* //
wordRes.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:63
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::fvMeshSubset
Given the original mesh and the list of selected cells, it creates the mesh consisting only of the de...
Definition: fvMeshSubset.H:73
fvMeshSubset.H
Foam::fvMeshSubsetProxy::mesh
const fvMesh & mesh() const
Access either base-mesh or sub-mesh.
Definition: fvMeshSubsetProxy.H:162
Foam::fvMeshSubsetProxy::baseMesh
const fvMesh & baseMesh() const
The entire base mesh.
Definition: fvMeshSubsetProxy.H:144
zeroGradientFvPatchField.H
Foam::fvMeshSubsetProxy::subsetType
subsetType
Internal bookkeeping for subset type.
Definition: fvMeshSubsetProxy.H:62
Foam::fvMeshSubsetProxy::interpolateInternal
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)
Foam::fvMeshSubsetProxy::selectedCells
const bitSet & selectedCells() const
The current cell selection, when subsetting is active.
Definition: fvMeshSubsetProxy.H:179
Foam::fvMeshSubsetProxy::interpolate
static tmp< GeoField > interpolate(const fvMeshSubset &subsetter, const GeoField &fld)
Wrapper for field or the subsetted field.
Foam::fvMeshSubsetProxy::useSubMesh
bool useSubMesh() const
Check if a sub-mesh is being used.
Definition: fvMeshSubsetProxy.H:156
Foam::fvMeshSubset::subMesh
const fvMesh & subMesh() const
Return reference to subset mesh.
Definition: fvMeshSubsetI.H:48
Foam::fvMeshSubsetProxy::name
const word & name() const
The associated (set or zone) name if any.
Definition: fvMeshSubsetProxy.H:173
Foam::fvMeshSubsetProxy::zeroGradientField
static tmp< GeometricField< Type, fvPatchField, volMesh > > zeroGradientField(const DimensionedField< Type, volMesh > &df)
Construct volField (with zeroGradient) from an internal field.
fld
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
Foam::fvMeshSubsetProxy::ZONES
Subset with multiple cellZones.
Definition: fvMeshSubsetProxy.H:67
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fvMeshSubsetProxy::subsetter
const fvMeshSubset & subsetter() const
The mesh subsetter.
Definition: fvMeshSubsetProxy.H:150
Foam::fvMeshSubsetProxy
Simple proxy for holding a mesh, or mesh-subset. The subMeshes are currently limited to cellSet or ce...
Definition: fvMeshSubsetProxy.H:55
Foam::polyMesh::readUpdateState
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: polyMesh.H:90
Foam::fvMeshSubsetProxy::ZONE
Subset with a cellZone.
Definition: fvMeshSubsetProxy.H:66
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::fvMeshSubsetProxy::NONE
No subset.
Definition: fvMeshSubsetProxy.H:64
Foam::fvMeshSubsetProxy::SET
Subset with a cellSet.
Definition: fvMeshSubsetProxy.H:65
Foam::fvMeshSubsetProxy::correct
bool correct(bool verbose=false)
Update of mesh subset.
Definition: fvMeshSubsetProxy.C:132
fvMeshSubsetProxyTemplates.C
Foam::fvMeshSubsetProxy::readUpdate
polyMesh::readUpdateState readUpdate()
Read mesh. Correct on topo-change.
Definition: fvMeshSubsetProxy.C:196
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54