39 std::size_t max_degree = 0;
40 for (
const auto &poly : polys)
44 const auto degree_0 = degrees[0];
45 std::size_t degree_d = 0;
46 for (
unsigned int d = 1; d < dim + 1; ++d)
47 degree_d =
std::max(degree_d, degrees[d]);
49 max_degree =
std::max(max_degree, degree_d + degree_0);
61 std::vector<PolyType> polys;
63 const auto reference_cell = ReferenceCells::get_simplex<dim>();
73 for (
const unsigned int v : reference_cell.vertex_indices())
80 for (
const unsigned int v : reference_cell.vertex_indices())
84 for (
const unsigned int l : reference_cell.line_indices())
86 const auto v0 = reference_cell.line_to_cell_vertices(l, 0);
87 const auto v1 = reference_cell.line_to_cell_vertices(l, 1);
97 for (
const unsigned int v : reference_cell.vertex_indices())
102 for (
unsigned int l : reference_cell.line_indices())
104 const auto v0 = reference_cell.line_to_cell_vertices(l, 0);
105 const auto v1 = reference_cell.line_to_cell_vertices(l, 1);
156 const std::vector<PolyType> &polynomials)
167 for (std::size_t i = 0; i < polynomials.size(); ++i)
170 for (
unsigned int d = 0; d < dim; ++d)
171 poly_grads[i][d] = polynomials[i].derivative(d);
174 for (
unsigned int d0 = 0; d0 < dim; ++d0)
175 for (
unsigned int d1 = 0; d1 < dim; ++d1)
179 for (
unsigned int d0 = 0; d0 < dim; ++d0)
180 for (
unsigned int d1 = 0; d1 < dim; ++d1)
181 for (
unsigned int d2 = 0; d2 < dim; ++d2)
186 for (
unsigned int d0 = 0; d0 < dim; ++d0)
187 for (
unsigned int d1 = 0; d1 < dim; ++d1)
188 for (
unsigned int d2 = 0; d2 < dim; ++d2)
189 for (
unsigned int d3 = 0; d3 < dim; ++d3)
201 std::vector<double> &values,
207 Assert(values.size() == this->n() || values.empty(),
209 Assert(grads.size() == this->n() || grads.empty(),
211 Assert(grad_grads.size() == this->n() || grad_grads.empty(),
213 Assert(third_derivatives.size() == this->n() || third_derivatives.empty(),
215 Assert(fourth_derivatives.size() == this->n() || fourth_derivatives.empty(),
218 for (std::size_t i = 0; i < polys.size(); ++i)
220 if (values.size() == this->n())
221 values[i] = polys[i].value(unit_point);
224 if (grads.size() == this->n())
225 for (
unsigned int d = 0; d < dim; ++d)
226 grads[i][d] = poly_grads[i][d].value(unit_point);
229 if (grad_grads.size() == this->n())
230 for (
unsigned int d0 = 0; d0 < dim; ++d0)
231 for (
unsigned int d1 = 0; d1 < dim; ++d1)
232 grad_grads[i][d0][d1] = poly_hessians[i][d0][d1].value(unit_point);
235 if (third_derivatives.size() == this->n())
236 for (
unsigned int d0 = 0; d0 < dim; ++d0)
237 for (
unsigned int d1 = 0; d1 < dim; ++d1)
238 for (
unsigned int d2 = 0; d2 < dim; ++d2)
239 third_derivatives[i][d0][d1][d2] =
240 poly_third_derivatives[i][d0][d1][d2].value(unit_point);
243 if (fourth_derivatives.size() == this->n())
244 for (
unsigned int d0 = 0; d0 < dim; ++d0)
245 for (
unsigned int d1 = 0; d1 < dim; ++d1)
246 for (
unsigned int d2 = 0; d2 < dim; ++d2)
247 for (
unsigned int d3 = 0; d3 < dim; ++d3)
248 fourth_derivatives[i][d0][d1][d2][d3] =
249 poly_fourth_derivatives[i][d0][d1][d2][d3].value(unit_point);
261 return polys[i].value(p);
272 for (
unsigned int d = 0; d < dim; ++d)
273 result[d] = poly_grads[i][d].value(p);
285 for (
unsigned int d0 = 0; d0 < dim; ++d0)
286 for (
unsigned int d1 = 0; d1 < dim; ++d1)
287 result[d0][d1] = poly_hessians[i][d0][d1].value(p);
300 for (
unsigned int d0 = 0; d0 < dim; ++d0)
301 for (
unsigned int d1 = 0; d1 < dim; ++d1)
302 for (
unsigned int d2 = 0; d2 < dim; ++d2)
303 result[d0][d1][d2] = poly_third_derivatives[i][d0][d1][d2].value(p);
316 for (
unsigned int d0 = 0; d0 < dim; ++d0)
317 for (
unsigned int d1 = 0; d1 < dim; ++d1)
318 for (
unsigned int d2 = 0; d2 < dim; ++d2)
319 for (
unsigned int d3 = 0; d3 < dim; ++d3)
320 result[d0][d1][d2][d3] =
321 poly_fourth_derivatives[i][d0][d1][d2][d3].value(p);
333 return compute_1st_derivative(i, p);
343 return compute_2nd_derivative(i, p);
349std::unique_ptr<ScalarPolynomialsBase<dim>>
352 return std::make_unique<BarycentricPolynomials<dim>>(*this);
361 return "BarycentricPolynomials<" + std::to_string(dim) +
">";
370 std::size_t poly_memory = 0;
371 for (
const auto &poly : polys)
372 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
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
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 Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch2(std::size_t arg1, std::size_t arg2, std::size_t arg3)
#define AssertIndexRange(index, range)
#define DEAL_II_NOT_IMPLEMENTED()
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 > &)