DOLFINx 0.11.0.0
DOLFINx C++
Loading...
Searching...
No Matches
cells.h
1// Copyright (C) 2019 Jorgen S. Dokken
2//
3// This file is part of DOLFINx (https://www.fenicsproject.org)
4//
5// SPDX-License-Identifier: LGPL-3.0-or-later
6
7#pragma once
8
9#include <array>
10#include <cstdint>
11#include <dolfinx/mesh/cell_types.h>
12#include <span>
13#include <vector>
14
20
119{
120
127int cell_degree(mesh::CellType type, int num_nodes);
128
138std::vector<std::uint16_t> perm_vtk(mesh::CellType type, int num_nodes);
139
149std::vector<std::uint16_t> perm_gmsh(mesh::CellType type, int num_nodes);
150
156std::vector<std::uint16_t> transpose(std::span<const std::uint16_t> map);
157
169std::vector<std::int64_t> apply_permutation(std::span<const std::int64_t> cells,
170 std::array<std::size_t, 2> shape,
171 std::span<const std::uint16_t> p);
172
178std::int8_t get_vtk_cell_type(mesh::CellType cell, int dim);
179
185inline std::tuple<mesh::CellType, std::int8_t>
186vtk_to_dolfinx(std::int8_t vtk_cell_type)
187{
188 {
189 // For a complete overview of VTK cell types, see
190 // https://vtk.org/doc/nightly/html/vtkCellType_8h_source.html
191 switch (vtk_cell_type)
192 {
193 using enum mesh::CellType;
194 case 1:
195 return {point, -1};
196 case 3:
197 return {interval, 1};
198 case 5:
199 return {triangle, 1};
200 case 9:
201 return {quadrilateral, 1};
202 case 10:
203 return {tetrahedron, 1};
204 case 12:
205 return {hexahedron, 1};
206 case 13:
207 return {prism, 1};
208 case 14:
209 return {pyramid, 1};
210 case 21:
211 return {interval, 2};
212 case 22:
213 return {triangle, 2};
214 case 23:
215 return {quadrilateral, 2};
216 case 24:
217 return {tetrahedron, 2};
218 case 25:
219 return {hexahedron, 2};
220 case 26:
221 return {prism, 2};
222 case 27:
223 return {pyramid, 2};
224 case 35:
225 return {interval, 3};
226 case 68:
227 return {interval, -1};
228 case 69:
229 return {triangle, -1};
230 case 70:
231 return {quadrilateral, -1};
232 case 71:
233 return {tetrahedron, -1};
234 case 72:
235 return {hexahedron, -1};
236 case 73:
237 return {prism, -1};
238 case 74:
239 return {pyramid,
240 -1}; // Not implemented in VTK yet, but added as placeholder.
241 default:
242 break;
243 }
244 throw std::runtime_error("Unknown VTK cell type");
245 }
246}
247
248} // namespace dolfinx::io::cells
Functions for the re-ordering of input mesh topology to the DOLFINx ordering, and transpose orderings...
Definition cells.h:119
std::tuple< mesh::CellType, std::int8_t > vtk_to_dolfinx(std::int8_t vtk_cell_type)
Get DOLFINx cell type and degree from VTK cell type.
Definition cells.h:186
std::int8_t get_vtk_cell_type(mesh::CellType cell, int dim)
Get VTK cell identifier.
Definition cells.cpp:715
std::vector< std::uint16_t > perm_vtk(mesh::CellType type, int num_nodes)
Permutation array to map from VTK to DOLFINx node ordering.
Definition cells.cpp:533
std::vector< std::uint16_t > transpose(std::span< const std::uint16_t > map)
Compute the transpose of a re-ordering map.
Definition cells.cpp:687
std::vector< std::int64_t > apply_permutation(std::span< const std::int64_t > cells, std::array< std::size_t, 2 > shape, std::span< const std::uint16_t > p)
Permute cell topology by applying a permutation array for each cell.
Definition cells.cpp:696
std::vector< std::uint16_t > perm_gmsh(mesh::CellType type, int num_nodes)
Permutation array to map from Gmsh to DOLFINx node ordering.
Definition cells.cpp:571
int cell_degree(mesh::CellType type, int num_nodes)
Get the Lagrange order of a given cell with a given number of nodes.
Definition cells.cpp:609
CellType
Cell type identifier.
Definition cell_types.h:21