FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::tetrahedron
00026 
00027 Description
00028     A tetrahedron primitive.
00029 
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 <OpenFOAM/point.H>
00043 #include <OpenFOAM/primitiveFieldsFwd.H>
00044 #include <OpenFOAM/pointHit.H>
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 namespace Foam
00049 {
00050 
00051 class Istream;
00052 class Ostream;
00053 
00054 // Forward declaration of friend functions and operators
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             //- Return centre (centroid)
00137             inline Point centre() const;
00138 
00139             //- Return volume
00140             inline scalar mag() const;
00141 
00142             //- Return circum-centre
00143             inline Point circumCentre() const;
00144 
00145             //- Return circum-radius
00146             inline scalar circumRadius() const;
00147 
00148             //- Return (min)containment sphere, i.e. the smallest sphere with
00149             //  all points inside. Returns pointHit with:
00150             //  - hit         : if sphere is equal to circumsphere
00151             //                  (biggest sphere)
00152             //  - point       : centre of sphere
00153             //  - distance    : radius of sphere
00154             //  - eligiblemiss: false
00155             // Tol (small compared to 1, e.g. 1E-9) is used to determine
00156             // whether point is inside: mag(pt - ctr) < (1+tol)*radius.
00157             pointHit containmentSphere(const scalar tol) const;
00158 
00159             //- Fill buffer with shape function products
00160             void gradNiSquared(scalarField& buffer) const;
00161 
00162             void gradNiDotGradNj(scalarField& buffer) const;
00163 
00164             void gradNiGradNi(tensorField& buffer) const;
00165 
00166             void gradNiGradNj(tensorField& buffer) const;
00167 
00168 
00169     // IOstream operators
00170 
00171         friend Istream& operator>> <Point, PointRef>
00172         (
00173             Istream&,
00174             tetrahedron&
00175         );
00176 
00177         friend Ostream& operator<< <Point, PointRef>
00178         (
00179             Ostream&,
00180             const tetrahedron&
00181         );
00182 };
00183 
00184 
00185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00186 
00187 } // End namespace Foam
00188 
00189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00190 
00191 #include <OpenFOAM/tetrahedronI.H>
00192 
00193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00194 
00195 #ifdef NoRepository
00196 #   include <OpenFOAM/tetrahedron.C>
00197 #endif
00198 
00199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00200 
00201 #endif
00202 
00203 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines