OISEAU
A modern DGTD framework
Loading...
Searching...
No Matches
ref_element.hpp
1// Copyright (C) 2025 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 inline unsigned order() const { return m_order; }
29 inline unsigned number_of_nodes() const { return m_np; }
30 inline unsigned number_of_face_nodes() const { return m_nfp; }
31
32 virtual xt::xarray<double> vandermonde(const xt::xarray<double>&) const = 0;
33
34 protected:
35 explicit RefElement(unsigned order) : m_order(order) {
36 if (order == 0) throw std::invalid_argument("Order must be greater than 0");
37 }
38
39 unsigned m_order;
40 unsigned m_np{};
41 unsigned m_nfp{};
42 xt::xarray<double> m_v;
43 xt::xarray<double> m_gv;
44 xt::xarray<double> m_d;
45 xt::xarray<double> m_r;
46};
47
48std::shared_ptr<RefElement> get_ref_element(RefElementType type, unsigned order);
49
50} // namespace oiseau::dg::nodal