GCC Code Coverage Report


Directory: src/oiseau/
File: src/oiseau/dg/dg_space.hpp
Date: 2026-11-23 22:30:49
Exec Total Coverage
Lines: 2 2 100.0%
Functions: 2 2 100.0%
Branches: 0 0 -%

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 <vector>
12 #include <xtensor/containers/xarray.hpp>
13 #include <xtensor/core/xtensor_forward.hpp>
14
15 #include "oiseau/mesh/cell.hpp"
16 #include "oiseau/mesh/mesh.hpp"
17
18 namespace oiseau::dg {
19
20 /**
21 * @brief Stores discontinuous Galerkin nodes grouped by cell kind and order.
22 * @details The mesh is referenced, not copied, and must outlive this space.
23 */
24 class DGSpace {
25 public:
26 /** @brief Stores cells that share a cell kind and polynomial order. */
27 struct ElementGroup {
28 /** @brief Reference-cell kind shared by every cell in the group. */
29 mesh::CellKind kind = mesh::CellKind::Undefined;
30 /** @brief Polynomial order shared by every cell in the group. */
31 unsigned order = 0;
32 /** @brief Source mesh indices for cells in this group. */
33 std::vector<std::size_t> cell_indices;
34 /**
35 * @brief Physical coordinates of the group nodes.
36 * @details Shape is [cells, nodes per cell, coordinate dimensions].
37 */
38 xt::xarray<double> nodes;
39 };
40
41 DGSpace(const DGSpace& V) = delete;
42 /**
43 * @brief Builds groups using one order per top-dimensional mesh cell.
44 * @param mesh Source mesh. It must outlive this space.
45 * @param orders Positive polynomial orders in top-dimensional cell order.
46 * Lower-dimensional cells, such as boundary edges, have no order.
47 * @throws std::invalid_argument If the order count, mesh dimensions,
48 * geometry, or cell kinds are invalid.
49 * @throws std::out_of_range If a cell references a missing mesh vertex.
50 */
51 DGSpace(const mesh::Mesh& mesh, const std::vector<unsigned>& orders);
52 /**
53 * @brief Builds groups using one order for every top-dimensional cell.
54 * @param mesh Source mesh. It must outlive this space.
55 * @param order Positive polynomial order assigned to each top-dimensional cell.
56 * @throws std::invalid_argument If the order is zero or the mesh is invalid.
57 * @throws std::out_of_range If a cell references a missing mesh vertex.
58 */
59 DGSpace(const mesh::Mesh& mesh, unsigned order);
60 DGSpace(DGSpace&& V) = default;
61 28 ~DGSpace() = default;
62 DGSpace& operator=(const DGSpace& V) = delete;
63 DGSpace& operator=(DGSpace&& V) = delete;
64
65 /** @brief Returns the source mesh. */
66 26 const mesh::Mesh& mesh() const { return m_mesh; }
67 /** @brief Returns all element groups. */
68 std::span<const ElementGroup> element_groups() const;
69 /**
70 * @brief Finds a group by cell kind and polynomial order.
71 * @param kind Cell kind to find.
72 * @param order Polynomial order to find.
73 * @return Matching group, or nullptr if no group exists.
74 */
75 const ElementGroup* element_group(mesh::CellKind kind, unsigned order) const;
76 /** @brief Returns orders for top-dimensional cells in mesh order. */
77 std::span<const unsigned> orders() const;
78
79 private:
80 const mesh::Mesh& m_mesh;
81 std::vector<ElementGroup> m_element_groups;
82 const std::vector<unsigned> m_orders;
83 };
84
85 } // namespace oiseau::dg
86