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);
602 for (
unsigned int d = 0;
d < dim; ++
d)
604 derivative_1[
d] = 1.;
605 for (
unsigned int x = 0; x < dim; ++x)
607 unsigned int x_order = 0;
611 derivative_1[
d] *= v[x][x_order];
621 for (
unsigned int d1 = 0; d1 < dim; ++d1)
622 for (
unsigned int d2 = 0; d2 < dim; ++d2)
624 derivative_2[d1][d2] = 1.;
625 for (
unsigned int x = 0; x < dim; ++x)
627 unsigned int x_order = 0;
633 derivative_2[d1][d2] *= v[x][x_order];
643 for (
unsigned int d1 = 0; d1 < dim; ++d1)
644 for (
unsigned int d2 = 0; d2 < dim; ++d2)
645 for (
unsigned int d3 = 0; d3 < dim; ++d3)
647 derivative_3[d1][d2][d3] = 1.;
648 for (
unsigned int x = 0; x < dim; ++x)
650 unsigned int x_order = 0;
658 derivative_3[d1][d2][d3] *= v[x][x_order];
668 for (
unsigned int d1 = 0; d1 < dim; ++d1)
669 for (
unsigned int d2 = 0; d2 < dim; ++d2)
670 for (
unsigned int d3 = 0; d3 < dim; ++d3)
671 for (
unsigned int d4 = 0; d4 < dim; ++d4)
673 derivative_4[d1][d2][d3][d4] = 1.;
674 for (
unsigned int x = 0; x < dim; ++x)
676 unsigned int x_order = 0;
686 derivative_4[d1][d2][d3][d4] *= v[x][x_order];
706 compute_derivative(
const unsigned int,
const Point<0> &)
const
715template <
int dim,
typename PolynomialType>
718 const unsigned int i,
721 return compute_derivative<1>(i, p);
726template <
int dim,
typename PolynomialType>
729 const unsigned int i,
732 return compute_derivative<2>(i, p);
737template <
int dim,
typename PolynomialType>
740 const unsigned int i,
743 return compute_derivative<3>(i, p);
748template <
int dim,
typename PolynomialType>
751 const unsigned int i,
754 return compute_derivative<4>(i, p);
765 std::array<unsigned int, dim> indices;
766 compute_index(i, indices);
768 std::vector<std::vector<double>> v(dim, std::vector<double>(order + 1));
769 for (
unsigned int d = 0;
d < dim; ++
d)
770 polynomials[d][indices[d]].
value(p[d], v[d]);
779 for (
unsigned int d = 0;
d < dim; ++
d)
781 derivative_1[
d] = 1.;
782 for (
unsigned int x = 0; x < dim; ++x)
784 unsigned int x_order = 0;
788 derivative_1[
d] *= v[x][x_order];
798 for (
unsigned int d1 = 0; d1 < dim; ++d1)
799 for (
unsigned int d2 = 0; d2 < dim; ++d2)
801 derivative_2[d1][d2] = 1.;
802 for (
unsigned int x = 0; x < dim; ++x)
804 unsigned int x_order = 0;
810 derivative_2[d1][d2] *= v[x][x_order];
820 for (
unsigned int d1 = 0; d1 < dim; ++d1)
821 for (
unsigned int d2 = 0; d2 < dim; ++d2)
822 for (
unsigned int d3 = 0; d3 < dim; ++d3)
824 derivative_3[d1][d2][d3] = 1.;
825 for (
unsigned int x = 0; x < dim; ++x)
827 unsigned int x_order = 0;
835 derivative_3[d1][d2][d3] *= v[x][x_order];
845 for (
unsigned int d1 = 0; d1 < dim; ++d1)
846 for (
unsigned int d2 = 0; d2 < dim; ++d2)
847 for (
unsigned int d3 = 0; d3 < dim; ++d3)
848 for (
unsigned int d4 = 0; d4 < dim; ++d4)
850 derivative_4[d1][d2][d3][d4] = 1.;
851 for (
unsigned int x = 0; x < dim; ++x)
853 unsigned int x_order = 0;
863 derivative_4[d1][d2][d3][d4] *= v[x][x_order];
897 return compute_derivative<1>(i, p);
907 return compute_derivative<2>(i, p);
917 return compute_derivative<3>(i, p);
927 return compute_derivative<4>(i, p);
936 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)
AnisotropicPolynomials(const std::vector< std::vector< Polynomials::Polynomial< double > > > &base_polynomials)
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