15#ifndef dealii_tensor_product_polynomials_h
16#define dealii_tensor_product_polynomials_h
74template <
int dim,
typename PolynomialType = Polynomials::Polynomial<
double>>
109 const std::vector<unsigned int> &
115 const std::vector<unsigned int> &
132 std::vector<double> &values,
238 virtual std::unique_ptr<ScalarPolynomialsBase<dim>>
239 clone()
const override;
251 std::vector<PolynomialType>
278 std::array<unsigned int, dim> &indices)
const;
353 const std::vector<unsigned int> &
359 const std::vector<unsigned int> &
377 std::vector<double> &values,
483 virtual std::unique_ptr<ScalarPolynomialsBase<dim>>
484 clone()
const override;
490 const std::vector<std::vector<Polynomials::Polynomial<double>>>
polynomials;
510 std::array<unsigned int, dim> &indices)
const;
528template <
int dim,
typename PolynomialType>
531 const std::vector<Pol> &pols)
533 , polynomials(pols.begin(), pols.end())
534 , index_map(this->n())
535 , index_map_inverse(this->n())
539 for (
unsigned int i = 0; i < this->
n(); ++i)
547template <
int dim,
typename PolynomialType>
548inline const std::vector<unsigned int> &
555template <
int dim,
typename PolynomialType>
556inline const std::vector<unsigned int> &
559 return index_map_inverse;
563template <
int dim,
typename PolynomialType>
567 return "TensorProductPolynomials";
571template <
int dim,
typename PolynomialType>
575 const unsigned int i,
578 std::array<unsigned int, dim> indices;
579 compute_index(i, indices);
583 std::vector<double> tmp(5);
584 for (
unsigned int d = 0;
d < dim; ++
d)
586 polynomials[indices[
d]].value(p[d], tmp);
595 if constexpr (order == 1)
598 for (
unsigned int d = 0;
d < dim; ++
d)
601 for (
unsigned int x = 0; x < dim; ++x)
603 unsigned int x_order = 0;
607 derivative[
d] *= v[x][x_order];
613 else if constexpr (order == 2)
616 for (
unsigned int d1 = 0; d1 < dim; ++d1)
617 for (
unsigned int d2 = 0; d2 < dim; ++d2)
619 derivative[d1][d2] = 1.;
620 for (
unsigned int x = 0; x < dim; ++x)
622 unsigned int x_order = 0;
628 derivative[d1][d2] *= v[x][x_order];
634 else if constexpr (order == 3)
637 for (
unsigned int d1 = 0; d1 < dim; ++d1)
638 for (
unsigned int d2 = 0; d2 < dim; ++d2)
639 for (
unsigned int d3 = 0; d3 < dim; ++d3)
641 derivative[d1][d2][d3] = 1.;
642 for (
unsigned int x = 0; x < dim; ++x)
644 unsigned int x_order = 0;
652 derivative[d1][d2][d3] *= v[x][x_order];
658 else if constexpr (order == 4)
661 for (
unsigned int d1 = 0; d1 < dim; ++d1)
662 for (
unsigned int d2 = 0; d2 < dim; ++d2)
663 for (
unsigned int d3 = 0; d3 < dim; ++d3)
664 for (
unsigned int d4 = 0; d4 < dim; ++d4)
666 derivative[d1][d2][d3][d4] = 1.;
667 for (
unsigned int x = 0; x < dim; ++x)
669 unsigned int x_order = 0;
679 derivative[d1][d2][d3][d4] *= v[x][x_order];
698 compute_derivative(
const unsigned int,
const Point<0> &)
const
707template <
int dim,
typename PolynomialType>
710 const unsigned int i,
713 return compute_derivative<1>(i, p);
718template <
int dim,
typename PolynomialType>
721 const unsigned int i,
724 return compute_derivative<2>(i, p);
729template <
int dim,
typename PolynomialType>
732 const unsigned int i,
735 return compute_derivative<3>(i, p);
740template <
int dim,
typename PolynomialType>
743 const unsigned int i,
746 return compute_derivative<4>(i, p);
757 std::array<unsigned int, dim> indices;
758 compute_index(i, indices);
760 std::vector<std::vector<double>> v(dim, std::vector<double>(order + 1));
761 for (
unsigned int d = 0;
d < dim; ++
d)
762 polynomials[d][indices[d]].
value(p[d], v[d]);
764 if constexpr (order == 1)
767 for (
unsigned int d = 0;
d < dim; ++
d)
770 for (
unsigned int x = 0; x < dim; ++x)
772 unsigned int x_order = 0;
776 derivative[
d] *= v[x][x_order];
782 else if constexpr (order == 2)
785 for (
unsigned int d1 = 0; d1 < dim; ++d1)
786 for (
unsigned int d2 = 0; d2 < dim; ++d2)
788 derivative[d1][d2] = 1.;
789 for (
unsigned int x = 0; x < dim; ++x)
791 unsigned int x_order = 0;
797 derivative[d1][d2] *= v[x][x_order];
803 else if constexpr (order == 3)
806 for (
unsigned int d1 = 0; d1 < dim; ++d1)
807 for (
unsigned int d2 = 0; d2 < dim; ++d2)
808 for (
unsigned int d3 = 0; d3 < dim; ++d3)
810 derivative[d1][d2][d3] = 1.;
811 for (
unsigned int x = 0; x < dim; ++x)
813 unsigned int x_order = 0;
821 derivative[d1][d2][d3] *= v[x][x_order];
827 else if constexpr (order == 4)
830 for (
unsigned int d1 = 0; d1 < dim; ++d1)
831 for (
unsigned int d2 = 0; d2 < dim; ++d2)
832 for (
unsigned int d3 = 0; d3 < dim; ++d3)
833 for (
unsigned int d4 = 0; d4 < dim; ++d4)
835 derivative[d1][d2][d3][d4] = 1.;
836 for (
unsigned int x = 0; x < dim; ++x)
838 unsigned int x_order = 0;
848 derivative[d1][d2][d3][d4] *= v[x][x_order];
881 return compute_derivative<1>(i, p);
891 return compute_derivative<2>(i, p);
901 return compute_derivative<3>(i, p);
911 return compute_derivative<4>(i, p);
920 return "AnisotropicPolynomials";
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
void set_numbering(const std::vector< unsigned int > &renumber)
const std::vector< std::vector< Polynomials::Polynomial< double > > > polynomials
virtual Tensor< 1, dim > compute_1st_derivative(const unsigned int i, const Point< dim > &p) const override
static unsigned int get_n_tensor_pols(const std::vector< std::vector< Polynomials::Polynomial< double > > > &pols)
std::vector< unsigned int > index_map
virtual Tensor< 3, dim > compute_3rd_derivative(const unsigned int i, const Point< dim > &p) const override
void compute_index(const unsigned int i, std::array< unsigned int, dim > &indices) const
Tensor< 2, dim > compute_grad_grad(const unsigned int i, const Point< dim > &p) const override
virtual Tensor< 2, dim > compute_2nd_derivative(const unsigned int i, const Point< dim > &p) const override
Tensor< order, dim > compute_derivative(const unsigned int i, const Point< dim > &p) const
const std::vector< unsigned int > & get_numbering() const
std::string name() const override
Tensor< 1, dim > compute_grad(const unsigned int i, const Point< dim > &p) const override
std::vector< unsigned int > index_map_inverse
virtual Tensor< 4, dim > compute_4th_derivative(const unsigned int i, const Point< dim > &p) const override
const std::vector< unsigned int > & get_numbering_inverse() const
virtual std::unique_ptr< ScalarPolynomialsBase< dim > > clone() 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
void output_indices(std::ostream &out) const
void compute_index(const unsigned int i, std::array< unsigned int, dim > &indices) const
double compute_value(const unsigned int i, const Point< dim > &p) const override
virtual std::size_t memory_consumption() const override
virtual Tensor< 2, dim > compute_2nd_derivative(const unsigned int i, const Point< dim > &p) const override
const std::vector< unsigned int > & get_numbering() const
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
virtual std::unique_ptr< ScalarPolynomialsBase< dim > > clone() const override
virtual Tensor< 1, dim > compute_1st_derivative(const unsigned int i, const Point< dim > &p) const override
std::vector< unsigned int > index_map
std::vector< unsigned int > index_map_inverse
std::vector< PolynomialType > get_underlying_polynomials() const
virtual Tensor< 3, dim > compute_3rd_derivative(const unsigned int i, const Point< dim > &p) const override
std::vector< PolynomialType > polynomials
void set_numbering(const std::vector< unsigned int > &renumber)
const std::vector< unsigned int > & get_numbering_inverse() const
Tensor< 2, dim > compute_grad_grad(const unsigned int i, const Point< dim > &p) const override
std::string name() const override
static constexpr unsigned int dimension
virtual Tensor< 4, dim > compute_4th_derivative(const unsigned int i, const Point< dim > &p) const override
TensorProductPolynomials(const std::vector< Pol > &pols)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
#define AssertThrow(cond, exc)
#define DEAL_II_NOT_IMPLEMENTED()
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
typename internal::ndarray::HelperArray< T, Ns... >::type ndarray