hexCell.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) 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#include "hexCell.H"
29#include "cellShape.H"
30
31// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32
33// Warning:
34// Ordering of faces needs to be the same for
35// a hexahedral cell shape model and a hexCell
36
37const Foam::label Foam::hexCell::modelFaces_[6][4] =
38{
39 {0, 4, 7, 3}, // x-min
40 {1, 2, 6, 5}, // x-max
41 {0, 1, 5, 4}, // y-min
42 {3, 7, 6, 2}, // y-max
43 {0, 3, 2, 1}, // z-min
44 {4, 5, 6, 7} // z-max
45};
46
47
48// Warning:
49// Ordering of edges needs to be the same for
50// a hexahedral cell shape model and a hexCell
51
52const Foam::label Foam::hexCell::modelEdges_[12][2] =
53{
54 {0, 1}, // x-direction
55 {3, 2},
56 {7, 6},
57 {4, 5},
58 {0, 3}, // y-direction
59 {1, 2},
60 {5, 6},
61 {4, 7},
62 {0, 4}, // z-direction
63 {1, 5},
64 {2, 6},
65 {3, 7}
66};
67
68
69// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
70
72{
73 static std::unique_ptr<Foam::faceList> ptr(nullptr);
74
75 if (!ptr)
76 {
77 ptr.reset(new Foam::faceList(hexCell::nFaces(), Foam::face(4)));
78
79 label facei = 0;
80 for (auto& f : *ptr)
81 {
82 f[0] = modelFaces_[facei][0];
83 f[1] = modelFaces_[facei][1];
84 f[2] = modelFaces_[facei][2];
85 f[3] = modelFaces_[facei][3];
86 ++facei;
87 }
88 }
89
90 return *ptr;
91}
92
93
95{
96 static std::unique_ptr<Foam::edgeList> ptr(nullptr);
97
98 if (!ptr)
99 {
100 ptr.reset(new Foam::edgeList(hexCell::nEdges()));
101
102 label edgei = 0;
103 for (auto& e : *ptr)
104 {
105 e[0] = modelEdges_[edgei][0];
106 e[1] = modelEdges_[edgei][1];
107 ++edgei;
108 }
109 }
110
111 return *ptr;
112}
113
114
115// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
116
118{
120
121 label facei = 0;
122 for (auto& f : theFaces)
123 {
124 copyFace(f, facei);
125 ++facei;
126 }
127
128 return theFaces;
129}
130
131
133{
135
136 label edgei = 0;
137 for (auto& e : theEdges)
138 {
139 e[0] = (*this)[modelEdges_[edgei][0]];
140 e[1] = (*this)[modelEdges_[edgei][1]];
141 ++edgei;
142 }
143
144 return theEdges;
145}
146
147
148Foam::cellShape Foam::hexCell::shape(const bool doCollapse) const
149{
150 static const cellModel* modelPtr(nullptr);
151
152 if (!modelPtr)
153 {
154 modelPtr = cellModel::ptr(cellModel::HEX);
155 }
156
157 return cellShape(*modelPtr, *this, doCollapse);
158}
159
160
161// ************************************************************************* //
Maps a geometry to a set of cell primitives.
Definition: cellModel.H:73
An analytical geometric cellShape.
Definition: cellShape.H:72
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
static const Foam::edgeList & modelEdges()
Return the model edges.
Definition: hexCell.C:94
static const Foam::faceList & modelFaces()
Return the model faces.
Definition: hexCell.C:71
Foam::faceList faces() const
Return list of cell faces [6].
Definition: hexCell.C:117
Foam::edgeList edges() const
Return list of cell edges [12].
Definition: hexCell.C:132
static constexpr label nFaces() noexcept
Number of faces for HEX.
Definition: hexCell.H:126
cellShape shape(const bool doCollapse=false) const
Return HEX shape cell.
Definition: hexCell.C:148
static constexpr label nEdges() noexcept
Number of edges for HEX.
Definition: hexCell.H:120
labelList f(nPoints)
volScalarField & e
Definition: createFields.H:11