1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
25 Foam::sampledIsoSurface
28 A sampledSurface defined by a surface of iso value. Always triangulated.
29 To be used in sampleSurfaces / functionObjects. Recalculates iso surface
35 \*---------------------------------------------------------------------------*/
37 #ifndef sampledIsoSurface_H
38 #define sampledIsoSurface_H
40 #include "isoSurface.H"
41 #include "sampledSurface.H"
43 #include "fvMeshSubset.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 /*---------------------------------------------------------------------------*\
51 Class sampledIsoSurface Declaration
52 \*---------------------------------------------------------------------------*/
54 class sampledIsoSurface
60 //- Field to get isoSurface of
67 const scalar mergeTol_;
70 const Switch regularise_;
72 //- Whether to recalculate cell values as average of point values
73 const Switch average_;
75 //- zone name/index (if restricted to zones)
76 mutable cellZoneID zoneID_;
78 //- for zones: patch to put exposed faces into
79 mutable word exposedPatchName_;
81 mutable autoPtr<isoSurface> surfPtr_;
83 //- triangles converted to faceList
84 mutable autoPtr<faceList> facesPtr_;
87 // Recreated for every isoSurface
89 //- Time at last call, also track if surface needs an update
90 mutable label prevTimeIndex_;
93 mutable autoPtr<volScalarField> storedVolFieldPtr_;
94 mutable const volScalarField* volFieldPtr_;
97 mutable autoPtr<pointScalarField> storedPointFieldPtr_;
98 mutable const pointScalarField* pointFieldPtr_;
100 // And on subsetted mesh
103 mutable autoPtr<fvMeshSubset> subMeshPtr_;
106 mutable autoPtr<volScalarField> storedVolSubFieldPtr_;
107 mutable const volScalarField* volSubFieldPtr_;
109 //- Cached pointfield
110 mutable autoPtr<pointScalarField> storedPointSubFieldPtr_;
111 mutable const pointScalarField* pointSubFieldPtr_;
115 // Private Member Functions
117 //- Get fields needed to recreate iso surface.
118 void getIsoFields() const;
120 //- Create iso surface (if time has changed)
121 // Do nothing (and return false) if no update was needed
122 bool updateGeometry() const;
124 //- sample field on faces
125 template <class Type>
126 tmp<Field<Type> > sampleField
128 const GeometricField<Type, fvPatchField, volMesh>& vField
132 template <class Type>
134 interpolateField(const interpolation<Type>&) const;
139 //- Runtime type information
140 TypeName("sampledIsoSurface");
145 //- Construct from dictionary
149 const polyMesh& mesh,
150 const dictionary& dict
155 virtual ~sampledIsoSurface();
160 //- Does the surface need an update?
161 virtual bool needsUpdate() const;
163 //- Mark the surface as needing an update.
164 // May also free up unneeded data.
165 // Return false if surface was already marked as expired.
166 virtual bool expire();
168 //- Update the surface as required.
169 // Do nothing (and return false) if no update was needed
170 virtual bool update();
173 //- Points of surface
174 virtual const pointField& points() const
176 return surface().points();
180 virtual const faceList& faces() const
182 if (facesPtr_.empty())
184 const triSurface& s = surface();
186 facesPtr_.reset(new faceList(s.size()));
190 facesPtr_()[i] = s[i].triFaceFace();
197 const isoSurface& surface() const
202 //- Lookup or read isoField. Sets volFieldPtr_ and pointFieldPtr_.
206 //- sample field on surface
207 virtual tmp<scalarField> sample
209 const volScalarField&
212 //- sample field on surface
213 virtual tmp<vectorField> sample
215 const volVectorField&
218 //- sample field on surface
219 virtual tmp<sphericalTensorField> sample
221 const volSphericalTensorField&
224 //- sample field on surface
225 virtual tmp<symmTensorField> sample
227 const volSymmTensorField&
230 //- sample field on surface
231 virtual tmp<tensorField> sample
233 const volTensorField&
237 //- interpolate field on surface
238 virtual tmp<scalarField> interpolate
240 const interpolation<scalar>&
243 //- interpolate field on surface
244 virtual tmp<vectorField> interpolate
246 const interpolation<vector>&
249 //- interpolate field on surface
250 virtual tmp<sphericalTensorField> interpolate
252 const interpolation<sphericalTensor>&
255 //- interpolate field on surface
256 virtual tmp<symmTensorField> interpolate
258 const interpolation<symmTensor>&
261 //- interpolate field on surface
262 virtual tmp<tensorField> interpolate
264 const interpolation<tensor>&
268 virtual void print(Ostream&) const;
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 } // End namespace Foam
276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 # include "sampledIsoSurfaceTemplates.C"
282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286 // ************************************************************************* //