OpenFOAM logo
Open Source CFD Toolkit

tetrahedron.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-2005 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 Class
00026     tetrahedron
00027 
00028 Description
00029     A tetrahedron primitive used for FEM and post-processing.
00030     Ordering of edges needs to be the same for a tetrahedron
00031     class, a tetrahedron cell shape model and a tetCell.
00032 
00033 SourceFiles
00034     tetrahedronI.H
00035     tetrahedron.C
00036 
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef tetrahedron_H
00040 #define tetrahedron_H
00041 
00042 #include "point.H"
00043 #include "primitiveFieldsFwd.H"
00044 #include "pointHit.H"
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 namespace Foam
00049 {
00050 
00051 class Istream;
00052 class Ostream;
00053 
00054 // * * * * * * Forward declaration of template friend fuctions * * * * * * * //
00055 
00056 template<class Point, class PointRef> class tetrahedron;
00057 
00058 template<class Point, class PointRef>
00059 inline Istream& operator>>
00060 (
00061     Istream&,
00062     tetrahedron<Point, PointRef>&
00063 );
00064 
00065 template<class Point, class PointRef>
00066 inline Ostream& operator<<
00067 (
00068     Ostream&,
00069     const tetrahedron<Point, PointRef>&
00070 );
00071 
00072 
00073 /*---------------------------------------------------------------------------*\
00074                            class tetrahedron Declaration
00075 \*---------------------------------------------------------------------------*/
00076 
00077 template<class Point, class PointRef>
00078 class tetrahedron
00079 {
00080     // Private data
00081 
00082         PointRef a_, b_, c_, d_;
00083 
00084 
00085 public:
00086 
00087     // Member constants
00088 
00089         enum
00090         {
00091             nVertices = 4,  // Number of vertices in tetrahedron
00092             nEdges = 6      // Number of edges in tetrahedron
00093         };
00094 
00095 
00096     // Constructors
00097 
00098         //- Construct from points
00099         inline tetrahedron
00100         (
00101             const Point& a,
00102             const Point& b,
00103             const Point& c,
00104             const Point& d
00105         );
00106 
00107         //- Construct from Istream
00108         inline tetrahedron(Istream&);
00109 
00110 
00111     // Member Functions
00112 
00113         // Access
00114 
00115             //- Return vertices
00116             inline const Point& a() const;
00117 
00118             inline const Point& b() const;
00119 
00120             inline const Point& c() const;
00121 
00122             inline const Point& d() const;
00123 
00124 
00125         // Properties
00126 
00127             //- Return face normal
00128             inline vector Sa() const;
00129 
00130             inline vector Sb() const;
00131 
00132             inline vector Sc() const;
00133 
00134             inline vector Sd() const;
00135 
00136 
00137             //- Return volume
00138             inline scalar mag() const;
00139 
00140             //- Return circum-centre
00141             inline vector circumCentre() const;
00142 
00143             //- Return circum-radius
00144             inline scalar circumRadius() const;
00145 
00146             //- Return (min)containment sphere, i.e. the smallest sphere with
00147             //  all points inside. Returns pointHit with:
00148             //  - hit         : if sphere is equal to circumsphere
00149             //                  (biggest sphere)
00150             //  - point       : centre of sphere
00151             //  - distance    : radius of sphere
00152             //  - eligiblemiss: false
00153             // Tol (small compared to 1, e.g. 1E-9) is used to determine
00154             // whether point is inside: mag(pt - ctr) < (1+tol)*radius.
00155             pointHit containmentSphere(const scalar tol) const;
00156 
00157             //- Fill buffer with shape function products
00158             void gradNiSquared(scalarField& buffer) const;
00159 
00160             void gradNiDotGradNj(scalarField& buffer) const;
00161 
00162             void gradNiGradNi(tensorField& buffer) const;
00163 
00164             void gradNiGradNj(tensorField& buffer) const;
00165 
00166 
00167     // IOstream operators
00168 
00169         friend Istream& operator>> <Point, PointRef>
00170         (
00171             Istream&,
00172             tetrahedron&
00173         );
00174 
00175         friend Ostream& operator<< <Point, PointRef>
00176         (
00177             Ostream&,
00178             const tetrahedron&
00179         );
00180 };
00181 
00182 
00183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00184 
00185 } // End namespace Foam
00186 
00187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00188 
00189 #include "tetrahedronI.H"
00190 
00191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00192 
00193 #ifdef NoRepository
00194 #   include "tetrahedron.C"
00195 #endif
00196 
00197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00198 
00199 #endif
00200 
00201 // ************************************************************************* //
For further information go to www.openfoam.org