15#ifndef dealii_tensor_product_polynomials_bubbles_h
16#define dealii_tensor_product_polynomials_bubbles_h
86 const std::vector<unsigned int> &
92 const std::vector<unsigned int> &
109 std::vector<double> &values,
223 virtual std::unique_ptr<ScalarPolynomialsBase<dim>>
224 clone()
const override;
253 const std::vector<Pol> &pols)
257 , index_map(tensor_polys.n() +
258 ((tensor_polys.polynomials.
size() <= 2) ? 1 : dim))
259 , index_map_inverse(tensor_polys.n() +
260 ((tensor_polys.polynomials.
size() <= 2) ? 1 : dim))
262 const unsigned int q_degree =
tensor_polys.polynomials.size() - 1;
263 const unsigned int n_bubbles = ((q_degree <= 1) ? 1 : dim);
265 for (
unsigned int i = 0; i <
tensor_polys.n() + n_bubbles; ++i)
277 return tensor_polys.n() + dim;
290inline const std::vector<unsigned int> &
298inline const std::vector<unsigned int> &
301 return index_map_inverse;
309 return "TensorProductPolynomialsBubbles";
317 const unsigned int i,
320 const unsigned int q_degree = tensor_polys.polynomials.size() - 1;
321 const unsigned int max_q_indices = tensor_polys.n();
322 Assert(i < max_q_indices + ((q_degree <= 1) ? 1 : dim),
326 if (i < max_q_indices)
327 return tensor_polys.template compute_derivative<order>(i, p);
329 [[maybe_unused]]
const unsigned int comp = i - tensor_polys.n();
331 if constexpr (order == 1)
334 for (
unsigned int d = 0;
d < dim; ++
d)
338 for (
unsigned j = 0; j < dim; ++j)
340 (d == j ? 4 * (1 - 2 * p[j]) : 4 * p[j] * (1 - p[j]));
342 for (
unsigned int i = 0; i < q_degree - 1; ++i)
343 derivative[d] *= 2 * p[comp] - 1;
350 for (
unsigned int j = 0; j < dim; ++j)
351 value *= 4 * p[j] * (1 - p[j]);
353 double tmp =
value * 2 * (q_degree - 1);
354 for (
unsigned int i = 0; i < q_degree - 2; ++i)
355 tmp *= 2 * p[comp] - 1;
356 derivative[comp] += tmp;
361 else if constexpr (order == 2)
365 double v[dim + 1][3];
367 for (
unsigned int c = 0; c < dim; ++c)
369 v[c][0] = 4 * p[c] * (1 - p[c]);
370 v[c][1] = 4 * (1 - 2 * p[c]);
375 for (
unsigned int i = 0; i < q_degree - 1; ++i)
376 tmp *= 2 * p[comp] - 1;
381 double tmp = 2 * (q_degree - 1);
382 for (
unsigned int i = 0; i < q_degree - 2; ++i)
383 tmp *= 2 * p[comp] - 1;
391 double tmp = 4 * (q_degree - 2) * (q_degree - 1);
392 for (
unsigned int i = 0; i < q_degree - 3; ++i)
393 tmp *= 2 * p[comp] - 1;
402 for (
unsigned int d1 = 0; d1 < dim; ++d1)
403 for (
unsigned int d2 = 0; d2 < dim; ++d2)
405 grad_grad_1[d1][d2] = v[dim][0];
406 for (
unsigned int x = 0; x < dim; ++x)
408 unsigned int derivative = 0;
409 if (d1 == x || d2 == x)
416 grad_grad_1[d1][d2] *= v[x][derivative];
424 for (
unsigned int d = 0;
d < dim; ++
d)
426 grad_grad_2[
d][comp] = v[dim][1];
427 grad_grad_3[comp][
d] = v[dim][1];
428 for (
unsigned int x = 0; x < dim; ++x)
430 grad_grad_2[
d][comp] *= v[x][
d == x];
431 grad_grad_3[comp][
d] *= v[x][
d == x];
436 double psi_value = 1.;
437 for (
unsigned int x = 0; x < dim; ++x)
438 psi_value *= v[x][0];
440 for (
unsigned int d1 = 0; d1 < dim; ++d1)
441 for (
unsigned int d2 = 0; d2 < dim; ++d2)
443 grad_grad_1[d1][d2] + grad_grad_2[d1][d2] + grad_grad_3[d1][d2];
444 derivative[comp][comp] += psi_value * v[dim][2];
460 const unsigned int i,
463 return compute_derivative<1>(i, p);
471 const unsigned int i,
474 return compute_derivative<2>(i, p);
482 const unsigned int i,
485 return compute_derivative<3>(i, p);
493 const unsigned int i,
496 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 Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
#define DEAL_II_NOT_IMPLEMENTED()
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
static const unsigned int invalid_unsigned_int