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
29 A sampledSurface defined by a distance to a surface.
34 \*---------------------------------------------------------------------------*/
36 #ifndef distanceSurface_H
37 #define distanceSurface_H
39 #include "sampledSurface.H"
40 #include "searchableSurface.H"
41 //#include "isoSurfaceCell.H"
42 #include "isoSurface.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 /*---------------------------------------------------------------------------*\
50 Class distanceSurface Declaration
51 \*---------------------------------------------------------------------------*/
60 const autoPtr<searchableSurface> surfPtr_;
63 const scalar distance_;
68 //- Whether to coarsen
69 const Switch regularise_;
71 //- zone name (if restricted to zones)
74 //- Track if the surface needs an update
75 mutable bool needsUpdate_;
78 //- Distance to cell centres
79 autoPtr<volScalarField> cellDistancePtr_;
81 //- Distance to points
82 scalarField pointDistance_;
84 //- Constructed iso surface
85 autoPtr<isoSurface> isoSurfPtr_;
87 //- triangles converted to faceList
88 mutable autoPtr<faceList> facesPtr_;
91 // Private Member Functions
93 //- Create iso surface
94 void createGeometry();
96 //- sample field on faces
98 tmp<Field<Type> > sampleField
100 const GeometricField<Type, fvPatchField, volMesh>& vField
104 template <class Type>
106 interpolateField(const interpolation<Type>&) const;
111 //- Runtime type information
112 TypeName("distanceSurface");
117 //- Construct from dictionary
121 const polyMesh& mesh,
122 const dictionary& dict
128 virtual ~distanceSurface();
133 //- Does the surface need an update?
134 virtual bool needsUpdate() const;
136 //- Mark the surface as needing an update.
137 // May also free up unneeded data.
138 // Return false if surface was already marked as expired.
139 virtual bool expire();
141 //- Update the surface as required.
142 // Do nothing (and return false) if no update was needed
143 virtual bool update();
145 //- Points of surface
146 virtual const pointField& points() const
148 return surface().points();
152 virtual const faceList& faces() const
154 if (facesPtr_.empty())
156 const triSurface& s = surface();
158 facesPtr_.reset(new faceList(s.size()));
162 facesPtr_()[i] = s[i].triFaceFace();
169 const isoSurface& surface() const
171 return isoSurfPtr_();
174 //- sample field on surface
175 virtual tmp<scalarField> sample
177 const volScalarField&
180 //- sample field on surface
181 virtual tmp<vectorField> sample
183 const volVectorField&
186 //- sample field on surface
187 virtual tmp<sphericalTensorField> sample
189 const volSphericalTensorField&
192 //- sample field on surface
193 virtual tmp<symmTensorField> sample
195 const volSymmTensorField&
198 //- sample field on surface
199 virtual tmp<tensorField> sample
201 const volTensorField&
205 //- interpolate field on surface
206 virtual tmp<scalarField> interpolate
208 const interpolation<scalar>&
211 //- interpolate field on surface
212 virtual tmp<vectorField> interpolate
214 const interpolation<vector>&
217 //- interpolate field on surface
218 virtual tmp<sphericalTensorField> interpolate
220 const interpolation<sphericalTensor>&
223 //- interpolate field on surface
224 virtual tmp<symmTensorField> interpolate
226 const interpolation<symmTensor>&
229 //- interpolate field on surface
230 virtual tmp<tensorField> interpolate
232 const interpolation<tensor>&
236 virtual void print(Ostream&) const;
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 } // End namespace Foam
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247 # include "distanceSurfaceTemplates.C"
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254 // ************************************************************************* //