sampledIsoSurfaceCell.H
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-2018 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 Class
25  Foam::sampledIsoSurfaceCell
26 
27 Description
28  A sampledSurface defined by a surface of iso value. Always triangulated.
29  To be used in sampleSurfaces / functionObjects. Recalculates iso surface
30  only if time changes.
31 
32 SourceFiles
33  sampledIsoSurfaceCell.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef sampledIsoSurfaceCell_H
38 #define sampledIsoSurfaceCell_H
39 
40 #include "sampledSurface.H"
41 #include "triSurface.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class sampledIsoSurfaceCell Declaration
50 \*---------------------------------------------------------------------------*/
51 
53 :
54  public sampledSurface,
55  public triSurface
56 {
57  // Private data
58 
59  //- Field to get isoSurface of
60  const word isoField_;
61 
62  //- Iso value
63  const scalar isoVal_;
64 
65  //- Whether to coarse
66  const Switch regularise_;
67 
68  //- Whether to recalculate cell values as average of point values
69  const Switch average_;
70 
71  //- If restricted to zones, name of this zone or a regular expression
72  keyType zoneKey_;
73 
74  //- Triangles converted to faceList
75  mutable autoPtr<faceList> facesPtr_;
76 
77 
78  // Recreated for every isoSurface
79 
80  //- Time at last call, also track it surface needs an update
81  mutable label prevTimeIndex_;
82 
83  //- For every triangle the original cell in mesh
84  mutable labelList meshCells_;
85 
86 
87  // Private Member Functions
88 
89  //- Create iso surface (if time has changed)
90  // Do nothing (and return false) if no update was needed
91  bool updateGeometry() const;
92 
93  //- Sample field on faces
94  template<class Type>
95  tmp<Field<Type>> sampleField
96  (
98  ) const;
99 
100 
101  template<class Type>
103  interpolateField(const interpolation<Type>&) const;
104 
105 
106 public:
107 
108  //- Runtime type information
109  TypeName("sampledIsoSurfaceCell");
110 
111 
112  // Constructors
113 
114  //- Construct from dictionary
116  (
117  const word& name,
118  const polyMesh& mesh,
119  const dictionary& dict
120  );
121 
122 
123  //- Destructor
124  virtual ~sampledIsoSurfaceCell();
125 
126 
127  // Member Functions
128 
129  //- Does the surface need an update?
130  virtual bool needsUpdate() const;
131 
132  //- Mark the surface as needing an update.
133  // May also free up unneeded data.
134  // Return false if surface was already marked as expired.
135  virtual bool expire();
136 
137  //- Update the surface as required.
138  // Do nothing (and return false) if no update was needed
139  virtual bool update();
140 
141 
142  //- Points of surface
143  virtual const pointField& points() const
144  {
145  return triSurface::points();
146  }
147 
148  //- Faces of surface
149  virtual const faceList& faces() const
150  {
151  if (facesPtr_.empty())
152  {
153  const triSurface& s = *this;
154 
155  facesPtr_.reset(new faceList(s.size()));
156 
157  forAll(s, i)
158  {
159  facesPtr_()[i] = s[i].triFaceFace();
160  }
161  }
162  return facesPtr_;
163  }
164 
165 
166  //- Sample field on surface
167  virtual tmp<scalarField> sample
168  (
169  const volScalarField&
170  ) const;
171 
172  //- Sample field on surface
173  virtual tmp<vectorField> sample
174  (
175  const volVectorField&
176  ) const;
177 
178  //- Sample field on surface
180  (
182  ) const;
183 
184  //- Sample field on surface
186  (
187  const volSymmTensorField&
188  ) const;
189 
190  //- Sample field on surface
191  virtual tmp<tensorField> sample
192  (
193  const volTensorField&
194  ) const;
195 
196 
197  //- Interpolate field on surface
199  (
200  const interpolation<scalar>&
201  ) const;
202 
203  //- Interpolate field on surface
205  (
206  const interpolation<vector>&
207  ) const;
208 
209  //- Interpolate field on surface
211  (
213  ) const;
214 
215  //- Interpolate field on surface
217  (
219  ) const;
220 
221  //- Interpolate field on surface
223  (
224  const interpolation<tensor>&
225  ) const;
226 
227  //- Write
228  virtual void print(Ostream&) const;
229 };
230 
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
234 } // End namespace Foam
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 #ifdef NoRepository
240 #endif
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 #endif
245 
246 // ************************************************************************* //
A class for handling keywords in dictionaries.
Definition: keyType.H:64
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
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:59
A sampledSurface defined by a surface of iso value. Always triangulated. To be used in sampleSurfaces...
void reset(T *=nullptr)
If object pointer already set, delete object and set to given.
Definition: autoPtrI.H:114
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
An abstract class for surfaces with sampling.
TypeName("sampledIsoSurfaceCell")
Runtime type information.
const word & name() const
Name of surface.
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
virtual void print(Ostream &) const
Write.
bool interpolate() const
Interpolation requested for surface.
List< face > faceList
Definition: faceListFwd.H:43
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none.
Definition: Switch.H:60
Generic GeometricField class.
virtual bool update()
Update the surface as required.
bool empty() const
Return true if the autoPtr is empty (ie, no pointer set)
Definition: autoPtrI.H:76
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
virtual tmp< scalarField > sample(const volScalarField &) const
Sample field on surface.
A class for handling words, derived from string.
Definition: word.H:59
const Field< point > & points() const
Return reference to global points.
virtual ~sampledIsoSurfaceCell()
Destructor.
const polyMesh & mesh() const
Access to the underlying mesh.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual const pointField & points() const
Points of surface.
sampledIsoSurfaceCell(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Abstract base class for interpolation.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
virtual bool expire()
Mark the surface as needing an update.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
A class for managing temporary objects.
Definition: PtrList.H:53
Triangulated surface description with patch information.
Definition: triSurface.H:66
virtual bool needsUpdate() const
Does the surface need an update?
virtual const faceList & faces() const
Faces of surface.
Namespace for OpenFOAM.