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

tetCellI.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 Description
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include "IOstreams.H"
00030 
00031 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00032 
00033 inline Foam::tetCell::tetCell()
00034 {}
00035 
00036 
00037 inline Foam::tetCell::tetCell
00038 (
00039     const label a,
00040     const label b,
00041     const label c,
00042     const label d
00043 )
00044 {
00045     operator[](0) = a;
00046     operator[](1) = b;
00047     operator[](2) = c;
00048     operator[](3) = d;
00049 }
00050 
00051 
00052 inline Foam::tetCell::tetCell(const FixedList<label, 4>& lst)
00053 :
00054     FixedList<label, 4>(lst)
00055 {}
00056 
00057 
00058 inline Foam::tetCell::tetCell(Istream& is)
00059 :
00060     FixedList<label, 4>(is)
00061 {}
00062 
00063 
00064 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00065 
00066 inline Foam::triFace Foam::tetCell::face(const label faceI) const
00067 {
00068     // Warning. Ordering of faces needs to be the same for a tetrahedron
00069     // class, a tetrahedron cell shape model and a tetCell
00070     static const label a[] = {1, 0, 0, 0};
00071     static const label b[] = {2, 3, 1, 2};
00072     static const label c[] = {3, 2, 3, 1};
00073 
00074 #   ifdef FULLDEBUG
00075     if (faceI >= 4)
00076     {
00077         FatalErrorIn("tetCell::tetEdge(const label faceI) const")
00078             << "index out of range 0 -> 3. faceI = " << faceI
00079             << abort(FatalError);
00080     }
00081 #   endif
00082 
00083     return triFace
00084     (
00085         operator[](a[faceI]),
00086         operator[](b[faceI]),
00087         operator[](c[faceI])
00088     );
00089 }
00090 
00091 
00092 inline Foam::label Foam::tetCell::edgeFace(const label edgeI) const
00093 {
00094     // Warning. Ordering of faces needs to be the same for a tetrahedron
00095     // class, a tetrahedron cell shape model and a tetCell
00096     //static const label edgeFaces[6] = {2, 1, 1, 0, 0, 0};
00097     static const label edgeFaces[6] = {2, 3, 1, 0, 0, 1};
00098 
00099 #   ifdef FULLDEBUG
00100     if (edgeI >= 6)
00101     {
00102         FatalErrorIn
00103         (
00104             "tetCell::edgeFace(const label edgeI)"
00105             "const"
00106         )   << "edge index out of range 0 -> 5. edgeI = " << edgeI
00107             << abort(FatalError);
00108     }
00109 #   endif
00110 
00111     return edgeFaces[edgeI];
00112 }
00113 
00114 
00115 inline Foam::label Foam::tetCell::edgeAdjacentFace
00116 (
00117     const label edgeI,
00118     const label faceI
00119 ) const
00120 {
00121     // Warning. Ordering of faces needs to be the same for a tetrahedron
00122     // class, a tetrahedron cell shape model and a tetCell
00123     static const label adjacentFace[6][4] =
00124     {
00125         {-1, -1, 3, 2},
00126         {-1, 3, -1, 1},
00127         {-1, 2, 1, -1},
00128         {2, -1, 0, -1},
00129         {3, -1, -1, 0},
00130         {1, 0, -1, -1}
00131     };
00132 
00133 #   ifdef FULLDEBUG
00134     if (faceI >= 4)
00135     {
00136         FatalErrorIn
00137         (
00138             "tetCell::edgeAdjacentFace(const label edgeI, const label faceI)"
00139             "const"
00140         )   << "face index out of range 0 -> 3. faceI = " << faceI
00141             << abort(FatalError);
00142     }
00143 
00144     if (edgeI >= 6)
00145     {
00146         FatalErrorIn
00147         (
00148             "tetCell::edgeAdjacentFace(const label edgeI, const label faceI)"
00149             "const"
00150         )   << "edge index out of range 0 -> 5. edgeI = " << edgeI
00151             << abort(FatalError);
00152     }
00153 #   endif
00154 
00155     return adjacentFace[edgeI][faceI];
00156 }
00157 
00158 
00159 inline Foam::edge Foam::tetCell::tetEdge(const label edgeI) const
00160 {
00161     // Warning. Ordering of edges needs to be the same for a tetrahedron
00162     // class, a tetrahedron cell shape model and a tetCell
00163     //
00164     static const label start[] = {0, 0, 0, 3, 1, 3};
00165     static const label end[] = {1, 2, 3, 1, 2, 2};
00166 
00167 #   ifdef FULLDEBUG
00168     if (edgeI >= 6)
00169     {
00170         FatalErrorIn("tetCell::tetEdge(const label edgeI) const")
00171             << "index out of range 0 -> 5. edgeI = " << edgeI
00172             << abort(FatalError);
00173     }
00174 #   endif
00175 
00176     return edge(operator[](start[edgeI]), operator[](end[edgeI]));
00177 }
00178 
00179 
00180 inline Foam::tetPointRef Foam::tetCell::tet(const pointField& points) const
00181 {
00182     return tetPointRef
00183     (
00184         points[operator[](0)],
00185         points[operator[](1)],
00186         points[operator[](2)],
00187         points[operator[](3)]
00188     );
00189 }
00190 
00191 
00192 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd