GCC Code Coverage Report


Directory: src/oiseau/
File: src/oiseau/dg/detail/cell_mapping.hpp
Date: 2026-11-23 22:30:49
Exec Total Coverage
Lines: 9 10 90.0%
Functions: 1 1 100.0%
Branches: 9 16 56.2%

Line Branch Exec Source
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
16 namespace oiseau::dg::detail {
17
18 /// Reorders mesh connectivity to match the node order of the reference element.
19 364 inline std::vector<std::size_t> reference_ordered_vertices(
20 mesh::CellType cell_type, std::span<const std::size_t> mesh_vertices) {
21
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 364 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
364 if (cell_type == nullptr) throw std::invalid_argument("Mesh cell type cannot be null");
22
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 364 times.
364 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
1/2
✓ Branch 3 taken 364 times.
✗ Branch 4 not taken.
364 std::vector<std::size_t> vertices(mesh_vertices.begin(), mesh_vertices.end());
27 364 const auto kind = cell_type->kind();
28
4/4
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 326 times.
364 if (kind == mesh::CellKind::Quadrilateral || kind == mesh::CellKind::Hexahedron) {
29 // Tensor-product reference nodes vary in the first coordinate first;
30
31 38 std::swap(vertices[2], vertices[3]);
32
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 37 times.
38 if (kind == mesh::CellKind::Hexahedron) std::swap(vertices[6], vertices[7]);
33 }
34 364 return vertices;
35 }
36
37 } // namespace oiseau::dg::detail
38