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::sampledIsoSurface 00026 00027 Description 00028 A sampledSurface defined by a surface of iso value. Always triangulated. 00029 To be used in sampleSurfaces / functionObjects. Recalculates iso surface 00030 only if time changes. 00031 00032 SourceFiles 00033 sampledIsoSurface.C 00034 00035 \*---------------------------------------------------------------------------*/ 00036 00037 #ifndef sampledIsoSurface_H 00038 #define sampledIsoSurface_H 00039 00040 #include "isoSurface.H" 00041 #include <sampling/sampledSurface.H> 00042 #include <OpenFOAM/ZoneIDs.H> 00043 #include <finiteVolume/fvMeshSubset.H> 00044 00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00046 00047 namespace Foam 00048 { 00049 00050 /*---------------------------------------------------------------------------*\ 00051 Class sampledIsoSurface Declaration 00052 \*---------------------------------------------------------------------------*/ 00053 00054 class sampledIsoSurface 00055 : 00056 public sampledSurface 00057 { 00058 // Private data 00059 00060 //- Field to get isoSurface of 00061 const word isoField_; 00062 00063 //- iso value 00064 const scalar isoVal_; 00065 00066 //- Merge tolerance 00067 const scalar mergeTol_; 00068 00069 //- Whether to coarse 00070 const Switch regularise_; 00071 00072 //- Whether to recalculate cell values as average of point values 00073 const Switch average_; 00074 00075 //- zone name/index (if restricted to zones) 00076 mutable cellZoneID zoneID_; 00077 00078 //- for zones: patch to put exposed faces into 00079 mutable word exposedPatchName_; 00080 00081 mutable autoPtr<isoSurface> surfPtr_; 00082 00083 //- triangles converted to faceList 00084 mutable autoPtr<faceList> facesPtr_; 00085 00086 00087 // Recreated for every isoSurface 00088 00089 //- Time at last call, also track if surface needs an update 00090 mutable label prevTimeIndex_; 00091 00092 //- Cached volfield 00093 mutable autoPtr<volScalarField> storedVolFieldPtr_; 00094 mutable const volScalarField* volFieldPtr_; 00095 00096 //- Cached pointfield 00097 mutable autoPtr<pointScalarField> storedPointFieldPtr_; 00098 mutable const pointScalarField* pointFieldPtr_; 00099 00100 // And on subsetted mesh 00101 00102 //- Cached submesh 00103 mutable autoPtr<fvMeshSubset> subMeshPtr_; 00104 00105 //- Cached volfield 00106 mutable autoPtr<volScalarField> storedVolSubFieldPtr_; 00107 mutable const volScalarField* volSubFieldPtr_; 00108 00109 //- Cached pointfield 00110 mutable autoPtr<pointScalarField> storedPointSubFieldPtr_; 00111 mutable const pointScalarField* pointSubFieldPtr_; 00112 00113 00114 00115 // Private Member Functions 00116 00117 //- Get fields needed to recreate iso surface. 00118 void getIsoFields() const; 00119 00120 tmp<volScalarField> average 00121 ( 00122 const fvMesh&, 00123 const pointScalarField& 00124 ) const; 00125 00126 tmp<pointScalarField> average 00127 ( 00128 const pointMesh&, 00129 const volScalarField& fld 00130 ) const; 00131 00132 //- Create iso surface (if time has changed) 00133 // Do nothing (and return false) if no update was needed 00134 bool updateGeometry() const; 00135 00136 //- sample field on faces 00137 template <class Type> 00138 tmp<Field<Type> > sampleField 00139 ( 00140 const GeometricField<Type, fvPatchField, volMesh>& vField 00141 ) const; 00142 00143 00144 template <class Type> 00145 tmp<Field<Type> > 00146 interpolateField(const interpolation<Type>&) const; 00147 00148 00149 public: 00150 00151 //- Runtime type information 00152 TypeName("sampledIsoSurface"); 00153 00154 00155 // Constructors 00156 00157 //- Construct from dictionary 00158 sampledIsoSurface 00159 ( 00160 const word& name, 00161 const polyMesh& mesh, 00162 const dictionary& dict 00163 ); 00164 00165 00166 // Destructor 00167 00168 virtual ~sampledIsoSurface(); 00169 00170 00171 // Member Functions 00172 00173 //- Does the surface need an update? 00174 virtual bool needsUpdate() const; 00175 00176 //- Mark the surface as needing an update. 00177 // May also free up unneeded data. 00178 // Return false if surface was already marked as expired. 00179 virtual bool expire(); 00180 00181 //- Update the surface as required. 00182 // Do nothing (and return false) if no update was needed 00183 virtual bool update(); 00184 00185 00186 //- Points of surface 00187 virtual const pointField& points() const 00188 { 00189 return surface().points(); 00190 } 00191 00192 //- Faces of surface 00193 virtual const faceList& faces() const 00194 { 00195 if (facesPtr_.empty()) 00196 { 00197 const triSurface& s = surface(); 00198 00199 facesPtr_.reset(new faceList(s.size())); 00200 00201 forAll(s, i) 00202 { 00203 facesPtr_()[i] = s[i].triFaceFace(); 00204 } 00205 } 00206 return facesPtr_; 00207 } 00208 00209 00210 const isoSurface& surface() const 00211 { 00212 return surfPtr_(); 00213 } 00214 00215 //- Lookup or read isoField. Sets volFieldPtr_ and pointFieldPtr_. 00216 void getIsoField(); 00217 00218 00219 //- sample field on surface 00220 virtual tmp<scalarField> sample 00221 ( 00222 const volScalarField& 00223 ) const; 00224 00225 //- sample field on surface 00226 virtual tmp<vectorField> sample 00227 ( 00228 const volVectorField& 00229 ) const; 00230 00231 //- sample field on surface 00232 virtual tmp<sphericalTensorField> sample 00233 ( 00234 const volSphericalTensorField& 00235 ) const; 00236 00237 //- sample field on surface 00238 virtual tmp<symmTensorField> sample 00239 ( 00240 const volSymmTensorField& 00241 ) const; 00242 00243 //- sample field on surface 00244 virtual tmp<tensorField> sample 00245 ( 00246 const volTensorField& 00247 ) const; 00248 00249 00250 //- interpolate field on surface 00251 virtual tmp<scalarField> interpolate 00252 ( 00253 const interpolation<scalar>& 00254 ) const; 00255 00256 //- interpolate field on surface 00257 virtual tmp<vectorField> interpolate 00258 ( 00259 const interpolation<vector>& 00260 ) const; 00261 00262 //- interpolate field on surface 00263 virtual tmp<sphericalTensorField> interpolate 00264 ( 00265 const interpolation<sphericalTensor>& 00266 ) const; 00267 00268 //- interpolate field on surface 00269 virtual tmp<symmTensorField> interpolate 00270 ( 00271 const interpolation<symmTensor>& 00272 ) const; 00273 00274 //- interpolate field on surface 00275 virtual tmp<tensorField> interpolate 00276 ( 00277 const interpolation<tensor>& 00278 ) const; 00279 00280 //- Write 00281 virtual void print(Ostream&) const; 00282 }; 00283 00284 00285 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00286 00287 } // End namespace Foam 00288 00289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00290 00291 #ifdef NoRepository 00292 # include "sampledIsoSurfaceTemplates.C" 00293 #endif 00294 00295 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00296 00297 #endif 00298 00299 // ************************ vim: set sw=4 sts=4 et: ************************ //