initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / finiteVolume / fvMesh / fvMeshCutSurface / tetEdges / centreEdge.H
bloba7646089e91908c2e754c6ba6508c473039c3184
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 Class
26     Foam::centreEdge
28 Description
29     Implicit description of faceCentre to cellCentre edge
30     (from tet decomposition).
32     Stores
33       - face label
34       - whether in owner or neighbour of face
36 SourceFiles
38 \*---------------------------------------------------------------------------*/
40 #ifndef centreEdge_H
41 #define centreEdge_H
43 #include "label.H"
44 #include "primitiveMesh.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 // Forward declaration of classes
53 /*---------------------------------------------------------------------------*\
54                            Class centreEdge Declaration
55 \*---------------------------------------------------------------------------*/
57 class centreEdge
59     // Private data
61         //- face label
62         label faceLabel_;
64         //- is in owner or neighbour of face
65         bool inOwner_;
67 public:
69     // Public classes
71         //- Hash function
72         class centreEdgeHash
73         {
75         public:
77             centreEdgeHash()
78             {}
80             //- simple hashing function of labels
81             label operator()(const centreEdge& ce, const label tableSize) const
82             {
83                 return (ce.faceLabel() + ce.inOwner()) % tableSize;
84             }
85         };
88     // Constructors
90         //- Construct null
91         inline centreEdge()
92         :
93             faceLabel_(-1),
94             inOwner_(-1)
95         {}
97         //- Construct from components
98         inline centreEdge(const label faceLabel, const bool inOwner)
99         :
100             faceLabel_(faceLabel),
101             inOwner_(inOwner)
102         {}
104     // Member Functions
106         label faceLabel() const
107         {   
108             return faceLabel_;
109         }
111         bool inOwner() const
112         {   
113             return inOwner_;
114         }
116         template <class T>
117         T interpolate
118         (
119             const primitiveMesh& mesh,
120             const Field<T>& cellField,
121             const Field<T>& faceField,
122             const scalar weight
123         ) const
124         {
125             label cellI;
126             if (inOwner_)
127             {
128                 cellI = mesh.faceOwner()[faceLabel_];
129             }
130             else
131             {
132                 cellI = mesh.faceNeighbour()[faceLabel_];
133             }
135             return
136                 (1-weight)*faceField[faceLabel_]
137               + weight*cellField[cellI];
138         }
140         point coord(const primitiveMesh& mesh, const scalar weight) const
141         {
142             return interpolate
143             (
144                 mesh,
145                 mesh.cellCentres(),
146                 mesh.faceCentres(),
147                 weight
148             );
149         }
152     // Member Operators
154         bool operator==(const centreEdge& ce) const
155         {
156             return
157                 (faceLabel() == ce.faceLabel())
158              && (inOwner() == ce.inOwner());
159         }
162     // IOstream Operators
164         inline friend Ostream& operator<<(Ostream& os, const centreEdge& ce)
165         {
166             os  << token::BEGIN_LIST
167                 << ce.faceLabel_ << token::SPACE
168                 << ce.inOwner_
169                 << token::END_LIST;
171             // Check state of Ostream
172             os.check("Ostream& operator<<(Ostream&, const centreEdge&)");
174             return os;
175         }
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 } // End namespace Foam
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 #endif
187 // ************************************************************************* //