13#ifndef dealii_tensor_product_polynomials_bubbles_h
14#define dealii_tensor_product_polynomials_bubbles_h
84 const std::vector<unsigned int> &
90 const std::vector<unsigned int> &
107 std::vector<double> &values,
221 virtual std::unique_ptr<ScalarPolynomialsBase<dim>>
222 clone()
const override;
251 const std::vector<Pol> &pols)
255 , index_map(tensor_polys.n() +
256 ((tensor_polys.polynomials.
size() <= 2) ? 1 : dim))
257 , index_map_inverse(tensor_polys.n() +
258 ((tensor_polys.polynomials.
size() <= 2) ? 1 : dim))
260 const unsigned int q_degree =
tensor_polys.polynomials.size() - 1;
261 const unsigned int n_bubbles = ((q_degree <= 1) ? 1 : dim);
263 for (
unsigned int i = 0; i <
tensor_polys.n() + n_bubbles; ++i)
275 return tensor_polys.n() + dim;
288inline const std::vector<unsigned int> &
296inline const std::vector<unsigned int> &
299 return index_map_inverse;
307 return "TensorProductPolynomialsBubbles";
315 const unsigned int i,
318 const unsigned int q_degree = tensor_polys.polynomials.size() - 1;
319 const unsigned int max_q_indices = tensor_polys.n();
320 Assert(i < max_q_indices + ((q_degree <= 1) ? 1 : dim),
324 if (i < max_q_indices)
325 return tensor_polys.template compute_derivative<order>(i, p);
327 [[maybe_unused]]
const unsigned int comp = i - tensor_polys.n();
329 if constexpr (order == 1)
332 for (
unsigned int d = 0;
d < dim; ++
d)
336 for (
unsigned j = 0; j < dim; ++j)
338 (d == j ? 4 * (1 - 2 * p[j]) : 4 * p[j] * (1 - p[j]));
340 for (
unsigned int i = 0; i < q_degree - 1; ++i)
341 derivative[d] *= 2 * p[comp] - 1;
348 for (
unsigned int j = 0; j < dim; ++j)
349 value *= 4 * p[j] * (1 - p[j]);
351 double tmp =
value * 2 * (q_degree - 1);
352 for (
unsigned int i = 0; i < q_degree - 2; ++i)
353 tmp *= 2 * p[comp] - 1;
354 derivative[comp] += tmp;
359 else if constexpr (order == 2)
363 double v[dim + 1][3];
365 for (
unsigned int c = 0; c < dim; ++c)
367 v[c][0] = 4 * p[c] * (1 - p[c]);
368 v[c][1] = 4 * (1 - 2 * p[c]);
373 for (
unsigned int i = 0; i < q_degree - 1; ++i)
374 tmp *= 2 * p[comp] - 1;
379 double tmp = 2 * (q_degree - 1);
380 for (
unsigned int i = 0; i < q_degree - 2; ++i)
381 tmp *= 2 * p[comp] - 1;
389 double tmp = 4 * (q_degree - 2) * (q_degree - 1);
390 for (
unsigned int i = 0; i < q_degree - 3; ++i)
391 tmp *= 2 * p[comp] - 1;
400 for (
unsigned int d1 = 0; d1 < dim; ++d1)
401 for (
unsigned int d2 = 0; d2 < dim; ++d2)
403 grad_grad_1[d1][d2] = v[dim][0];
404 for (
unsigned int x = 0; x < dim; ++x)
406 unsigned int derivative = 0;
407 if (d1 == x || d2 == x)
414 grad_grad_1[d1][d2] *= v[x][derivative];
422 for (
unsigned int d = 0;
d < dim; ++
d)
424 grad_grad_2[
d][comp] = v[dim][1];
425 grad_grad_3[comp][
d] = v[dim][1];
426 for (
unsigned int x = 0; x < dim; ++x)
428 grad_grad_2[
d][comp] *= v[x][
d == x];
429 grad_grad_3[comp][
d] *= v[x][
d == x];
434 double psi_value = 1.;
435 for (
unsigned int x = 0; x < dim; ++x)
436 psi_value *= v[x][0];
438 for (
unsigned int d1 = 0; d1 < dim; ++d1)
439 for (
unsigned int d2 = 0; d2 < dim; ++d2)
441 grad_grad_1[d1][d2] + grad_grad_2[d1][d2] + grad_grad_3[d1][d2];
442 derivative[comp][comp] += psi_value * v[dim][2];
458 const unsigned int i,
461 return compute_derivative<1>(i, p);
469 const unsigned int i,
472 return compute_derivative<2>(i, p);
480 const unsigned int i,
483 return compute_derivative<3>(i, p);
491 const unsigned int i,
494 return compute_derivative<4>(i, p);
const std::vector< unsigned int > & get_numbering_inverse() const
virtual Tensor< 2, dim > compute_2nd_derivative(const unsigned int i, const Point< dim > &p) const override
std::string name() 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
Tensor< 1, dim > compute_grad(const unsigned int i, const Point< dim > &p) const override
Tensor< order, dim > compute_derivative(const unsigned int i, const Point< dim > &p) const
Tensor< 2, dim > compute_grad_grad(const unsigned int i, const Point< dim > &p) const override
std::vector< unsigned int > index_map_inverse
TensorProductPolynomialsBubbles(const std::vector< Pol > &pols)
std::vector< unsigned int > index_map
static constexpr unsigned int dimension
void set_numbering(const std::vector< unsigned int > &renumber)
virtual Tensor< 1, dim > compute_1st_derivative(const unsigned int i, const Point< dim > &p) const override
virtual Tensor< 3, dim > compute_3rd_derivative(const unsigned int i, const Point< dim > &p) const override
TensorProductPolynomials< dim > tensor_polys
const std::vector< unsigned int > & get_numbering() const
virtual Tensor< 4, dim > compute_4th_derivative(const unsigned int i, const Point< dim > &p) const override
void output_indices(std::ostream &out) const
double compute_value(const unsigned int i, const Point< dim > &p) const override
virtual std::unique_ptr< ScalarPolynomialsBase< dim > > clone() const override
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NOT_IMPLEMENTED()
#define Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
constexpr unsigned int invalid_unsigned_int