hexCellI.H
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) 2021 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29
30inline void Foam::hexCell::copyFace(Foam::face& f, const label facei) const
31{
32 f[0] = (*this)[modelFaces_[facei][0]];
33 f[1] = (*this)[modelFaces_[facei][1]];
34 f[2] = (*this)[modelFaces_[facei][2]];
35 f[3] = (*this)[modelFaces_[facei][3]];
36}
37
38
39// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40
42:
43 FixedList<label, 8>(-1)
44{}
45
46
47inline Foam::hexCell::hexCell(std::initializer_list<label> list)
48:
49 FixedList<label, 8>(list)
50{}
51
52
54:
55 FixedList<label, 8>(list)
56{}
57
58
60(
61 const labelUList& list,
62 const FixedList<label, 8>& indices
63)
64:
65 FixedList<label, 8>(list, indices)
66{}
67
68
69template<unsigned AnyNum>
71(
72 const FixedList<label, AnyNum>& list,
73 const FixedList<label, 8>& indices
74)
75:
76 FixedList<label, 8>(list, indices)
77{}
78
79
81:
82 FixedList<label, 8>(is)
83{}
84
85
86// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
87
88inline Foam::face Foam::hexCell::face(const label facei) const
89{
90 #ifdef FULLDEBUG
91 if (facei < 0 || facei >= hexCell::nFaces())
92 {
94 << "Face index (" << facei << ") out of range 0..5\n"
95 << abort(FatalError);
96 }
97 #endif
98
99 Foam::face f(4);
100 copyFace(f, facei);
101
102 return f;
103}
104
105
106inline Foam::edge Foam::hexCell::edge(const label edgei) const
107{
108 #ifdef FULLDEBUG
109 if (edgei < 0 || edgei >= hexCell::nEdges())
110 {
112 << "Edge index (" << edgei << ") out of range 0..11\n"
113 << abort(FatalError);
114 }
115 #endif
116
117 return Foam::edge
118 (
119 (*this)[modelEdges_[edgei][0]],
120 (*this)[modelEdges_[edgei][1]]
121 );
122}
123
124
125inline Foam::edge Foam::hexCell::reverseEdge(const label edgei) const
126{
127 // Reverse edge. Using a copy is cheaper than inplace flip
128 return this->edge(edgei).reverseEdge();
129}
130
131
133(
134 const UList<point>& meshPoints
135) const
136{
137 // Simple estimate of cell centre by averaging cell points
138 point cEst = Zero;
139 int npts = 0;
140 for (const label pointi : *this)
141 {
142 if (pointi >= 0)
143 {
144 cEst += meshPoints[pointi];
145 ++npts;
146 }
147 }
148
149 return (npts > 1 ? (cEst/scalar(npts)) : cEst);
150}
151
152
154(
155 const UList<point>& meshPoints
156) const
157{
158 return pointField(List<point>(meshPoints, *this));
159}
160
161
162// ************************************************************************* //
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: FixedList.H:81
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
scalar centre() const
Mid-point location, zero for an empty list.
Definition: PDRblockI.H:67
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:66
edge reverseEdge() const
Return reverse edge as copy.
Definition: edgeI.H:225
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
static constexpr label nFaces() noexcept
Number of faces for HEX.
Definition: hexCell.H:126
static constexpr label nEdges() noexcept
Number of edges for HEX.
Definition: hexCell.H:120
hexCell()
Default construct, with invalid point labels (-1)
Definition: hexCellI.H:41
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
const pointField & points
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
errorManip< error > abort(error &err)
Definition: errorManip.H:144
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
error FatalError
labelList f(nPoints)