Loading...
Searching...
No Matches
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 * * * * * * * * * * * * * * //
42:
43 FixedList<label, 8>(-1)
44{}
45
47inline Foam::hexCell::hexCell(std::initializer_list<label> list)
48:
49 FixedList<label, 8>(list)
50{}
51
54:
55 FixedList<label, 8>(list)
56{}
57
58
60(
61 const labelUList& list,
62 const FixedList<label, 8>& indices
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
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
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
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;
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:73
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
Definition edge.H:62
A face is a list of labels corresponding to mesh vertices.
Definition face.H:71
Foam::edge edge(const label edgei) const
Return i-th edge.
Definition hexCellI.H:99
Foam::face face(const label facei) const
Return i-th face.
Definition hexCellI.H:81
pointField points(const UList< point > &meshPoints) const
The points corresponding to this shape.
Definition hexCellI.H:147
point centre(const UList< point > &meshPoints) const
Cell centre - uses simple average of points.
Definition hexCellI.H:126
Foam::edge reverseEdge(const label edgei) const
Return i-th edge reversed.
Definition hexCellI.H:118
static constexpr label nFaces() noexcept
Number of faces for HEX.
Definition hexCell.H:159
static constexpr label nEdges() noexcept
Number of edges for HEX.
Definition hexCell.H:151
hexCell()
Default construct, with invalid point labels (-1).
Definition hexCellI.H:34
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
errorManip< error > abort(error &err)
Definition errorManip.H:139
vector point
Point is a vector.
Definition point.H:37
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
Definition UList.H:75
labelList f(nPoints)