33 std::array<unsigned int, dim> ix;
38 for (
unsigned int d = 0;
d < dim; ++
d)
49 const std::vector<unsigned int> &renumber)
55 for (
unsigned int i = 0; i <
index_map.size(); ++i)
58 std::vector<unsigned int> renumber_base;
60 renumber_base.push_back(renumber[i]);
73 Assert(i < max_q_indices + ((q_degree <= 1) ? 1 : dim),
77 if (i < max_q_indices)
84 for (
unsigned int j = 0; j < dim; ++j)
85 value *= 4 * p(j) * (1 - p(j));
87 for (
unsigned int i = 0; i < q_degree - 1; ++i)
88 value *= 2 * p(comp) - 1;
112 Assert(i < max_q_indices + ((q_degree <= 1) ? 1 : dim),
116 if (i < max_q_indices)
122 for (
unsigned int d = 0;
d < dim; ++
d)
126 for (
unsigned j = 0; j < dim; ++j)
127 grad[
d] *= (
d == j ? 4 * (1 - 2 * p(j)) : 4 * p(j) * (1 - p(j)));
129 for (
unsigned int i = 0; i < q_degree - 1; ++i)
130 grad[
d] *= 2 * p(comp) - 1;
137 for (
unsigned int j = 0; j < dim; ++j)
138 value *= 4 * p(j) * (1 - p(j));
140 double tmp =
value * 2 * (q_degree - 1);
141 for (
unsigned int i = 0; i < q_degree - 2; ++i)
142 tmp *= 2 * p(comp) - 1;
154 const unsigned int i,
159 Assert(i < max_q_indices + ((q_degree <= 1) ? 1 : dim),
163 if (i < max_q_indices)
168 double v[dim + 1][3];
170 for (
unsigned int c = 0; c < dim; ++c)
172 v[c][0] = 4 * p(c) * (1 - p(c));
173 v[c][1] = 4 * (1 - 2 * p(c));
178 for (
unsigned int i = 0; i < q_degree - 1; ++i)
179 tmp *= 2 * p(comp) - 1;
184 double tmp = 2 * (q_degree - 1);
185 for (
unsigned int i = 0; i < q_degree - 2; ++i)
186 tmp *= 2 * p(comp) - 1;
194 double tmp = 4 * (q_degree - 2) * (q_degree - 1);
195 for (
unsigned int i = 0; i < q_degree - 3; ++i)
196 tmp *= 2 * p(comp) - 1;
205 for (
unsigned int d1 = 0; d1 < dim; ++d1)
206 for (
unsigned int d2 = 0; d2 < dim; ++d2)
208 grad_grad_1[d1][d2] = v[dim][0];
209 for (
unsigned int x = 0; x < dim; ++x)
211 unsigned int derivative = 0;
212 if (d1 == x || d2 == x)
219 grad_grad_1[d1][d2] *= v[x][derivative];
227 for (
unsigned int d = 0;
d < dim; ++
d)
229 grad_grad_2[
d][comp] = v[dim][1];
230 grad_grad_3[comp][
d] = v[dim][1];
231 for (
unsigned int x = 0; x < dim; ++x)
233 grad_grad_2[
d][comp] *= v[x][
d == x];
234 grad_grad_3[comp][
d] *= v[x][
d == x];
240 double psi_value = 1.;
241 for (
unsigned int x = 0; x < dim; ++x)
242 psi_value *= v[x][0];
244 for (
unsigned int d1 = 0; d1 < dim; ++d1)
245 for (
unsigned int d2 = 0; d2 < dim; ++d2)
247 grad_grad_1[d1][d2] + grad_grad_2[d1][d2] + grad_grad_3[d1][d2];
248 grad_grad[comp][comp] += psi_value * v[dim][2];
259 std::vector<double> & values,
268 const unsigned int n_bubbles = ((q_degree <= 1) ? 1 : dim);
269 Assert(values.size() == max_q_indices + n_bubbles || values.size() == 0,
271 Assert(grads.size() == max_q_indices + n_bubbles || grads.size() == 0,
274 grad_grads.size() == max_q_indices + n_bubbles || grad_grads.size() == 0,
276 Assert(third_derivatives.size() == max_q_indices + n_bubbles ||
277 third_derivatives.size() == 0,
279 max_q_indices + n_bubbles,
281 Assert(fourth_derivatives.size() == max_q_indices + n_bubbles ||
282 fourth_derivatives.size() == 0,
284 max_q_indices + n_bubbles,
287 bool do_values =
false, do_grads =
false, do_grad_grads =
false;
288 bool do_3rd_derivatives =
false, do_4th_derivatives =
false;
289 if (values.empty() ==
false)
294 if (grads.empty() ==
false)
299 if (grad_grads.empty() ==
false)
302 do_grad_grads =
true;
304 if (third_derivatives.empty() ==
false)
307 do_3rd_derivatives =
true;
309 if (fourth_derivatives.empty() ==
false)
312 do_4th_derivatives =
true;
316 p, values, grads, grad_grads, third_derivatives, fourth_derivatives);
326 if (do_3rd_derivatives)
327 third_derivatives.push_back(compute_derivative<3>(i, p));
328 if (do_4th_derivatives)
329 fourth_derivatives.push_back(compute_derivative<4>(i, p));
336 std::unique_ptr<ScalarPolynomialsBase<dim>>
339 return std_cxx14::make_unique<TensorProductPolynomialsBubbles<dim>>(*this);