Forward compatibility: flex
[foam-extend-3.2.git] / src / foam / meshes / primitiveShapes / tetrahedron / tetrahedron.H
blob299eafef3ba780dd02ac39b6964214320eb9941e
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::tetrahedron
27 Description
28     A tetrahedron primitive.
30     Ordering of edges needs to be the same for a tetrahedron
31     class, a tetrahedron cell shape model and a tetCell.
33 SourceFiles
34     tetrahedronI.H
35     tetrahedron.C
37 \*---------------------------------------------------------------------------*/
39 #ifndef tetrahedron_H
40 #define tetrahedron_H
42 #include "point.H"
43 #include "primitiveFieldsFwd.H"
44 #include "pointHit.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 class Istream;
52 class Ostream;
54 // Forward declaration of friend functions and operators
56 template<class Point, class PointRef> class tetrahedron;
58 template<class Point, class PointRef>
59 inline Istream& operator>>
61     Istream&,
62     tetrahedron<Point, PointRef>&
65 template<class Point, class PointRef>
66 inline Ostream& operator<<
68     Ostream&,
69     const tetrahedron<Point, PointRef>&
73 /*---------------------------------------------------------------------------*\
74                            class tetrahedron Declaration
75 \*---------------------------------------------------------------------------*/
77 template<class Point, class PointRef>
78 class tetrahedron
80     // Private data
82         PointRef a_, b_, c_, d_;
85 public:
87     // Member constants
89         enum
90         {
91             nVertices = 4,  // Number of vertices in tetrahedron
92             nEdges = 6      // Number of edges in tetrahedron
93         };
96     // Constructors
98         //- Construct from points
99         inline tetrahedron
100         (
101             const Point& a,
102             const Point& b,
103             const Point& c,
104             const Point& d
105         );
107         //- Construct from Istream
108         inline tetrahedron(Istream&);
111     // Member Functions
113         // Access
115             //- Return vertices
116             inline const Point& a() const;
118             inline const Point& b() const;
120             inline const Point& c() const;
122             inline const Point& d() const;
125         // Properties
127             //- Return face normal
128             inline vector Sa() const;
130             inline vector Sb() const;
132             inline vector Sc() const;
134             inline vector Sd() const;
137             //- Return volume
138             inline scalar mag() const;
140             //- Return centre
141             inline vector centre() const;
143             //- Return circum-centre
144             inline vector circumCentre() const;
146             //- Return circum-radius
147             inline scalar circumRadius() const;
149             //- Return (min)containment sphere, i.e. the smallest sphere with
150             //  all points inside. Returns pointHit with:
151             //  - hit         : if sphere is equal to circumsphere
152             //                  (biggest sphere)
153             //  - point       : centre of sphere
154             //  - distance    : radius of sphere
155             //  - eligiblemiss: false
156             // Tol (small compared to 1, e.g. 1E-9) is used to determine
157             // whether point is inside: mag(pt - ctr) < (1+tol)*radius.
158             pointHit containmentSphere(const scalar tol) const;
160             //- Fill buffer with shape function products
161             void gradNiSquared(scalarField& buffer) const;
163             void gradNiDotGradNj(scalarField& buffer) const;
165             void gradNiGradNi(tensorField& buffer) const;
167             void gradNiGradNj(tensorField& buffer) const;
170     // IOstream operators
172         friend Istream& operator>> <Point, PointRef>
173         (
174             Istream&,
175             tetrahedron&
176         );
178         friend Ostream& operator<< <Point, PointRef>
179         (
180             Ostream&,
181             const tetrahedron&
182         );
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 } // End namespace Foam
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 #include "tetrahedronI.H"
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 #ifdef NoRepository
197 #   include "tetrahedron.C"
198 #endif
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 #endif
204 // ************************************************************************* //