1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. 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 tmp<volScalarField> average
123 const pointScalarField&
126 tmp<pointScalarField> average
129 const volScalarField& fld
132 //- Create iso surface (if time has changed)
133 // Do nothing (and return false) if no update was needed
134 bool updateGeometry() const;
136 //- sample field on faces
137 template <class Type>
138 tmp<Field<Type> > sampleField
140 const GeometricField<Type, fvPatchField, volMesh>& vField
144 template <class Type>
146 interpolateField(const interpolation<Type>&) const;
151 //- Runtime type information
152 TypeName("sampledIsoSurface");
157 //- Construct from dictionary
161 const polyMesh& mesh,
162 const dictionary& dict
168 virtual ~sampledIsoSurface();
173 //- Does the surface need an update?
174 virtual bool needsUpdate() const;
176 //- Mark the surface as needing an update.
177 // May also free up unneeded data.
178 // Return false if surface was already marked as expired.
179 virtual bool expire();
181 //- Update the surface as required.
182 // Do nothing (and return false) if no update was needed
183 virtual bool update();
186 //- Points of surface
187 virtual const pointField& points() const
189 return surface().points();
193 virtual const faceList& faces() const
195 if (facesPtr_.empty())
197 const triSurface& s = surface();
199 facesPtr_.reset(new faceList(s.size()));
203 facesPtr_()[i] = s[i].triFaceFace();
210 const isoSurface& surface() const
215 //- Lookup or read isoField. Sets volFieldPtr_ and pointFieldPtr_.
219 //- sample field on surface
220 virtual tmp<scalarField> sample
222 const volScalarField&
225 //- sample field on surface
226 virtual tmp<vectorField> sample
228 const volVectorField&
231 //- sample field on surface
232 virtual tmp<sphericalTensorField> sample
234 const volSphericalTensorField&
237 //- sample field on surface
238 virtual tmp<symmTensorField> sample
240 const volSymmTensorField&
243 //- sample field on surface
244 virtual tmp<tensorField> sample
246 const volTensorField&
250 //- interpolate field on surface
251 virtual tmp<scalarField> interpolate
253 const interpolation<scalar>&
256 //- interpolate field on surface
257 virtual tmp<vectorField> interpolate
259 const interpolation<vector>&
262 //- interpolate field on surface
263 virtual tmp<sphericalTensorField> interpolate
265 const interpolation<sphericalTensor>&
268 //- interpolate field on surface
269 virtual tmp<symmTensorField> interpolate
271 const interpolation<symmTensor>&
274 //- interpolate field on surface
275 virtual tmp<tensorField> interpolate
277 const interpolation<tensor>&
281 virtual void print(Ostream&) const;
285 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 } // End namespace Foam
289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292 # include "sampledIsoSurfaceTemplates.C"
295 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299 // ************************************************************************* //