initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / meshes / primitiveShapes / tetrahedron / tetrahedron.H
blobf282e32f77cab7fdd6a0f9769a87915df64303e2
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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::tetrahedron
28 Description
29     A tetrahedron primitive.
31     Ordering of edges needs to be the same for a tetrahedron
32     class, a tetrahedron cell shape model and a tetCell.
34 SourceFiles
35     tetrahedronI.H
36     tetrahedron.C
38 \*---------------------------------------------------------------------------*/
40 #ifndef tetrahedron_H
41 #define tetrahedron_H
43 #include "point.H"
44 #include "primitiveFieldsFwd.H"
45 #include "pointHit.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 namespace Foam
52 class Istream;
53 class Ostream;
55 // Forward declaration of friend functions and operators
57 template<class Point, class PointRef> class tetrahedron;
59 template<class Point, class PointRef>
60 inline Istream& operator>>
62     Istream&,
63     tetrahedron<Point, PointRef>&
66 template<class Point, class PointRef>
67 inline Ostream& operator<<
69     Ostream&,
70     const tetrahedron<Point, PointRef>&
74 /*---------------------------------------------------------------------------*\
75                            class tetrahedron Declaration
76 \*---------------------------------------------------------------------------*/
78 template<class Point, class PointRef>
79 class tetrahedron
81     // Private data
83         PointRef a_, b_, c_, d_;
86 public:
88     // Member constants
90         enum
91         {
92             nVertices = 4,  // Number of vertices in tetrahedron
93             nEdges = 6      // Number of edges in tetrahedron
94         };
97     // Constructors
99         //- Construct from points
100         inline tetrahedron
101         (
102             const Point& a,
103             const Point& b,
104             const Point& c,
105             const Point& d
106         );
108         //- Construct from Istream
109         inline tetrahedron(Istream&);
112     // Member Functions
114         // Access
116             //- Return vertices
117             inline const Point& a() const;
119             inline const Point& b() const;
121             inline const Point& c() const;
123             inline const Point& d() const;
126         // Properties
128             //- Return face normal
129             inline vector Sa() const;
131             inline vector Sb() const;
133             inline vector Sc() const;
135             inline vector Sd() const;
138             //- Return volume
139             inline scalar mag() const;
141             //- Return circum-centre
142             inline vector circumCentre() const;
144             //- Return circum-radius
145             inline scalar circumRadius() const;
147             //- Return (min)containment sphere, i.e. the smallest sphere with
148             //  all points inside. Returns pointHit with:
149             //  - hit         : if sphere is equal to circumsphere
150             //                  (biggest sphere)
151             //  - point       : centre of sphere
152             //  - distance    : radius of sphere
153             //  - eligiblemiss: false
154             // Tol (small compared to 1, e.g. 1E-9) is used to determine
155             // whether point is inside: mag(pt - ctr) < (1+tol)*radius.
156             pointHit containmentSphere(const scalar tol) const;
158             //- Fill buffer with shape function products
159             void gradNiSquared(scalarField& buffer) const;
161             void gradNiDotGradNj(scalarField& buffer) const;
163             void gradNiGradNi(tensorField& buffer) const;
165             void gradNiGradNj(tensorField& buffer) const;
168     // IOstream operators
170         friend Istream& operator>> <Point, PointRef>
171         (
172             Istream&,
173             tetrahedron&
174         );
176         friend Ostream& operator<< <Point, PointRef>
177         (
178             Ostream&,
179             const tetrahedron&
180         );
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 } // End namespace Foam
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 #include "tetrahedronI.H"
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 #ifdef NoRepository
195 #   include "tetrahedron.C"
196 #endif
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 #endif
202 // ************************************************************************* //