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-2020 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  //- Check for tet values above/below given (iso) value
131  // Result encoded as a single integer
132  inline static constexpr int getTetCutIndex
133  (
134  const scalar a,
135  const scalar b,
136  const scalar c,
137  const scalar d,
138  const scalar isoval
139  ) noexcept
140  {
141  return
142  (
143  (a < isoval ? 1 : 0)
144  | (b < isoval ? 2 : 0)
145  | (c < isoval ? 4 : 0)
146  | (d < isoval ? 8 : 0)
147  );
148  }
149 
150  //- Count the number of cuts matching the mask type
151  // Checks as bitmask or as zero.
152  static label countCutType
153  (
154  const UList<cutType>& cuts,
155  const uint8_t maskValue
156  );
157 
158  //- Dummy templated interpolate method
159  template<class Type>
161  (
163  const Field<Type>& pointValues
164  ) const
165  {
166  return nullptr;
167  }
168 
169  //- No copy construct
170  isoSurfaceBase(const isoSurfaceBase&) = delete;
171 
172  //- No copy assignment
173  void operator=(const isoSurfaceBase&) = delete;
174 
175 
176 public:
177 
178  // Typedefs for code transition
181 
182 
183  // Constructors
184 
185  //- Construct with mesh, cell/point values and iso-value
187  (
188  const polyMesh& mesh,
189  const scalarField& cellValues,
190  const scalarField& pointValues,
191  const scalar iso,
192  const isoSurfaceParams& params = isoSurfaceParams()
193  );
194 
195 
196  // Selector
197 
198  //- Create for specified algorithm type
199  // Currently uses hard-code lookups based in isoSurfaceParams
201  (
202  const isoSurfaceParams& params,
203  const volScalarField& cellValues,
204  const scalarField& pointValues,
205  const scalar iso,
206  const bitSet& ignoreCells = bitSet()
207  );
208 
209 
210  // Member Functions
211 
212  // Access, Edit
213 
214  //- The mesh for which the iso-surface is associated
215  const polyMesh& mesh() const noexcept
216  {
217  return mesh_;
218  }
219 
220  //- The mesh cell values used for creating the iso-surface
221  const scalarField& cellValues() const noexcept
222  {
223  return cVals_;
224  }
225 
226  //- The mesh point values used for creating the iso-surface
227  const scalarField& pointValues() const noexcept
228  {
229  return pVals_;
230  }
231 
232  //- The iso-value associated with the surface
233  scalar isoValue() const noexcept
234  {
235  return iso_;
236  }
237 
238  //- For each face, the original cell in mesh
239  const labelList& meshCells() const noexcept
240  {
241  return meshCells_;
242  }
243 
244  //- For each face, the original cell in mesh
245  labelList& meshCells() noexcept
246  {
247  return meshCells_;
248  }
249 
250 
251  // Helpers
252 
253  //- Restore non-BLOCKED state to an UNVISITED state
254  static void resetCuts(UList<cutType>& cuts);
255 
256  //- Mark ignoreCells as BLOCKED
257  label blockCells
258  (
259  UList<cutType>& cuts,
260  const bitSet& ignoreCells
261  ) const;
262 
263  //- Mark cells inside/outside a (valid) bound box as BLOCKED
264  // The volType is INSIDE or OUTSIDE only
265  label blockCells
266  (
267  UList<cutType>& cuts,
268  const boundBox& bb,
269  const volumeType::type volType
270  ) const;
271 
272 
273  // Cutting
274 
275  //- Set ignoreBoundaryFaces to ignore cyclics (cyclicACMI)
276  void ignoreCyclics();
277 
278  //- Populate a list of candidate cell cuts using getCellCutType()
279  label calcCellCuts(List<cutType>& cuts) const;
280 
281  //- Determine face cut for an individual face
282  cutType getFaceCutType(const label facei) const;
283 
284  //- Cell cut for an individual cell, with special handling
285  //- for TETCUT and SPHERE cuts
286  cutType getCellCutType(const label celli) const;
287 
288 
289  // Sampling
290 
291 #undef declareIsoSurfaceInterpolateMethod
292 #define declareIsoSurfaceInterpolateMethod(Type) \
293  \
294  virtual tmp<Field<Type>> \
295  interpolate \
296  ( \
297  const GeometricField<Type, fvPatchField, volMesh>& cellValues, \
298  const Field<Type>& pointValues \
299  ) const;
300 
306 };
307 
308 
309 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
310 
311 } // End namespace Foam
312 
313 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
314 
315 #endif
316 
317 // ************************************************************************* //
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::getTetCutIndex
static constexpr int getTetCutIndex(const scalar a, const scalar b, const scalar c, const scalar d, const scalar isoval) noexcept
Check for tet values above/below given (iso) value.
Definition: isoSurfaceBase.H:132
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:291
Foam::isoSurfaceParams::algorithmType
algorithmType
The algorithm types.
Definition: isoSurfaceParams.H:98
Foam::isoSurfaceBase::meshCells
labelList & meshCells() noexcept
For each face, the original cell in mesh.
Definition: isoSurfaceBase.H:244
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:214
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::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
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:133
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:91
Foam::isoSurfaceBase::meshCells
const labelList & meshCells() const noexcept
For each face, the original cell in mesh.
Definition: isoSurfaceBase.H:238
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:220
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:160
Foam::isoSurfaceBase::isoValue
scalar isoValue() const noexcept
The iso-value associated with the surface.
Definition: isoSurfaceBase.H:232
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::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
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:226
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:107
MeshedSurface.H