Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "sampledPatch.H"
00027 #include <OpenFOAM/dictionary.H>
00028 #include <OpenFOAM/polyMesh.H>
00029 #include <OpenFOAM/polyPatch.H>
00030 #include <finiteVolume/volFields.H>
00031
00032 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00033
00034
00035
00036 namespace Foam
00037 {
00038 defineTypeNameAndDebug(sampledPatch, 0);
00039 addNamedToRunTimeSelectionTable(sampledSurface, sampledPatch, word, patch);
00040 }
00041
00042
00043
00044
00045 Foam::sampledPatch::sampledPatch
00046 (
00047 const word& name,
00048 const polyMesh& mesh,
00049 const word& patchName,
00050 const bool triangulate
00051 )
00052 :
00053 sampledSurface(name, mesh),
00054 patchName_(patchName),
00055 triangulate_(triangulate),
00056 needsUpdate_(true),
00057 patchFaceLabels_(0)
00058 {}
00059
00060
00061 Foam::sampledPatch::sampledPatch
00062 (
00063 const word& name,
00064 const polyMesh& mesh,
00065 const dictionary& dict
00066 )
00067 :
00068 sampledSurface(name, mesh, dict),
00069 patchName_(dict.lookup("patchName")),
00070 triangulate_(dict.lookupOrDefault("triangulate", false)),
00071 needsUpdate_(true),
00072 patchFaceLabels_(0)
00073 {}
00074
00075
00076
00077
00078 Foam::sampledPatch::~sampledPatch()
00079 {}
00080
00081
00082
00083
00084 bool Foam::sampledPatch::needsUpdate() const
00085 {
00086 return needsUpdate_;
00087 }
00088
00089
00090 bool Foam::sampledPatch::expire()
00091 {
00092
00093 if (needsUpdate_)
00094 {
00095 return false;
00096 }
00097
00098 sampledSurface::clearGeom();
00099 MeshStorage::clear();
00100 patchFaceLabels_.clear();
00101
00102 needsUpdate_ = true;
00103 return true;
00104 }
00105
00106
00107 bool Foam::sampledPatch::update()
00108 {
00109 if (!needsUpdate_)
00110 {
00111 return false;
00112 }
00113
00114 const label patchI = mesh().boundaryMesh().findPatchID(patchName_);
00115
00116 if (patchI != -1)
00117 {
00118 const polyPatch& p = mesh().boundaryMesh()[patchI];
00119 this->storedPoints() = p.localPoints();
00120 this->storedFaces() = p.localFaces();
00121
00122
00123 patchFaceLabels_.setSize(faces().size());
00124 forAll(patchFaceLabels_, i)
00125 {
00126 patchFaceLabels_[i] = i;
00127 }
00128
00129
00130
00131
00132
00133 if (triangulate_)
00134 {
00135 MeshStorage::triangulate();
00136 }
00137 }
00138
00139 if (debug)
00140 {
00141 print(Pout);
00142 Pout<< endl;
00143 }
00144
00145 needsUpdate_ = false;
00146 return true;
00147 }
00148
00149
00150
00151 void Foam::sampledPatch::remapFaces
00152 (
00153 const UList<label>& faceMap
00154 )
00155 {
00156
00157 if (&faceMap && faceMap.size())
00158 {
00159 MeshStorage::remapFaces(faceMap);
00160 patchFaceLabels_ = labelList
00161 (
00162 UIndirectList<label>(patchFaceLabels_, faceMap)
00163 );
00164 }
00165 }
00166
00167
00168
00169 Foam::tmp<Foam::scalarField>
00170 Foam::sampledPatch::sample
00171 (
00172 const volScalarField& vField
00173 ) const
00174 {
00175 return sampleField(vField);
00176 }
00177
00178
00179 Foam::tmp<Foam::vectorField>
00180 Foam::sampledPatch::sample
00181 (
00182 const volVectorField& vField
00183 ) const
00184 {
00185 return sampleField(vField);
00186 }
00187
00188 Foam::tmp<Foam::sphericalTensorField>
00189 Foam::sampledPatch::sample
00190 (
00191 const volSphericalTensorField& vField
00192 ) const
00193 {
00194 return sampleField(vField);
00195 }
00196
00197
00198 Foam::tmp<Foam::symmTensorField>
00199 Foam::sampledPatch::sample
00200 (
00201 const volSymmTensorField& vField
00202 ) const
00203 {
00204 return sampleField(vField);
00205 }
00206
00207
00208 Foam::tmp<Foam::tensorField>
00209 Foam::sampledPatch::sample
00210 (
00211 const volTensorField& vField
00212 ) const
00213 {
00214 return sampleField(vField);
00215 }
00216
00217
00218 Foam::tmp<Foam::scalarField>
00219 Foam::sampledPatch::interpolate
00220 (
00221 const interpolation<scalar>& interpolator
00222 ) const
00223 {
00224 return interpolateField(interpolator);
00225 }
00226
00227
00228 Foam::tmp<Foam::vectorField>
00229 Foam::sampledPatch::interpolate
00230 (
00231 const interpolation<vector>& interpolator
00232 ) const
00233 {
00234 return interpolateField(interpolator);
00235 }
00236
00237 Foam::tmp<Foam::sphericalTensorField>
00238 Foam::sampledPatch::interpolate
00239 (
00240 const interpolation<sphericalTensor>& interpolator
00241 ) const
00242 {
00243 return interpolateField(interpolator);
00244 }
00245
00246
00247 Foam::tmp<Foam::symmTensorField>
00248 Foam::sampledPatch::interpolate
00249 (
00250 const interpolation<symmTensor>& interpolator
00251 ) const
00252 {
00253 return interpolateField(interpolator);
00254 }
00255
00256
00257 Foam::tmp<Foam::tensorField>
00258 Foam::sampledPatch::interpolate
00259 (
00260 const interpolation<tensor>& interpolator
00261 ) const
00262 {
00263 return interpolateField(interpolator);
00264 }
00265
00266
00267 void Foam::sampledPatch::print(Ostream& os) const
00268 {
00269 os << "sampledPatch: " << name() << " :"
00270 << " patch:" << patchName()
00271 << " faces:" << faces().size()
00272 << " points:" << points().size();
00273 }
00274
00275
00276