tetCell.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "tetCell.H"
30 #include "cellShape.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 // Warning.
35 // Ordering of faces needs to be the same for
36 // a tetrahedron class, a tetrahedron cell shape model and a tetCell
37 
38 const Foam::label Foam::tetCell::modelFaces_[4][3] =
39 {
40  {1, 2, 3},
41  {0, 3, 2},
42  {0, 1, 3},
43  {0, 2, 1},
44 };
45 
46 
47 // Warning.
48 // Ordering of edges needs to be the same for
49 // a tetrahedron class, a tetrahedron cell shape model and a tetCell
50 
51 const Foam::label Foam::tetCell::modelEdges_[6][2] =
52 {
53  {0, 1},
54  {0, 2},
55  {0, 3},
56  {3, 1},
57  {1, 2},
58  {3, 2}
59 };
60 
61 
62 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
63 
65 {
66  static std::unique_ptr<Foam::faceList> ptr(nullptr);
67 
68  if (!ptr)
69  {
70  ptr.reset(new Foam::faceList(tetCell::nFaces(), Foam::face(3)));
71 
72  label facei = 0;
73  for (auto& f : *ptr)
74  {
75  f[0] = modelFaces_[facei][0];
76  f[1] = modelFaces_[facei][1];
77  f[2] = modelFaces_[facei][2];
78  ++facei;
79  }
80  }
81 
82  return *ptr;
83 }
84 
85 
87 {
88  static std::unique_ptr<Foam::edgeList> ptr(nullptr);
89 
90  if (!ptr)
91  {
92  ptr.reset(new Foam::edgeList(tetCell::nEdges()));
93 
94  label edgei = 0;
95  for (auto& e : *ptr)
96  {
97  e[0] = modelEdges_[edgei][0];
98  e[1] = modelEdges_[edgei][1];
99  ++edgei;
100  }
101  }
102 
103  return *ptr;
104 }
105 
106 
138 
139 
140 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
141 
143 {
144  static const cellModel* modelPtr(nullptr);
145 
146  if (!modelPtr)
147  {
148  modelPtr = cellModel::ptr(cellModel::TET);
149  }
150 
151  return cellShape(*modelPtr, *this);
152 }
153 
154 
156 {
157  return this->shape();
158 }
159 
160 
161 // ************************************************************************* //
Foam::tetCell::nEdges
static constexpr label nEdges() noexcept
Number of edges for TET.
Definition: tetCell.H:127
Foam::cellModel::ptr
static const cellModel * ptr(const modelType model)
Look up pointer to cellModel by enumeration, or nullptr on failure.
Definition: cellModels.C:120
Foam::tetCell::modelFaces
static const Foam::faceList & modelFaces()
Return the model faces.
Definition: tetCell.C:64
Foam::cellModel::TET
tet
Definition: cellModel.H:85
Foam::tetCell::nFaces
static constexpr label nFaces() noexcept
Number of faces for TET.
Definition: tetCell.H:133
Foam::cellShape
An analytical geometric cellShape.
Definition: cellShape.H:69
Foam::tetCell::modelEdges
static const Foam::edgeList & modelEdges()
Return the model edges.
Definition: tetCell.C:86
Foam::tetCell::tetCellShape
cellShape tetCellShape() const
Identical to shape()
Definition: tetCell.C:155
f
labelList f(nPoints)
Foam::List< face >
Foam::tetCell::shape
cellShape shape() const
Return TET shape cell.
Definition: tetCell.C:142
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
cellShape.H
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
Foam::cellModel
Maps a geometry to a set of cell primitives.
Definition: cellModel.H:72
tetCell.H