1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Foam::sampledIsoSurface
29 A sampledSurface defined by a surface of iso value. Always triangulated.
30 To be used in sampleSurfaces / functionObjects. Recalculates iso surface
36 \*---------------------------------------------------------------------------*/
38 #ifndef sampledIsoSurface_H
39 #define sampledIsoSurface_H
41 #include "isoSurface.H"
42 #include "sampledSurface.H"
44 #include "fvMeshSubset.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 /*---------------------------------------------------------------------------*\
52 Class sampledIsoSurface Declaration
53 \*---------------------------------------------------------------------------*/
55 class sampledIsoSurface
61 //- Field to get isoSurface of
68 const scalar mergeTol_;
71 const Switch regularise_;
73 //- Whether to recalculate cell values as average of point values
74 const Switch average_;
76 //- zone name/index (if restricted to zones)
77 mutable cellZoneID zoneID_;
79 //- for zones: patch to put exposed faces into
80 mutable word exposedPatchName_;
82 mutable autoPtr<isoSurface> surfPtr_;
84 //- triangles converted to faceList
85 mutable autoPtr<faceList> facesPtr_;
88 // Recreated for every isoSurface
90 //- Time at last call, also track if surface needs an update
91 mutable label prevTimeIndex_;
94 mutable autoPtr<volScalarField> storedVolFieldPtr_;
95 mutable const volScalarField* volFieldPtr_;
98 mutable autoPtr<pointScalarField> storedPointFieldPtr_;
99 mutable const pointScalarField* pointFieldPtr_;
101 // And on subsetted mesh
104 mutable autoPtr<fvMeshSubset> subMeshPtr_;
107 mutable autoPtr<volScalarField> storedVolSubFieldPtr_;
108 mutable const volScalarField* volSubFieldPtr_;
110 //- Cached pointfield
111 mutable autoPtr<pointScalarField> storedPointSubFieldPtr_;
112 mutable const pointScalarField* pointSubFieldPtr_;
116 // Private Member Functions
118 //- Get fields needed to recreate iso surface.
119 void getIsoFields() const;
121 tmp<volScalarField> average
124 const pointScalarField&
127 tmp<pointScalarField> average
130 const volScalarField& fld
133 //- Create iso surface (if time has changed)
134 // Do nothing (and return false) if no update was needed
135 bool updateGeometry() const;
137 //- sample field on faces
138 template <class Type>
139 tmp<Field<Type> > sampleField
141 const GeometricField<Type, fvPatchField, volMesh>& vField
145 template <class Type>
147 interpolateField(const interpolation<Type>&) const;
152 //- Runtime type information
153 TypeName("sampledIsoSurface");
158 //- Construct from dictionary
162 const polyMesh& mesh,
163 const dictionary& dict
169 virtual ~sampledIsoSurface();
174 //- Does the surface need an update?
175 virtual bool needsUpdate() const;
177 //- Mark the surface as needing an update.
178 // May also free up unneeded data.
179 // Return false if surface was already marked as expired.
180 virtual bool expire();
182 //- Update the surface as required.
183 // Do nothing (and return false) if no update was needed
184 virtual bool update();
187 //- Points of surface
188 virtual const pointField& points() const
190 return surface().points();
194 virtual const faceList& faces() const
196 if (facesPtr_.empty())
198 const triSurface& s = surface();
200 facesPtr_.reset(new faceList(s.size()));
204 facesPtr_()[i] = s[i].triFaceFace();
211 const isoSurface& surface() const
216 //- Lookup or read isoField. Sets volFieldPtr_ and pointFieldPtr_.
220 //- sample field on surface
221 virtual tmp<scalarField> sample
223 const volScalarField&
226 //- sample field on surface
227 virtual tmp<vectorField> sample
229 const volVectorField&
232 //- sample field on surface
233 virtual tmp<sphericalTensorField> sample
235 const volSphericalTensorField&
238 //- sample field on surface
239 virtual tmp<symmTensorField> sample
241 const volSymmTensorField&
244 //- sample field on surface
245 virtual tmp<tensorField> sample
247 const volTensorField&
251 //- interpolate field on surface
252 virtual tmp<scalarField> interpolate
254 const interpolation<scalar>&
257 //- interpolate field on surface
258 virtual tmp<vectorField> interpolate
260 const interpolation<vector>&
263 //- interpolate field on surface
264 virtual tmp<sphericalTensorField> interpolate
266 const interpolation<sphericalTensor>&
269 //- interpolate field on surface
270 virtual tmp<symmTensorField> interpolate
272 const interpolation<symmTensor>&
275 //- interpolate field on surface
276 virtual tmp<tensorField> interpolate
278 const interpolation<tensor>&
282 virtual void print(Ostream&) const;
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
288 } // End namespace Foam
290 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
293 # include "sampledIsoSurfaceTemplates.C"
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
300 // ************************************************************************* //