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-2019 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 // Forward declarations
53 class Time;
54 
55 /*---------------------------------------------------------------------------*\
56  Class fvMeshSubsetProxy Declaration
57 \*---------------------------------------------------------------------------*/
58 
60 {
61 public:
62 
63  //- Internal bookkeeping for subset type
64  enum subsetType
65  {
66  NONE, //<! No subset
67  SET, //<! Subset with a cellSet
68  ZONE, //<! Subset with a cellZone
69  ZONES //<! Subset with multiple cellZones
70  };
71 
72 
73 private:
74 
75  // Private Data
76 
77  //- Reference to mesh
78  fvMesh& baseMesh_;
79 
80  //- Subsetting engine
81  fvMeshSubset subsetter_;
82 
83  //- Patch ID for exposed internal faces
84  label exposedPatchId_;
85 
86  //- The subsetting type
87  subsetType type_;
88 
89  //- Name of the cellSet/cellZone (or empty)
90  word name_;
91 
92  //- Selection for multiple cell zones
93  wordRes names_;
94 
95  //- The (cached) cell selection
96  bitSet selectedCells_;
97 
98 
99  // Private Member Functions
100 
101  //- No copy construct
102  fvMeshSubsetProxy(const fvMeshSubsetProxy&) = delete;
103 
104  //- No copy assignment
105  void operator=(const fvMeshSubsetProxy&) = delete;
106 
107 
108 public:
109 
110  // Constructors
111 
112  //- Construct a pass-through proxy. No correct() invoked or required.
113  explicit fvMeshSubsetProxy(fvMesh& baseMesh);
114 
115  //- Construct from components
117  (
118  fvMesh& baseMesh,
119  const subsetType type,
120  const word& selectionName,
121  label exposedPatchId = -1
122  );
123 
124  //- Construct from components. The subsetType is ZONES.
126  (
127  fvMesh& baseMesh,
128  const wordRes& zoneNames,
129  label exposedPatchId = -1
130  );
131 
132  //- Construct from components. The subsetType is ZONES.
134  (
135  fvMesh& baseMesh,
136  wordRes&& zoneNames,
137  label exposedPatchId = -1
138  );
139 
140 
141  // Member Functions
142 
143  // Access
144 
145  //- The entire base mesh
146  inline const fvMesh& baseMesh() const
147  {
148  return baseMesh_;
149  }
150 
151  //- The mesh subsetter
152  inline const fvMeshSubset& subsetter() const
153  {
154  return subsetter_;
155  }
156 
157  //- Check if a sub-mesh is being used
158  inline bool useSubMesh() const
159  {
160  return type_ != NONE;
161  }
162 
163  //- Access either base-mesh or sub-mesh
164  inline const fvMesh& mesh() const
165  {
166  if (useSubMesh())
167  {
168  return subsetter_.subMesh();
169  }
170 
171  return baseMesh_;
172  }
173 
174  //- The associated (set or zone) name if any.
175  inline const word& name() const
176  {
177  return name_;
178  }
179 
180  //- The current cell selection, when subsetting is active
181  inline const bitSet& selectedCells() const
182  {
183  return selectedCells_;
184  }
185 
186 
187  // Edit
188 
189  //- Update of mesh subset.
190  // Return true if the subset changed from previous call.
191  bool correct(bool verbose = false);
192 
193  //- Read mesh. Correct on topo-change
195 
196 
197  // Fields
198 
199  //- Construct volField (with zeroGradient) from an internal field
200  template<class Type>
203  (
205  );
206 
207  //- Convert an internal field to a volume field (with zeroGradient)
208  template<class Type>
211  (
212  const fvMeshSubset& subsetter,
214  );
215 
216  //- Convert an internal field to a volume field (with zeroGradient)
217  // Currently no proper memory reuse
218  template<class Type>
221  (
222  const fvMeshSubset& subsetter,
224  );
225 
226  //- Wrapper for field or the subsetted field.
227  // Pass through or forward to fvMeshSubset::interpolate()
228  template<class GeoField>
230  (
231  const fvMeshSubset& subsetter,
232  const GeoField& fld
233  );
234 
235  //- Wrapper for field or the subsetted field.
236  // Pass through or forward to fvMeshSubset::interpolate()
237  template<class GeoField>
239  (
240  const fvMeshSubset& subsetter,
241  const tmp<GeoField>& fld
242  );
243 
244 
245  // Fields
246 
247  //- Convert an internal field to a volume field (with zeroGradient)
248  template<class Type>
251  (
253  ) const;
254 
255  //- Convert an internal field to a volume field (with zeroGradient)
256  // Currently no proper memory reuse
257  template<class Type>
260  (
262  ) const;
263 
264 
265  //- Wrapper for field or the subsetted field.
266  // Pass through or forward to fvMeshSubset::interpolate()
267  template<class GeoField>
268  tmp<GeoField> interpolate(const GeoField& fld) const;
269 
270  //- Wrapper for field or the subsetted field.
271  // Pass through or forward to fvMeshSubset::interpolate()
272  template<class GeoField>
274 };
275 
276 
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 
279 } // End namespace Foam
280 
281 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
282 
283 #ifdef NoRepository
285 #endif
286 
287 #endif
288 
289 // ************************************************************************* //
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:64
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
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:163
Foam::fvMeshSubsetProxy::baseMesh
const fvMesh & baseMesh() const
The entire base mesh.
Definition: fvMeshSubsetProxy.H:145
zeroGradientFvPatchField.H
Foam::fvMeshSubsetProxy::subsetType
subsetType
Internal bookkeeping for subset type.
Definition: fvMeshSubsetProxy.H:63
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:180
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:157
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
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:174
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
Definition: fvMeshSubsetProxy.H:68
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fvMeshSubsetProxy::subsetter
const fvMeshSubset & subsetter() const
The mesh subsetter.
Definition: fvMeshSubsetProxy.H:151
Foam::fvMeshSubsetProxy
Simple proxy for holding a mesh, or mesh-subset. The subMeshes are currently limited to cellSet or ce...
Definition: fvMeshSubsetProxy.H:58
Foam::polyMesh::readUpdateState
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: polyMesh.H:91
Foam::fvMeshSubsetProxy::ZONE
Definition: fvMeshSubsetProxy.H:67
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
Definition: fvMeshSubsetProxy.H:65
Foam::fvMeshSubsetProxy::SET
Definition: fvMeshSubsetProxy.H:66
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