OpenFOAM logo
Open Source CFD Toolkit

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