#include <fesa/fem/gauss_rule.hpp>

#include <array>
#include <stdexcept>

namespace fesa {

namespace {

constexpr std::array<GaussPoint1D, 1> order_one{{
    {0.0, 2.0},
}};

constexpr double inverse_sqrt_three = 0.57735026918962576451;
constexpr std::array<GaussPoint1D, 2> order_two{{
    {-inverse_sqrt_three, 1.0},
    {inverse_sqrt_three, 1.0},
}};

}  // namespace

std::span<const GaussPoint1D> gauss_rule_1d(const int order) {
    switch (order) {
        case 1:
            return order_one;
        case 2:
            return order_two;
        default:
            throw std::invalid_argument{"Gauss rule order must be 1 or 2."};
    }
}

}  // namespace fesa
