sampledIsoSurface.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "sampledIsoSurface.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace sampledSurfaces
34 {
37 }
38 }
39 
40 
41 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
42 
44 Foam::sampledSurfaces::isoSurface::calcIsoSurf() const
45 {
46  // Lookup the field
47  const volScalarField& vField =
48  mesh().lookupObject<volScalarField>(isoFieldName_);
49 
50  // Interpolate the field to the points
51  tmp<pointScalarField> pField
52  (
53  volPointInterpolation::New(vField.mesh()).interpolate(vField)
54  );
55 
56  // Construct iso-surfaces for the given iso-values
57  PtrList<cutPolyIsoSurface> isoSurfs(isoValues_.size());
58  forAll(isoValues_, i)
59  {
60  isoSurfs.set
61  (
62  i,
63  new cutPolyIsoSurface(mesh(), pField, isoValues_[i], zoneName())
64  );
65  }
66 
67  // Return or combine into a single surface
68  if (isoValues_.size() == 1)
69  {
70  return autoPtr<cutPolyIsoSurface>(isoSurfs.set(0, nullptr));
71  }
72  else
73  {
74  return autoPtr<cutPolyIsoSurface>(new cutPolyIsoSurface(isoSurfs));
75  }
76 }
77 
78 
79 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
80 
82 (
83  const word& name,
84  const polyMesh& mesh,
85  const dictionary& dict
86 )
87 :
89  isoFieldName_(dict.lookup("isoField")),
90  isoValues_
91  (
92  dict.found("isoValues")
93  ? scalarField(dict.lookup("isoValues"))
94  : scalarField(1, dict.lookup<scalar>("isoValue"))
95  )
96 {}
97 
98 
99 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
100 
102 {}
103 
104 
105 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106 
108 {
109  return wordList(isoFieldName_);
110 }
111 
112 
114 {
115  return timeIndex() != mesh().time().timeIndex();
116 }
117 
118 
120 {
121  os << "isoSurface: " << name() << " :"
122  << " field:" << isoFieldName_;
123  if (isoValues_.size() == 1)
124  {
125  os << " value:" << isoValues_[0];
126  }
127  else
128  {
129  os << " values:" << isoValues_;
130  }
131  os << " faces:" << faces().size()
132  << " points:" << points().size();
133 }
134 
135 
136 // ************************************************************************* //
bool found
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Macros for easy insertion into run-time selection tables.
static volPointInterpolation & New(const word &name, const fvMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
An abstract class for surfaces with sampling.
const polyMesh & mesh() const
Access to the underlying mesh.
A sampledSurface defined by an iso-value of a field.
virtual wordList fields() const
Return the list of fields required.
isoSurface(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
virtual bool needsUpdate() const
Does the surface need an update?
virtual void print(Ostream &) const
Write.
A base class for sampled surfaces constructed from iso-surfaces.
const word & zoneName() const
Access the zoneName.
tmp< PointField< Type > > interpolate(const VolField< Type > &) const
Interpolate volField using inverse distance weighting.
A class for handling words, derived from string.
Definition: word.H:62
const pointField & points
defineTypeNameAndDebug(cutPlane, 0)
addToRunTimeSelectionTable(sampledSurface, cutPlane, word)
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:54
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:64
label timeIndex
Definition: getTimeIndex.H:4
dictionary dict