38 std::size_t max_degree = 0;
39 for (
const auto &poly : polys)
43 const auto degree_0 = degrees[0];
44 std::size_t degree_d = 0;
45 for (
unsigned int d = 1;
d < dim + 1; ++
d)
46 degree_d =
std::max(degree_d, degrees[
d]);
48 max_degree =
std::max(max_degree, degree_d + degree_0);
60 std::vector<BarycentricPolynomial<dim>> polys;
62 auto M = [](
const unsigned int d) {
68 polys.push_back(0 * M(0) + 1);
72 for (
unsigned int d = 0;
d < dim + 1; ++
d)
73 polys.push_back(M(
d));
78 for (
unsigned int d = 0;
d < dim + 1; ++
d)
79 polys.push_back(M(
d) * (2 * M(
d) - 1));
80 polys.push_back(4 * M(1) * M(0));
83 polys.push_back(4 * M(1) * M(2));
84 polys.push_back(4 * M(2) * M(0));
88 polys.push_back(4 * M(3) * M(0));
89 polys.push_back(4 * M(1) * M(3));
90 polys.push_back(4 * M(2) * M(3));
116 for (std::size_t i = 0; i < polynomials.size(); ++i)
119 for (
unsigned int d = 0;
d < dim; ++
d)
123 for (
unsigned int d0 = 0; d0 < dim; ++d0)
124 for (
unsigned int d1 = 0; d1 < dim; ++d1)
128 for (
unsigned int d0 = 0; d0 < dim; ++d0)
129 for (
unsigned int d1 = 0; d1 < dim; ++d1)
130 for (
unsigned int d2 = 0; d2 < dim; ++d2)
135 for (
unsigned int d0 = 0; d0 < dim; ++d0)
136 for (
unsigned int d1 = 0; d1 < dim; ++d1)
137 for (
unsigned int d2 = 0; d2 < dim; ++d2)
138 for (
unsigned int d3 = 0; d3 < dim; ++d3)
150 std::vector<double> &
values,
158 Assert(grads.size() == this->n() || grads.size() == 0,
160 Assert(grad_grads.size() == this->n() || grad_grads.size() == 0,
162 Assert(third_derivatives.size() == this->n() || third_derivatives.size() == 0,
164 Assert(fourth_derivatives.size() == this->n() ||
165 fourth_derivatives.size() == 0,
168 for (std::size_t i = 0; i < polys.size(); ++i)
170 if (
values.size() == this->n())
171 values[i] = polys[i].value(unit_point);
174 if (grads.size() == this->n())
175 for (
unsigned int d = 0;
d < dim; ++
d)
176 grads[i][
d] = poly_grads[i][
d].value(unit_point);
179 if (grad_grads.size() == this->n())
180 for (
unsigned int d0 = 0; d0 < dim; ++d0)
181 for (
unsigned int d1 = 0; d1 < dim; ++d1)
182 grad_grads[i][d0][d1] = poly_hessians[i][d0][d1].value(unit_point);
185 if (third_derivatives.size() == this->n())
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 third_derivatives[i][d0][d1][d2] =
190 poly_third_derivatives[i][d0][d1][d2].value(unit_point);
193 if (fourth_derivatives.size() == this->n())
194 for (
unsigned int d0 = 0; d0 < dim; ++d0)
195 for (
unsigned int d1 = 0; d1 < dim; ++d1)
196 for (
unsigned int d2 = 0; d2 < dim; ++d2)
197 for (
unsigned int d3 = 0; d3 < dim; ++d3)
198 fourth_derivatives[i][d0][d1][d2][d3] =
199 poly_fourth_derivatives[i][d0][d1][d2][d3].value(unit_point);
211 return polys[i].value(p);
222 for (
unsigned int d = 0;
d < dim; ++
d)
223 result[
d] = poly_grads[i][
d].value(p);
235 for (
unsigned int d0 = 0; d0 < dim; ++d0)
236 for (
unsigned int d1 = 0; d1 < dim; ++d1)
237 result[d0][d1] = poly_hessians[i][d0][d1].value(p);
250 for (
unsigned int d0 = 0; d0 < dim; ++d0)
251 for (
unsigned int d1 = 0; d1 < dim; ++d1)
252 for (
unsigned int d2 = 0; d2 < dim; ++d2)
253 result[d0][d1][d2] = poly_third_derivatives[i][d0][d1][d2].value(p);
266 for (
unsigned int d0 = 0; d0 < dim; ++d0)
267 for (
unsigned int d1 = 0; d1 < dim; ++d1)
268 for (
unsigned int d2 = 0; d2 < dim; ++d2)
269 for (
unsigned int d3 = 0; d3 < dim; ++d3)
270 result[d0][d1][d2][d3] =
271 poly_fourth_derivatives[i][d0][d1][d2][d3].value(p);
283 return compute_1st_derivative(i, p);
293 return compute_2nd_derivative(i, p);
299std::unique_ptr<ScalarPolynomialsBase<dim>>
302 return std::make_unique<BarycentricPolynomials<dim>>(*this);
320 std::size_t poly_memory = 0;
321 for (
const auto &poly : polys)
322 poly_memory += poly.memory_consumption();
324 poly_grads.memory_consumption() + poly_hessians.memory_consumption() +
325 poly_third_derivatives.memory_consumption() +
326 poly_fourth_derivatives.memory_consumption();
static BarycentricPolynomial< dim, Number > monomial(const unsigned int d)
Table< 2, BarycentricPolynomial< dim > > poly_grads
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
std::vector< BarycentricPolynomial< dim > > polys
Tensor< 2, dim > compute_grad_grad(const unsigned int i, const Point< dim > &p) const override
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
Table< 3, BarycentricPolynomial< dim > > poly_hessians
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
Table< 4, BarycentricPolynomial< dim > > poly_third_derivatives
Table< 5, BarycentricPolynomial< dim > > poly_fourth_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
static BarycentricPolynomials< dim > get_fe_p_basis(const unsigned int degree)
virtual std::size_t memory_consumption() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
std::string to_string(const T &t)
static ::ExceptionBase & ExcDimensionMismatch2(int arg1, int arg2, int arg3)
#define AssertIndexRange(index, range)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
unsigned int get_degree(const std::vector< BarycentricPolynomial< dim > > &polys)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)