OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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