16 #include <deal.II/base/polynomial_space.h> 17 #include <deal.II/base/exceptions.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)
49 unsigned int (&index)[1])
const 53 const unsigned int n=index_map[i];
63 unsigned int (&index)[2])
const 67 const unsigned int n=index_map[i];
72 const unsigned int n_1d=polynomials.size();
74 for (
unsigned int iy=0; iy<n_1d; ++iy)
91 unsigned int (&index)[3])
const 95 const unsigned int n=index_map[i];
103 const unsigned int n_1d=polynomials.size();
105 for (
unsigned int iz=0; iz<n_1d; ++iz)
106 for (
unsigned int iy=0; iy<n_1d-iz; ++iy)
107 if (n < k+n_1d-iy-iz)
122 const std::vector<unsigned int> &renumber)
124 Assert(renumber.size()==index_map.size(),
128 for (
unsigned int i=0; i<index_map.size(); ++i)
129 index_map_inverse[index_map[i]]=i;
139 unsigned int ix[dim];
145 for (
unsigned int d=0; d<dim; ++d)
146 result *= polynomials[ix[d]].value(p(d));
157 unsigned int ix[dim];
161 for (
unsigned int d=0; d<dim; ++d)
165 std::vector<double> v(2);
166 for (
unsigned int d=0; d<dim; ++d)
168 polynomials[ix[d]].value(p(d), v);
170 for (
unsigned int d1=0; d1<dim; ++d1)
183 unsigned int ix[dim];
187 for (
unsigned int d=0; d<dim; ++d)
188 for (
unsigned int d1=0; d1<dim; ++d1)
193 std::vector<double> v(3);
194 for (
unsigned int d=0; d<dim; ++d)
196 polynomials[ix[d]].value(p(d), v);
197 result[d][d] *= v[2];
198 for (
unsigned int d1=0; d1<dim; ++d1)
202 result[d][d1] *= v[1];
203 result[d1][d] *= v[1];
204 for (
unsigned int d2=0; d2<dim; ++d2)
206 result[d1][d2] *= v[0];
217 std::vector<double> &values,
223 const unsigned int n_1d=polynomials.size();
225 Assert(values.size()==n_pols || values.size()==0,
227 Assert(grads.size()==n_pols|| grads.size()==0,
229 Assert(grad_grads.size()==n_pols|| grad_grads.size()==0,
231 Assert(third_derivatives.size()==n_pols|| third_derivatives.size()==0,
233 Assert(fourth_derivatives.size()==n_pols|| fourth_derivatives.size()==0,
236 unsigned int v_size=0;
237 bool update_values=
false, update_grads=
false, update_grad_grads=
false;
239 if (values.size()==n_pols)
244 if (grads.size()==n_pols)
249 if (grad_grads.size()==n_pols)
251 update_grad_grads=
true;
254 if (third_derivatives.size()==n_pols)
259 if (fourth_derivatives.size()==n_pols)
261 update_4th_derivatives=
true;
272 for (
unsigned int d=0; d<v.
size()[0]; ++d)
273 for (
unsigned int i=0; i<v.
size()[1]; ++i)
275 v(d,i).resize (v_size, 0.);
276 polynomials[i].value(p(d), v(d,i));
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)
286 values[index_map_inverse[k++]] =
288 * ((dim>1) ? v[1][iy][0] : 1.)
289 * ((dim>2) ? v[2][iz][0] : 1.);
296 for (
unsigned int iz=0; iz<((dim>2) ? n_1d : 1); ++iz)
297 for (
unsigned int iy=0; iy<((dim>1) ? n_1d-iz : 1); ++iy)
298 for (
unsigned int ix=0; ix<n_1d-iy-iz; ++ix)
300 const unsigned int k2=index_map_inverse[k++];
301 for (
unsigned int d=0; d<dim; ++d)
302 grads[k2][d] = v[0][ix][(d==0) ? 1 : 0]
303 * ((dim>1) ? v[1][iy][(d==1) ? 1 : 0] : 1.)
304 * ((dim>2) ? v[2][iz][(d==2) ? 1 : 0] : 1.);
308 if (update_grad_grads)
312 for (
unsigned int iz=0; iz<((dim>2) ? n_1d : 1); ++iz)
313 for (
unsigned int iy=0; iy<((dim>1) ? n_1d-iz : 1); ++iy)
314 for (
unsigned int ix=0; ix<n_1d-iy-iz; ++ix)
316 const unsigned int k2=index_map_inverse[k++];
317 for (
unsigned int d1=0; d1<dim; ++d1)
318 for (
unsigned int d2=0; d2<dim; ++d2)
324 j0 = ((d1==0) ? 1 : 0) + ((d2==0) ? 1 : 0);
326 j1 = ((d1==1) ? 1 : 0) + ((d2==1) ? 1 : 0);
328 j2 = ((d1==2) ? 1 : 0) + ((d2==2) ? 1 : 0);
330 grad_grads[k2][d1][d2] =
332 * ((dim>1) ? v[1][iy][j1] : 1.)
333 * ((dim>2) ? v[2][iz][j2] : 1.);
342 for (
unsigned int iz=0; iz<((dim>2) ? n_1d : 1); ++iz)
343 for (
unsigned int iy=0; iy<((dim>1) ? n_1d-iz : 1); ++iy)
344 for (
unsigned int ix=0; ix<n_1d-iy-iz; ++ix)
346 const unsigned int k2=index_map_inverse[k++];
347 for (
unsigned int d1=0; d1<dim; ++d1)
348 for (
unsigned int d2=0; d2<dim; ++d2)
349 for (
unsigned int d3=0; d3<dim; ++d3)
354 std::vector<unsigned int> deriv_order (dim, 0);
355 for (
unsigned int x=0; x<dim; ++x)
357 if (d1==x) ++deriv_order[x];
358 if (d2==x) ++deriv_order[x];
359 if (d3==x) ++deriv_order[x];
362 third_derivatives[k2][d1][d2][d3] =
363 v[0][ix][deriv_order[0]]
364 * ((dim>1) ? v[1][iy][deriv_order[1]] : 1.)
365 * ((dim>2) ? v[2][iz][deriv_order[2]] : 1.);
370 if (update_4th_derivatives)
374 for (
unsigned int iz=0; iz<((dim>2) ? n_1d : 1); ++iz)
375 for (
unsigned int iy=0; iy<((dim>1) ? n_1d-iz : 1); ++iy)
376 for (
unsigned int ix=0; ix<n_1d-iy-iz; ++ix)
378 const unsigned int k2=index_map_inverse[k++];
379 for (
unsigned int d1=0; d1<dim; ++d1)
380 for (
unsigned int d2=0; d2<dim; ++d2)
381 for (
unsigned int d3=0; d3<dim; ++d3)
382 for (
unsigned int d4=0; d4<dim; ++d4)
387 std::vector<unsigned int> deriv_order (dim, 0);
388 for (
unsigned int x=0; x<dim; ++x)
390 if (d1==x) ++deriv_order[x];
391 if (d2==x) ++deriv_order[x];
392 if (d3==x) ++deriv_order[x];
393 if (d4==x) ++deriv_order[x];
396 fourth_derivatives[k2][d1][d2][d3][d4] =
397 v[0][ix][deriv_order[0]]
398 * ((dim>1) ? v[1][iy][deriv_order[1]] : 1.)
399 * ((dim>2) ? v[2][iz][deriv_order[2]] : 1.);
410 DEAL_II_NAMESPACE_CLOSE
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)
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
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
unsigned int size(const unsigned int i) const
void compute_index(const unsigned int n, unsigned int(&index)[dim >0?dim:1]) const