feat(fem-and-beam-kernel): step 0 — quadrature-and-shape-functions
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#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
|
||||
@@ -0,0 +1,31 @@
|
||||
#include <fesa/fem/line2_shape.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace fesa {
|
||||
|
||||
std::array<double, 2> line2_shape(const double xi) {
|
||||
return {0.5 * (1.0 - xi), 0.5 * (1.0 + xi)};
|
||||
}
|
||||
|
||||
std::array<double, 2> line2_shape_derivative(const double) {
|
||||
return {-0.5, 0.5};
|
||||
}
|
||||
|
||||
double line2_jacobian(const double length) {
|
||||
if (!std::isfinite(length) || length <= 0.0) {
|
||||
throw std::invalid_argument{
|
||||
"Line2 Jacobian requires a positive finite length."};
|
||||
}
|
||||
|
||||
const double jacobian = length / 2.0;
|
||||
if (jacobian == 0.0) {
|
||||
throw std::invalid_argument{
|
||||
"Line2 Jacobian must be representable as a positive double."};
|
||||
}
|
||||
|
||||
return jacobian;
|
||||
}
|
||||
|
||||
} // namespace fesa
|
||||
Reference in New Issue
Block a user