16#ifndef dealii_simplex_barycentric_polynomials_h
17#define dealii_simplex_barycentric_polynomials_h
81template <
int dim,
typename Number =
double>
109 print(std::ostream &out)
const;
126 template <
typename Number2>
133 template <
typename Number2>
140 template <
typename Number2>
147 template <
typename Number2>
272 std::vector<double> &values,
334 name()
const override;
339 virtual std::unique_ptr<ScalarPolynomialsBase<dim>>
340 clone()
const override;
355template <
int dim,
typename Number1,
typename Number2>
365template <
int dim,
typename Number1,
typename Number2>
375template <
int dim,
typename Number1,
typename Number2>
385template <
int dim,
typename Number>
396template <
int dim,
typename Number>
400 for (
unsigned int d = 0; d < dim + 1; ++d)
409template <
int dim,
typename Number>
415 for (
unsigned int d = 0; d < dim + 1; ++d)
424template <
int dim,
typename Number>
436template <
int dim,
typename Number>
440 const auto &
coeffs = this->coefficients;
448 for (std::size_t i = 1; i <
coeffs.n_elements(); ++i)
450 const auto indices = index_to_indices(i,
coeffs.size());
451 if (
coeffs(indices) == Number())
456 for (
unsigned int d = 0; d < dim + 1; ++d)
459 out <<
" * t" << d <<
'^' << indices[d];
470template <
int dim,
typename Number>
474 auto deg = coefficients.size();
475 for (
unsigned int d = 0; d < dim + 1; ++d)
482template <
int dim,
typename Number>
486 return *
this * Number(-1);
491template <
int dim,
typename Number>
492template <
typename Number2>
497 result.coefficients(index_to_indices(0,
result.coefficients.size())) += a;
504template <
int dim,
typename Number>
505template <
typename Number2>
514template <
int dim,
typename Number>
515template <
typename Number2>
525 for (std::size_t i = 0; i <
result.coefficients.n_elements(); ++i)
527 const auto index = index_to_indices(i,
result.coefficients.size());
528 result.coefficients(index) *= a;
536template <
int dim,
typename Number>
537template <
typename Number2>
542 return *
this * (Number(1) / Number(a));
547template <
int dim,
typename Number>
553 for (
unsigned int d = 0; d < dim + 1; ++d)
561 for (std::size_t i = 0; i < in.n_elements(); ++i)
563 const auto index = index_to_indices(i, in.size());
564 result.coefficients(index) += in(index);
575template <
int dim,
typename Number>
585template <
int dim,
typename Number>
591 for (
unsigned int d = 0; d < dim + 1; ++d)
598 const auto &
coef_1 = this->coefficients;
602 for (std::size_t
i1 = 0;
i1 <
coef_1.n_elements(); ++
i1)
605 for (std::size_t
i2 = 0;
i2 <
coef_2.n_elements(); ++
i2)
610 for (
unsigned int d = 0; d < dim + 1; ++d)
621template <
int dim,
typename Number>
631 auto deg = degrees();
634 std::numeric_limits<Number>::max());
637 for (std::size_t i = 0; i <
coeffs_out.n_elements(); ++i)
639 const auto out_index = index_to_indices(i,
coeffs_out.size());
651template <
int dim,
typename Number>
657 return -barycentric_derivative(0) + barycentric_derivative(
coordinate + 1);
662template <
int dim,
typename Number>
672 std::array<Number, dim + 1>
b_point;
674 for (
unsigned int d = 0; d < dim; ++d)
681 for (std::size_t i = 0; i < coefficients.n_elements(); ++i)
683 const auto indices = index_to_indices(i, coefficients.size());
684 const auto coef = coefficients(indices);
685 if (coef == Number())
688 auto temp = Number(1);
689 for (
unsigned int d = 0; d < dim + 1; ++d)
699template <
int dim,
typename Number>
708template <
int dim,
typename Number>
711 const std::size_t &index,
717 for (
unsigned int n = 0; n < dim + 1; ++n)
720 for (
unsigned int n2 = n + 1;
n2 < dim + 1; ++
n2)
BarycentricPolynomial< dim, Number > operator*(const Number2 &a) const
std::size_t memory_consumption() const
BarycentricPolynomial< dim, Number > operator+(const Number2 &a) const
TableIndices< dim+1 > degrees() const
Table< dim+1, Number > coefficients
BarycentricPolynomial< dim, Number > barycentric_derivative(const unsigned int coordinate) const
Number value(const Point< dim > &point) const
static TableIndices< dim+1 > index_to_indices(const std::size_t &index, const TableIndices< dim+1 > &extents)
BarycentricPolynomial< dim, Number > operator/(const Number2 &a) const
BarycentricPolynomial< dim, Number > operator-() const
void print(std::ostream &out) const
static BarycentricPolynomial< dim, Number > monomial(const unsigned int d)
BarycentricPolynomial< dim, Number > derivative(const unsigned int coordinate) const
std::array< HessianType, dim > ThirdDerivativesType
Tensor< 1, dim > compute_grad(const unsigned int i, const Point< dim > &p) const override
std::array< PolyType, dim > GradType
virtual std::size_t memory_consumption() const override
Tensor< 2, dim > compute_grad_grad(const unsigned int i, const Point< dim > &p) const override
std::array< ThirdDerivativesType, dim > FourthDerivativesType
std::vector< GradType > poly_grads
std::string name() const override
Tensor< 3, dim > compute_3rd_derivative(const unsigned int i, const Point< dim > &p) const override
Tensor< 1, dim > compute_1st_derivative(const unsigned int i, const Point< dim > &p) const override
Tensor< 2, dim > compute_2nd_derivative(const unsigned int i, const Point< dim > &p) const override
static constexpr unsigned int dimension
std::vector< PolyType > polys
void evaluate(const Point< dim > &unit_point, std::vector< double > &values, std::vector< Tensor< 1, dim > > &grads, std::vector< Tensor< 2, dim > > &grad_grads, std::vector< Tensor< 3, dim > > &third_derivatives, std::vector< Tensor< 4, dim > > &fourth_derivatives) const override
double compute_value(const unsigned int i, const Point< dim > &p) const override
const BarycentricPolynomial< dim > & operator[](const std::size_t i) const
std::vector< ThirdDerivativesType > poly_third_derivatives
std::array< GradType, dim > HessianType
virtual std::unique_ptr< ScalarPolynomialsBase< dim > > clone() const override
Tensor< 4, dim > compute_4th_derivative(const unsigned int i, const Point< dim > &p) const override
std::vector< HessianType > poly_hessians
static BarycentricPolynomials< dim > get_fe_p_basis(const unsigned int degree)
std::vector< FourthDerivativesType > poly_fourth_derivatives
virtual unsigned int degree() const
static constexpr std::size_t memory_consumption()
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcDivideByZero()
constexpr T pow(const T base, const int iexp)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
BarycentricPolynomial< dim, Number1 > operator-(const Number2 &a, const BarycentricPolynomial< dim, Number1 > &bp)
BarycentricPolynomial< dim, Number1 > operator+(const Number2 &a, const BarycentricPolynomial< dim, Number1 > &bp)
std::ostream & operator<<(std::ostream &out, const BarycentricPolynomial< dim, Number > &bp)
BarycentricPolynomial< dim, Number1 > operator*(const Number2 &a, const BarycentricPolynomial< dim, Number1 > &bp)