sampledIsoSurfaceCell.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::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  //- Optional bounding box to trim triangles against
66  const boundBox bounds_;
67 
68  //- Whether to coarse
69  const Switch regularise_;
70 
71  //- Whether to recalculate cell values as average of point values
72  const Switch average_;
73 
74  //- If restricted to zones, name of this zone or a regular expression
76 
77  //- Triangles converted to faceList
79 
80 
81  // Recreated for every isoSurface
82 
83  //- Time at last call, also track it surface needs an update
84  mutable label prevTimeIndex_;
85 
86  //- For every triangle the original cell in mesh
87  mutable labelList meshCells_;
88 
89 
90  // Private Member Functions
91 
92  //- Create iso surface (if time has changed)
93  // Do nothing (and return false) if no update was needed
94  bool updateGeometry() const;
95 
96  //- Sample field on faces
97  template<class Type>
99  (
101  ) const;
102 
103 
104  template<class Type>
107 
108 
109 public:
110 
111  //- Runtime type information
112  TypeName("sampledIsoSurfaceCell");
113 
114 
115  // Constructors
116 
117  //- Construct from dictionary
119  (
120  const word& name,
121  const polyMesh& mesh,
122  const dictionary& dict
123  );
124 
125 
126  //- Destructor
127  virtual ~sampledIsoSurfaceCell();
128 
129 
130  // Member Functions
131 
132  //- Does the surface need an update?
133  virtual bool needsUpdate() const;
134 
135  //- Mark the surface as needing an update.
136  // May also free up unneeded data.
137  // Return false if surface was already marked as expired.
138  virtual bool expire();
139 
140  //- Update the surface as required.
141  // Do nothing (and return false) if no update was needed
142  virtual bool update();
143 
144 
145  //- Points of surface
146  virtual const pointField& points() const
147  {
148  return triSurface::points();
149  }
150 
151  //- Faces of surface
152  virtual const faceList& faces() const
153  {
154  if (facesPtr_.empty())
155  {
156  const triSurface& s = *this;
157 
158  facesPtr_.reset(new faceList(s.size()));
159 
160  forAll(s, i)
161  {
162  facesPtr_()[i] = s[i].triFaceFace();
163  }
164  }
165  return facesPtr_;
166  }
167 
168 
169  //- Sample field on surface
170  virtual tmp<scalarField> sample
171  (
172  const volScalarField&
173  ) const;
174 
175  //- Sample field on surface
176  virtual tmp<vectorField> sample
177  (
178  const volVectorField&
179  ) const;
180 
181  //- Sample field on surface
183  (
185  ) const;
186 
187  //- Sample field on surface
189  (
190  const volSymmTensorField&
191  ) const;
192 
193  //- Sample field on surface
194  virtual tmp<tensorField> sample
195  (
196  const volTensorField&
197  ) const;
198 
199 
200  //- Interpolate field on surface
202  (
203  const interpolation<scalar>&
204  ) const;
205 
206  //- Interpolate field on surface
208  (
209  const interpolation<vector>&
210  ) const;
211 
212  //- Interpolate field on surface
214  (
216  ) const;
217 
218  //- Interpolate field on surface
220  (
222  ) const;
223 
224  //- Interpolate field on surface
226  (
227  const interpolation<tensor>&
228  ) const;
229 
230  //- Write
231  virtual void print(Ostream&) const;
232 };
233 
234 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 } // End namespace Foam
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 #ifdef NoRepository
243 #endif
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #endif
248 
249 // ************************************************************************* //
Foam::sampledIsoSurfaceCell::zoneKey_
keyType zoneKey_
If restricted to zones, name of this zone or a regular expression.
Definition: sampledIsoSurfaceCell.H:74
Foam::sampledIsoSurfaceCell::expire
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledIsoSurfaceCell.C:246
sampledIsoSurfaceCellTemplates.C
Foam::sampledIsoSurfaceCell::print
virtual void print(Ostream &) const
Write.
Definition: sampledIsoSurfaceCell.C:370
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< labelledTri, List, pointField, point >::points
const Field< point > & 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::sampledIsoSurfaceCell::faces
virtual const faceList & faces() const
Faces of surface.
Definition: sampledIsoSurfaceCell.H:151
Foam::sampledIsoSurfaceCell::meshCells_
labelList meshCells_
For every triangle the original cell in mesh.
Definition: sampledIsoSurfaceCell.H:86
Foam::sampledIsoSurfaceCell::sampleField
tmp< Field< Type > > sampleField(const GeometricField< Type, fvPatchField, volMesh > &vField) const
Sample field on faces.
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::sampledIsoSurfaceCell::prevTimeIndex_
label prevTimeIndex_
Time at last call, also track it surface needs an update.
Definition: sampledIsoSurfaceCell.H:83
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::sampledIsoSurfaceCell::needsUpdate
virtual bool needsUpdate() const
Does the surface need an update?
Definition: sampledIsoSurfaceCell.C:238
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::sampledIsoSurfaceCell::updateGeometry
bool updateGeometry() const
Create iso surface (if time has changed)
Definition: sampledIsoSurfaceCell.C:50
Foam::keyType
A class for handling keywords in dictionaries.
Definition: keyType.H:56
Foam::sampledIsoSurfaceCell::facesPtr_
autoPtr< faceList > facesPtr_
Triangles converted to faceList.
Definition: sampledIsoSurfaceCell.H:77
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::sampledIsoSurfaceCell::regularise_
const Switch regularise_
Whether to coarse.
Definition: sampledIsoSurfaceCell.H:68
sampledSurface.H
Foam::sampledIsoSurfaceCell::points
virtual const pointField & points() const
Points of surface.
Definition: sampledIsoSurfaceCell.H:145
Foam::sampledSurface
An abstract class for surfaces with sampling.
Definition: sampledSurface.H:77
Foam::sampledIsoSurfaceCell::interpolateField
tmp< Field< Type > > interpolateField(const interpolation< Type > &) const
Foam::interpolation< Type >
Foam::sampledIsoSurfaceCell::update
virtual bool update()
Update the surface as required.
Definition: sampledIsoSurfaceCell.C:265
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::sampledIsoSurfaceCell::sample
virtual tmp< scalarField > sample(const volScalarField &) const
Sample field on surface.
Definition: sampledIsoSurfaceCell.C:273
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::sampledIsoSurfaceCell::isoVal_
const scalar isoVal_
Iso value.
Definition: sampledIsoSurfaceCell.H:62
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::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::sampledIsoSurfaceCell::bounds_
const boundBox bounds_
Optional bounding box to trim triangles against.
Definition: sampledIsoSurfaceCell.H:65
Foam::faceList
List< face > faceList
Definition: faceListFwd.H:43
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::sampledSurface::name
const word & name() const
Name of surface.
Definition: sampledSurface.H:250
Foam::sampledIsoSurfaceCell::~sampledIsoSurfaceCell
virtual ~sampledIsoSurfaceCell()
Destructor.
Definition: sampledIsoSurfaceCell.C:232
Foam::sampledIsoSurfaceCell::isoField_
const word isoField_
Field to get isoSurface of.
Definition: sampledIsoSurfaceCell.H:59
Foam::boundBox
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:55
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::sampledIsoSurfaceCell::TypeName
TypeName("sampledIsoSurfaceCell")
Runtime type information.
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::sampledSurface::interpolate
bool interpolate() const
Interpolation requested for surface.
Definition: sampledSurface.H:256
Foam::sampledIsoSurfaceCell::sampledIsoSurfaceCell
sampledIsoSurfaceCell(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: sampledIsoSurfaceCell.C:203
Foam::sampledIsoSurfaceCell
A sampledSurface defined by a surface of iso value. Always triangulated. To be used in sampleSurfaces...
Definition: sampledIsoSurfaceCell.H:51
Foam::sampledIsoSurfaceCell::average_
const Switch average_
Whether to recalculate cell values as average of point values.
Definition: sampledIsoSurfaceCell.H:71