17 #include <deal.II/base/polynomials_bernardi_raugel.h> 19 DEAL_II_NAMESPACE_OPEN
25 , n_pols(compute_n_pols(k))
26 , polynomial_space_Q(create_polynomials_Q())
27 , polynomial_space_bubble(create_polynomials_bubble())
32 std::vector<std::vector<Polynomials::Polynomial<double>>>
35 std::vector<std::vector<Polynomials::Polynomial<double>>> pols;
36 std::vector<Polynomials::Polynomial<double>> bubble_shapes;
41 for (
unsigned int d = 0; d < dim; ++d)
42 pols.push_back(bubble_shapes);
54 std::vector<std::vector<Polynomials::Polynomial<double>>>
57 std::vector<std::vector<Polynomials::Polynomial<double>>> pols;
58 std::vector<Polynomials::Polynomial<double>> Q_shapes;
61 for (
unsigned int d = 0; d < dim; ++d)
62 pols.push_back(Q_shapes);
78 Assert(values.size() == n_pols || values.size() == 0,
80 Assert(grads.size() == n_pols || grads.size() == 0,
82 Assert(grad_grads.size() == n_pols || grad_grads.size() == 0,
84 Assert(third_derivatives.size() == n_pols || third_derivatives.size() == 0,
86 Assert(fourth_derivatives.size() == n_pols || fourth_derivatives.size() == 0,
89 std::vector<double> Q_values;
90 std::vector<Tensor<1, dim>> Q_grads;
91 std::vector<Tensor<2, dim>> Q_grad_grads;
92 std::vector<Tensor<3, dim>> Q_third_derivatives;
93 std::vector<Tensor<4, dim>> Q_fourth_derivatives;
94 std::vector<double> bubble_values;
95 std::vector<Tensor<1, dim>> bubble_grads;
96 std::vector<Tensor<2, dim>> bubble_grad_grads;
97 std::vector<Tensor<3, dim>> bubble_third_derivatives;
98 std::vector<Tensor<4, dim>> bubble_fourth_derivatives;
100 constexpr
int n_bubbles =
102 constexpr
int n_q = 1 << dim;
105 Q_values.resize((values.size() == 0) ? 0 : n_q);
106 Q_grads.resize((grads.size() == 0) ? 0 : n_q);
107 Q_grad_grads.resize((grad_grads.size() == 0) ? 0 : n_q);
108 Q_third_derivatives.resize((third_derivatives.size() == 0) ? 0 : n_q);
109 Q_fourth_derivatives.resize((fourth_derivatives.size() == 0) ? 0 : n_q);
110 bubble_values.resize((values.size() == 0) ? 0 : n_bubbles);
111 bubble_grads.resize((grads.size() == 0) ? 0 : n_bubbles);
112 bubble_grad_grads.resize((grad_grads.size() == 0) ? 0 : n_bubbles);
113 bubble_third_derivatives.resize((third_derivatives.size() == 0) ? 0 :
115 bubble_fourth_derivatives.resize(
116 (fourth_derivatives.size() == 0) ? 0 : n_bubbles);
121 std::vector<Tensor<1, dim>> normals;
122 for (
unsigned int i = 0; i < GeometryInfo<dim>::faces_per_cell; ++i)
126 normals.push_back(normal);
130 std::vector<Tensor<1, dim>> units;
131 for (
unsigned int i = 0; i < dim; ++i)
135 units.push_back(unit);
140 std::vector<int> aniso_indices;
143 aniso_indices.push_back(6);
144 aniso_indices.push_back(7);
145 aniso_indices.push_back(2);
146 aniso_indices.push_back(5);
150 aniso_indices.push_back(24);
151 aniso_indices.push_back(25);
152 aniso_indices.push_back(20);
153 aniso_indices.push_back(23);
154 aniso_indices.push_back(8);
155 aniso_indices.push_back(17);
158 polynomial_space_bubble.compute(unit_point,
162 bubble_third_derivatives,
163 bubble_fourth_derivatives);
164 polynomial_space_Q.compute(unit_point,
169 Q_fourth_derivatives);
172 for (
unsigned int i = 0; i < dim * GeometryInfo<dim>::vertices_per_cell; ++i)
174 if (values.size() != 0)
176 values[i] = units[i % dim] * Q_values[i / dim];
178 if (grads.size() != 0)
182 if (grad_grads.size() != 0)
184 grad_grads[i] =
outer_product(units[i % dim], Q_grad_grads[i / dim]);
186 if (third_derivatives.size() != 0)
188 third_derivatives[i] =
191 if (fourth_derivatives.size() != 0)
193 fourth_derivatives[i] =
194 outer_product(units[i % dim], Q_fourth_derivatives[i / dim]);
200 i < dim * GeometryInfo<dim>::vertices_per_cell +
208 if (values.size() != 0)
210 values[i] = normals[j] * bubble_values[aniso_indices[j]];
212 if (grads.size() != 0)
214 grads[i] =
outer_product(normals[j], bubble_grads[aniso_indices[j]]);
216 if (grad_grads.size() != 0)
219 outer_product(normals[j], bubble_grad_grads[aniso_indices[j]]);
221 if (third_derivatives.size() != 0)
223 third_derivatives[i] =
225 bubble_third_derivatives[aniso_indices[j]]);
227 if (fourth_derivatives.size() != 0)
229 fourth_derivatives[i] =
231 bubble_fourth_derivatives[aniso_indices[j]]);
242 if (dim == 2 || dim == 3)
256 DEAL_II_NAMESPACE_CLOSE
static std::vector< std::vector< Polynomials::Polynomial< double > > > create_polynomials_Q()
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
constexpr unsigned int pow(const unsigned int base, const int iexp)
SymmetricTensor< 4, dim, Number > outer_product(const SymmetricTensor< 2, dim, Number > &t1, const SymmetricTensor< 2, dim, Number > &t2)
static std::vector< std::vector< Polynomials::Polynomial< double > > > create_polynomials_bubble()
PolynomialsBernardiRaugel(const unsigned int k)
static unsigned int compute_n_pols(const unsigned int k)
static ::ExceptionBase & ExcNotImplemented()
void compute(const Point< dim > &unit_point, std::vector< Tensor< 1, dim >> &values, std::vector< Tensor< 2, dim >> &grads, std::vector< Tensor< 3, dim >> &grad_grads, std::vector< Tensor< 4, dim >> &third_derivatives, std::vector< Tensor< 5, dim >> &fourth_derivatives) const