3 template <
typename T,
unsigned Dim,
unsigned NumElementDOFs,
typename ElementType,
4 typename QuadratureType,
typename FieldLHS,
typename FieldRHS>
7 ElementType& ref_element,
8 const QuadratureType& quadrature)
12 assert(mesh.
Dimension ==
Dim &&
"Mesh dimension does not match the dimension of the space");
23 template <
typename T,
unsigned Dim,
unsigned NumElementDOFs,
typename ElementType,
24 typename QuadratureType,
typename FieldLHS,
typename FieldRHS>
28 assert(mesh.
Dimension ==
Dim &&
"Mesh dimension does not match the dimension of the space");
36 for (
size_t d = 0; d <
Dim; ++d) {
37 assert(
nr_m[d] > 1 &&
"Mesh has no cells in at least one dimension");
41 template <
typename T,
unsigned Dim,
unsigned NumElementDOFs,
typename ElementType,
42 typename QuadratureType,
typename FieldLHS,
typename FieldRHS>
47 size_t num_elements = 1;
48 for (
size_t d = 0; d <
Dim; ++d) {
49 num_elements *= cells_per_dim[d];
55 template <
typename T,
unsigned Dim,
unsigned NumElementDOFs,
typename ElementType,
56 typename QuadratureType,
typename FieldLHS,
typename FieldRHS>
57 KOKKOS_FUNCTION
size_t
63 template <
typename T,
unsigned Dim,
unsigned NumElementDOFs,
typename ElementType,
64 typename QuadratureType,
typename FieldLHS,
typename FieldRHS>
70 size_t index = vertex_index;
82 size_t remaining_number_of_vertices = 1;
83 for (
const size_t num_vertices : vertices_per_dim) {
84 remaining_number_of_vertices *= num_vertices;
87 for (
int d =
Dim - 1; d >= 0; --d) {
88 remaining_number_of_vertices /= vertices_per_dim[d];
89 vertex_indices[d] = index / remaining_number_of_vertices;
90 index -= vertex_indices[d] * remaining_number_of_vertices;
93 return vertex_indices;
96 template <
typename T,
unsigned Dim,
unsigned NumElementDOFs,
typename ElementType,
97 typename QuadratureType,
typename FieldLHS,
typename FieldRHS>
98 KOKKOS_FUNCTION
size_t
105 for (
size_t d = 1; d <
dim; ++d) {
106 for (
size_t d2 = d; d2 <
Dim; ++d2) {
112 return vertexNDIndex.dot(vec);
116 template <
typename T,
unsigned Dim,
unsigned NumElementDOFs,
typename ElementType,
117 typename QuadratureType,
typename FieldLHS,
typename FieldRHS>
123 size_t index = element_index;
136 size_t remaining_number_of_cells = 1;
137 for (
const size_t num_cells : cells_per_dim) {
138 remaining_number_of_cells *= num_cells;
141 for (
int d =
Dim - 1; d >= 0; --d) {
142 remaining_number_of_cells /= cells_per_dim[d];
143 element_nd_index[d] = (index / remaining_number_of_cells);
144 index -= (element_nd_index[d]) * remaining_number_of_cells;
147 return element_nd_index;
151 template <
typename T,
unsigned Dim,
unsigned NumElementDOFs,
typename ElementType,
152 typename QuadratureType,
typename FieldLHS,
typename FieldRHS>
153 KOKKOS_FUNCTION
size_t
158 size_t element_index = 0;
164 size_t remaining_number_of_cells = 1;
166 for (
unsigned int d = 0; d <
Dim; ++d) {
167 element_index += ndindex[d] * remaining_number_of_cells;
168 remaining_number_of_cells *= cells_per_dim[d];
171 return element_index;
174 template <
typename T,
unsigned Dim,
unsigned NumElementDOFs,
typename ElementType,
175 typename QuadratureType,
typename FieldLHS,
typename FieldRHS>
176 KOKKOS_FUNCTION
typename FiniteElementSpace<
T,
Dim, NumElementDOFs, ElementType, QuadratureType,
177 FieldLHS, FieldRHS>::vertex_indices_t
184 size_t smallest_vertex_index = 0;
185 for (
int d =
Dim - 1; d >= 0; --d) {
186 size_t temp_index = element_nd_index[d];
187 for (
int i = d; i >= 1; --i) {
188 temp_index *= num_vertices[i];
190 smallest_vertex_index += temp_index;
195 vertex_indices[0] = smallest_vertex_index;
196 vertex_indices[1] = vertex_indices[0] + 1;
213 for (
size_t d = 1; d <
Dim; ++d) {
214 for (
size_t i = 0; i < static_cast<unsigned>(1 << d); ++i) {
216 for (
size_t j = 0; j < d; ++j) {
217 size *= num_vertices[j];
219 vertex_indices[i + (1 << d)] = vertex_indices[i] + size;
223 return vertex_indices;
226 template <
typename T,
unsigned Dim,
unsigned NumElementDOFs,
typename ElementType,
227 typename QuadratureType,
typename FieldLHS,
typename FieldRHS>
229 FieldLHS, FieldRHS>::indices_list_t
236 indices_t smallest_vertex_nd_index = elementNDIndex;
256 for (
size_t i = 0; i < (1 <<
Dim); ++i) {
257 vertex_nd_indices[i] = smallest_vertex_nd_index;
258 for (
size_t j = 0; j <
Dim; ++j) {
259 vertex_nd_indices[i][j] += (i >> j) & 1;
263 return vertex_nd_indices;
266 template <
typename T,
unsigned Dim,
unsigned NumElementDOFs,
typename ElementType,
267 typename QuadratureType,
typename FieldLHS,
typename FieldRHS>
280 for (
size_t i = 0; i < vertex_nd_indices.
dim; ++i) {
282 for (
size_t d = 0; d <
Dim; ++d) {
283 temp_ndindex[d] =
Index(vertex_nd_indices[i][d], vertex_nd_indices[i][d]);
284 vertex_points[i][d] = (temp_ndindex[d].
first() * this->
hr_m[d]) + this->
origin_m[d];
287 return vertex_points;
The FiniteElementSpace class handles the mesh index mapping to vertices and elements and is the base ...
KOKKOS_FUNCTION vertex_indices_t getElementMeshVertexIndices(const indices_t &elementNDIndex) const
Get all the global vertex indices of an element (given by its NDIndex).
KOKKOS_FUNCTION size_t getElementIndex(const indices_t &ndindex) const
Get the global index of a mesh element given the NDIndex.
FiniteElementSpace(UniformCartesian< T, Dim > &mesh, ElementType &ref_element, const QuadratureType &quadrature)
Construct a new FiniteElementSpace object.
Vector< indices_t, numElementVertices > indices_list_t
static constexpr unsigned dim
Vector< size_t, Dim > indices_t
Vector< size_t, numElementVertices > vertex_indices_t
KOKKOS_FUNCTION indices_list_t getElementMeshVertexNDIndices(const indices_t &elementNDIndex) const
Get all the NDIndices of the vertices of an element (given by its NDIndex).
const QuadratureType & quadrature_m
ElementType ref_element_m
KOKKOS_FUNCTION size_t numElementsInDim(const size_t &dim) const
Get the number of elements in a given dimension.
Vector< size_t, Dim > nr_m
Vector< point_t, numElementVertices > vertex_points_t
KOKKOS_FUNCTION indices_t getMeshVertexNDIndex(const size_t &vertex_index) const
Get the NDIndex of a mesh vertex.
Vector< double, Dim > origin_m
KOKKOS_FUNCTION vertex_points_t getElementMeshVertexPoints(const indices_t &elementNDIndex) const
Get all the global vertex points of an element (given by its NDIndex).
void setMesh(UniformCartesian< T, Dim > &mesh)
UniformCartesian< T, Dim > & mesh_m
Member variables //////////////////////////////////////////////////.
KOKKOS_FUNCTION size_t getMeshVertexIndex(const indices_t &vertex_nd_index) const
Get the global index of a mesh vertex given its NDIndex.
KOKKOS_FUNCTION indices_t getElementNDIndex(const size_t &elementIndex) const
Get the NDIndex (vector of indices for each dimension) of a mesh element.
Vector< double, Dim > hr_m
KOKKOS_FUNCTION size_t numElements() const
Mesh and Element operations ///////////////////////////////////////.
KOKKOS_INLINE_FUNCTION Vector< int, Dim > first() const
static constexpr unsigned dim