OISEAU
A modern DGTD framework
Loading...
Searching...
No Matches
ref_element.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 <memory>
10#include <stdexcept>
11#include <xtensor/containers/xarray.hpp>
12
13#include "xtensor/core/xtensor_forward.hpp"
14
15namespace oiseau::dg::nodal {
16
17enum class RefElementType { Line, Triangle, Quadrilateral, Tetrahedron, Hexahedron };
18
19class RefElement {
20 public:
21 virtual ~RefElement() = default;
22
23 inline const xt::xarray<double>& v() const { return m_v; }
24 inline const xt::xarray<double>& gv() const { return m_gv; }
25 inline const xt::xarray<double>& d() const { return m_d; }
26 inline const xt::xarray<double>& r() const { return m_r; }
27
28 xt::xarray<double> mass() const;
29 xt::xarray<double> inv_mass() const;
30 xt::xarray<double> inv_v() const;
31
32 inline unsigned order() const { return m_order; }
33 inline unsigned number_of_nodes() const { return m_np; }
34 inline unsigned number_of_face_nodes() const { return m_nfp; }
35
36 virtual xt::xarray<double> vandermonde(const xt::xarray<double>&) const = 0;
37
38 protected:
39 explicit RefElement(unsigned order) : m_order(order) {
40 if (order == 0) throw std::invalid_argument("Order must be greater than 0");
41 }
42
43 unsigned m_order;
44 unsigned m_np{};
45 unsigned m_nfp{};
46 xt::xarray<double> m_v;
47 xt::xarray<double> m_gv;
48 xt::xarray<double> m_d;
49 xt::xarray<double> m_r;
50};
51
52std::shared_ptr<RefElement> get_ref_element(RefElementType type, unsigned order);
53
54} // namespace oiseau::dg::nodal