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/>.
28 A sampledSurface defined by a distance to a surface.
33 \*---------------------------------------------------------------------------*/
35 #ifndef distanceSurface_H
36 #define distanceSurface_H
38 #include "sampledSurface.H"
39 #include "searchableSurface.H"
40 //#include "isoSurfaceCell.H"
41 #include "isoSurface.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 /*---------------------------------------------------------------------------*\
49 Class distanceSurface Declaration
50 \*---------------------------------------------------------------------------*/
59 const autoPtr<searchableSurface> surfPtr_;
62 const scalar distance_;
67 //- Whether to coarsen
68 const Switch regularise_;
70 //- Whether to recalculate cell values as average of point values
71 const Switch average_;
73 //- If restricted to zones, name of this zone or a regular expression
76 //- Track if the surface needs an update
77 mutable bool needsUpdate_;
80 //- Distance to cell centres
81 autoPtr<volScalarField> cellDistancePtr_;
83 //- Distance to points
84 scalarField pointDistance_;
86 //- Constructed iso surface
87 //autoPtr<isoSurfaceCell> isoSurfPtr_;
88 autoPtr<isoSurface> isoSurfPtr_;
90 //- triangles converted to faceList
91 mutable autoPtr<faceList> facesPtr_;
94 // Private Member Functions
96 //- Create iso surface
97 void createGeometry();
99 //- sample field on faces
100 template <class Type>
101 tmp<Field<Type> > sampleField
103 const GeometricField<Type, fvPatchField, volMesh>& vField
107 template <class Type>
109 interpolateField(const interpolation<Type>&) const;
114 //- Runtime type information
115 TypeName("distanceSurface");
120 //- Construct from dictionary
124 const polyMesh& mesh,
125 const dictionary& dict
130 virtual ~distanceSurface();
135 //- Does the surface need an update?
136 virtual bool needsUpdate() const;
138 //- Mark the surface as needing an update.
139 // May also free up unneeded data.
140 // Return false if surface was already marked as expired.
141 virtual bool expire();
143 //- Update the surface as required.
144 // Do nothing (and return false) if no update was needed
145 virtual bool update();
147 //- Points of surface
148 virtual const pointField& points() const
150 return surface().points();
154 virtual const faceList& faces() const
156 if (facesPtr_.empty())
158 const triSurface& s = surface();
160 facesPtr_.reset(new faceList(s.size()));
164 facesPtr_()[i] = s[i].triFaceFace();
171 //const isoSurfaceCell& surface() const
172 const isoSurface& surface() const
174 return isoSurfPtr_();
177 //- sample field on surface
178 virtual tmp<scalarField> sample
180 const volScalarField&
183 //- sample field on surface
184 virtual tmp<vectorField> sample
186 const volVectorField&
189 //- sample field on surface
190 virtual tmp<sphericalTensorField> sample
192 const volSphericalTensorField&
195 //- sample field on surface
196 virtual tmp<symmTensorField> sample
198 const volSymmTensorField&
201 //- sample field on surface
202 virtual tmp<tensorField> sample
204 const volTensorField&
208 //- interpolate field on surface
209 virtual tmp<scalarField> interpolate
211 const interpolation<scalar>&
214 //- interpolate field on surface
215 virtual tmp<vectorField> interpolate
217 const interpolation<vector>&
220 //- interpolate field on surface
221 virtual tmp<sphericalTensorField> interpolate
223 const interpolation<sphericalTensor>&
226 //- interpolate field on surface
227 virtual tmp<symmTensorField> interpolate
229 const interpolation<symmTensor>&
232 //- interpolate field on surface
233 virtual tmp<tensorField> interpolate
235 const interpolation<tensor>&
239 virtual void print(Ostream&) const;
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 } // End namespace Foam
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 # include "distanceSurfaceTemplates.C"
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 // ************************************************************************* //