Reference documentation for deal.II version GIT 35969cdc9b 2023-12-09 01:10:02+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
fe_values_views.cc
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2023 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
17 #include <deal.II/base/numbers.h>
18 
20 
21 #include <deal.II/fe/fe.h>
25 
26 #include <deal.II/lac/vector.h>
27 
29 
30 
31 namespace internal
32 {
33  namespace
34  {
35  template <int dim, int spacedim>
36  inline std::vector<unsigned int>
38  {
39  std::vector<unsigned int> shape_function_to_row_table(
40  fe.n_dofs_per_cell() * fe.n_components(),
42  unsigned int row = 0;
43  for (unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
44  {
45  // loop over all components that are nonzero for this particular
46  // shape function. if a component is zero then we leave the
47  // value in the table unchanged (at the invalid value)
48  // otherwise it is mapped to the next free entry
49  unsigned int nth_nonzero_component = 0;
50  for (unsigned int c = 0; c < fe.n_components(); ++c)
51  if (fe.get_nonzero_components(i)[c] == true)
52  {
53  shape_function_to_row_table[i * fe.n_components() + c] =
54  row + nth_nonzero_component;
55  ++nth_nonzero_component;
56  }
57  row += fe.n_nonzero_components(i);
58  }
59 
60  return shape_function_to_row_table;
61  }
62  } // namespace
63 } // namespace internal
64 
65 
66 
67 namespace FEValuesViews
68 {
69  template <int dim, int spacedim>
71  const unsigned int component)
72  : fe_values(&fe_values)
73  , component(component)
74  , shape_function_data(this->fe_values->fe->n_dofs_per_cell())
75  {
76  const FiniteElement<dim, spacedim> &fe = *this->fe_values->fe;
78 
79  // TODO: we'd like to use the fields with the same name as these
80  // variables from FEValuesBase, but they aren't initialized yet
81  // at the time we get here, so re-create it all
82  const std::vector<unsigned int> shape_function_to_row_table =
84 
85  for (unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
86  {
87  const bool is_primitive = fe.is_primitive() || fe.is_primitive(i);
88 
89  if (is_primitive == true)
90  shape_function_data[i].is_nonzero_shape_function_component =
91  (component == fe.system_to_component_index(i).first);
92  else
93  shape_function_data[i].is_nonzero_shape_function_component =
94  (fe.get_nonzero_components(i)[component] == true);
95 
96  if (shape_function_data[i].is_nonzero_shape_function_component == true)
97  shape_function_data[i].row_index =
98  shape_function_to_row_table[i * fe.n_components() + component];
99  else
101  }
102  }
103 
104 
105 
106  template <int dim, int spacedim>
108  : fe_values(nullptr)
109  , component(numbers::invalid_unsigned_int)
110  {}
111 
112 
113 
114  template <int dim, int spacedim>
116  const unsigned int first_vector_component)
117  : fe_values(&fe_values)
118  , first_vector_component(first_vector_component)
119  , shape_function_data(this->fe_values->fe->n_dofs_per_cell())
120  {
121  const FiniteElement<dim, spacedim> &fe = *this->fe_values->fe;
123 
124  // TODO: we'd like to use the fields with the same name as these
125  // variables from FEValuesBase, but they aren't initialized yet
126  // at the time we get here, so re-create it all
127  const std::vector<unsigned int> shape_function_to_row_table =
129 
130  for (unsigned int d = 0; d < spacedim; ++d)
131  {
132  const unsigned int component = first_vector_component + d;
133 
134  for (unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
135  {
136  const bool is_primitive = fe.is_primitive() || fe.is_primitive(i);
137 
138  if (is_primitive == true)
139  shape_function_data[i].is_nonzero_shape_function_component[d] =
140  (component == fe.system_to_component_index(i).first);
141  else
142  shape_function_data[i].is_nonzero_shape_function_component[d] =
143  (fe.get_nonzero_components(i)[component] == true);
144 
145  if (shape_function_data[i].is_nonzero_shape_function_component[d] ==
146  true)
147  shape_function_data[i].row_index[d] =
148  shape_function_to_row_table[i * fe.n_components() + component];
149  else
150  shape_function_data[i].row_index[d] =
152  }
153  }
154 
155  for (unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
156  {
157  unsigned int n_nonzero_components = 0;
158  for (unsigned int d = 0; d < spacedim; ++d)
159  if (shape_function_data[i].is_nonzero_shape_function_component[d] ==
160  true)
161  ++n_nonzero_components;
162 
163  if (n_nonzero_components == 0)
164  shape_function_data[i].single_nonzero_component = -2;
165  else if (n_nonzero_components > 1)
166  shape_function_data[i].single_nonzero_component = -1;
167  else
168  {
169  for (unsigned int d = 0; d < spacedim; ++d)
170  if (shape_function_data[i]
171  .is_nonzero_shape_function_component[d] == true)
172  {
173  shape_function_data[i].single_nonzero_component =
174  shape_function_data[i].row_index[d];
175  shape_function_data[i].single_nonzero_component_index = d;
176  break;
177  }
178  }
179  }
180  }
181 
182 
183 
184  template <int dim, int spacedim>
186  : fe_values(nullptr)
187  , first_vector_component(numbers::invalid_unsigned_int)
188  {}
189 
190 
191 
192  template <int dim, int spacedim>
194  const FEValuesBase<dim, spacedim> &fe_values,
195  const unsigned int first_tensor_component)
196  : fe_values(&fe_values)
197  , first_tensor_component(first_tensor_component)
198  , shape_function_data(this->fe_values->fe->n_dofs_per_cell())
199  {
200  const FiniteElement<dim, spacedim> &fe = *this->fe_values->fe;
201  Assert(first_tensor_component + (dim * dim + dim) / 2 - 1 <
202  fe.n_components(),
204  first_tensor_component +
206  0,
207  fe.n_components()));
208  // TODO: we'd like to use the fields with the same name as these
209  // variables from FEValuesBase, but they aren't initialized yet
210  // at the time we get here, so re-create it all
211  const std::vector<unsigned int> shape_function_to_row_table =
213 
214  for (unsigned int d = 0;
215  d < ::SymmetricTensor<2, dim>::n_independent_components;
216  ++d)
217  {
218  const unsigned int component = first_tensor_component + d;
219 
220  for (unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
221  {
222  const bool is_primitive = fe.is_primitive() || fe.is_primitive(i);
223 
224  if (is_primitive == true)
225  shape_function_data[i].is_nonzero_shape_function_component[d] =
226  (component == fe.system_to_component_index(i).first);
227  else
228  shape_function_data[i].is_nonzero_shape_function_component[d] =
229  (fe.get_nonzero_components(i)[component] == true);
230 
231  if (shape_function_data[i].is_nonzero_shape_function_component[d] ==
232  true)
233  shape_function_data[i].row_index[d] =
234  shape_function_to_row_table[i * fe.n_components() + component];
235  else
236  shape_function_data[i].row_index[d] =
238  }
239  }
240 
241  for (unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
242  {
243  unsigned int n_nonzero_components = 0;
244  for (unsigned int d = 0;
245  d < ::SymmetricTensor<2, dim>::n_independent_components;
246  ++d)
247  if (shape_function_data[i].is_nonzero_shape_function_component[d] ==
248  true)
249  ++n_nonzero_components;
250 
251  if (n_nonzero_components == 0)
252  shape_function_data[i].single_nonzero_component = -2;
253  else if (n_nonzero_components > 1)
254  shape_function_data[i].single_nonzero_component = -1;
255  else
256  {
257  for (unsigned int d = 0;
258  d < ::SymmetricTensor<2, dim>::n_independent_components;
259  ++d)
260  if (shape_function_data[i]
261  .is_nonzero_shape_function_component[d] == true)
262  {
263  shape_function_data[i].single_nonzero_component =
264  shape_function_data[i].row_index[d];
265  shape_function_data[i].single_nonzero_component_index = d;
266  break;
267  }
268  }
269  }
270  }
271 
272 
273 
274  template <int dim, int spacedim>
276  : fe_values(nullptr)
277  , first_tensor_component(numbers::invalid_unsigned_int)
278  {}
279 
280 
281 
282  template <int dim, int spacedim>
284  const unsigned int first_tensor_component)
285  : fe_values(&fe_values)
286  , first_tensor_component(first_tensor_component)
287  , shape_function_data(this->fe_values->fe->n_dofs_per_cell())
288  {
289  const FiniteElement<dim, spacedim> &fe = *this->fe_values->fe;
290  AssertIndexRange(first_tensor_component + dim * dim - 1, fe.n_components());
291  // TODO: we'd like to use the fields with the same name as these
292  // variables from FEValuesBase, but they aren't initialized yet
293  // at the time we get here, so re-create it all
294  const std::vector<unsigned int> shape_function_to_row_table =
296 
297  for (unsigned int d = 0; d < dim * dim; ++d)
298  {
299  const unsigned int component = first_tensor_component + d;
300 
301  for (unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
302  {
303  const bool is_primitive = fe.is_primitive() || fe.is_primitive(i);
304 
305  if (is_primitive == true)
306  shape_function_data[i].is_nonzero_shape_function_component[d] =
307  (component == fe.system_to_component_index(i).first);
308  else
309  shape_function_data[i].is_nonzero_shape_function_component[d] =
310  (fe.get_nonzero_components(i)[component] == true);
311 
312  if (shape_function_data[i].is_nonzero_shape_function_component[d] ==
313  true)
314  shape_function_data[i].row_index[d] =
315  shape_function_to_row_table[i * fe.n_components() + component];
316  else
317  shape_function_data[i].row_index[d] =
319  }
320  }
321 
322  for (unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
323  {
324  unsigned int n_nonzero_components = 0;
325  for (unsigned int d = 0; d < dim * dim; ++d)
326  if (shape_function_data[i].is_nonzero_shape_function_component[d] ==
327  true)
328  ++n_nonzero_components;
329 
330  if (n_nonzero_components == 0)
331  shape_function_data[i].single_nonzero_component = -2;
332  else if (n_nonzero_components > 1)
333  shape_function_data[i].single_nonzero_component = -1;
334  else
335  {
336  for (unsigned int d = 0; d < dim * dim; ++d)
337  if (shape_function_data[i]
338  .is_nonzero_shape_function_component[d] == true)
339  {
340  shape_function_data[i].single_nonzero_component =
341  shape_function_data[i].row_index[d];
342  shape_function_data[i].single_nonzero_component_index = d;
343  break;
344  }
345  }
346  }
347  }
348 
349 
350 
351  template <int dim, int spacedim>
353  : fe_values(nullptr)
354  , first_tensor_component(numbers::invalid_unsigned_int)
355  {}
356 
357 
358 
359  template <int dim, int spacedim>
360  template <typename Number>
361  void
363  const ReadVector<Number> &fe_function,
364  std::vector<solution_value_type<Number>> &values) const
365  {
366  Assert(fe_values->update_flags & update_values,
368  "update_values")));
369  Assert(fe_values->present_cell.is_initialized(),
371 
372  // get function values of dofs on this cell and call internal worker
373  // function
374  ::Vector<Number> dof_values(fe_values->dofs_per_cell);
375  fe_values->present_cell.get_interpolated_dof_values(fe_function,
376  dof_values);
377  internal::do_function_values<dim, spacedim>(
378  make_const_array_view(dof_values),
379  fe_values->finite_element_output.shape_values,
380  shape_function_data,
381  values);
382  }
383 
384 
385 
386  template <int dim, int spacedim>
387  template <class InputVector>
388  void
390  const InputVector &dof_values,
392  const
393  {
394  Assert(fe_values->update_flags & update_values,
396  "update_values")));
397  Assert(fe_values->present_cell.is_initialized(),
399  AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
400 
401  internal::do_function_values<dim, spacedim>(
402  make_const_array_view(dof_values),
403  fe_values->finite_element_output.shape_values,
404  shape_function_data,
405  values);
406  }
407 
408 
409 
410  template <int dim, int spacedim>
411  template <typename Number>
412  void
414  const ReadVector<Number> &fe_function,
415  std::vector<solution_gradient_type<Number>> &gradients) const
416  {
417  Assert(fe_values->update_flags & update_gradients,
419  "update_gradients")));
420  Assert(fe_values->present_cell.is_initialized(),
422  AssertDimension(fe_function.size(),
423  fe_values->present_cell.n_dofs_for_dof_handler());
424 
425  // get function values of dofs on this cell
426  ::Vector<Number> dof_values(fe_values->dofs_per_cell);
427  fe_values->present_cell.get_interpolated_dof_values(fe_function,
428  dof_values);
429  internal::do_function_derivatives<1, dim, spacedim>(
430  make_const_array_view(dof_values),
431  fe_values->finite_element_output.shape_gradients,
432  shape_function_data,
433  gradients);
434  }
435 
436 
437 
438  template <int dim, int spacedim>
439  template <typename InputVector>
440  void
442  const InputVector &dof_values,
444  &gradients) const
445  {
446  Assert(fe_values->update_flags & update_gradients,
448  "update_gradients")));
449  Assert(fe_values->present_cell.is_initialized(),
451  AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
452 
453  internal::do_function_derivatives<1, dim, spacedim>(
454  make_const_array_view(dof_values),
455  fe_values->finite_element_output.shape_gradients,
456  shape_function_data,
457  gradients);
458  }
459 
460 
461 
462  template <int dim, int spacedim>
463  template <typename Number>
464  void
466  const ReadVector<Number> &fe_function,
467  std::vector<solution_hessian_type<Number>> &hessians) const
468  {
469  Assert(fe_values->update_flags & update_hessians,
471  "update_hessians")));
472  Assert(fe_values->present_cell.is_initialized(),
474  AssertDimension(fe_function.size(),
475  fe_values->present_cell.n_dofs_for_dof_handler());
476 
477  // get function values of dofs on this cell
478  ::Vector<Number> dof_values(fe_values->dofs_per_cell);
479  fe_values->present_cell.get_interpolated_dof_values(fe_function,
480  dof_values);
481  internal::do_function_derivatives<2, dim, spacedim>(
482  make_const_array_view(dof_values),
483  fe_values->finite_element_output.shape_hessians,
484  shape_function_data,
485  hessians);
486  }
487 
488 
489 
490  template <int dim, int spacedim>
491  template <class InputVector>
492  void
494  const InputVector &dof_values,
496  &hessians) const
497  {
498  Assert(fe_values->update_flags & update_hessians,
500  "update_hessians")));
501  Assert(fe_values->present_cell.is_initialized(),
503  AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
504 
505  internal::do_function_derivatives<2, dim, spacedim>(
506  make_const_array_view(dof_values),
507  fe_values->finite_element_output.shape_hessians,
508  shape_function_data,
509  hessians);
510  }
511 
512 
513 
514  template <int dim, int spacedim>
515  template <typename Number>
516  void
518  const ReadVector<Number> &fe_function,
519  std::vector<solution_laplacian_type<Number>> &laplacians) const
520  {
521  Assert(fe_values->update_flags & update_hessians,
523  "update_hessians")));
524  Assert(fe_values->present_cell.is_initialized(),
526  AssertDimension(fe_function.size(),
527  fe_values->present_cell.n_dofs_for_dof_handler());
528 
529  // get function values of dofs on this cell
530  ::Vector<Number> dof_values(fe_values->dofs_per_cell);
531  fe_values->present_cell.get_interpolated_dof_values(fe_function,
532  dof_values);
533  internal::do_function_laplacians<dim, spacedim>(
534  make_const_array_view(dof_values),
535  fe_values->finite_element_output.shape_hessians,
536  shape_function_data,
537  laplacians);
538  }
539 
540 
541 
542  template <int dim, int spacedim>
543  template <class InputVector>
544  void
546  const InputVector &dof_values,
548  &laplacians) const
549  {
550  Assert(fe_values->update_flags & update_hessians,
552  "update_hessians")));
553  Assert(fe_values->present_cell.is_initialized(),
555  AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
556 
557  internal::do_function_laplacians<dim, spacedim>(
558  make_const_array_view(dof_values),
559  fe_values->finite_element_output.shape_hessians,
560  shape_function_data,
561  laplacians);
562  }
563 
564 
565 
566  template <int dim, int spacedim>
567  template <typename Number>
568  void
570  const ReadVector<Number> &fe_function,
571  std::vector<solution_third_derivative_type<Number>> &third_derivatives)
572  const
573  {
574  Assert(fe_values->update_flags & update_3rd_derivatives,
576  "update_3rd_derivatives")));
577  Assert(fe_values->present_cell.is_initialized(),
579  AssertDimension(fe_function.size(),
580  fe_values->present_cell.n_dofs_for_dof_handler());
581 
582  // get function values of dofs on this cell
583  ::Vector<Number> dof_values(fe_values->dofs_per_cell);
584  fe_values->present_cell.get_interpolated_dof_values(fe_function,
585  dof_values);
586  internal::do_function_derivatives<3, dim, spacedim>(
587  make_const_array_view(dof_values),
588  fe_values->finite_element_output.shape_3rd_derivatives,
589  shape_function_data,
590  third_derivatives);
591  }
592 
593 
594 
595  template <int dim, int spacedim>
596  template <class InputVector>
597  void
599  const InputVector &dof_values,
600  std::vector<
602  &third_derivatives) const
603  {
604  Assert(fe_values->update_flags & update_3rd_derivatives,
606  "update_3rd_derivatives")));
607  Assert(fe_values->present_cell.is_initialized(),
609  AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
610 
611  internal::do_function_derivatives<3, dim, spacedim>(
612  make_const_array_view(dof_values),
613  fe_values->finite_element_output.shape_3rd_derivatives,
614  shape_function_data,
615  third_derivatives);
616  }
617 
618 
619 
620  template <int dim, int spacedim>
621  template <typename Number>
622  void
624  const ReadVector<Number> &fe_function,
625  std::vector<solution_value_type<Number>> &values) const
626  {
627  Assert(fe_values->update_flags & update_values,
629  "update_values")));
630  Assert(fe_values->present_cell.is_initialized(),
632 
633  // get function values of dofs on this cell
634  ::Vector<Number> dof_values(fe_values->dofs_per_cell);
635  fe_values->present_cell.get_interpolated_dof_values(fe_function,
636  dof_values);
637  internal::do_function_values<dim, spacedim>(
638  make_const_array_view(dof_values),
639  fe_values->finite_element_output.shape_values,
640  shape_function_data,
641  values);
642  }
643 
644 
645 
646  template <int dim, int spacedim>
647  template <class InputVector>
648  void
650  const InputVector &dof_values,
652  const
653  {
654  Assert(fe_values->update_flags & update_values,
656  "update_values")));
657  Assert(fe_values->present_cell.is_initialized(),
659  AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
660 
661  internal::do_function_values<dim, spacedim>(
662  make_const_array_view(dof_values),
663  fe_values->finite_element_output.shape_values,
664  shape_function_data,
665  values);
666  }
667 
668 
669 
670  template <int dim, int spacedim>
671  template <typename Number>
672  void
674  const ReadVector<Number> &fe_function,
675  std::vector<solution_gradient_type<Number>> &gradients) const
676  {
677  Assert(fe_values->update_flags & update_gradients,
679  "update_gradients")));
680  Assert(fe_values->present_cell.is_initialized(),
682  AssertDimension(fe_function.size(),
683  fe_values->present_cell.n_dofs_for_dof_handler());
684 
685  // get function values of dofs on this cell
686  ::Vector<Number> dof_values(fe_values->dofs_per_cell);
687  fe_values->present_cell.get_interpolated_dof_values(fe_function,
688  dof_values);
689  internal::do_function_derivatives<1, dim, spacedim>(
690  make_const_array_view(dof_values),
691  fe_values->finite_element_output.shape_gradients,
692  shape_function_data,
693  gradients);
694  }
695 
696 
697 
698  template <int dim, int spacedim>
699  template <typename InputVector>
700  void
702  const InputVector &dof_values,
704  &gradients) const
705  {
706  Assert(fe_values->update_flags & update_gradients,
708  "update_gradients")));
709  Assert(fe_values->present_cell.is_initialized(),
711  AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
712 
713  internal::do_function_derivatives<1, dim, spacedim>(
714  make_const_array_view(dof_values),
715  fe_values->finite_element_output.shape_gradients,
716  shape_function_data,
717  gradients);
718  }
719 
720 
721 
722  template <int dim, int spacedim>
723  template <typename Number>
724  void
726  const ReadVector<Number> &fe_function,
727  std::vector<solution_symmetric_gradient_type<Number>> &symmetric_gradients)
728  const
729  {
730  Assert(fe_values->update_flags & update_gradients,
732  "update_gradients")));
733  Assert(fe_values->present_cell.is_initialized(),
735  AssertDimension(fe_function.size(),
736  fe_values->present_cell.n_dofs_for_dof_handler());
737 
738  // get function values of dofs on this cell
739  ::Vector<Number> dof_values(fe_values->dofs_per_cell);
740  fe_values->present_cell.get_interpolated_dof_values(fe_function,
741  dof_values);
742  internal::do_function_symmetric_gradients<dim, spacedim>(
743  make_const_array_view(dof_values),
744  fe_values->finite_element_output.shape_gradients,
745  shape_function_data,
746  symmetric_gradients);
747  }
748 
749 
750 
751  template <int dim, int spacedim>
752  template <class InputVector>
753  void
755  const InputVector &dof_values,
756  std::vector<
758  &symmetric_gradients) const
759  {
760  Assert(fe_values->update_flags & update_gradients,
762  "update_gradients")));
763  Assert(fe_values->present_cell.is_initialized(),
765  AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
766 
767  internal::do_function_symmetric_gradients<dim, spacedim>(
768  make_const_array_view(dof_values),
769  fe_values->finite_element_output.shape_gradients,
770  shape_function_data,
771  symmetric_gradients);
772  }
773 
774 
775 
776  template <int dim, int spacedim>
777  template <typename Number>
778  void
780  const ReadVector<Number> &fe_function,
781  std::vector<solution_divergence_type<Number>> &divergences) const
782  {
783  Assert(fe_values->update_flags & update_gradients,
785  "update_gradients")));
786  Assert(fe_values->present_cell.is_initialized(),
788  AssertDimension(fe_function.size(),
789  fe_values->present_cell.n_dofs_for_dof_handler());
790 
791  // get function values of dofs
792  // on this cell
793  ::Vector<Number> dof_values(fe_values->dofs_per_cell);
794  fe_values->present_cell.get_interpolated_dof_values(fe_function,
795  dof_values);
796  internal::do_function_divergences<dim, spacedim>(
797  make_const_array_view(dof_values),
798  fe_values->finite_element_output.shape_gradients,
799  shape_function_data,
800  divergences);
801  }
802 
803 
804 
805  template <int dim, int spacedim>
806  template <class InputVector>
807  void
809  const InputVector &dof_values,
811  &divergences) const
812  {
813  Assert(fe_values->update_flags & update_gradients,
815  "update_gradients")));
816  Assert(fe_values->present_cell.is_initialized(),
818  AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
819 
820  internal::do_function_divergences<dim, spacedim>(
821  make_const_array_view(dof_values),
822  fe_values->finite_element_output.shape_gradients,
823  shape_function_data,
824  divergences);
825  }
826 
827 
828 
829  template <int dim, int spacedim>
830  template <typename Number>
831  void
833  const ReadVector<Number> &fe_function,
834  std::vector<solution_curl_type<Number>> &curls) const
835  {
836  Assert(fe_values->update_flags & update_gradients,
838  "update_gradients")));
839  Assert(fe_values->present_cell.is_initialized(),
840  ExcMessage("FEValues object is not reinited to any cell"));
841  AssertDimension(fe_function.size(),
842  fe_values->present_cell.n_dofs_for_dof_handler());
843 
844  // get function values of dofs on this cell
845  ::Vector<Number> dof_values(fe_values->dofs_per_cell);
846  fe_values->present_cell.get_interpolated_dof_values(fe_function,
847  dof_values);
848  internal::do_function_curls<dim, spacedim>(
849  make_const_array_view(dof_values),
850  fe_values->finite_element_output.shape_gradients,
851  shape_function_data,
852  curls);
853  }
854 
855 
856 
857  template <int dim, int spacedim>
858  template <class InputVector>
859  void
861  const InputVector &dof_values,
863  const
864  {
865  Assert(fe_values->update_flags & update_gradients,
867  "update_gradients")));
868  Assert(fe_values->present_cell.is_initialized(),
869  ExcMessage("FEValues object is not reinited to any cell"));
870  AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
871 
872  internal::do_function_curls<dim, spacedim>(
873  make_const_array_view(dof_values),
874  fe_values->finite_element_output.shape_gradients,
875  shape_function_data,
876  curls);
877  }
878 
879 
880 
881  template <int dim, int spacedim>
882  template <typename Number>
883  void
885  const ReadVector<Number> &fe_function,
886  std::vector<solution_hessian_type<Number>> &hessians) const
887  {
888  Assert(fe_values->update_flags & update_hessians,
890  "update_hessians")));
891  Assert(fe_values->present_cell.is_initialized(),
893  AssertDimension(fe_function.size(),
894  fe_values->present_cell.n_dofs_for_dof_handler());
895 
896  // get function values of dofs on this cell
897  ::Vector<Number> dof_values(fe_values->dofs_per_cell);
898  fe_values->present_cell.get_interpolated_dof_values(fe_function,
899  dof_values);
900  internal::do_function_derivatives<2, dim, spacedim>(
901  make_const_array_view(dof_values),
902  fe_values->finite_element_output.shape_hessians,
903  shape_function_data,
904  hessians);
905  }
906 
907 
908 
909  template <int dim, int spacedim>
910  template <class InputVector>
911  void
913  const InputVector &dof_values,
915  &hessians) const
916  {
917  Assert(fe_values->update_flags & update_hessians,
919  "update_hessians")));
920  Assert(fe_values->present_cell.is_initialized(),
922  AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
923 
924  internal::do_function_derivatives<2, dim, spacedim>(
925  make_const_array_view(dof_values),
926  fe_values->finite_element_output.shape_hessians,
927  shape_function_data,
928  hessians);
929  }
930 
931 
932 
933  template <int dim, int spacedim>
934  template <typename Number>
935  void
937  const ReadVector<Number> &fe_function,
938  std::vector<solution_value_type<Number>> &laplacians) const
939  {
940  Assert(fe_values->update_flags & update_hessians,
942  "update_hessians")));
943  Assert(laplacians.size() == fe_values->n_quadrature_points,
944  ExcDimensionMismatch(laplacians.size(),
945  fe_values->n_quadrature_points));
946  Assert(fe_values->present_cell.is_initialized(),
948  Assert(
949  fe_function.size() == fe_values->present_cell.n_dofs_for_dof_handler(),
950  ExcDimensionMismatch(fe_function.size(),
951  fe_values->present_cell.n_dofs_for_dof_handler()));
952 
953  // get function values of dofs on this cell
954  ::Vector<Number> dof_values(fe_values->dofs_per_cell);
955  fe_values->present_cell.get_interpolated_dof_values(fe_function,
956  dof_values);
957  internal::do_function_laplacians<dim, spacedim>(
958  make_const_array_view(dof_values),
959  fe_values->finite_element_output.shape_hessians,
960  shape_function_data,
961  laplacians);
962  }
963 
964 
965 
966  template <int dim, int spacedim>
967  template <class InputVector>
968  void
970  const InputVector &dof_values,
972  &laplacians) const
973  {
974  Assert(fe_values->update_flags & update_hessians,
976  "update_hessians")));
977  Assert(laplacians.size() == fe_values->n_quadrature_points,
978  ExcDimensionMismatch(laplacians.size(),
979  fe_values->n_quadrature_points));
980  Assert(fe_values->present_cell.is_initialized(),
982  AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
983 
984  internal::do_function_laplacians<dim, spacedim>(
985  make_const_array_view(dof_values),
986  fe_values->finite_element_output.shape_hessians,
987  shape_function_data,
988  laplacians);
989  }
990 
991 
992 
993  template <int dim, int spacedim>
994  template <typename Number>
995  void
997  const ReadVector<Number> &fe_function,
998  std::vector<solution_third_derivative_type<Number>> &third_derivatives)
999  const
1000  {
1001  Assert(fe_values->update_flags & update_3rd_derivatives,
1003  "update_3rd_derivatives")));
1004  Assert(fe_values->present_cell.is_initialized(),
1006  AssertDimension(fe_function.size(),
1007  fe_values->present_cell.n_dofs_for_dof_handler());
1008 
1009  // get function values of dofs on this cell
1010  ::Vector<Number> dof_values(fe_values->dofs_per_cell);
1011  fe_values->present_cell.get_interpolated_dof_values(fe_function,
1012  dof_values);
1013  internal::do_function_derivatives<3, dim, spacedim>(
1014  make_const_array_view(dof_values),
1015  fe_values->finite_element_output.shape_3rd_derivatives,
1016  shape_function_data,
1017  third_derivatives);
1018  }
1019 
1020 
1021 
1022  template <int dim, int spacedim>
1023  template <class InputVector>
1024  void
1026  const InputVector &dof_values,
1027  std::vector<
1029  &third_derivatives) const
1030  {
1031  Assert(fe_values->update_flags & update_3rd_derivatives,
1033  "update_3rd_derivatives")));
1034  Assert(fe_values->present_cell.is_initialized(),
1036  AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
1037 
1038  internal::do_function_derivatives<3, dim, spacedim>(
1039  make_const_array_view(dof_values),
1040  fe_values->finite_element_output.shape_3rd_derivatives,
1041  shape_function_data,
1042  third_derivatives);
1043  }
1044 
1045 
1046 
1047  template <int dim, int spacedim>
1048  template <typename Number>
1049  void
1051  const ReadVector<Number> &fe_function,
1052  std::vector<solution_value_type<Number>> &values) const
1053  {
1054  Assert(fe_values->update_flags & update_values,
1056  "update_values")));
1057  Assert(fe_values->present_cell.is_initialized(),
1059 
1060  // get function values of dofs on this cell
1061  ::Vector<Number> dof_values(fe_values->dofs_per_cell);
1062  fe_values->present_cell.get_interpolated_dof_values(fe_function,
1063  dof_values);
1064  internal::do_function_values<dim, spacedim>(
1065  make_const_array_view(dof_values),
1066  fe_values->finite_element_output.shape_values,
1067  shape_function_data,
1068  values);
1069  }
1070 
1071 
1072 
1073  template <int dim, int spacedim>
1074  template <class InputVector>
1075  void
1077  const InputVector &dof_values,
1079  const
1080  {
1081  Assert(fe_values->update_flags & update_values,
1083  "update_values")));
1084  Assert(fe_values->present_cell.is_initialized(),
1086  AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
1087 
1088  internal::do_function_values<dim, spacedim>(
1089  make_const_array_view(dof_values),
1090  fe_values->finite_element_output.shape_values,
1091  shape_function_data,
1092  values);
1093  }
1094 
1095 
1096 
1097  template <int dim, int spacedim>
1098  template <typename Number>
1099  void
1101  const ReadVector<Number> &fe_function,
1102  std::vector<solution_divergence_type<Number>> &divergences) const
1103  {
1104  Assert(fe_values->update_flags & update_gradients,
1106  "update_gradients")));
1107  Assert(fe_values->present_cell.is_initialized(),
1109  AssertDimension(fe_function.size(),
1110  fe_values->present_cell.n_dofs_for_dof_handler());
1111 
1112  // get function values of dofs
1113  // on this cell
1114  ::Vector<Number> dof_values(fe_values->dofs_per_cell);
1115  fe_values->present_cell.get_interpolated_dof_values(fe_function,
1116  dof_values);
1117  internal::do_function_divergences<dim, spacedim>(
1118  make_const_array_view(dof_values),
1119  fe_values->finite_element_output.shape_gradients,
1120  shape_function_data,
1121  divergences);
1122  }
1123 
1124 
1125 
1126  template <int dim, int spacedim>
1127  template <class InputVector>
1128  void
1131  const InputVector &dof_values,
1133  &divergences) const
1134  {
1135  Assert(fe_values->update_flags & update_gradients,
1137  "update_gradients")));
1138  Assert(fe_values->present_cell.is_initialized(),
1140  AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
1141 
1142  internal::do_function_divergences<dim, spacedim>(
1143  make_const_array_view(dof_values),
1144  fe_values->finite_element_output.shape_gradients,
1145  shape_function_data,
1146  divergences);
1147  }
1148 
1149 
1150 
1151  template <int dim, int spacedim>
1152  template <typename Number>
1153  void
1155  const ReadVector<Number> &fe_function,
1156  std::vector<solution_value_type<Number>> &values) const
1157  {
1158  Assert(fe_values->update_flags & update_values,
1160  "update_values")));
1161  Assert(fe_values->present_cell.is_initialized(),
1163 
1164  // get function values of dofs on this cell
1165  ::Vector<Number> dof_values(fe_values->dofs_per_cell);
1166  fe_values->present_cell.get_interpolated_dof_values(fe_function,
1167  dof_values);
1168  internal::do_function_values<dim, spacedim>(
1169  make_const_array_view(dof_values),
1170  fe_values->finite_element_output.shape_values,
1171  shape_function_data,
1172  values);
1173  }
1174 
1175 
1176 
1177  template <int dim, int spacedim>
1178  template <class InputVector>
1179  void
1181  const InputVector &dof_values,
1183  const
1184  {
1185  Assert(fe_values->update_flags & update_values,
1187  "update_values")));
1188  Assert(fe_values->present_cell.is_initialized(),
1190  AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
1191 
1192  internal::do_function_values<dim, spacedim>(
1193  make_const_array_view(dof_values),
1194  fe_values->finite_element_output.shape_values,
1195  shape_function_data,
1196  values);
1197  }
1198 
1199 
1200 
1201  template <int dim, int spacedim>
1202  template <typename Number>
1203  void
1205  const ReadVector<Number> &fe_function,
1206  std::vector<solution_divergence_type<Number>> &divergences) const
1207  {
1208  Assert(fe_values->update_flags & update_gradients,
1210  "update_gradients")));
1211  Assert(fe_values->present_cell.is_initialized(),
1213  AssertDimension(fe_function.size(),
1214  fe_values->present_cell.n_dofs_for_dof_handler());
1215 
1216  // get function values of dofs
1217  // on this cell
1218  ::Vector<Number> dof_values(fe_values->dofs_per_cell);
1219  fe_values->present_cell.get_interpolated_dof_values(fe_function,
1220  dof_values);
1221  internal::do_function_divergences<dim, spacedim>(
1222  make_const_array_view(dof_values),
1223  fe_values->finite_element_output.shape_gradients,
1224  shape_function_data,
1225  divergences);
1226  }
1227 
1228 
1229 
1230  template <int dim, int spacedim>
1231  template <class InputVector>
1232  void
1234  const InputVector &dof_values,
1236  &divergences) const
1237  {
1238  Assert(fe_values->update_flags & update_gradients,
1240  "update_gradients")));
1241  Assert(fe_values->present_cell.is_initialized(),
1243  AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
1244 
1245  internal::do_function_divergences<dim, spacedim>(
1246  make_const_array_view(dof_values),
1247  fe_values->finite_element_output.shape_gradients,
1248  shape_function_data,
1249  divergences);
1250  }
1251 
1252 
1253 
1254  template <int dim, int spacedim>
1255  template <typename Number>
1256  void
1258  const ReadVector<Number> &fe_function,
1259  std::vector<solution_gradient_type<Number>> &gradients) const
1260  {
1261  Assert(fe_values->update_flags & update_gradients,
1263  "update_gradients")));
1264  Assert(fe_values->present_cell.is_initialized(),
1266  AssertDimension(fe_function.size(),
1267  fe_values->present_cell.n_dofs_for_dof_handler());
1268 
1269  // get function values of dofs
1270  // on this cell
1271  ::Vector<Number> dof_values(fe_values->dofs_per_cell);
1272  fe_values->present_cell.get_interpolated_dof_values(fe_function,
1273  dof_values);
1274  internal::do_function_gradients<dim, spacedim>(
1275  make_const_array_view(dof_values),
1276  fe_values->finite_element_output.shape_gradients,
1277  shape_function_data,
1278  gradients);
1279  }
1280 
1281 
1282 
1283  template <int dim, int spacedim>
1284  template <class InputVector>
1285  void
1287  const InputVector &dof_values,
1289  &gradients) const
1290  {
1291  Assert(fe_values->update_flags & update_gradients,
1293  "update_gradients")));
1294  Assert(fe_values->present_cell.is_initialized(),
1296  AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
1297 
1298  internal::do_function_gradients<dim, spacedim>(
1299  make_const_array_view(dof_values),
1300  fe_values->finite_element_output.shape_gradients,
1301  shape_function_data,
1302  gradients);
1303  }
1304 } // namespace FEValuesViews
1305 
1306 
1307 namespace internal
1308 {
1309  namespace FEValuesViews
1310  {
1311  template <int dim, int spacedim>
1313  {
1314  const FiniteElement<dim, spacedim> &fe = fe_values.get_fe();
1315 
1316  const unsigned int n_scalars = fe.n_components();
1317  scalars.resize(n_scalars);
1318 
1319  // compute number of vectors that we can fit into this finite element.
1320  // note that this is based on the dimensionality 'dim' of the manifold,
1321  // not 'spacedim' of the output vector
1322  const unsigned int n_vectors =
1325  1 :
1326  0);
1327  vectors.resize(n_vectors);
1328 
1329  // compute number of symmetric tensors in the same way as above
1330  const unsigned int n_symmetric_second_order_tensors =
1331  (fe.n_components() >=
1333  fe.n_components() -
1335  0);
1336  symmetric_second_order_tensors.resize(n_symmetric_second_order_tensors);
1337 
1338  // compute number of symmetric tensors in the same way as above
1339  const unsigned int n_second_order_tensors =
1342  1 :
1343  0);
1344  second_order_tensors.resize(n_second_order_tensors);
1345  }
1346  } // namespace FEValuesViews
1347 } // namespace internal
1348 
1349 /*------------------------------- Explicit Instantiations -------------*/
1350 
1351 #include "fe_values_views.inst"
1352 
auto make_const_array_view(const Container &container) -> decltype(make_array_view(container))
Definition: array_view.h:1700
const SmartPointer< const FiniteElement< dim, spacedim >, FEValuesBase< dim, spacedim > > fe
const FiniteElement< dim, spacedim > & get_fe() const
typename ProductType< Number, hessian_type >::type solution_hessian_type
void get_function_values_from_local_dof_values(const InputVector &dof_values, std::vector< solution_value_type< typename InputVector::value_type >> &values) const
void get_function_gradients_from_local_dof_values(const InputVector &dof_values, std::vector< solution_gradient_type< typename InputVector::value_type >> &gradients) const
std::vector< ShapeFunctionData > shape_function_data
typename ProductType< Number, value_type >::type solution_laplacian_type
void get_function_third_derivatives(const ReadVector< Number > &fe_function, std::vector< solution_third_derivative_type< Number >> &third_derivatives) const
void get_function_gradients(const ReadVector< Number > &fe_function, std::vector< solution_gradient_type< Number >> &gradients) const
typename ProductType< Number, third_derivative_type >::type solution_third_derivative_type
typename ProductType< Number, value_type >::type solution_value_type
typename ProductType< Number, gradient_type >::type solution_gradient_type
void get_function_laplacians(const ReadVector< Number > &fe_function, std::vector< solution_laplacian_type< Number >> &laplacians) const
void get_function_hessians_from_local_dof_values(const InputVector &dof_values, std::vector< solution_hessian_type< typename InputVector::value_type >> &hessians) const
void get_function_values(const ReadVector< Number > &fe_function, std::vector< solution_value_type< Number >> &values) const
void get_function_hessians(const ReadVector< Number > &fe_function, std::vector< solution_hessian_type< Number >> &hessians) const
void get_function_laplacians_from_local_dof_values(const InputVector &dof_values, std::vector< solution_laplacian_type< typename InputVector::value_type >> &laplacians) const
void get_function_third_derivatives_from_local_dof_values(const InputVector &dof_values, std::vector< solution_third_derivative_type< typename InputVector::value_type >> &third_derivatives) const
typename ProductType< Number, value_type >::type solution_value_type
typename ProductType< Number, divergence_type >::type solution_divergence_type
typename ProductType< Number, value_type >::type solution_value_type
typename ProductType< Number, divergence_type >::type solution_divergence_type
typename ProductType< Number, gradient_type >::type solution_gradient_type
typename ProductType< Number, third_derivative_type >::type solution_third_derivative_type
void get_function_symmetric_gradients_from_local_dof_values(const InputVector &dof_values, std::vector< solution_symmetric_gradient_type< typename InputVector::value_type >> &symmetric_gradients) const
typename ProductType< Number, divergence_type >::type solution_divergence_type
unsigned int first_vector_component
typename ProductType< Number, hessian_type >::type solution_hessian_type
void get_function_laplacians_from_local_dof_values(const InputVector &dof_values, std::vector< solution_laplacian_type< typename InputVector::value_type >> &laplacians) const
void get_function_laplacians(const ReadVector< Number > &fe_function, std::vector< solution_laplacian_type< Number >> &laplacians) const
void get_function_third_derivatives(const ReadVector< Number > &fe_function, std::vector< solution_third_derivative_type< Number >> &third_derivatives) const
void get_function_hessians(const ReadVector< Number > &fe_function, std::vector< solution_hessian_type< Number >> &hessians) const
void get_function_curls(const ReadVector< Number > &fe_function, std::vector< solution_curl_type< Number >> &curls) const
typename ProductType< Number, symmetric_gradient_type >::type solution_symmetric_gradient_type
void get_function_divergences(const ReadVector< Number > &fe_function, std::vector< solution_divergence_type< Number >> &divergences) const
typename ProductType< Number, gradient_type >::type solution_gradient_type
typename ProductType< Number, value_type >::type solution_value_type
void get_function_hessians_from_local_dof_values(const InputVector &dof_values, std::vector< solution_hessian_type< typename InputVector::value_type >> &hessians) const
void get_function_gradients_from_local_dof_values(const InputVector &dof_values, std::vector< solution_gradient_type< typename InputVector::value_type >> &gradients) const
void get_function_values_from_local_dof_values(const InputVector &dof_values, std::vector< solution_value_type< typename InputVector::value_type >> &values) const
void get_function_third_derivatives_from_local_dof_values(const InputVector &dof_values, std::vector< solution_third_derivative_type< typename InputVector::value_type >> &third_derivatives) const
void get_function_values(const ReadVector< Number > &fe_function, std::vector< solution_value_type< Number >> &values) const
typename ProductType< Number, curl_type >::type solution_curl_type
std::vector< ShapeFunctionData > shape_function_data
typename ProductType< Number, value_type >::type solution_laplacian_type
void get_function_curls_from_local_dof_values(const InputVector &dof_values, std::vector< solution_curl_type< typename InputVector::value_type >> &curls) const
void get_function_gradients(const ReadVector< Number > &fe_function, std::vector< solution_gradient_type< Number >> &gradients) const
void get_function_divergences_from_local_dof_values(const InputVector &dof_values, std::vector< solution_divergence_type< typename InputVector::value_type >> &divergences) const
void get_function_symmetric_gradients(const ReadVector< Number > &fe_function, std::vector< solution_symmetric_gradient_type< Number >> &symmetric_gradients) const
unsigned int n_dofs_per_cell() const
unsigned int n_components() const
std::pair< unsigned int, unsigned int > system_to_component_index(const unsigned int index) const
const ComponentMask & get_nonzero_components(const unsigned int i) const
bool is_primitive() const
unsigned int n_nonzero_components(const unsigned int i) const
virtual size_type size() const =0
constexpr DEAL_II_HOST SymmetricTensor()=default
Definition: tensor.h:516
friend class Tensor
Definition: tensor.h:907
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:477
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:478
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
#define Assert(cond, exc)
Definition: exceptions.h:1631
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1820
#define AssertIndexRange(index, range)
Definition: exceptions.h:1888
static ::ExceptionBase & ExcIndexRange(std::size_t arg1, std::size_t arg2, std::size_t arg3)
static ::ExceptionBase & ExcMessage(std::string arg1)
@ update_hessians
Second derivatives of shape functions.
@ update_values
Shape function values.
@ update_3rd_derivatives
Third derivatives of shape functions.
@ update_gradients
Shape function gradients.
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
std::vector< unsigned int > make_shape_function_to_row_table(const FiniteElement< dim, spacedim > &fe)
Definition: fe_values.cc:50
static const unsigned int invalid_unsigned_int
Definition: types.h:221
Cache(const FEValuesBase< dim, spacedim > &fe_values)