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

refinementDataI.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 
00028 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00029 
00030 
00031 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00032 
00033 // Null constructor
00034 inline Foam::refinementData::refinementData()
00035 :
00036     refinementCount_(-1),
00037     count_(-1)
00038 {}
00039 
00040 
00041 // Construct from components
00042 inline Foam::refinementData::refinementData
00043 (
00044     const label refinementCount,
00045     const label count
00046 )
00047 :
00048     refinementCount_(refinementCount),
00049     count_(count)
00050 {}
00051 
00052 
00053 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00054 
00055 inline bool Foam::refinementData::valid() const
00056 {
00057     return count_ != -1;
00058 }
00059 
00060 
00061 // No geometric data so never any problem on cyclics
00062 inline bool Foam::refinementData::sameGeometry
00063 (
00064     const polyMesh&,
00065     const refinementData&,
00066     const scalar
00067 ) const
00068 {
00069     return true;
00070 }
00071 
00072 
00073 // No geometric data.
00074 inline void Foam::refinementData::leaveDomain
00075 (
00076     const polyMesh&,
00077     const polyPatch& patch,
00078     const label patchFaceI,
00079     const point& faceCentre
00080 )
00081 {}
00082 
00083 
00084 // No geometric data.
00085 inline void Foam::refinementData::transform
00086 (
00087     const polyMesh&,
00088     const tensor& rotTensor
00089 )
00090 {}
00091 
00092 
00093 // No geometric data.
00094 inline void Foam::refinementData::enterDomain
00095 (
00096     const polyMesh&,
00097     const polyPatch& patch,
00098     const label patchFaceI,
00099     const point& faceCentre
00100 )
00101 {}
00102 
00103 
00104 // Update cell with neighbouring face information
00105 inline bool Foam::refinementData::updateCell
00106 (
00107     const polyMesh&,
00108     const label thisCellI,
00109     const label neighbourFaceI,
00110     const refinementData& neighbourInfo,
00111     const scalar tol
00112 )
00113 {
00114     if (!valid())
00115     {
00116         FatalErrorIn("refinementData::updateCell") << "problem"
00117             << abort(FatalError);
00118         return false;
00119     }
00120 
00121 
00122     // Check if more than 2:1 ratio. This is when I am not refined but neighbour
00123     // is and neighbour already had higher cell level.
00124     if
00125     (
00126         neighbourInfo.isRefined()
00127     && !isRefined()
00128     &&  neighbourInfo.refinementCount() > refinementCount()
00129     )
00130     {
00131         count_ = refinementCount();
00132         return true;
00133     }
00134 
00135 
00136 
00137     // Count from neighbour face by the time it reaches the current cell.
00138     label transportedFaceCount;
00139 
00140     if (neighbourInfo.isRefined())
00141     {
00142         // refined so passes through two cells.
00143         transportedFaceCount = max(0, neighbourInfo.count()-2);
00144     }
00145     else
00146     {
00147         // unrefined.
00148         transportedFaceCount = max(0, neighbourInfo.count()-1);
00149     }
00150 
00151     if (count_ >= transportedFaceCount)
00152     {
00153         return false;
00154     }
00155     else
00156     {
00157         count_ = transportedFaceCount;
00158 
00159         return true;
00160     }
00161 }
00162 
00163 
00164 // Update face with neighbouring cell information
00165 inline bool Foam::refinementData::updateFace
00166 (
00167     const polyMesh&,
00168     const label thisFaceI,
00169     const label neighbourCellI,
00170     const refinementData& neighbourInfo,
00171     const scalar tol
00172 )
00173 {
00174     // From cell to its faces.
00175     if (!valid())
00176     {
00177         refinementCount_ = neighbourInfo.refinementCount();
00178         count_ = neighbourInfo.count();
00179 
00180         return true;
00181     }
00182 
00183     if (count_ >= neighbourInfo.count())
00184     {
00185         return false;
00186     }
00187     else
00188     {
00189         refinementCount_ = neighbourInfo.refinementCount();
00190         count_ = neighbourInfo.count();
00191 
00192         return true;
00193     }
00194 }
00195 
00196 
00197 // Update face with coupled face information
00198 inline bool Foam::refinementData::updateFace
00199 (
00200     const polyMesh&,
00201     const label thisFaceI,
00202     const refinementData& neighbourInfo,
00203     const scalar tol
00204 )
00205 {
00206     // From face to face (e.g. coupled faces)
00207     if (!valid())
00208     {
00209         refinementCount_ = neighbourInfo.refinementCount();
00210         count_ = neighbourInfo.count();
00211 
00212         return true;
00213     }
00214 
00215     if (count_ >= neighbourInfo.count())
00216     {
00217         return false;
00218     }
00219     else
00220     {
00221         refinementCount_ = neighbourInfo.refinementCount();
00222         count_ = neighbourInfo.count();
00223 
00224         return true;
00225     }
00226 }    
00227 
00228 
00229 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00230 
00231 inline bool Foam::refinementData::operator==(const Foam::refinementData& rhs)
00232  const
00233 {
00234     return count() == rhs.count() && refinementCount() == rhs.refinementCount();
00235 }
00236 
00237 
00238 inline bool Foam::refinementData::operator!=(const Foam::refinementData& rhs)
00239  const
00240 {
00241     return !(*this == rhs);
00242 }
00243 
00244 
00245 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd