sampledIsoSurface.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 | Copyright (C) 2011-2015 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::sampledIsoSurface
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  sampledIsoSurface.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef sampledIsoSurface_H
38 #define sampledIsoSurface_H
39 
40 #include "isoSurface.H"
41 #include "sampledSurface.H"
42 #include "ZoneIDs.H"
43 #include "fvMeshSubset.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class sampledIsoSurface Declaration
52 \*---------------------------------------------------------------------------*/
53 
55 :
56  public sampledSurface
57 {
58  // Private data
59 
60  //- Field to get isoSurface of
61  const word isoField_;
62 
63  //- Iso value
64  const scalar isoVal_;
65 
66  //- Optional bounding box to trim triangles against
67  const boundBox bounds_;
68 
69  //- Merge tolerance
70  const scalar mergeTol_;
71 
72  //- Whether to coarse
73  const Switch regularise_;
74 
75  //- Whether to recalculate cell values as average of point values
76  const Switch average_;
77 
78  //- Zone name/index (if restricted to zones)
79  mutable cellZoneID zoneID_;
80 
81  //- For zones: patch to put exposed faces into
82  mutable word exposedPatchName_;
83 
85 
86  //- Triangles converted to faceList
88 
89 
90  // Recreated for every isoSurface
91 
92  //- Time at last call, also track if surface needs an update
93  mutable label prevTimeIndex_;
94 
95  //- Cached volfield
97  mutable const volScalarField* volFieldPtr_;
98 
99  //- Cached pointfield
100  mutable const pointScalarField* pointFieldPtr_;
101 
102  // And on subsetted mesh
103 
104  //- Cached submesh
106 
107  //- Cached volfield
109  mutable const volScalarField* volSubFieldPtr_;
110 
111  //- Cached pointfield
112  mutable const pointScalarField* pointSubFieldPtr_;
113 
114 
115 
116  // Private Member Functions
117 
118  //- Get fields needed to recreate iso surface.
119  void getIsoFields() const;
120 
121  //- Create iso surface (if time has changed)
122  // Do nothing (and return false) if no update was needed
123  bool updateGeometry() const;
124 
125  //- Sample field on faces
126  template<class Type>
128  (
130  ) const;
131 
132 
133  template<class Type>
136 
137 
138 public:
139 
140  //- Runtime type information
141  TypeName("sampledIsoSurface");
142 
143 
144  // Constructors
145 
146  //- Construct from dictionary
148  (
149  const word& name,
150  const polyMesh& mesh,
151  const dictionary& dict
152  );
153 
154 
155  //- Destructor
156  virtual ~sampledIsoSurface();
157 
158 
159  // Member Functions
160 
161  //- Does the surface need an update?
162  virtual bool needsUpdate() const;
163 
164  //- Mark the surface as needing an update.
165  // May also free up unneeded data.
166  // Return false if surface was already marked as expired.
167  virtual bool expire();
168 
169  //- Update the surface as required.
170  // Do nothing (and return false) if no update was needed
171  virtual bool update();
172 
173 
174  //- Points of surface
175  virtual const pointField& points() const
176  {
177  return surface().points();
178  }
179 
180  //- Faces of surface
181  virtual const faceList& faces() const
182  {
183  if (facesPtr_.empty())
184  {
185  const triSurface& s = surface();
186 
187  facesPtr_.reset(new faceList(s.size()));
188 
189  forAll(s, i)
190  {
191  facesPtr_()[i] = s[i].triFaceFace();
192  }
193  }
194  return facesPtr_;
195  }
196 
197 
198  const isoSurface& surface() const
199  {
200  return surfPtr_();
201  }
202 
203  //- Lookup or read isoField. Sets volFieldPtr_ and pointFieldPtr_.
204  void getIsoField();
205 
206 
207  //- Sample field on surface
208  virtual tmp<scalarField> sample
209  (
210  const volScalarField&
211  ) const;
212 
213  //- Sample field on surface
214  virtual tmp<vectorField> sample
215  (
216  const volVectorField&
217  ) const;
218 
219  //- Sample field on surface
221  (
223  ) const;
224 
225  //- Sample field on surface
227  (
228  const volSymmTensorField&
229  ) const;
230 
231  //- Sample field on surface
232  virtual tmp<tensorField> sample
233  (
234  const volTensorField&
235  ) const;
236 
237 
238  //- Interpolate field on surface
240  (
241  const interpolation<scalar>&
242  ) const;
243 
244  //- Interpolate field on surface
246  (
247  const interpolation<vector>&
248  ) const;
249 
250  //- Interpolate field on surface
252  (
254  ) const;
255 
256  //- Interpolate field on surface
258  (
260  ) const;
261 
262  //- Interpolate field on surface
264  (
265  const interpolation<tensor>&
266  ) const;
267 
268  //- Write
269  virtual void print(Ostream&) const;
270 };
271 
272 
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 
275 } // End namespace Foam
276 
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 
279 #ifdef NoRepository
281 #endif
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 
285 #endif
286 
287 // ************************************************************************* //
sampledIsoSurfaceTemplates.C
Foam::sampledIsoSurface::updateGeometry
bool updateGeometry() const
Create iso surface (if time has changed)
Definition: sampledIsoSurface.C:345
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::PrimitivePatch::points
const Field< PointType > & points() const
Return reference to global points.
Definition: PrimitivePatchTemplate.H:282
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::sampledIsoSurface::interpolateField
tmp< Field< Type > > interpolateField(const interpolation< Type > &) const
Foam::sampledIsoSurface::sample
virtual tmp< scalarField > sample(const volScalarField &) const
Sample field on surface.
Definition: sampledIsoSurface.C:555
Foam::sampledIsoSurface::needsUpdate
virtual bool needsUpdate() const
Does the surface need an update?
Definition: sampledIsoSurface.C:519
Foam::sampledIsoSurface::isoVal_
const scalar isoVal_
Iso value.
Definition: sampledIsoSurface.H:63
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
fvMeshSubset.H
Foam::sampledIsoSurface::pointSubFieldPtr_
const pointScalarField * pointSubFieldPtr_
Cached pointfield.
Definition: sampledIsoSurface.H:111
Foam::sampledIsoSurface::storedVolFieldPtr_
autoPtr< volScalarField > storedVolFieldPtr_
Cached volfield.
Definition: sampledIsoSurface.H:95
Foam::sampledIsoSurface::points
virtual const pointField & points() const
Points of surface.
Definition: sampledIsoSurface.H:174
ZoneIDs.H
Foam::sampledIsoSurface::update
virtual bool update()
Update the surface as required.
Definition: sampledIsoSurface.C:548
Foam::DynamicID< cellZoneMesh >
Foam::sampledIsoSurface::print
virtual void print(Ostream &) const
Write.
Definition: sampledIsoSurface.C:643
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::sampledIsoSurface::regularise_
const Switch regularise_
Whether to coarse.
Definition: sampledIsoSurface.H:72
Foam::sampledIsoSurface::mergeTol_
const scalar mergeTol_
Merge tolerance.
Definition: sampledIsoSurface.H:69
Foam::isoSurface
A surface formed by the iso value. After "Regularised Marching Tetrahedra: improved iso-surface extra...
Definition: isoSurface.H:85
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:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::triSurface
Triangulated surface description with patch information.
Definition: triSurface.H:57
Foam::sampledIsoSurface::facesPtr_
autoPtr< faceList > facesPtr_
Triangles converted to faceList.
Definition: sampledIsoSurface.H:86
Foam::sampledIsoSurface::volSubFieldPtr_
const volScalarField * volSubFieldPtr_
Definition: sampledIsoSurface.H:108
Foam::sampledIsoSurface::bounds_
const boundBox bounds_
Optional bounding box to trim triangles against.
Definition: sampledIsoSurface.H:66
sampledSurface.H
Foam::sampledIsoSurface
A sampledSurface defined by a surface of iso value. Always triangulated. To be used in sampleSurfaces...
Definition: sampledIsoSurface.H:53
Foam::sampledIsoSurface::prevTimeIndex_
label prevTimeIndex_
Time at last call, also track if surface needs an update.
Definition: sampledIsoSurface.H:92
Foam::sampledSurface
An abstract class for surfaces with sampling.
Definition: sampledSurface.H:77
Foam::interpolation< Type >
Foam::sampledIsoSurface::expire
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledIsoSurface.C:527
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::sampledIsoSurface::isoField_
const word isoField_
Field to get isoSurface of.
Definition: sampledIsoSurface.H:60
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
s
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))
Foam::sampledIsoSurface::getIsoFields
void getIsoFields() const
Get fields needed to recreate iso surface.
Definition: sampledIsoSurface.C:48
isoSurface.H
Foam::sampledIsoSurface::getIsoField
void getIsoField()
Lookup or read isoField. Sets volFieldPtr_ and pointFieldPtr_.
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::sampledIsoSurface::sampleField
tmp< Field< Type > > sampleField(const GeometricField< Type, fvPatchField, volMesh > &vField) const
Sample field on faces.
Foam::sampledIsoSurface::zoneID_
cellZoneID zoneID_
Zone name/index (if restricted to zones)
Definition: sampledIsoSurface.H:78
Foam::sampledIsoSurface::average_
const Switch average_
Whether to recalculate cell values as average of point values.
Definition: sampledIsoSurface.H:75
Foam::faceList
List< face > faceList
Definition: faceListFwd.H:43
Foam::sampledIsoSurface::pointFieldPtr_
const pointScalarField * pointFieldPtr_
Cached pointfield.
Definition: sampledIsoSurface.H:99
Foam::sampledIsoSurface::surface
const isoSurface & surface() const
Definition: sampledIsoSurface.H:197
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::sampledIsoSurface::faces
virtual const faceList & faces() const
Faces of surface.
Definition: sampledIsoSurface.H:180
Foam::sampledSurface::name
const word & name() const
Name of surface.
Definition: sampledSurface.H:250
Foam::boundBox
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:55
Foam::sampledIsoSurface::storedVolSubFieldPtr_
autoPtr< volScalarField > storedVolSubFieldPtr_
Cached volfield.
Definition: sampledIsoSurface.H:107
Foam::sampledIsoSurface::subMeshPtr_
autoPtr< fvMeshSubset > subMeshPtr_
Cached submesh.
Definition: sampledIsoSurface.H:104
Foam::sampledSurface::mesh
const polyMesh & mesh() const
Access to the underlying mesh.
Definition: sampledSurface.H:244
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::sampledSurface::interpolate
bool interpolate() const
Interpolation requested for surface.
Definition: sampledSurface.H:256
Foam::sampledIsoSurface::~sampledIsoSurface
virtual ~sampledIsoSurface()
Destructor.
Definition: sampledIsoSurface.C:513
Foam::sampledIsoSurface::exposedPatchName_
word exposedPatchName_
For zones: patch to put exposed faces into.
Definition: sampledIsoSurface.H:81
Foam::sampledIsoSurface::sampledIsoSurface
sampledIsoSurface(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: sampledIsoSurface.C:455
Foam::sampledIsoSurface::surfPtr_
autoPtr< isoSurface > surfPtr_
Definition: sampledIsoSurface.H:83
Foam::sampledIsoSurface::TypeName
TypeName("sampledIsoSurface")
Runtime type information.
Foam::sampledIsoSurface::volFieldPtr_
const volScalarField * volFieldPtr_
Definition: sampledIsoSurface.H:96