DOLFINx
0.12.0.0
DOLFINx C++
Toggle main menu visibility
Loading...
Searching...
No Matches
dolfinx
io
cells.h
1
// Copyright (C) 2019 Jorgen S. Dokken
2
// Copyright (C) 2026 Garth N. Wells
3
//
4
// This file is part of DOLFINx (https://www.fenicsproject.org)
5
//
6
// SPDX-License-Identifier: LGPL-3.0-or-later
7
8
#pragma once
9
10
#include <array>
11
#include <cstdint>
12
#include <dolfinx/mesh/cell_types.h>
13
#include <span>
14
#include <stdexcept>
15
#include <tuple>
16
#include <vector>
17
23
121
namespace
dolfinx::io::cells
122
{
123
141
int
cell_degree
(
mesh::CellType
type,
int
num_nodes);
142
152
std::vector<std::uint16_t>
perm_vtk
(
mesh::CellType
type,
int
num_nodes);
153
163
std::vector<std::uint16_t>
perm_gmsh
(
mesh::CellType
type,
int
num_nodes);
164
170
std::vector<std::uint16_t>
transpose
(std::span<const std::uint16_t> map);
171
183
std::vector<std::int64_t>
apply_permutation
(std::span<const std::int64_t>
cells
,
184
std::array<std::size_t, 2> shape,
185
std::span<const std::uint16_t> p);
186
205
std::int8_t
get_vtk_cell_type
(
mesh::CellType
cell,
int
num_nodes);
206
212
inline
std::tuple<mesh::CellType, std::int8_t>
213
vtk_to_dolfinx
(std::int8_t vtk_cell_type)
214
{
215
{
216
// For a complete overview of VTK cell types, see
217
// https://vtk.org/doc/nightly/html/vtkCellType_8h_source.html
218
switch
(vtk_cell_type)
219
{
220
using
enum
mesh::CellType
;
221
case
1:
222
return
{point, -1};
223
case
3:
224
return
{interval, 1};
225
case
5:
226
return
{triangle, 1};
227
case
9:
228
return
{quadrilateral, 1};
229
case
10:
230
return
{tetrahedron, 1};
231
case
12:
232
return
{hexahedron, 1};
233
case
13:
234
return
{prism, 1};
235
case
14:
236
return
{pyramid, 1};
237
case
21:
238
return
{interval, 2};
239
case
22:
240
return
{triangle, 2};
241
case
23:
242
return
{quadrilateral, 2};
243
case
24:
244
return
{tetrahedron, 2};
245
case
25:
246
return
{hexahedron, 2};
247
case
26:
248
return
{prism, 2};
249
case
27:
250
return
{pyramid, 2};
251
case
35:
252
return
{interval, 3};
253
case
68:
254
return
{interval, -1};
255
case
69:
256
return
{triangle, -1};
257
case
70:
258
return
{quadrilateral, -1};
259
case
71:
260
return
{tetrahedron, -1};
261
case
72:
262
return
{hexahedron, -1};
263
case
73:
264
return
{prism, -1};
265
case
74:
266
return
{pyramid,
267
-1};
// Not implemented in VTK yet, but added as placeholder.
268
default
:
269
break
;
270
}
271
throw
std::invalid_argument(
"Unknown VTK cell type"
);
272
}
273
}
274
275
}
// namespace dolfinx::io::cells
dolfinx::io::cells
Functions for the re-ordering of input mesh topology to the DOLFINx ordering, and transpose orderings...
Definition
cells.h:122
dolfinx::io::cells::vtk_to_dolfinx
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:213
dolfinx::io::cells::get_vtk_cell_type
std::int8_t get_vtk_cell_type(mesh::CellType cell, int num_nodes)
Get the VTK cell identifier for a cell type and node layout.
Definition
cells.cpp:749
dolfinx::io::cells::perm_vtk
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:556
dolfinx::io::cells::transpose
std::vector< std::uint16_t > transpose(std::span< const std::uint16_t > map)
Compute the transpose of a re-ordering map.
Definition
cells.cpp:720
dolfinx::io::cells::apply_permutation
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:729
dolfinx::io::cells::perm_gmsh
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:594
dolfinx::io::cells::cell_degree
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:632
dolfinx::mesh::CellType
CellType
Cell type identifier.
Definition
cell_types.h:24
Generated by
1.18.0