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

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