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 <OpenFOAM/transform.H>
00027 #include <OpenFOAM/polyMesh.H>
00028
00029
00030
00031
00032 inline Foam::label Foam::refinementDistanceData::wantedLevel(const point& pt)
00033 const
00034 {
00035 const scalar distSqr = magSqr(pt-origin_);
00036
00037
00038 scalar levelSize = level0Size_/(1<<originLevel_);
00039
00040 scalar r = 0;
00041
00042 for (label level = originLevel_; level >= 0; --level)
00043 {
00044
00045 r += levelSize;
00046
00047
00048 if (sqr(r) > distSqr)
00049 {
00050 return level;
00051 }
00052
00053
00054 levelSize *= 2;
00055 }
00056 return 0;
00057 }
00058
00059
00060 inline bool Foam::refinementDistanceData::update
00061 (
00062 const point& pos,
00063 const refinementDistanceData& neighbourInfo,
00064 const scalar tol
00065 )
00066 {
00067 if (!valid())
00068 {
00069 if (!neighbourInfo.valid())
00070 {
00071 FatalErrorIn("refinementDistanceData::update(..)")
00072 << "problem" << abort(FatalError);
00073 }
00074 operator=(neighbourInfo);
00075 return true;
00076 }
00077
00078
00079 label cellLevel = wantedLevel(pos);
00080
00081
00082 label nbrLevel = neighbourInfo.wantedLevel(pos);
00083
00084 if (nbrLevel > cellLevel)
00085 {
00086 operator=(neighbourInfo);
00087 return true;
00088 }
00089 else if (nbrLevel == cellLevel)
00090 {
00091 scalar myDistSqr = magSqr(pos-origin_);
00092 scalar nbrDistSqr = magSqr(pos - neighbourInfo.origin());
00093 scalar diff = myDistSqr - nbrDistSqr;
00094
00095 if (diff < 0)
00096 {
00097
00098 return false;
00099 }
00100
00101 if ((diff < SMALL) || ((myDistSqr > SMALL) && (diff/myDistSqr < tol)))
00102 {
00103
00104 return false;
00105 }
00106 else
00107 {
00108
00109 operator=(neighbourInfo);
00110 return true;
00111 }
00112 }
00113 else
00114 {
00115 return false;
00116 }
00117 }
00118
00119
00120
00121
00122
00123 inline Foam::refinementDistanceData::refinementDistanceData()
00124 :
00125 level0Size_(-1)
00126 {}
00127
00128
00129
00130 inline Foam::refinementDistanceData::refinementDistanceData
00131 (
00132 const scalar level0Size,
00133 const point& origin,
00134 const label originLevel
00135 )
00136 :
00137 level0Size_(level0Size),
00138 origin_(origin),
00139 originLevel_(originLevel)
00140 {}
00141
00142
00143
00144
00145 inline bool Foam::refinementDistanceData::valid() const
00146 {
00147 return level0Size_ != -1;
00148 }
00149
00150
00151
00152 inline bool Foam::refinementDistanceData::sameGeometry
00153 (
00154 const polyMesh&,
00155 const refinementDistanceData&,
00156 const scalar
00157 ) const
00158 {
00159 return true;
00160 }
00161
00162
00163 inline void Foam::refinementDistanceData::leaveDomain
00164 (
00165 const polyMesh&,
00166 const polyPatch& patch,
00167 const label patchFaceI,
00168 const point& faceCentre
00169 )
00170 {
00171 origin_ -= faceCentre;
00172 }
00173
00174
00175 inline void Foam::refinementDistanceData::transform
00176 (
00177 const polyMesh&,
00178 const tensor& rotTensor
00179 )
00180 {
00181 origin_ = Foam::transform(rotTensor, origin_);
00182 }
00183
00184
00185
00186 inline void Foam::refinementDistanceData::enterDomain
00187 (
00188 const polyMesh&,
00189 const polyPatch& patch,
00190 const label patchFaceI,
00191 const point& faceCentre
00192 )
00193 {
00194
00195 origin_ += faceCentre;
00196 }
00197
00198
00199
00200 inline bool Foam::refinementDistanceData::updateCell
00201 (
00202 const polyMesh& mesh,
00203 const label thisCellI,
00204 const label neighbourFaceI,
00205 const refinementDistanceData& neighbourInfo,
00206 const scalar tol
00207 )
00208 {
00209 const point& pos = mesh.cellCentres()[thisCellI];
00210
00211 return update(pos, neighbourInfo, tol);
00212 }
00213
00214
00215
00216 inline bool Foam::refinementDistanceData::updateFace
00217 (
00218 const polyMesh& mesh,
00219 const label thisFaceI,
00220 const label neighbourCellI,
00221 const refinementDistanceData& neighbourInfo,
00222 const scalar tol
00223 )
00224 {
00225 const point& pos = mesh.faceCentres()[thisFaceI];
00226
00227 return update(pos, neighbourInfo, tol);
00228 }
00229
00230
00231
00232 inline bool Foam::refinementDistanceData::updateFace
00233 (
00234 const polyMesh& mesh,
00235 const label thisFaceI,
00236 const refinementDistanceData& neighbourInfo,
00237 const scalar tol
00238 )
00239 {
00240 const point& pos = mesh.faceCentres()[thisFaceI];
00241
00242 return update(pos, neighbourInfo, tol);
00243 }
00244
00245
00246
00247
00248 inline bool Foam::refinementDistanceData::operator==
00249 (
00250 const Foam::refinementDistanceData& rhs
00251 )
00252 const
00253 {
00254 if (!valid())
00255 {
00256 if (!rhs.valid())
00257 {
00258 return true;
00259 }
00260 else
00261 {
00262 return false;
00263 }
00264 }
00265 else
00266 {
00267 return
00268 level0Size_ == rhs.level0Size_
00269 && origin_ == rhs.origin_
00270 && originLevel_ == rhs.originLevel_;
00271 }
00272 }
00273
00274
00275 inline bool Foam::refinementDistanceData::operator!=
00276 (
00277 const Foam::refinementDistanceData& rhs
00278 )
00279 const
00280 {
00281 return !(*this == rhs);
00282 }
00283
00284
00285