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

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