OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

wallPointI.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "polyMesh.H"
00028 #include "transform.H"
00029 
00030 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00031 
00032 // Update this with w2 if w2 nearer to pt.
00033 inline bool Foam::wallPoint::update
00034 (
00035     const point& pt,
00036     const wallPoint& w2,
00037     const scalar tol
00038 )
00039 {
00040     //Already done in calling algorithm
00041     //if (w2.origin() == origin_)
00042     //{
00043     //    // Shortcut. Same input so same distance.
00044     //    return false;
00045     //}
00046 
00047     scalar dist2 = magSqr(pt - w2.origin());
00048 
00049     if (!valid())
00050     {
00051         // current not yet set so use any value
00052         distSqr_ = dist2;
00053         origin_ = w2.origin();
00054 
00055         return true;
00056     }        
00057 
00058     scalar diff = distSqr_ - dist2;
00059 
00060     if (diff < 0)
00061     {
00062         // already nearer to pt
00063         return false;
00064     }
00065 
00066     if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
00067     {
00068         // don't propagate small changes
00069         return false;
00070     }
00071     else
00072     {
00073         // update with new values
00074         distSqr_ = dist2;
00075         origin_ = w2.origin();
00076 
00077         return true;
00078     }
00079 }
00080     
00081 
00082 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00083 
00084 // Null constructor
00085 inline Foam::wallPoint::wallPoint()
00086 :
00087     origin_(greatPoint),
00088     distSqr_(GREAT)
00089 {}
00090 
00091 
00092 // Construct from origin, distance
00093 inline Foam::wallPoint::wallPoint(const point& origin, const scalar distSqr)
00094 :
00095     origin_(origin), distSqr_(distSqr)
00096 {}
00097 
00098 
00099 // Construct as copy
00100 inline Foam::wallPoint::wallPoint(const wallPoint& wpt)
00101 :
00102     origin_(wpt.origin()), distSqr_(wpt.distSqr())
00103 {}
00104 
00105 
00106 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00107 
00108 inline const Foam::point& Foam::wallPoint::origin() const
00109 {
00110     return origin_;
00111 }
00112 
00113 
00114 inline Foam::point& Foam::wallPoint::origin()
00115 {
00116     return origin_;
00117 }
00118 
00119 
00120 inline Foam::scalar Foam::wallPoint::distSqr() const
00121 {
00122     return distSqr_;
00123 }
00124 
00125 
00126 inline Foam::scalar& Foam::wallPoint::distSqr()
00127 {
00128     return distSqr_;
00129 }
00130 
00131 
00132 inline bool Foam::wallPoint::valid() const
00133 {
00134     return origin_ != greatPoint;
00135 }
00136 
00137 
00138 // Checks for cyclic faces
00139 inline bool Foam::wallPoint::sameGeometry
00140 (
00141     const polyMesh&,
00142     const wallPoint& w2,
00143     const scalar tol
00144 )
00145  const
00146 {
00147     scalar diff = mag(distSqr() - w2.distSqr());
00148 
00149     if (diff < SMALL)
00150     {
00151         return true;
00152     }
00153     else
00154     {
00155         if ((distSqr() > SMALL) && ((diff/distSqr()) < tol))
00156         {
00157             return true;
00158         }
00159         else
00160         {
00161             return false;
00162         }
00163     }
00164 }
00165 
00166 
00167 inline void Foam::wallPoint::leaveDomain
00168 (
00169     const polyMesh&,
00170     const polyPatch&,
00171     const label,
00172     const point& faceCentre
00173 )
00174 {
00175     origin_ -= faceCentre;
00176 }
00177 
00178 
00179 inline void Foam::wallPoint::transform
00180 (
00181     const polyMesh&,
00182     const tensor& rotTensor
00183 )
00184 {
00185     origin_ = Foam::transform(rotTensor, origin_);
00186 }
00187 
00188 
00189 // Update absolute geometric quantities. Note that distance (distSqr_)
00190 // is not affected by leaving/entering domain.
00191 inline void Foam::wallPoint::enterDomain
00192 (
00193     const polyMesh&,
00194     const polyPatch&,
00195     const label,
00196     const point& faceCentre
00197 )
00198 {
00199     // back to absolute form
00200     origin_ += faceCentre;
00201 }
00202 
00203 
00204 // Update this with w2 if w2 nearer to pt.
00205 inline bool Foam::wallPoint::updateCell
00206 (
00207     const polyMesh& mesh,
00208     const label thisCellI,
00209     const label neighbourFaceI,
00210     const wallPoint& neighbourWallInfo,
00211     const scalar tol
00212 )
00213 {
00214     return 
00215         update
00216         (
00217             mesh.cellCentres()[thisCellI],
00218             neighbourWallInfo,
00219             tol
00220         );
00221     }    
00222 
00223 
00224 // Update this with w2 if w2 nearer to pt.
00225 inline bool Foam::wallPoint::updateFace
00226 (
00227     const polyMesh& mesh,
00228     const label thisFaceI,
00229     const label neighbourCellI,
00230     const wallPoint& neighbourWallInfo,
00231     const scalar tol
00232 )
00233 {
00234     return
00235         update
00236         (
00237             mesh.faceCentres()[thisFaceI],
00238             neighbourWallInfo,
00239             tol
00240         );
00241 }    
00242 
00243 // Update this with w2 if w2 nearer to pt.
00244 inline bool Foam::wallPoint::updateFace
00245 (
00246     const polyMesh& mesh,
00247     const label thisFaceI,
00248     const wallPoint& neighbourWallInfo,
00249     const scalar tol
00250 )
00251 {
00252     return
00253         update
00254         (
00255             mesh.faceCentres()[thisFaceI],
00256             neighbourWallInfo,
00257             tol
00258         );
00259 }    
00260 
00261 
00262 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00263 
00264 inline bool Foam::wallPoint::operator==(const Foam::wallPoint& rhs) const
00265 {
00266     return origin() == rhs.origin();
00267 }
00268 
00269 
00270 inline bool Foam::wallPoint::operator!=(const Foam::wallPoint& rhs) const
00271 {
00272     return !(*this == rhs);
00273 }
00274 
00275 
00276 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd