libMesh
Loading...
Searching...
No Matches
fe_reference_element_traits.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18#ifndef LIBMESH_FE_REFERENCE_ELEMENT_TRAITS_H
19#define LIBMESH_FE_REFERENCE_ELEMENT_TRAITS_H
20
21#include "libmesh/libmesh.h" // invalid_uint
22
23namespace libMesh
24{
25
46static constexpr unsigned int unused_side_node = 99;
47
53template <unsigned int Rows, unsigned int Cols>
55{
56 unsigned int values[Rows][Cols];
57};
58
62constexpr unsigned int no_face_node (const unsigned int)
63{
64 return invalid_uint;
65}
66
72template <class FirstOrder, unsigned int Edges>
73constexpr NodeMapTable<Edges, 3>
75{
77 for (unsigned int e = 0; e != Edges; ++e)
78 {
79 t.values[e][0] = FirstOrder::edge_nodes_map[e][0];
80 t.values[e][1] = FirstOrder::edge_nodes_map[e][1];
81 t.values[e][2] = FirstOrder::num_nodes + e;
82 }
83 return t;
84}
85
91template <class FirstOrder>
92constexpr unsigned int n_side_vertices (const unsigned int s)
93{
94 unsigned int n = 0;
95 for (unsigned int k = 0; k != FirstOrder::nodes_per_side; ++k)
96 if (FirstOrder::side_nodes_map[s][k] != unused_side_node)
97 ++n;
98 return n;
99}
100
105template <unsigned int Edges>
106constexpr unsigned int mid_edge_node (const unsigned int (&edges)[Edges][3],
107 const unsigned int a,
108 const unsigned int b)
109{
110 for (unsigned int e = 0; e != Edges; ++e)
111 if ((edges[e][0] == a && edges[e][1] == b) ||
112 (edges[e][0] == b && edges[e][1] == a))
113 return edges[e][2];
114 return invalid_uint;
115}
116
124template <class FirstOrder, unsigned int Sides, unsigned int Cols,
125 unsigned int Edges, class FaceNode>
126constexpr NodeMapTable<Sides, Cols>
127derived_side_nodes (const unsigned int (&edges)[Edges][3],
128 FaceNode face_node)
129{
131 for (unsigned int s = 0; s != Sides; ++s)
132 {
133 const unsigned int nv = n_side_vertices<FirstOrder>(s);
134 unsigned int n = 0;
135 for (unsigned int k = 0; k != nv; ++k)
136 t.values[s][n++] = FirstOrder::side_nodes_map[s][k];
137 for (unsigned int k = 0; k != nv; ++k)
138 t.values[s][n++] = mid_edge_node(edges,
139 FirstOrder::side_nodes_map[s][k],
140 FirstOrder::side_nodes_map[s][(k+1) % nv]);
141 if (face_node(s) != invalid_uint)
142 t.values[s][n++] = face_node(s);
143 for (; n != Cols; ++n)
144 t.values[s][n] = unused_side_node;
145 }
146 return t;
147}
148
154template <class FirstOrder, unsigned int Sides>
155constexpr NodeMapTable<Sides, 3>
157{
159 for (unsigned int s = 0; s != Sides; ++s)
160 {
161 t.values[s][0] = FirstOrder::side_nodes_map[s][0];
162 t.values[s][1] = FirstOrder::side_nodes_map[s][1];
163 t.values[s][2] = FirstOrder::num_nodes + s;
164 }
165 return t;
166}
167
168} // namespace libMesh
169
170#endif // LIBMESH_FE_REFERENCE_ELEMENT_TRAITS_H
static const Real b
The libMesh namespace provides an interface to certain functionality in the library.
constexpr unsigned int n_side_vertices(const unsigned int s)
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition libmesh.h:303
static constexpr unsigned int unused_side_node
The second-order elements' node maps are not independent facts.
constexpr unsigned int no_face_node(const unsigned int)
The face-node rule for elements with no face nodes.
constexpr unsigned int mid_edge_node(const unsigned int(&edges)[Edges][3], const unsigned int a, const unsigned int b)
constexpr NodeMapTable< Edges, 3 > derived_edge_nodes()
constexpr NodeMapTable< Sides, 3 > derived_side_nodes()
A fixed-size table that constexpr functions can return.
unsigned int values[Rows][Cols]