parallel postChannel
[OpenFOAM-1.5.x.git] / applications / utilities / postProcessing / miscellaneous / postChannel / sumDataI.H
blob107cba063dccdc7006cb43da53913ce11a29e6dc
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "polyMesh.H"
29 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
32 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
34 // Null constructor
35 inline Foam::sumData::sumData()
37     oldFace_(-1),
38     sum_(0.0),
39     count_(0)
43 // Construct from components
44 inline Foam::sumData::sumData
46     const label oldFace,
47     const scalar sum,
48     const label count
51     oldFace_(oldFace),
52     sum_(sum),
53     count_(count)
57 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
59 inline bool Foam::sumData::valid() const
61     return oldFace_ != -1;
65 // No geometric data so never any problem on cyclics
66 inline bool Foam::sumData::sameGeometry
68     const polyMesh&,
69     const sumData&,
70     const scalar
71 ) const
73     return true;
77 // No geometric data.
78 inline void Foam::sumData::leaveDomain
80     const polyMesh&,
81     const polyPatch& patch,
82     const label patchFaceI,
83     const point& faceCentre
88 // No geometric data.
89 inline void Foam::sumData::transform
91     const polyMesh&,
92     const tensor& rotTensor
97 // No geometric data.
98 inline void Foam::sumData::enterDomain
100     const polyMesh&,
101     const polyPatch& patch,
102     const label patchFaceI,
103     const point& faceCentre
106     oldFace_ = -1;
110 // Update cell with neighbouring face information
111 inline bool Foam::sumData::updateCell
113     const polyMesh&,
114     const label thisCellI,
115     const label neighbourFaceI,
116     const sumData& neighbourInfo,
117     const scalar tol
120     if (!valid())
121     {
122         FatalErrorIn("sumData::updateCell") << "problem"
123             << abort(FatalError);
124         return false;
125     }
128     if (count_ == 0)
129     {
130         sum_ += neighbourInfo.sum();
131         count_ = neighbourInfo.count() + 1;
132         oldFace_ = neighbourFaceI;
133         return true;
134     }
135     else
136     {
137         return false;
138     }
142 // Update face with neighbouring cell information
143 inline bool Foam::sumData::updateFace
145     const polyMesh& mesh,
146     const label thisFaceI,
147     const label neighbourCellI,
148     const sumData& neighbourInfo,
149     const scalar tol
152     // From cell to its faces.
154     // Check that face is opposite the previous one.
155     const cell& cFaces = mesh.cells()[neighbourCellI];
157     label wantedFaceI = cFaces.opposingFaceLabel
158     (
159         neighbourInfo.oldFace(),
160         mesh.faces()
161     );
163     if (thisFaceI == wantedFaceI)
164     {
165         if (count_ != 0)
166         {
167             FatalErrorIn("sumData::updateFace") << "problem"
168                 << abort(FatalError);
169             return false;
170         }
172         sum_ += neighbourInfo.sum();
173         count_ = neighbourInfo.count();
174         oldFace_ = thisFaceI;
175         return true;
176     }
177     else
178     {
179         return false;
180     }
184 // Update face with coupled face information
185 inline bool Foam::sumData::updateFace
187     const polyMesh&,
188     const label thisFaceI,
189     const sumData& neighbourInfo,
190     const scalar tol
193     // From face to face (e.g. coupled faces)
194     if (count_ == 0)
195     {
196         sum_ += neighbourInfo.sum();
197         count_ = neighbourInfo.count();
198         oldFace_ = thisFaceI;
199         return true;
200     }
201     else
202     {
203         return false;
204     }
205 }    
208 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
210 inline bool Foam::sumData::operator==(const Foam::sumData& rhs)
211  const
213     return
214         oldFace() == rhs.oldFace()
215      && sum() == rhs.sum()
216      && count() == rhs.count();
220 inline bool Foam::sumData::operator!=(const Foam::sumData& rhs)
221  const
223     return !(*this == rhs);
227 // ************************************************************************* //