isoSurfaceBase.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) 2019-2021 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::isoSurfaceBase
28 
29 Description
30  Low-level components common to various iso-surface algorithms.
31 
32 Note
33  The interpolation samplers currently require a volField for the cell
34  values. This is largely a restriction imposed by the point algorithm
35  and may be revised in the future.
36 
37 SourceFiles
38  isoSurfaceBase.C
39  isoSurfaceBaseNew.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef isoSurfaceBase_H
44 #define isoSurfaceBase_H
45 
46 #include "isoSurfaceParams.H"
47 #include "bitSet.H"
48 #include "scalarField.H"
49 #include "volumeType.H"
50 #include "volFieldsFwd.H"
51 #include "MeshedSurface.H"
52 #include "MeshedSurfacesFwd.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 
59 // Forward Declarations
60 class polyMesh;
61 class tetCell;
62 
63 /*---------------------------------------------------------------------------*\
64  Class isoSurfaceBase Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 class isoSurfaceBase
68 :
69  public meshedSurface,
70  public isoSurfaceParams
71 {
72 public:
73 
74  // Data Types
75 
76  //- The type of cell/face cuts
77  enum cutType : uint8_t
78  {
79  NOTCUT = 0,
80  CUT = 0x1,
81  TETCUT = 0x2,
82  SPHERE = 0x4,
83  ANYCUT = 0xF,
84 
85  UNVISITED = 0x10,
86  BLOCKED = 0x20,
87  SPECIAL = 0xF0
88  };
89 
90 
91 protected:
92 
93  // Protected typedefs for convenience
94  typedef meshedSurface Mesh;
95 
96  // Typedef for code transition
97  typedef cutType cellCutType;
98 
99 
100  // Protected Data
101 
102  //- Reference to mesh
103  const polyMesh& mesh_;
104 
105  //- Cell values
106  const scalarField& cVals_;
107 
108  //- Point values
109  const scalarField& pVals_;
110 
111  //- Iso value
112  const scalar iso_;
113 
114 
115  // Controls, restrictions
116 
117  //- Optional boundary faces to ignore.
118  // Eg, Used to exclude cyclicACMI (since duplicate faces)
120 
121 
122  // Sampling information
123 
124  //- For every face, the original cell in mesh
126 
127 
128  // Protected Member Functions
129 
130  //- Count the number of cuts matching the mask type
131  // Checks as bitmask or as zero.
132  static label countCutType
133  (
134  const UList<cutType>& cuts,
135  const uint8_t maskValue
136  );
137 
138  //- Dummy templated interpolate method
139  template<class Type>
141  (
143  const Field<Type>& pointValues
144  ) const
145  {
146  return nullptr;
147  }
148 
149  //- No copy construct
150  isoSurfaceBase(const isoSurfaceBase&) = delete;
151 
152  //- No copy assignment
153  void operator=(const isoSurfaceBase&) = delete;
154 
155 
156 public:
157 
158  // Typedefs for code transition
161 
162 
163  // Constructors
164 
165  //- Construct with mesh, cell/point values and iso-value
167  (
168  const polyMesh& mesh,
169  const scalarField& cellValues,
170  const scalarField& pointValues,
171  const scalar iso,
172  const isoSurfaceParams& params = isoSurfaceParams()
173  );
174 
175 
176  // Selector
177 
178  //- Create for specified algorithm type
179  // Currently uses hard-code lookups based in isoSurfaceParams
181  (
182  const isoSurfaceParams& params,
183  const volScalarField& cellValues,
184  const scalarField& pointValues,
185  const scalar iso,
186  const bitSet& ignoreCells = bitSet()
187  );
188 
189 
190  // Member Functions
191 
192  // Access, Edit
193 
194  //- The mesh for which the iso-surface is associated
195  const polyMesh& mesh() const noexcept
196  {
197  return mesh_;
198  }
199 
200  //- The mesh cell values used for creating the iso-surface
201  const scalarField& cellValues() const noexcept
202  {
203  return cVals_;
204  }
205 
206  //- The mesh point values used for creating the iso-surface
207  const scalarField& pointValues() const noexcept
208  {
209  return pVals_;
210  }
211 
212  //- The iso-value associated with the surface
213  scalar isoValue() const noexcept
214  {
215  return iso_;
216  }
217 
218  //- For each face, the original cell in mesh
219  const labelList& meshCells() const noexcept
220  {
221  return meshCells_;
222  }
223 
224  //- For each face, the original cell in mesh
225  labelList& meshCells() noexcept
226  {
227  return meshCells_;
228  }
229 
230 
231  // Helpers
232 
233  //- Restore non-BLOCKED state to an UNVISITED state
234  static void resetCuts(UList<cutType>& cuts);
235 
236  //- Mark ignoreCells as BLOCKED
237  label blockCells
238  (
239  UList<cutType>& cuts,
240  const bitSet& ignoreCells
241  ) const;
242 
243  //- Mark cells inside/outside a (valid) bound box as BLOCKED
244  // The volType is INSIDE or OUTSIDE only
245  label blockCells
246  (
247  UList<cutType>& cuts,
248  const boundBox& bb,
249  const volumeType::type volType
250  ) const;
251 
252 
253  // Cutting
254 
255  //- Set ignoreBoundaryFaces to ignore cyclics (cyclicACMI)
256  void ignoreCyclics();
257 
258  //- Populate a list of candidate cell cuts using getCellCutType()
259  label calcCellCuts(List<cutType>& cuts) const;
260 
261  //- Determine face cut for an individual face
262  cutType getFaceCutType(const label facei) const;
263 
264  //- Cell cut for an individual cell, with special handling
265  //- for TETCUT and SPHERE cuts
266  cutType getCellCutType(const label celli) const;
267 
268 
269  // Sampling
270 
271 #undef declareIsoSurfaceInterpolateMethod
272 #define declareIsoSurfaceInterpolateMethod(Type) \
273  \
274  virtual tmp<Field<Type>> \
275  interpolate \
276  ( \
277  const GeometricField<Type, fvPatchField, volMesh>& cellValues, \
278  const Field<Type>& pointValues \
279  ) const;
280 
286 };
287 
288 
289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290 
291 } // End namespace Foam
292 
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
294 
295 #endif
296 
297 // ************************************************************************* //
volFieldsFwd.H
Foam::isoSurfaceBase::blockCells
label blockCells(UList< cutType > &cuts, const bitSet &ignoreCells) const
Mark ignoreCells as BLOCKED.
Definition: isoSurfaceBase.C:148
Foam::sphericalTensor
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
Definition: sphericalTensor.H:54
Foam::volumeType::type
type
Volume classification types.
Definition: volumeType.H:65
Foam::isoSurfaceBase::New
static autoPtr< isoSurfaceBase > New(const isoSurfaceParams &params, const volScalarField &cellValues, const scalarField &pointValues, const scalar iso, const bitSet &ignoreCells=bitSet())
Create for specified algorithm type.
Definition: isoSurfaceBaseNew.C:37
Foam::isoSurfaceBase
Low-level components common to various iso-surface algorithms.
Definition: isoSurfaceBase.H:66
Foam::isoSurfaceBase::ignoreCyclics
void ignoreCyclics()
Set ignoreBoundaryFaces to ignore cyclics (cyclicACMI)
Definition: isoSurfaceBase.C:99
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:63
Foam::isoSurfaceBase::BLOCKED
Blocked (never cut)
Definition: isoSurfaceBase.H:85
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
scalarField.H
Foam::isoSurfaceBase::cVals_
const scalarField & cVals_
Cell values.
Definition: isoSurfaceBase.H:105
Foam::isoSurfaceBase::getCellCutType
cutType getCellCutType(const label celli) const
Definition: isoSurfaceBase.C:248
declareIsoSurfaceInterpolateMethod
#define declareIsoSurfaceInterpolateMethod(Type)
Definition: isoSurfaceBase.H:271
Foam::isoSurfaceParams::algorithmType
algorithmType
The algorithm types.
Definition: isoSurfaceParams.H:114
Foam::isoSurfaceBase::meshCells
labelList & meshCells() noexcept
For each face, the original cell in mesh.
Definition: isoSurfaceBase.H:224
Foam::isoSurfaceBase::UNVISITED
Unvisited.
Definition: isoSurfaceBase.H:84
bitSet.H
isoSurfaceParams.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::isoSurfaceBase::countCutType
static label countCutType(const UList< cutType > &cuts, const uint8_t maskValue)
Count the number of cuts matching the mask type.
Definition: isoSurfaceBase.C:116
Foam::isoSurfaceBase::mesh
const polyMesh & mesh() const noexcept
The mesh for which the iso-surface is associated.
Definition: isoSurfaceBase.H:194
Foam::isoSurfaceBase::isoSurfaceBase
isoSurfaceBase(const isoSurfaceBase &)=delete
No copy construct.
Foam::isoSurfaceBase::mesh_
const polyMesh & mesh_
Reference to mesh.
Definition: isoSurfaceBase.H:102
volumeType.H
Foam::Field< scalar >
Foam::isoSurfaceParams::isoSurfaceParams
isoSurfaceParams(const algorithmType algo=algorithmType::ALGO_DEFAULT, const filterType filter=filterType::DIAGCELL) noexcept
Default construct, or with specified algorithm.
Definition: isoSurfaceParams.C:135
Foam::isoSurfaceBase::meshCells_
labelList meshCells_
For every face, the original cell in mesh.
Definition: isoSurfaceBase.H:124
Foam::isoSurfaceBase::pVals_
const scalarField & pVals_
Point values.
Definition: isoSurfaceBase.H:108
Foam::isoSurfaceBase::getFaceCutType
cutType getFaceCutType(const label facei) const
Determine face cut for an individual face.
Definition: isoSurfaceBase.C:234
Foam::symmTensor
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Definition: symmTensor.H:59
Foam::isoSurfaceBase::iso_
const scalar iso_
Iso value.
Definition: isoSurfaceBase.H:111
Foam::isoSurfaceBase::operator=
void operator=(const isoSurfaceBase &)=delete
No copy assignment.
Foam::isoSurfaceBase::SPHERE
All edges to cell centre cut.
Definition: isoSurfaceBase.H:81
Foam::isoSurfaceBase::CUT
Normal cut.
Definition: isoSurfaceBase.H:79
Foam::isoSurfaceBase::TETCUT
Cell cut is a tet.
Definition: isoSurfaceBase.H:80
Foam::isoSurfaceBase::calcCellCuts
label calcCellCuts(List< cutType > &cuts) const
Populate a list of candidate cell cuts using getCellCutType()
Definition: isoSurfaceBase.C:208
Foam::isoSurfaceParams
Preferences for controlling iso-surface algorithms.
Definition: isoSurfaceParams.H:107
Foam::isoSurfaceBase::meshCells
const labelList & meshCells() const noexcept
For each face, the original cell in mesh.
Definition: isoSurfaceBase.H:218
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::isoSurfaceBase::resetCuts
static void resetCuts(UList< cutType > &cuts)
Restore non-BLOCKED state to an UNVISITED state.
Definition: isoSurfaceBase.C:135
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::isoSurfaceBase::Mesh
meshedSurface Mesh
Definition: isoSurfaceBase.H:93
Foam::isoSurfaceBase::cellValues
const scalarField & cellValues() const noexcept
The mesh cell values used for creating the iso-surface.
Definition: isoSurfaceBase.H:200
Foam::isoSurfaceBase::interpolateTemplate
tmp< Field< Type > > interpolateTemplate(const GeometricField< Type, fvPatchField, volMesh > &cellValues, const Field< Type > &pointValues) const
Dummy templated interpolate method.
Definition: isoSurfaceBase.H:140
Foam::isoSurfaceBase::isoValue
scalar isoValue() const noexcept
The iso-value associated with the surface.
Definition: isoSurfaceBase.H:212
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::isoSurfaceBase::cellCutType
cutType cellCutType
Definition: isoSurfaceBase.H:96
Foam::List< label >
Foam::isoSurfaceBase::SPECIAL
Bitmask for specials.
Definition: isoSurfaceBase.H:86
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:103
Foam::isoSurfaceBase::cutType
cutType
The type of cell/face cuts.
Definition: isoSurfaceBase.H:76
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::isoSurfaceBase::NOTCUT
Not cut.
Definition: isoSurfaceBase.H:78
Foam::isoSurfaceBase::ignoreBoundaryFaces_
bitSet ignoreBoundaryFaces_
Optional boundary faces to ignore.
Definition: isoSurfaceBase.H:118
MeshedSurfacesFwd.H
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::MeshedSurface< face >
Foam::isoSurfaceBase::pointValues
const scalarField & pointValues() const noexcept
The mesh point values used for creating the iso-surface.
Definition: isoSurfaceBase.H:206
Foam::isoSurfaceBase::ANYCUT
Any cut type (bitmask)
Definition: isoSurfaceBase.H:82
Foam::tensor
Tensor< scalar > tensor
Tensor of scalars, i.e. Tensor<scalar>.
Definition: symmTensor.H:61
Foam::isoSurfaceParams::filterType
filterType
The filtering (regularization) to apply.
Definition: isoSurfaceParams.H:123
MeshedSurface.H