1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 An abstract class for surfaces with sampling.
31 The constructors for the derived classes should generally start in a
32 'expired' condition (ie, needsUpdate() == true) and rely on a
33 subsequent call to the update() method to complete the initialization.
34 Delaying the final construction as late as possible allows the
35 construction of surfaces that may depend on intermediate calculation
36 results (eg, iso-surfaces) and also avoids the unnecessary
37 reconstruction of surfaces between sampling intervals.
39 It is the responsibility of the caller to ensure that the surface
40 update() is called before the surface is used. The update() method
41 implementation should do nothing when the surface is already
46 sampledSurfaceTemplates.C
48 \*---------------------------------------------------------------------------*/
50 #ifndef sampledSurface_H
51 #define sampledSurface_H
53 #include "pointField.H"
55 #include "labelList.H"
58 #include "runTimeSelectionTables.H"
60 #include "volFieldsFwd.H"
62 #include "coordinateSystems.H"
63 #include "interpolation.H"
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 /*---------------------------------------------------------------------------*\
71 Class sampledSurface Declaration
72 \*---------------------------------------------------------------------------*/
78 //- Name of sample surface
82 const polyMesh& mesh_;
84 //- Do we intend to interpolate the information?
91 mutable vectorField* SfPtr_;
93 //- Mag face area vectors
94 mutable scalarField* magSfPtr_;
97 mutable vectorField* CfPtr_;
99 //- Total surface area
100 mutable scalar area_;
102 // Make geometric data
108 void makeMagSf() const;
115 //- Check field size matches surface size
117 bool checkFieldSize(const Field<Type>&) const;
119 //- Project field onto surface
120 template<class ReturnType, class Type>
127 //- Project field onto surface
128 template<class ReturnType, class Type>
132 const tmp<Field<Type> >&
135 //- Project field onto surface
136 template<class ReturnType, class Type>
137 tmp<Field<ReturnType> > project(const tmp<Field<Type> >&) const;
141 // Protected Member functions
143 virtual void clearGeom() const;
147 //- Runtime type information
148 TypeName("sampledSurface");
151 // Declare run-time constructor selection table
153 declareRunTimeSelectionTable
160 const polyMesh& mesh,
161 const dictionary& dict
167 //- Class used for the PtrLists read-construction
170 //- Reference to the volume mesh
171 const polyMesh& mesh_;
175 iNew(const polyMesh& mesh)
180 autoPtr<sampledSurface> operator()(Istream& is) const
185 return sampledSurface::New(name, mesh_, dict);
192 //- Construct from name, mesh
199 //- Construct from dictionary
208 autoPtr<sampledSurface> clone() const
210 notImplemented("autoPtr<sampledSurface> clone() const");
211 return autoPtr<sampledSurface>(NULL);
217 //- Return a reference to the selected surface
218 static autoPtr<sampledSurface> New
228 virtual ~sampledSurface();
235 //- Access to the underlying mesh
236 const polyMesh& mesh() const
242 const word& name() const
247 //- interpolation requested for surface
248 bool interpolate() const
253 //- Does the surface need an update?
254 virtual bool needsUpdate() const = 0;
256 //- Mark the surface as needing an update.
257 // May also free up unneeded data.
258 // Return false if surface was already marked as expired.
259 virtual bool expire() = 0;
261 //- Update the surface as required.
262 // Do nothing (and return false) if no update was required
263 virtual bool update() = 0;
266 //- Points of surface
267 virtual const pointField& points() const = 0;
270 virtual const faceList& faces() const = 0;
272 //- Return face area vectors
273 virtual const vectorField& Sf() const;
275 //- Return face area magnitudes
276 virtual const scalarField& magSf() const;
278 //- Return face centres as vectorField
279 virtual const vectorField& Cf() const;
281 //- The total surface area
284 //- Integration of a field across the surface
286 Type integrate(const Field<Type>&) const;
288 //- Integration of a field across the surface
290 Type integrate(const tmp<Field<Type> >&) const;
292 //- Area-averaged value of a field across the surface
294 Type average(const Field<Type>&) const;
296 //- Area-averaged value of a field across the surface
298 Type average(const tmp<Field<Type> >&) const;
300 //- Project field onto surface
301 tmp<Field<scalar> > project(const Field<scalar>&) const;
303 //- Project field onto surface
304 tmp<Field<scalar> > project(const Field<vector>&) const;
306 //- Project field onto surface
307 tmp<Field<vector> > project(const Field<sphericalTensor>&) const;
309 //- Project field onto surface
310 tmp<Field<vector> > project(const Field<symmTensor>&) const;
312 //- Project field onto surface
313 tmp<Field<vector> > project(const Field<tensor>&) const;
315 //- Sample field on surface
316 virtual tmp<scalarField> sample
318 const volScalarField&
321 //- Sample field on surface
322 virtual tmp<vectorField> sample
324 const volVectorField&
327 //- Sample field on surface
328 virtual tmp<sphericalTensorField> sample
330 const volSphericalTensorField&
333 //- Sample field on surface
334 virtual tmp<symmTensorField> sample
336 const volSymmTensorField&
339 //- Sample field on surface
340 virtual tmp<tensorField> sample
342 const volTensorField&
346 //- Interpolate field on surface
347 virtual tmp<scalarField> interpolate
349 const interpolation<scalar>&
353 //- Interpolate field on surface
354 virtual tmp<vectorField> interpolate
356 const interpolation<vector>&
359 //- Interpolate field on surface
360 virtual tmp<sphericalTensorField> interpolate
362 const interpolation<sphericalTensor>&
365 //- Interpolate field on surface
366 virtual tmp<symmTensorField> interpolate
368 const interpolation<symmTensor>&
371 //- Interpolate field on surface
372 virtual tmp<tensorField> interpolate
374 const interpolation<tensor>&
381 virtual void rename(const word& newName)
390 virtual void print(Ostream&) const;
393 // IOstream operators
395 friend Ostream& operator<<(Ostream&, const sampledSurface&);
399 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
401 } // End namespace Foam
403 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
406 # include "sampledSurfaceTemplates.C"
409 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
413 // ************************************************************************* //