16 #include <deal.II/base/exceptions.h> 17 #include <deal.II/base/polynomial_space.h> 18 #include <deal.II/base/table.h> 20 DEAL_II_NAMESPACE_OPEN
27 unsigned int n_pols = n;
28 for (
unsigned int i = 1; i < dim; ++i)
46 std::array<unsigned int, 1>
50 return {{index_map[i]}};
56 std::array<unsigned int, 2>
60 const unsigned int n = index_map[i];
65 const unsigned int n_1d = polynomials.size();
67 for (
unsigned int iy = 0; iy < n_1d; ++iy)
68 if (n < k + n_1d - iy)
82 std::array<unsigned int, 3>
86 const unsigned int n = index_map[i];
94 const unsigned int n_1d = polynomials.size();
96 for (
unsigned int iz = 0; iz < n_1d; ++iz)
97 for (
unsigned int iy = 0; iy < n_1d - iz; ++iy)
98 if (n < k + n_1d - iy - iz)
100 return {{n - k, iy, iz}};
114 Assert(renumber.size() == index_map.size(),
117 index_map = renumber;
118 for (
unsigned int i = 0; i < index_map.size(); ++i)
119 index_map_inverse[index_map[i]] = i;
129 const auto ix = compute_index(i);
134 for (
unsigned int d = 0; d < dim; ++d)
135 result *= polynomials[ix[d]].value(p(d));
146 const auto ix = compute_index(i);
149 for (
unsigned int d = 0; d < dim; ++d)
153 std::vector<double> v(2);
154 for (
unsigned int d = 0; d < dim; ++d)
156 polynomials[ix[d]].value(p(d), v);
158 for (
unsigned int d1 = 0; d1 < dim; ++d1)
171 const auto ix = compute_index(i);
174 for (
unsigned int d = 0; d < dim; ++d)
175 for (
unsigned int d1 = 0; d1 < dim; ++d1)
180 std::vector<double> v(3);
181 for (
unsigned int d = 0; d < dim; ++d)
183 polynomials[ix[d]].value(p(d), v);
184 result[d][d] *= v[2];
185 for (
unsigned int d1 = 0; d1 < dim; ++d1)
189 result[d][d1] *= v[1];
190 result[d1][d] *= v[1];
191 for (
unsigned int d2 = 0; d2 < dim; ++d2)
193 result[d1][d2] *= v[0];
205 std::vector<double> & values,
211 const unsigned int n_1d = polynomials.size();
213 Assert(values.size() == n_pols || values.size() == 0,
215 Assert(grads.size() == n_pols || grads.size() == 0,
217 Assert(grad_grads.size() == n_pols || grad_grads.size() == 0,
219 Assert(third_derivatives.size() == n_pols || third_derivatives.size() == 0,
221 Assert(fourth_derivatives.size() == n_pols || fourth_derivatives.size() == 0,
224 unsigned int v_size = 0;
225 bool update_values =
false, update_grads =
false, update_grad_grads =
false;
227 if (values.size() == n_pols)
232 if (grads.size() == n_pols)
237 if (grad_grads.size() == n_pols)
239 update_grad_grads =
true;
242 if (third_derivatives.size() == n_pols)
247 if (fourth_derivatives.size() == n_pols)
249 update_4th_derivatives =
true;
260 for (
unsigned int d = 0; d < v.
size()[0]; ++d)
261 for (
unsigned int i = 0; i < v.
size()[1]; ++i)
263 v(d, i).resize(v_size, 0.);
264 polynomials[i].value(p(d), v(d, i));
271 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
272 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
273 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
274 values[index_map_inverse[k++]] = v[0][ix][0] *
275 ((dim > 1) ? v[1][iy][0] : 1.) *
276 ((dim > 2) ? v[2][iz][0] : 1.);
283 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
284 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
285 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
287 const unsigned int k2 = index_map_inverse[k++];
288 for (
unsigned int d = 0; d < dim; ++d)
289 grads[k2][d] = v[0][ix][(d == 0) ? 1 : 0] *
290 ((dim > 1) ? v[1][iy][(d == 1) ? 1 : 0] : 1.) *
291 ((dim > 2) ? v[2][iz][(d == 2) ? 1 : 0] : 1.);
295 if (update_grad_grads)
299 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
300 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
301 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
303 const unsigned int k2 = index_map_inverse[k++];
304 for (
unsigned int d1 = 0; d1 < dim; ++d1)
305 for (
unsigned int d2 = 0; d2 < dim; ++d2)
310 const unsigned int j0 =
311 ((d1 == 0) ? 1 : 0) + ((d2 == 0) ? 1 : 0);
312 const unsigned int j1 =
313 ((d1 == 1) ? 1 : 0) + ((d2 == 1) ? 1 : 0);
314 const unsigned int j2 =
315 ((d1 == 2) ? 1 : 0) + ((d2 == 2) ? 1 : 0);
317 grad_grads[k2][d1][d2] = v[0][ix][j0] *
318 ((dim > 1) ? v[1][iy][j1] : 1.) *
319 ((dim > 2) ? v[2][iz][j2] : 1.);
328 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
329 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
330 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
332 const unsigned int k2 = index_map_inverse[k++];
333 for (
unsigned int d1 = 0; d1 < dim; ++d1)
334 for (
unsigned int d2 = 0; d2 < dim; ++d2)
335 for (
unsigned int d3 = 0; d3 < dim; ++d3)
340 std::vector<unsigned int> deriv_order(dim, 0);
341 for (
unsigned int x = 0; x < dim; ++x)
351 third_derivatives[k2][d1][d2][d3] =
352 v[0][ix][deriv_order[0]] *
353 ((dim > 1) ? v[1][iy][deriv_order[1]] : 1.) *
354 ((dim > 2) ? v[2][iz][deriv_order[2]] : 1.);
359 if (update_4th_derivatives)
363 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
364 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
365 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
367 const unsigned int k2 = index_map_inverse[k++];
368 for (
unsigned int d1 = 0; d1 < dim; ++d1)
369 for (
unsigned int d2 = 0; d2 < dim; ++d2)
370 for (
unsigned int d3 = 0; d3 < dim; ++d3)
371 for (
unsigned int d4 = 0; d4 < dim; ++d4)
376 std::vector<unsigned int> deriv_order(dim, 0);
377 for (
unsigned int x = 0; x < dim; ++x)
389 fourth_derivatives[k2][d1][d2][d3][d4] =
390 v[0][ix][deriv_order[0]] *
391 ((dim > 1) ? v[1][iy][deriv_order[1]] : 1.) *
392 ((dim > 2) ? v[2][iz][deriv_order[2]] : 1.);
403 DEAL_II_NAMESPACE_CLOSE
static const unsigned int invalid_unsigned_int
static ::ExceptionBase & ExcDimensionMismatch2(int arg1, int arg2, int arg3)
void set_numbering(const std::vector< unsigned int > &renumber)
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
Third derivatives of shape functions.
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
std::array< unsigned int, dim > compute_index(const unsigned int n) const
Tensor< 2, dim > compute_grad_grad(const unsigned int i, const Point< dim > &p) const
double compute_value(const unsigned int i, const Point< dim > &p) const
static unsigned int compute_n_pols(const unsigned int n)
Tensor< 1, dim > compute_grad(const unsigned int i, const Point< dim > &p) const
size_type size(const unsigned int i) 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
static ::ExceptionBase & ExcInternalError()