16 #ifndef dealii_tensor_product_polynomials_h 17 #define dealii_tensor_product_polynomials_h 20 #include <deal.II/base/config.h> 22 #include <deal.II/base/exceptions.h> 23 #include <deal.II/base/point.h> 24 #include <deal.II/base/polynomial.h> 25 #include <deal.II/base/tensor.h> 26 #include <deal.II/base/utilities.h> 30 DEAL_II_NAMESPACE_OPEN
64 template <
int dim,
typename PolynomialType = Polynomials::Polynomial<
double>>
99 const std::vector<unsigned int> &
105 const std::vector<unsigned int> &
122 std::vector<double> & values,
229 unsigned int (&indices)[(dim > 0 ? dim : 1)])
const;
296 std::vector<double> & values,
376 const std::vector<std::vector<Polynomials::Polynomial<double>>>
polynomials;
391 compute_index(
const unsigned int i,
unsigned int (&indices)[dim])
const;
409 template <
int dim,
typename PolynomialType>
412 const std::vector<Pol> &pols)
413 : polynomials(pols.begin(), pols.end())
414 , n_tensor_pols(
Utilities::fixed_power<dim>(pols.size()))
415 , index_map(n_tensor_pols)
416 , index_map_inverse(n_tensor_pols)
423 index_map_inverse[i] = i;
429 template <
int dim,
typename PolynomialType>
436 return n_tensor_pols;
441 template <
int dim,
typename PolynomialType>
442 inline const std::vector<unsigned int> &
449 template <
int dim,
typename PolynomialType>
450 inline const std::vector<unsigned int> &
453 return index_map_inverse;
456 template <
int dim,
typename PolynomialType>
460 const unsigned int i,
463 unsigned int indices[dim];
464 compute_index(i, indices);
468 std::vector<double> tmp(5);
469 for (
unsigned int d = 0;
d < dim; ++
d)
471 polynomials[indices[
d]].value(p(d), tmp);
487 for (
unsigned int d = 0;
d < dim; ++
d)
489 derivative_1[
d] = 1.;
490 for (
unsigned int x = 0; x < dim; ++x)
492 unsigned int x_order = 0;
496 derivative_1[
d] *= v[x][x_order];
506 for (
unsigned int d1 = 0; d1 < dim; ++d1)
507 for (
unsigned int d2 = 0; d2 < dim; ++d2)
509 derivative_2[d1][d2] = 1.;
510 for (
unsigned int x = 0; x < dim; ++x)
512 unsigned int x_order = 0;
518 derivative_2[d1][d2] *= v[x][x_order];
528 for (
unsigned int d1 = 0; d1 < dim; ++d1)
529 for (
unsigned int d2 = 0; d2 < dim; ++d2)
530 for (
unsigned int d3 = 0; d3 < dim; ++d3)
532 derivative_3[d1][d2][d3] = 1.;
533 for (
unsigned int x = 0; x < dim; ++x)
535 unsigned int x_order = 0;
543 derivative_3[d1][d2][d3] *= v[x][x_order];
553 for (
unsigned int d1 = 0; d1 < dim; ++d1)
554 for (
unsigned int d2 = 0; d2 < dim; ++d2)
555 for (
unsigned int d3 = 0; d3 < dim; ++d3)
556 for (
unsigned int d4 = 0; d4 < dim; ++d4)
558 derivative_4[d1][d2][d3][d4] = 1.;
559 for (
unsigned int x = 0; x < dim; ++x)
561 unsigned int x_order = 0;
571 derivative_4[d1][d2][d3][d4] *= v[x][x_order];
591 unsigned int indices[dim];
592 compute_index(i, indices);
594 std::vector<std::vector<double>> v(dim, std::vector<double>(order + 1));
595 for (
unsigned int d = 0;
d < dim; ++
d)
596 polynomials[d][indices[d]].value(p(d), v[d]);
605 for (
unsigned int d = 0;
d < dim; ++
d)
607 derivative_1[
d] = 1.;
608 for (
unsigned int x = 0; x < dim; ++x)
610 unsigned int x_order = 0;
614 derivative_1[
d] *= v[x][x_order];
624 for (
unsigned int d1 = 0; d1 < dim; ++d1)
625 for (
unsigned int d2 = 0; d2 < dim; ++d2)
627 derivative_2[d1][d2] = 1.;
628 for (
unsigned int x = 0; x < dim; ++x)
630 unsigned int x_order = 0;
636 derivative_2[d1][d2] *= v[x][x_order];
646 for (
unsigned int d1 = 0; d1 < dim; ++d1)
647 for (
unsigned int d2 = 0; d2 < dim; ++d2)
648 for (
unsigned int d3 = 0; d3 < dim; ++d3)
650 derivative_3[d1][d2][d3] = 1.;
651 for (
unsigned int x = 0; x < dim; ++x)
653 unsigned int x_order = 0;
661 derivative_3[d1][d2][d3] *= v[x][x_order];
671 for (
unsigned int d1 = 0; d1 < dim; ++d1)
672 for (
unsigned int d2 = 0; d2 < dim; ++d2)
673 for (
unsigned int d3 = 0; d3 < dim; ++d3)
674 for (
unsigned int d4 = 0; d4 < dim; ++d4)
676 derivative_4[d1][d2][d3][d4] = 1.;
677 for (
unsigned int x = 0; x < dim; ++x)
679 unsigned int x_order = 0;
689 derivative_4[d1][d2][d3][d4] *= v[x][x_order];
706 DEAL_II_NAMESPACE_CLOSE
Tensor< 1, dim > compute_grad(const unsigned int i, const Point< dim > &p) const
void compute(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
unsigned int n_tensor_pols
static const unsigned int invalid_unsigned_int
Tensor< 1, dim > compute_grad(const unsigned int i, const Point< dim > &p) const
std::vector< PolynomialType > polynomials
Tensor< order, dim > compute_derivative(const unsigned int i, const Point< dim > &p) const
void output_indices(std::ostream &out) const
void set_numbering(const std::vector< unsigned int > &renumber)
void compute(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
static unsigned int get_n_tensor_pols(const std::vector< std::vector< Polynomials::Polynomial< double >>> &pols)
TensorProductPolynomials(const std::vector< Pol > &pols)
void compute_index(const unsigned int i, unsigned int(&indices)[dim]) const
Tensor< order, dim > compute_derivative(const unsigned int i, const Point< dim > &p) const
#define Assert(cond, exc)
const std::vector< std::vector< Polynomials::Polynomial< double > > > polynomials
std::vector< unsigned int > index_map_inverse
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
const std::vector< unsigned int > & get_numbering() const
static const unsigned int dimension
std::vector< unsigned int > index_map
double compute_value(const unsigned int i, const Point< dim > &p) const
const std::vector< unsigned int > & get_numbering_inverse() const
static ::ExceptionBase & ExcNotImplemented()
AnisotropicPolynomials(const std::vector< std::vector< Polynomials::Polynomial< double >>> &base_polynomials)
const unsigned int n_tensor_pols
Tensor< 2, dim > compute_grad_grad(const unsigned int i, const Point< dim > &p) const
void compute_index(const unsigned int i, unsigned int(&indices)[(dim > 0 ? dim :1)]) const
double compute_value(const unsigned int i, const Point< dim > &p) const
Tensor< 2, dim > compute_grad_grad(const unsigned int i, const Point< dim > &p) const