FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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