00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software: you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. 00023 00024 Class 00025 Foam::distanceSurface 00026 00027 Description 00028 A sampledSurface defined by a distance to a surface. 00029 00030 SourceFiles 00031 distanceSurface.C 00032 00033 \*---------------------------------------------------------------------------*/ 00034 00035 #ifndef distanceSurface_H 00036 #define distanceSurface_H 00037 00038 #include <sampling/sampledSurface.H> 00039 #include <meshTools/searchableSurface.H> 00040 //#include "isoSurfaceCell.H" 00041 #include <sampling/isoSurface.H> 00042 00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00044 00045 namespace Foam 00046 { 00047 00048 /*---------------------------------------------------------------------------*\ 00049 Class distanceSurface Declaration 00050 \*---------------------------------------------------------------------------*/ 00051 00052 class distanceSurface 00053 : 00054 public sampledSurface 00055 { 00056 // Private data 00057 00058 //- Surface 00059 const autoPtr<searchableSurface> surfPtr_; 00060 00061 //- distance value 00062 const scalar distance_; 00063 00064 //- signed distance 00065 const bool signed_; 00066 00067 //- Whether to coarsen 00068 const Switch regularise_; 00069 00070 //- zone name (if restricted to zones) 00071 word zoneName_; 00072 00073 //- Track if the surface needs an update 00074 mutable bool needsUpdate_; 00075 00076 00077 //- Distance to cell centres 00078 autoPtr<volScalarField> cellDistancePtr_; 00079 00080 //- Distance to points 00081 scalarField pointDistance_; 00082 00083 //- Constructed iso surface 00084 autoPtr<isoSurface> isoSurfPtr_; 00085 00086 //- triangles converted to faceList 00087 mutable autoPtr<faceList> facesPtr_; 00088 00089 00090 // Private Member Functions 00091 00092 //- Create iso surface 00093 void createGeometry(); 00094 00095 //- sample field on faces 00096 template <class Type> 00097 tmp<Field<Type> > sampleField 00098 ( 00099 const GeometricField<Type, fvPatchField, volMesh>& vField 00100 ) const; 00101 00102 00103 template <class Type> 00104 tmp<Field<Type> > 00105 interpolateField(const interpolation<Type>&) const; 00106 00107 00108 public: 00109 00110 //- Runtime type information 00111 TypeName("distanceSurface"); 00112 00113 00114 // Constructors 00115 00116 //- Construct from dictionary 00117 distanceSurface 00118 ( 00119 const word& name, 00120 const polyMesh& mesh, 00121 const dictionary& dict 00122 ); 00123 00124 00125 // Destructor 00126 00127 virtual ~distanceSurface(); 00128 00129 00130 // Member Functions 00131 00132 //- Does the surface need an update? 00133 virtual bool needsUpdate() const; 00134 00135 //- Mark the surface as needing an update. 00136 // May also free up unneeded data. 00137 // Return false if surface was already marked as expired. 00138 virtual bool expire(); 00139 00140 //- Update the surface as required. 00141 // Do nothing (and return false) if no update was needed 00142 virtual bool update(); 00143 00144 //- Points of surface 00145 virtual const pointField& points() const 00146 { 00147 return surface().points(); 00148 } 00149 00150 //- Faces of surface 00151 virtual const faceList& faces() const 00152 { 00153 if (facesPtr_.empty()) 00154 { 00155 const triSurface& s = surface(); 00156 00157 facesPtr_.reset(new faceList(s.size())); 00158 00159 forAll(s, i) 00160 { 00161 facesPtr_()[i] = s[i].triFaceFace(); 00162 } 00163 } 00164 return facesPtr_; 00165 } 00166 00167 00168 const isoSurface& surface() const 00169 { 00170 return isoSurfPtr_(); 00171 } 00172 00173 //- sample field on surface 00174 virtual tmp<scalarField> sample 00175 ( 00176 const volScalarField& 00177 ) const; 00178 00179 //- sample field on surface 00180 virtual tmp<vectorField> sample 00181 ( 00182 const volVectorField& 00183 ) const; 00184 00185 //- sample field on surface 00186 virtual tmp<sphericalTensorField> sample 00187 ( 00188 const volSphericalTensorField& 00189 ) const; 00190 00191 //- sample field on surface 00192 virtual tmp<symmTensorField> sample 00193 ( 00194 const volSymmTensorField& 00195 ) const; 00196 00197 //- sample field on surface 00198 virtual tmp<tensorField> sample 00199 ( 00200 const volTensorField& 00201 ) const; 00202 00203 00204 //- interpolate field on surface 00205 virtual tmp<scalarField> interpolate 00206 ( 00207 const interpolation<scalar>& 00208 ) const; 00209 00210 //- interpolate field on surface 00211 virtual tmp<vectorField> interpolate 00212 ( 00213 const interpolation<vector>& 00214 ) const; 00215 00216 //- interpolate field on surface 00217 virtual tmp<sphericalTensorField> interpolate 00218 ( 00219 const interpolation<sphericalTensor>& 00220 ) const; 00221 00222 //- interpolate field on surface 00223 virtual tmp<symmTensorField> interpolate 00224 ( 00225 const interpolation<symmTensor>& 00226 ) const; 00227 00228 //- interpolate field on surface 00229 virtual tmp<tensorField> interpolate 00230 ( 00231 const interpolation<tensor>& 00232 ) const; 00233 00234 //- Write 00235 virtual void print(Ostream&) const; 00236 }; 00237 00238 00239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00240 00241 } // End namespace Foam 00242 00243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00244 00245 #ifdef NoRepository 00246 # include "distanceSurfaceTemplates.C" 00247 #endif 00248 00249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00250 00251 #endif 00252 00253 // ************************ vim: set sw=4 sts=4 et: ************************ //