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/>.
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 //- zone name (if restricted to zones)
73 //- Track if the surface needs an update
74 mutable bool needsUpdate_;
77 //- Distance to cell centres
78 autoPtr<volScalarField> cellDistancePtr_;
80 //- Distance to points
81 scalarField pointDistance_;
83 //- Constructed iso surface
84 autoPtr<isoSurface> isoSurfPtr_;
86 //- triangles converted to faceList
87 mutable autoPtr<faceList> facesPtr_;
90 // Private Member Functions
92 //- Create iso surface
93 void createGeometry();
95 //- sample field on faces
97 tmp<Field<Type> > sampleField
99 const GeometricField<Type, fvPatchField, volMesh>& vField
103 template <class Type>
105 interpolateField(const interpolation<Type>&) const;
110 //- Runtime type information
111 TypeName("distanceSurface");
116 //- Construct from dictionary
120 const polyMesh& mesh,
121 const dictionary& dict
127 virtual ~distanceSurface();
132 //- Does the surface need an update?
133 virtual bool needsUpdate() const;
135 //- Mark the surface as needing an update.
136 // May also free up unneeded data.
137 // Return false if surface was already marked as expired.
138 virtual bool expire();
140 //- Update the surface as required.
141 // Do nothing (and return false) if no update was needed
142 virtual bool update();
144 //- Points of surface
145 virtual const pointField& points() const
147 return surface().points();
151 virtual const faceList& faces() const
153 if (facesPtr_.empty())
155 const triSurface& s = surface();
157 facesPtr_.reset(new faceList(s.size()));
161 facesPtr_()[i] = s[i].triFaceFace();
168 const isoSurface& surface() const
170 return isoSurfPtr_();
173 //- sample field on surface
174 virtual tmp<scalarField> sample
176 const volScalarField&
179 //- sample field on surface
180 virtual tmp<vectorField> sample
182 const volVectorField&
185 //- sample field on surface
186 virtual tmp<sphericalTensorField> sample
188 const volSphericalTensorField&
191 //- sample field on surface
192 virtual tmp<symmTensorField> sample
194 const volSymmTensorField&
197 //- sample field on surface
198 virtual tmp<tensorField> sample
200 const volTensorField&
204 //- interpolate field on surface
205 virtual tmp<scalarField> interpolate
207 const interpolation<scalar>&
210 //- interpolate field on surface
211 virtual tmp<vectorField> interpolate
213 const interpolation<vector>&
216 //- interpolate field on surface
217 virtual tmp<sphericalTensorField> interpolate
219 const interpolation<sphericalTensor>&
222 //- interpolate field on surface
223 virtual tmp<symmTensorField> interpolate
225 const interpolation<symmTensor>&
228 //- interpolate field on surface
229 virtual tmp<tensorField> interpolate
231 const interpolation<tensor>&
235 virtual void print(Ostream&) const;
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 } // End namespace Foam
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 # include "distanceSurfaceTemplates.C"
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 // ************************************************************************* //