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::sampledIsoSurfaceCell
28 A sampledSurface defined by a surface of iso value. Always triangulated.
29 To be used in sampleSurfaces / functionObjects. Recalculates iso surface
33 sampledIsoSurfaceCell.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef sampledIsoSurfaceCell_H
38 #define sampledIsoSurfaceCell_H
40 #include "sampledSurface.H"
41 #include "triSurface.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 /*---------------------------------------------------------------------------*\
49 Class sampledIsoSurfaceCell Declaration
50 \*---------------------------------------------------------------------------*/
52 class sampledIsoSurfaceCell
54 public sampledSurface,
59 //- Field to get isoSurface of
66 const Switch regularise_;
68 //- Whether to recalculate cell values as average of point values
69 const Switch average_;
71 //- If restricted to zones, name of this zone or a regular expression
74 //- triangles converted to faceList
75 mutable autoPtr<faceList> facesPtr_;
78 // Recreated for every isoSurface
80 //- Time at last call, also track it surface needs an update
81 mutable label prevTimeIndex_;
83 //- For every triangle the original cell in mesh
84 mutable labelList meshCells_;
87 // Private Member Functions
89 //- Create iso surface (if time has changed)
90 // Do nothing (and return false) if no update was needed
91 bool updateGeometry() const;
93 //- sample field on faces
95 tmp<Field<Type> > sampleField
97 const GeometricField<Type, fvPatchField, volMesh>& vField
101 template <class Type>
103 interpolateField(const interpolation<Type>&) const;
108 //- Runtime type information
109 TypeName("sampledIsoSurfaceCell");
114 //- Construct from dictionary
115 sampledIsoSurfaceCell
118 const polyMesh& mesh,
119 const dictionary& dict
124 virtual ~sampledIsoSurfaceCell();
129 //- Does the surface need an update?
130 virtual bool needsUpdate() const;
132 //- Mark the surface as needing an update.
133 // May also free up unneeded data.
134 // Return false if surface was already marked as expired.
135 virtual bool expire();
137 //- Update the surface as required.
138 // Do nothing (and return false) if no update was needed
139 virtual bool update();
142 //- Points of surface
143 virtual const pointField& points() const
145 return triSurface::points();
149 virtual const faceList& faces() const
151 if (facesPtr_.empty())
153 const triSurface& s = *this;
155 facesPtr_.reset(new faceList(s.size()));
159 facesPtr_()[i] = s[i].triFaceFace();
166 //- sample field on surface
167 virtual tmp<scalarField> sample
169 const volScalarField&
172 //- sample field on surface
173 virtual tmp<vectorField> sample
175 const volVectorField&
178 //- sample field on surface
179 virtual tmp<sphericalTensorField> sample
181 const volSphericalTensorField&
184 //- sample field on surface
185 virtual tmp<symmTensorField> sample
187 const volSymmTensorField&
190 //- sample field on surface
191 virtual tmp<tensorField> sample
193 const volTensorField&
197 //- interpolate field on surface
198 virtual tmp<scalarField> interpolate
200 const interpolation<scalar>&
203 //- interpolate field on surface
204 virtual tmp<vectorField> interpolate
206 const interpolation<vector>&
209 //- interpolate field on surface
210 virtual tmp<sphericalTensorField> interpolate
212 const interpolation<sphericalTensor>&
215 //- interpolate field on surface
216 virtual tmp<symmTensorField> interpolate
218 const interpolation<symmTensor>&
221 //- interpolate field on surface
222 virtual tmp<tensorField> interpolate
224 const interpolation<tensor>&
228 virtual void print(Ostream&) const;
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 } // End namespace Foam
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 # include "sampledIsoSurfaceCellTemplates.C"
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 // ************************************************************************* //