42 std::size_t max_degree = 0;
43 for (
const auto &poly : polys)
47 const auto degree_0 = degrees[0];
48 std::size_t degree_d = 0;
49 for (
unsigned int d = 1; d < dim + 1; ++d)
50 degree_d =
std::max(degree_d, degrees[d]);
52 max_degree =
std::max(max_degree, degree_d + degree_0);
64 std::vector<PolyType> polys;
66 const auto reference_cell = ReferenceCells::get_simplex<dim>();
76 for (
const unsigned int v : reference_cell.vertex_indices())
83 for (
const unsigned int v : reference_cell.vertex_indices())
87 for (
const unsigned int l : reference_cell.line_indices())
89 const auto v0 = reference_cell.line_to_cell_vertices(l, 0);
90 const auto v1 = reference_cell.line_to_cell_vertices(l, 1);
100 for (
const unsigned int v : reference_cell.vertex_indices())
105 for (
unsigned int l : reference_cell.line_indices())
107 const auto v0 = reference_cell.line_to_cell_vertices(l, 0);
108 const auto v1 = reference_cell.line_to_cell_vertices(l, 1);
159 const std::vector<PolyType> &polynomials)
169 for (std::size_t i = 0; i < polynomials.size(); ++i)
172 for (
unsigned int d = 0; d < dim; ++d)
173 poly_grads[i][d] = polynomials[i].derivative(d);
176 for (
unsigned int d0 = 0; d0 < dim; ++d0)
177 for (
unsigned int d1 = 0; d1 < dim; ++d1)
181 for (
unsigned int d0 = 0; d0 < dim; ++d0)
182 for (
unsigned int d1 = 0; d1 < dim; ++d1)
183 for (
unsigned int d2 = 0; d2 < dim; ++d2)
188 for (
unsigned int d0 = 0; d0 < dim; ++d0)
189 for (
unsigned int d1 = 0; d1 < dim; ++d1)
190 for (
unsigned int d2 = 0; d2 < dim; ++d2)
191 for (
unsigned int d3 = 0; d3 < dim; ++d3)
203 std::vector<double> &values,
209 Assert(values.size() == this->n() || values.empty(),
211 Assert(grads.size() == this->n() || grads.empty(),
213 Assert(grad_grads.size() == this->n() || grad_grads.empty(),
215 Assert(third_derivatives.size() == this->n() || third_derivatives.empty(),
217 Assert(fourth_derivatives.size() == this->n() || fourth_derivatives.empty(),
220 for (std::size_t i = 0; i < polys.size(); ++i)
222 if (values.size() == this->n())
223 values[i] = polys[i].value(unit_point);
226 if (grads.size() == this->n())
227 for (
unsigned int d = 0; d < dim; ++d)
228 grads[i][d] = poly_grads[i][d].value(unit_point);
231 if (grad_grads.size() == this->n())
232 for (
unsigned int d0 = 0; d0 < dim; ++d0)
233 for (
unsigned int d1 = 0; d1 < dim; ++d1)
234 grad_grads[i][d0][d1] = poly_hessians[i][d0][d1].value(unit_point);
237 if (third_derivatives.size() == this->n())
238 for (
unsigned int d0 = 0; d0 < dim; ++d0)
239 for (
unsigned int d1 = 0; d1 < dim; ++d1)
240 for (
unsigned int d2 = 0; d2 < dim; ++d2)
241 third_derivatives[i][d0][d1][d2] =
242 poly_third_derivatives[i][d0][d1][d2].value(unit_point);
245 if (fourth_derivatives.size() == this->n())
246 for (
unsigned int d0 = 0; d0 < dim; ++d0)
247 for (
unsigned int d1 = 0; d1 < dim; ++d1)
248 for (
unsigned int d2 = 0; d2 < dim; ++d2)
249 for (
unsigned int d3 = 0; d3 < dim; ++d3)
250 fourth_derivatives[i][d0][d1][d2][d3] =
251 poly_fourth_derivatives[i][d0][d1][d2][d3].value(unit_point);
263 return polys[i].value(p);
274 for (
unsigned int d = 0; d < dim; ++d)
275 result[d] = poly_grads[i][d].value(p);
287 for (
unsigned int d0 = 0; d0 < dim; ++d0)
288 for (
unsigned int d1 = 0; d1 < dim; ++d1)
289 result[d0][d1] = poly_hessians[i][d0][d1].value(p);
302 for (
unsigned int d0 = 0; d0 < dim; ++d0)
303 for (
unsigned int d1 = 0; d1 < dim; ++d1)
304 for (
unsigned int d2 = 0; d2 < dim; ++d2)
305 result[d0][d1][d2] = poly_third_derivatives[i][d0][d1][d2].value(p);
318 for (
unsigned int d0 = 0; d0 < dim; ++d0)
319 for (
unsigned int d1 = 0; d1 < dim; ++d1)
320 for (
unsigned int d2 = 0; d2 < dim; ++d2)
321 for (
unsigned int d3 = 0; d3 < dim; ++d3)
322 result[d0][d1][d2][d3] =
323 poly_fourth_derivatives[i][d0][d1][d2][d3].value(p);
335 return compute_1st_derivative(i, p);
345 return compute_2nd_derivative(i, p);
351std::unique_ptr<ScalarPolynomialsBase<dim>>
354 return std::make_unique<BarycentricPolynomials<dim>>(*this);
363 return "BarycentricPolynomials<" + std::to_string(dim) +
">";
372 std::size_t poly_memory = 0;
373 for (
const auto &poly : polys)
374 poly_memory += poly.memory_consumption();
static BarycentricPolynomial< dim, Number > monomial(const unsigned int d)
Tensor< 1, dim > compute_grad(const unsigned int i, const Point< dim > &p) const override
BarycentricPolynomials(const std::vector< BarycentricPolynomial< dim > > &polynomials)
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::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
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
std::vector< ThirdDerivativesType > poly_third_derivatives
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 std::size_t memory_consumption() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NOT_IMPLEMENTED()
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch2(std::size_t arg1, std::size_t arg2, std::size_t arg3)
#define AssertIndexRange(index, range)
std::enable_if_t< std::is_fundamental_v< T >, std::size_t > memory_consumption(const T &t)
unsigned int get_degree(const std::vector< typename BarycentricPolynomials< dim >::PolyType > &polys)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)