OISEAU
A modern DGTD framework
Loading...
Searching...
No Matches
cell_mapping.hpp
1// Copyright (C) 2026 Tiago V. L. Amorim (@tiagovla)
2//
3// This file is part of oiseau (https://github.com/tiagovla/oiseau)
4//
5// SPDX-License-Identifier: GPL-3.0-or-later
6
7#pragma once
8
9#include <cstddef>
10#include <span>
11#include <stdexcept>
12#include <vector>
13
14#include "oiseau/mesh/cell.hpp"
15
16namespace oiseau::dg::detail {
17
19inline std::vector<std::size_t> reference_ordered_vertices(
20 mesh::CellType cell_type, std::span<const std::size_t> mesh_vertices) {
21 if (cell_type == nullptr) throw std::invalid_argument("Mesh cell type cannot be null");
22 if (mesh_vertices.size() != static_cast<std::size_t>(cell_type->num_sub_entities(0))) {
23 throw std::invalid_argument("Cell connectivity does not match its cell type");
24 }
25
26 std::vector<std::size_t> vertices(mesh_vertices.begin(), mesh_vertices.end());
27 const auto kind = cell_type->kind();
28 if (kind == mesh::CellKind::Quadrilateral || kind == mesh::CellKind::Hexahedron) {
29 // Tensor-product reference nodes vary in the first coordinate first;
30
31 std::swap(vertices[2], vertices[3]);
32 if (kind == mesh::CellKind::Hexahedron) std::swap(vertices[6], vertices[7]);
33 }
34 return vertices;
35}
36
37} // namespace oiseau::dg::detail