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::sampledCuttingPlane 00026 00027 Description 00028 A sampledSurface defined by a plane 00029 00030 SourceFiles 00031 sampledCuttingPlane.C 00032 00033 \*---------------------------------------------------------------------------*/ 00034 00035 #ifndef sampledCuttingPlane_H 00036 #define sampledCuttingPlane_H 00037 00038 #include <sampling/sampledSurface.H> 00039 #include <sampling/isoSurface.H> 00040 #include <OpenFOAM/plane.H> 00041 #include <OpenFOAM/ZoneIDs.H> 00042 #include <finiteVolume/fvMeshSubset.H> 00043 00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00045 00046 namespace Foam 00047 { 00048 00049 /*---------------------------------------------------------------------------*\ 00050 Class sampledCuttingPlane Declaration 00051 \*---------------------------------------------------------------------------*/ 00052 00053 class sampledCuttingPlane 00054 : 00055 public sampledSurface 00056 { 00057 // Private data 00058 00059 //- Plane 00060 const plane plane_; 00061 00062 //- Merge tolerance 00063 const scalar mergeTol_; 00064 00065 //- Whether to coarsen 00066 const Switch regularise_; 00067 00068 //- zone name/index (if restricted to zones) 00069 mutable cellZoneID zoneID_; 00070 00071 //- for zones: patch to put exposed faces into 00072 mutable word exposedPatchName_; 00073 00074 //- Track if the surface needs an update 00075 mutable bool needsUpdate_; 00076 00077 00078 //- Optional subsetted mesh 00079 autoPtr<fvMeshSubset> subMeshPtr_; 00080 00081 //- Distance to cell centres 00082 autoPtr<volScalarField> cellDistancePtr_; 00083 00084 //- Distance to points 00085 scalarField pointDistance_; 00086 00087 //- Constructed iso surface 00088 autoPtr<isoSurface> isoSurfPtr_; 00089 00090 //- triangles converted to faceList 00091 mutable autoPtr<faceList> facesPtr_; 00092 00093 00094 // Private Member Functions 00095 00096 //- Create iso surface 00097 void createGeometry(); 00098 00099 //- sample field on faces 00100 template <class Type> 00101 tmp<Field<Type> > sampleField 00102 ( 00103 const GeometricField<Type, fvPatchField, volMesh>& vField 00104 ) const; 00105 00106 00107 template <class Type> 00108 tmp<Field<Type> > 00109 interpolateField(const interpolation<Type>&) const; 00110 00111 00112 public: 00113 00114 //- Runtime type information 00115 TypeName("sampledCuttingPlane"); 00116 00117 00118 // Constructors 00119 00120 //- Construct from dictionary 00121 sampledCuttingPlane 00122 ( 00123 const word& name, 00124 const polyMesh& mesh, 00125 const dictionary& dict 00126 ); 00127 00128 00129 // Destructor 00130 00131 virtual ~sampledCuttingPlane(); 00132 00133 00134 // Member Functions 00135 00136 //- Does the surface need an update? 00137 virtual bool needsUpdate() const; 00138 00139 //- Mark the surface as needing an update. 00140 // May also free up unneeded data. 00141 // Return false if surface was already marked as expired. 00142 virtual bool expire(); 00143 00144 //- Update the surface as required. 00145 // Do nothing (and return false) if no update was needed 00146 virtual bool update(); 00147 00148 //- Points of surface 00149 virtual const pointField& points() const 00150 { 00151 return surface().points(); 00152 } 00153 00154 //- Faces of surface 00155 virtual const faceList& faces() const 00156 { 00157 if (facesPtr_.empty()) 00158 { 00159 const triSurface& s = surface(); 00160 00161 facesPtr_.reset(new faceList(s.size())); 00162 00163 forAll(s, i) 00164 { 00165 facesPtr_()[i] = s[i].triFaceFace(); 00166 } 00167 } 00168 return facesPtr_; 00169 } 00170 00171 00172 const isoSurface& surface() const 00173 { 00174 return isoSurfPtr_(); 00175 } 00176 00177 //- sample field on surface 00178 virtual tmp<scalarField> sample 00179 ( 00180 const volScalarField& 00181 ) const; 00182 00183 //- sample field on surface 00184 virtual tmp<vectorField> sample 00185 ( 00186 const volVectorField& 00187 ) const; 00188 00189 //- sample field on surface 00190 virtual tmp<sphericalTensorField> sample 00191 ( 00192 const volSphericalTensorField& 00193 ) const; 00194 00195 //- sample field on surface 00196 virtual tmp<symmTensorField> sample 00197 ( 00198 const volSymmTensorField& 00199 ) const; 00200 00201 //- sample field on surface 00202 virtual tmp<tensorField> sample 00203 ( 00204 const volTensorField& 00205 ) const; 00206 00207 00208 //- interpolate field on surface 00209 virtual tmp<scalarField> interpolate 00210 ( 00211 const interpolation<scalar>& 00212 ) const; 00213 00214 //- interpolate field on surface 00215 virtual tmp<vectorField> interpolate 00216 ( 00217 const interpolation<vector>& 00218 ) const; 00219 00220 //- interpolate field on surface 00221 virtual tmp<sphericalTensorField> interpolate 00222 ( 00223 const interpolation<sphericalTensor>& 00224 ) const; 00225 00226 //- interpolate field on surface 00227 virtual tmp<symmTensorField> interpolate 00228 ( 00229 const interpolation<symmTensor>& 00230 ) const; 00231 00232 //- interpolate field on surface 00233 virtual tmp<tensorField> interpolate 00234 ( 00235 const interpolation<tensor>& 00236 ) const; 00237 00238 //- Write 00239 virtual void print(Ostream&) const; 00240 }; 00241 00242 00243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00244 00245 } // End namespace Foam 00246 00247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00248 00249 #ifdef NoRepository 00250 # include "sampledCuttingPlaneTemplates.C" 00251 #endif 00252 00253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00254 00255 #endif 00256 00257 // ************************ vim: set sw=4 sts=4 et: ************************ //