Reference documentation for deal.II version 9.6.0
\(\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\}}\)
Loading...
Searching...
No Matches
fe_values_views.cc
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 1998 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
17
19
20#include <deal.II/fe/fe.h>
24
25#include <deal.II/lac/vector.h>
26
28
29
30namespace internal
31{
32 namespace
33 {
34 template <int dim, int spacedim>
35 inline std::vector<unsigned int>
37 {
38 std::vector<unsigned int> shape_function_to_row_table(
39 fe.n_dofs_per_cell() * fe.n_components(),
41 unsigned int row = 0;
42 for (unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
43 {
44 // loop over all components that are nonzero for this particular
45 // shape function. if a component is zero then we leave the
46 // value in the table unchanged (at the invalid value)
47 // otherwise it is mapped to the next free entry
48 unsigned int nth_nonzero_component = 0;
49 for (unsigned int c = 0; c < fe.n_components(); ++c)
50 if (fe.get_nonzero_components(i)[c] == true)
51 {
52 shape_function_to_row_table[i * fe.n_components() + c] =
53 row + nth_nonzero_component;
54 ++nth_nonzero_component;
55 }
56 row += fe.n_nonzero_components(i);
57 }
58
59 return shape_function_to_row_table;
60 }
61 } // namespace
62} // namespace internal
63
64
65
66namespace FEValuesViews
67{
68 template <int dim, int spacedim>
70 const unsigned int component)
71 : fe_values(&fe_values)
72 , component(component)
73 , shape_function_data(this->fe_values->fe->n_dofs_per_cell())
74 {
75 const FiniteElement<dim, spacedim> &fe = *this->fe_values->fe;
77
78 // TODO: we'd like to use the fields with the same name as these
79 // variables from FEValuesBase, but they aren't initialized yet
80 // at the time we get here, so re-create it all
81 const std::vector<unsigned int> shape_function_to_row_table =
83
84 for (unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
85 {
86 const bool is_primitive = fe.is_primitive() || fe.is_primitive(i);
87
88 if (is_primitive == true)
89 shape_function_data[i].is_nonzero_shape_function_component =
90 (component == fe.system_to_component_index(i).first);
91 else
92 shape_function_data[i].is_nonzero_shape_function_component =
93 (fe.get_nonzero_components(i)[component] == true);
94
95 if (shape_function_data[i].is_nonzero_shape_function_component == true)
96 shape_function_data[i].row_index =
97 shape_function_to_row_table[i * fe.n_components() + component];
98 else
100 }
101 }
102
103
104
105 template <int dim, int spacedim>
107 : fe_values(nullptr)
108 , component(numbers::invalid_unsigned_int)
109 {}
110
111
112
113 template <int dim, int spacedim>
115 const unsigned int first_vector_component)
116 : fe_values(&fe_values)
117 , first_vector_component(first_vector_component)
118 , shape_function_data(this->fe_values->fe->n_dofs_per_cell())
119 {
120 const FiniteElement<dim, spacedim> &fe = *this->fe_values->fe;
122
123 // TODO: we'd like to use the fields with the same name as these
124 // variables from FEValuesBase, but they aren't initialized yet
125 // at the time we get here, so re-create it all
126 const std::vector<unsigned int> shape_function_to_row_table =
128
129 for (unsigned int d = 0; d < spacedim; ++d)
130 {
131 const unsigned int component = first_vector_component + d;
132
133 for (unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
134 {
135 const bool is_primitive = fe.is_primitive() || fe.is_primitive(i);
136
137 if (is_primitive == true)
138 shape_function_data[i].is_nonzero_shape_function_component[d] =
139 (component == fe.system_to_component_index(i).first);
140 else
141 shape_function_data[i].is_nonzero_shape_function_component[d] =
142 (fe.get_nonzero_components(i)[component] == true);
143
144 if (shape_function_data[i].is_nonzero_shape_function_component[d] ==
145 true)
146 shape_function_data[i].row_index[d] =
147 shape_function_to_row_table[i * fe.n_components() + component];
148 else
149 shape_function_data[i].row_index[d] =
151 }
152 }
153
154 for (unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
155 {
156 unsigned int n_nonzero_components = 0;
157 for (unsigned int d = 0; d < spacedim; ++d)
158 if (shape_function_data[i].is_nonzero_shape_function_component[d] ==
159 true)
160 ++n_nonzero_components;
161
162 if (n_nonzero_components == 0)
163 shape_function_data[i].single_nonzero_component = -2;
164 else if (n_nonzero_components > 1)
165 shape_function_data[i].single_nonzero_component = -1;
166 else
167 {
168 for (unsigned int d = 0; d < spacedim; ++d)
170 .is_nonzero_shape_function_component[d] == true)
171 {
172 shape_function_data[i].single_nonzero_component =
173 shape_function_data[i].row_index[d];
174 shape_function_data[i].single_nonzero_component_index = d;
175 break;
176 }
177 }
178 }
179 }
180
181
182
183 template <int dim, int spacedim>
185 : fe_values(nullptr)
186 , first_vector_component(numbers::invalid_unsigned_int)
187 {}
188
189
190
191 template <int dim, int spacedim>
193 const FEValuesBase<dim, spacedim> &fe_values,
194 const unsigned int first_tensor_component)
195 : fe_values(&fe_values)
196 , first_tensor_component(first_tensor_component)
197 , shape_function_data(this->fe_values->fe->n_dofs_per_cell())
198 {
199 const FiniteElement<dim, spacedim> &fe = *this->fe_values->fe;
200 Assert(first_tensor_component + (dim * dim + dim) / 2 - 1 <
201 fe.n_components(),
203 first_tensor_component +
205 0,
206 fe.n_components()));
207 // TODO: we'd like to use the fields with the same name as these
208 // variables from FEValuesBase, but they aren't initialized yet
209 // at the time we get here, so re-create it all
210 const std::vector<unsigned int> shape_function_to_row_table =
212
213 for (unsigned int d = 0;
214 d < ::SymmetricTensor<2, dim>::n_independent_components;
215 ++d)
216 {
217 const unsigned int component = first_tensor_component + d;
218
219 for (unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
220 {
221 const bool is_primitive = fe.is_primitive() || fe.is_primitive(i);
222
223 if (is_primitive == true)
224 shape_function_data[i].is_nonzero_shape_function_component[d] =
225 (component == fe.system_to_component_index(i).first);
226 else
227 shape_function_data[i].is_nonzero_shape_function_component[d] =
228 (fe.get_nonzero_components(i)[component] == true);
229
230 if (shape_function_data[i].is_nonzero_shape_function_component[d] ==
231 true)
232 shape_function_data[i].row_index[d] =
233 shape_function_to_row_table[i * fe.n_components() + component];
234 else
235 shape_function_data[i].row_index[d] =
237 }
238 }
239
240 for (unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
241 {
242 unsigned int n_nonzero_components = 0;
243 for (unsigned int d = 0;
244 d < ::SymmetricTensor<2, dim>::n_independent_components;
245 ++d)
246 if (shape_function_data[i].is_nonzero_shape_function_component[d] ==
247 true)
248 ++n_nonzero_components;
249
250 if (n_nonzero_components == 0)
251 shape_function_data[i].single_nonzero_component = -2;
252 else if (n_nonzero_components > 1)
253 shape_function_data[i].single_nonzero_component = -1;
254 else
255 {
256 for (unsigned int d = 0;
257 d < ::SymmetricTensor<2, dim>::n_independent_components;
258 ++d)
259 if (shape_function_data[i]
260 .is_nonzero_shape_function_component[d] == true)
261 {
262 shape_function_data[i].single_nonzero_component =
263 shape_function_data[i].row_index[d];
264 shape_function_data[i].single_nonzero_component_index = d;
265 break;
266 }
267 }
268 }
269 }
270
271
272
273 template <int dim, int spacedim>
275 : fe_values(nullptr)
276 , first_tensor_component(numbers::invalid_unsigned_int)
277 {}
278
279
280
281 template <int dim, int spacedim>
283 const unsigned int first_tensor_component)
284 : fe_values(&fe_values)
285 , first_tensor_component(first_tensor_component)
286 , shape_function_data(this->fe_values->fe->n_dofs_per_cell())
287 {
288 const FiniteElement<dim, spacedim> &fe = *this->fe_values->fe;
289 AssertIndexRange(first_tensor_component + dim * dim - 1, fe.n_components());
290 // TODO: we'd like to use the fields with the same name as these
291 // variables from FEValuesBase, but they aren't initialized yet
292 // at the time we get here, so re-create it all
293 const std::vector<unsigned int> shape_function_to_row_table =
295
296 for (unsigned int d = 0; d < dim * dim; ++d)
297 {
298 const unsigned int component = first_tensor_component + d;
299
300 for (unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
301 {
302 const bool is_primitive = fe.is_primitive() || fe.is_primitive(i);
303
304 if (is_primitive == true)
305 shape_function_data[i].is_nonzero_shape_function_component[d] =
306 (component == fe.system_to_component_index(i).first);
307 else
308 shape_function_data[i].is_nonzero_shape_function_component[d] =
309 (fe.get_nonzero_components(i)[component] == true);
310
311 if (shape_function_data[i].is_nonzero_shape_function_component[d] ==
312 true)
313 shape_function_data[i].row_index[d] =
314 shape_function_to_row_table[i * fe.n_components() + component];
315 else
316 shape_function_data[i].row_index[d] =
318 }
319 }
320
321 for (unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
322 {
323 unsigned int n_nonzero_components = 0;
324 for (unsigned int d = 0; d < dim * dim; ++d)
325 if (shape_function_data[i].is_nonzero_shape_function_component[d] ==
326 true)
327 ++n_nonzero_components;
328
329 if (n_nonzero_components == 0)
330 shape_function_data[i].single_nonzero_component = -2;
331 else if (n_nonzero_components > 1)
332 shape_function_data[i].single_nonzero_component = -1;
333 else
334 {
335 for (unsigned int d = 0; d < dim * dim; ++d)
336 if (shape_function_data[i]
337 .is_nonzero_shape_function_component[d] == true)
338 {
339 shape_function_data[i].single_nonzero_component =
340 shape_function_data[i].row_index[d];
341 shape_function_data[i].single_nonzero_component_index = d;
342 break;
343 }
344 }
345 }
346 }
347
348
349
350 template <int dim, int spacedim>
352 : fe_values(nullptr)
353 , first_tensor_component(numbers::invalid_unsigned_int)
354 {}
355
356
357
358 template <int dim, int spacedim>
359 template <typename Number>
360 void
362 const ReadVector<Number> &fe_function,
363 std::vector<solution_value_type<Number>> &values) const
364 {
365 Assert(fe_values->update_flags & update_values,
367 "update_values")));
368 Assert(fe_values->present_cell.is_initialized(),
370
371 // get function values of dofs on this cell and call internal worker
372 // function
373 ::Vector<Number> dof_values(fe_values->dofs_per_cell);
374 fe_values->present_cell.get_interpolated_dof_values(fe_function,
375 dof_values);
377 make_const_array_view(dof_values),
378 fe_values->finite_element_output.shape_values,
379 shape_function_data,
380 values);
381 }
382
383
384
385 template <int dim, int spacedim>
386 template <class InputVector>
387 void
389 const InputVector &dof_values,
391 const
392 {
393 Assert(fe_values->update_flags & update_values,
395 "update_values")));
396 Assert(fe_values->present_cell.is_initialized(),
398 AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
399
401 make_const_array_view(dof_values),
402 fe_values->finite_element_output.shape_values,
403 shape_function_data,
404 values);
405 }
406
407
408
409 template <int dim, int spacedim>
410 template <typename Number>
411 void
413 const ReadVector<Number> &fe_function,
414 std::vector<solution_gradient_type<Number>> &gradients) const
415 {
416 Assert(fe_values->update_flags & update_gradients,
418 "update_gradients")));
419 Assert(fe_values->present_cell.is_initialized(),
421 AssertDimension(fe_function.size(),
422 fe_values->present_cell.n_dofs_for_dof_handler());
423
424 // get function values of dofs on this cell
425 ::Vector<Number> dof_values(fe_values->dofs_per_cell);
426 fe_values->present_cell.get_interpolated_dof_values(fe_function,
427 dof_values);
429 make_const_array_view(dof_values),
430 fe_values->finite_element_output.shape_gradients,
431 shape_function_data,
432 gradients);
433 }
434
435
436
437 template <int dim, int spacedim>
438 template <typename InputVector>
439 void
441 const InputVector &dof_values,
443 &gradients) const
444 {
445 Assert(fe_values->update_flags & update_gradients,
447 "update_gradients")));
448 Assert(fe_values->present_cell.is_initialized(),
450 AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
451
453 make_const_array_view(dof_values),
454 fe_values->finite_element_output.shape_gradients,
455 shape_function_data,
456 gradients);
457 }
458
459
460
461 template <int dim, int spacedim>
462 template <typename Number>
463 void
465 const ReadVector<Number> &fe_function,
466 std::vector<solution_hessian_type<Number>> &hessians) const
467 {
468 Assert(fe_values->update_flags & update_hessians,
470 "update_hessians")));
471 Assert(fe_values->present_cell.is_initialized(),
473 AssertDimension(fe_function.size(),
474 fe_values->present_cell.n_dofs_for_dof_handler());
475
476 // get function values of dofs on this cell
477 ::Vector<Number> dof_values(fe_values->dofs_per_cell);
478 fe_values->present_cell.get_interpolated_dof_values(fe_function,
479 dof_values);
481 make_const_array_view(dof_values),
482 fe_values->finite_element_output.shape_hessians,
483 shape_function_data,
484 hessians);
485 }
486
487
488
489 template <int dim, int spacedim>
490 template <class InputVector>
491 void
493 const InputVector &dof_values,
495 &hessians) const
496 {
497 Assert(fe_values->update_flags & update_hessians,
499 "update_hessians")));
500 Assert(fe_values->present_cell.is_initialized(),
502 AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
503
505 make_const_array_view(dof_values),
506 fe_values->finite_element_output.shape_hessians,
507 shape_function_data,
508 hessians);
509 }
510
511
512
513 template <int dim, int spacedim>
514 template <typename Number>
515 void
517 const ReadVector<Number> &fe_function,
518 std::vector<solution_laplacian_type<Number>> &laplacians) const
519 {
520 Assert(fe_values->update_flags & update_hessians,
522 "update_hessians")));
523 Assert(fe_values->present_cell.is_initialized(),
525 AssertDimension(fe_function.size(),
526 fe_values->present_cell.n_dofs_for_dof_handler());
527
528 // get function values of dofs on this cell
529 ::Vector<Number> dof_values(fe_values->dofs_per_cell);
530 fe_values->present_cell.get_interpolated_dof_values(fe_function,
531 dof_values);
533 make_const_array_view(dof_values),
534 fe_values->finite_element_output.shape_hessians,
535 shape_function_data,
536 laplacians);
537 }
538
539
540
541 template <int dim, int spacedim>
542 template <class InputVector>
543 void
545 const InputVector &dof_values,
547 &laplacians) const
548 {
549 Assert(fe_values->update_flags & update_hessians,
551 "update_hessians")));
552 Assert(fe_values->present_cell.is_initialized(),
554 AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
555
557 make_const_array_view(dof_values),
558 fe_values->finite_element_output.shape_hessians,
559 shape_function_data,
560 laplacians);
561 }
562
563
564
565 template <int dim, int spacedim>
566 template <typename Number>
567 void
569 const ReadVector<Number> &fe_function,
570 std::vector<solution_third_derivative_type<Number>> &third_derivatives)
571 const
572 {
573 Assert(fe_values->update_flags & update_3rd_derivatives,
575 "update_3rd_derivatives")));
576 Assert(fe_values->present_cell.is_initialized(),
578 AssertDimension(fe_function.size(),
579 fe_values->present_cell.n_dofs_for_dof_handler());
580
581 // get function values of dofs on this cell
582 ::Vector<Number> dof_values(fe_values->dofs_per_cell);
583 fe_values->present_cell.get_interpolated_dof_values(fe_function,
584 dof_values);
586 make_const_array_view(dof_values),
587 fe_values->finite_element_output.shape_3rd_derivatives,
588 shape_function_data,
589 third_derivatives);
590 }
591
592
593
594 template <int dim, int spacedim>
595 template <class InputVector>
596 void
598 const InputVector &dof_values,
599 std::vector<
601 &third_derivatives) const
602 {
603 Assert(fe_values->update_flags & update_3rd_derivatives,
605 "update_3rd_derivatives")));
606 Assert(fe_values->present_cell.is_initialized(),
608 AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
609
611 make_const_array_view(dof_values),
612 fe_values->finite_element_output.shape_3rd_derivatives,
613 shape_function_data,
614 third_derivatives);
615 }
616
617
618
619 template <int dim, int spacedim>
620 template <typename Number>
621 void
623 const ReadVector<Number> &fe_function,
624 std::vector<solution_value_type<Number>> &values) const
625 {
626 Assert(fe_values->update_flags & update_values,
628 "update_values")));
629 Assert(fe_values->present_cell.is_initialized(),
631
632 // get function values of dofs on this cell
633 ::Vector<Number> dof_values(fe_values->dofs_per_cell);
634 fe_values->present_cell.get_interpolated_dof_values(fe_function,
635 dof_values);
637 make_const_array_view(dof_values),
638 fe_values->finite_element_output.shape_values,
639 shape_function_data,
640 values);
641 }
642
643
644
645 template <int dim, int spacedim>
646 template <class InputVector>
647 void
649 const InputVector &dof_values,
651 const
652 {
653 Assert(fe_values->update_flags & update_values,
655 "update_values")));
656 Assert(fe_values->present_cell.is_initialized(),
658 AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
659
661 make_const_array_view(dof_values),
662 fe_values->finite_element_output.shape_values,
663 shape_function_data,
664 values);
665 }
666
667
668
669 template <int dim, int spacedim>
670 template <typename Number>
671 void
673 const ReadVector<Number> &fe_function,
674 std::vector<solution_gradient_type<Number>> &gradients) const
675 {
676 Assert(fe_values->update_flags & update_gradients,
678 "update_gradients")));
679 Assert(fe_values->present_cell.is_initialized(),
681 AssertDimension(fe_function.size(),
682 fe_values->present_cell.n_dofs_for_dof_handler());
683
684 // get function values of dofs on this cell
685 ::Vector<Number> dof_values(fe_values->dofs_per_cell);
686 fe_values->present_cell.get_interpolated_dof_values(fe_function,
687 dof_values);
689 make_const_array_view(dof_values),
690 fe_values->finite_element_output.shape_gradients,
691 shape_function_data,
692 gradients);
693 }
694
695
696
697 template <int dim, int spacedim>
698 template <typename InputVector>
699 void
701 const InputVector &dof_values,
703 &gradients) const
704 {
705 Assert(fe_values->update_flags & update_gradients,
707 "update_gradients")));
708 Assert(fe_values->present_cell.is_initialized(),
710 AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
711
713 make_const_array_view(dof_values),
714 fe_values->finite_element_output.shape_gradients,
715 shape_function_data,
716 gradients);
717 }
718
719
720
721 template <int dim, int spacedim>
722 template <typename Number>
723 void
725 const ReadVector<Number> &fe_function,
726 std::vector<solution_symmetric_gradient_type<Number>> &symmetric_gradients)
727 const
728 {
729 Assert(fe_values->update_flags & update_gradients,
731 "update_gradients")));
732 Assert(fe_values->present_cell.is_initialized(),
734 AssertDimension(fe_function.size(),
735 fe_values->present_cell.n_dofs_for_dof_handler());
736
737 // get function values of dofs on this cell
738 ::Vector<Number> dof_values(fe_values->dofs_per_cell);
739 fe_values->present_cell.get_interpolated_dof_values(fe_function,
740 dof_values);
742 make_const_array_view(dof_values),
743 fe_values->finite_element_output.shape_gradients,
744 shape_function_data,
745 symmetric_gradients);
746 }
747
748
749
750 template <int dim, int spacedim>
751 template <class InputVector>
752 void
754 const InputVector &dof_values,
755 std::vector<
757 &symmetric_gradients) const
758 {
759 Assert(fe_values->update_flags & update_gradients,
761 "update_gradients")));
762 Assert(fe_values->present_cell.is_initialized(),
764 AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
765
767 make_const_array_view(dof_values),
768 fe_values->finite_element_output.shape_gradients,
769 shape_function_data,
770 symmetric_gradients);
771 }
772
773
774
775 template <int dim, int spacedim>
776 template <typename Number>
777 void
779 const ReadVector<Number> &fe_function,
780 std::vector<solution_divergence_type<Number>> &divergences) const
781 {
782 Assert(fe_values->update_flags & update_gradients,
784 "update_gradients")));
785 Assert(fe_values->present_cell.is_initialized(),
787 AssertDimension(fe_function.size(),
788 fe_values->present_cell.n_dofs_for_dof_handler());
789
790 // get function values of dofs
791 // on this cell
792 ::Vector<Number> dof_values(fe_values->dofs_per_cell);
793 fe_values->present_cell.get_interpolated_dof_values(fe_function,
794 dof_values);
796 make_const_array_view(dof_values),
797 fe_values->finite_element_output.shape_gradients,
798 shape_function_data,
799 divergences);
800 }
801
802
803
804 template <int dim, int spacedim>
805 template <class InputVector>
806 void
808 const InputVector &dof_values,
810 &divergences) const
811 {
812 Assert(fe_values->update_flags & update_gradients,
814 "update_gradients")));
815 Assert(fe_values->present_cell.is_initialized(),
817 AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
818
820 make_const_array_view(dof_values),
821 fe_values->finite_element_output.shape_gradients,
822 shape_function_data,
823 divergences);
824 }
825
826
827
828 template <int dim, int spacedim>
829 template <typename Number>
830 void
832 const ReadVector<Number> &fe_function,
833 std::vector<solution_curl_type<Number>> &curls) const
834 {
835 Assert(fe_values->update_flags & update_gradients,
837 "update_gradients")));
838 Assert(fe_values->present_cell.is_initialized(),
839 ExcMessage("FEValues object is not reinited to any cell"));
840 AssertDimension(fe_function.size(),
841 fe_values->present_cell.n_dofs_for_dof_handler());
842
843 // get function values of dofs on this cell
844 ::Vector<Number> dof_values(fe_values->dofs_per_cell);
845 fe_values->present_cell.get_interpolated_dof_values(fe_function,
846 dof_values);
848 make_const_array_view(dof_values),
849 fe_values->finite_element_output.shape_gradients,
850 shape_function_data,
851 curls);
852 }
853
854
855
856 template <int dim, int spacedim>
857 template <class InputVector>
858 void
860 const InputVector &dof_values,
862 const
863 {
864 Assert(fe_values->update_flags & update_gradients,
866 "update_gradients")));
867 Assert(fe_values->present_cell.is_initialized(),
868 ExcMessage("FEValues object is not reinited to any cell"));
869 AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
870
872 make_const_array_view(dof_values),
873 fe_values->finite_element_output.shape_gradients,
874 shape_function_data,
875 curls);
876 }
877
878
879
880 template <int dim, int spacedim>
881 template <typename Number>
882 void
884 const ReadVector<Number> &fe_function,
885 std::vector<solution_hessian_type<Number>> &hessians) const
886 {
887 Assert(fe_values->update_flags & update_hessians,
889 "update_hessians")));
890 Assert(fe_values->present_cell.is_initialized(),
892 AssertDimension(fe_function.size(),
893 fe_values->present_cell.n_dofs_for_dof_handler());
894
895 // get function values of dofs on this cell
896 ::Vector<Number> dof_values(fe_values->dofs_per_cell);
897 fe_values->present_cell.get_interpolated_dof_values(fe_function,
898 dof_values);
900 make_const_array_view(dof_values),
901 fe_values->finite_element_output.shape_hessians,
902 shape_function_data,
903 hessians);
904 }
905
906
907
908 template <int dim, int spacedim>
909 template <class InputVector>
910 void
912 const InputVector &dof_values,
914 &hessians) const
915 {
916 Assert(fe_values->update_flags & update_hessians,
918 "update_hessians")));
919 Assert(fe_values->present_cell.is_initialized(),
921 AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
922
924 make_const_array_view(dof_values),
925 fe_values->finite_element_output.shape_hessians,
926 shape_function_data,
927 hessians);
928 }
929
930
931
932 template <int dim, int spacedim>
933 template <typename Number>
934 void
936 const ReadVector<Number> &fe_function,
937 std::vector<solution_value_type<Number>> &laplacians) const
938 {
939 Assert(fe_values->update_flags & update_hessians,
941 "update_hessians")));
942 Assert(laplacians.size() == fe_values->n_quadrature_points,
943 ExcDimensionMismatch(laplacians.size(),
944 fe_values->n_quadrature_points));
945 Assert(fe_values->present_cell.is_initialized(),
947 Assert(
948 fe_function.size() == fe_values->present_cell.n_dofs_for_dof_handler(),
949 ExcDimensionMismatch(fe_function.size(),
950 fe_values->present_cell.n_dofs_for_dof_handler()));
951
952 // get function values of dofs on this cell
953 ::Vector<Number> dof_values(fe_values->dofs_per_cell);
954 fe_values->present_cell.get_interpolated_dof_values(fe_function,
955 dof_values);
957 make_const_array_view(dof_values),
958 fe_values->finite_element_output.shape_hessians,
959 shape_function_data,
960 laplacians);
961 }
962
963
964
965 template <int dim, int spacedim>
966 template <class InputVector>
967 void
969 const InputVector &dof_values,
971 &laplacians) const
972 {
973 Assert(fe_values->update_flags & update_hessians,
975 "update_hessians")));
976 Assert(laplacians.size() == fe_values->n_quadrature_points,
977 ExcDimensionMismatch(laplacians.size(),
978 fe_values->n_quadrature_points));
979 Assert(fe_values->present_cell.is_initialized(),
981 AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
982
984 make_const_array_view(dof_values),
985 fe_values->finite_element_output.shape_hessians,
986 shape_function_data,
987 laplacians);
988 }
989
990
991
992 template <int dim, int spacedim>
993 template <typename Number>
994 void
996 const ReadVector<Number> &fe_function,
997 std::vector<solution_third_derivative_type<Number>> &third_derivatives)
998 const
999 {
1000 Assert(fe_values->update_flags & update_3rd_derivatives,
1002 "update_3rd_derivatives")));
1003 Assert(fe_values->present_cell.is_initialized(),
1005 AssertDimension(fe_function.size(),
1006 fe_values->present_cell.n_dofs_for_dof_handler());
1007
1008 // get function values of dofs on this cell
1009 ::Vector<Number> dof_values(fe_values->dofs_per_cell);
1010 fe_values->present_cell.get_interpolated_dof_values(fe_function,
1011 dof_values);
1013 make_const_array_view(dof_values),
1014 fe_values->finite_element_output.shape_3rd_derivatives,
1015 shape_function_data,
1016 third_derivatives);
1017 }
1018
1019
1020
1021 template <int dim, int spacedim>
1022 template <class InputVector>
1023 void
1025 const InputVector &dof_values,
1026 std::vector<
1028 &third_derivatives) const
1029 {
1030 Assert(fe_values->update_flags & update_3rd_derivatives,
1032 "update_3rd_derivatives")));
1033 Assert(fe_values->present_cell.is_initialized(),
1035 AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
1036
1038 make_const_array_view(dof_values),
1039 fe_values->finite_element_output.shape_3rd_derivatives,
1040 shape_function_data,
1041 third_derivatives);
1042 }
1043
1044
1045
1046 template <int dim, int spacedim>
1047 template <typename Number>
1048 void
1050 const ReadVector<Number> &fe_function,
1051 std::vector<solution_value_type<Number>> &values) const
1052 {
1053 Assert(fe_values->update_flags & update_values,
1055 "update_values")));
1056 Assert(fe_values->present_cell.is_initialized(),
1058
1059 // get function values of dofs on this cell
1060 ::Vector<Number> dof_values(fe_values->dofs_per_cell);
1061 fe_values->present_cell.get_interpolated_dof_values(fe_function,
1062 dof_values);
1064 make_const_array_view(dof_values),
1065 fe_values->finite_element_output.shape_values,
1066 shape_function_data,
1067 values);
1068 }
1069
1070
1071
1072 template <int dim, int spacedim>
1073 template <class InputVector>
1074 void
1076 const InputVector &dof_values,
1078 const
1079 {
1080 Assert(fe_values->update_flags & update_values,
1082 "update_values")));
1083 Assert(fe_values->present_cell.is_initialized(),
1085 AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
1086
1088 make_const_array_view(dof_values),
1089 fe_values->finite_element_output.shape_values,
1090 shape_function_data,
1091 values);
1092 }
1093
1094
1095
1096 template <int dim, int spacedim>
1097 template <typename Number>
1098 void
1100 const ReadVector<Number> &fe_function,
1101 std::vector<solution_divergence_type<Number>> &divergences) const
1102 {
1103 Assert(fe_values->update_flags & update_gradients,
1105 "update_gradients")));
1106 Assert(fe_values->present_cell.is_initialized(),
1108 AssertDimension(fe_function.size(),
1109 fe_values->present_cell.n_dofs_for_dof_handler());
1110
1111 // get function values of dofs
1112 // on this cell
1113 ::Vector<Number> dof_values(fe_values->dofs_per_cell);
1114 fe_values->present_cell.get_interpolated_dof_values(fe_function,
1115 dof_values);
1117 make_const_array_view(dof_values),
1118 fe_values->finite_element_output.shape_gradients,
1119 shape_function_data,
1120 divergences);
1121 }
1122
1123
1124
1125 template <int dim, int spacedim>
1126 template <class InputVector>
1127 void
1130 const InputVector &dof_values,
1132 &divergences) const
1133 {
1134 Assert(fe_values->update_flags & update_gradients,
1136 "update_gradients")));
1137 Assert(fe_values->present_cell.is_initialized(),
1139 AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
1140
1142 make_const_array_view(dof_values),
1143 fe_values->finite_element_output.shape_gradients,
1144 shape_function_data,
1145 divergences);
1146 }
1147
1148
1149
1150 template <int dim, int spacedim>
1151 template <typename Number>
1152 void
1154 const ReadVector<Number> &fe_function,
1155 std::vector<solution_value_type<Number>> &values) const
1156 {
1157 Assert(fe_values->update_flags & update_values,
1159 "update_values")));
1160 Assert(fe_values->present_cell.is_initialized(),
1162
1163 // get function values of dofs on this cell
1164 ::Vector<Number> dof_values(fe_values->dofs_per_cell);
1165 fe_values->present_cell.get_interpolated_dof_values(fe_function,
1166 dof_values);
1168 make_const_array_view(dof_values),
1169 fe_values->finite_element_output.shape_values,
1170 shape_function_data,
1171 values);
1172 }
1173
1174
1175
1176 template <int dim, int spacedim>
1177 template <class InputVector>
1178 void
1180 const InputVector &dof_values,
1182 const
1183 {
1184 Assert(fe_values->update_flags & update_values,
1186 "update_values")));
1187 Assert(fe_values->present_cell.is_initialized(),
1189 AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
1190
1192 make_const_array_view(dof_values),
1193 fe_values->finite_element_output.shape_values,
1194 shape_function_data,
1195 values);
1196 }
1197
1198
1199
1200 template <int dim, int spacedim>
1201 template <typename Number>
1202 void
1204 const ReadVector<Number> &fe_function,
1205 std::vector<solution_divergence_type<Number>> &divergences) const
1206 {
1207 Assert(fe_values->update_flags & update_gradients,
1209 "update_gradients")));
1210 Assert(fe_values->present_cell.is_initialized(),
1212 AssertDimension(fe_function.size(),
1213 fe_values->present_cell.n_dofs_for_dof_handler());
1214
1215 // get function values of dofs
1216 // on this cell
1217 ::Vector<Number> dof_values(fe_values->dofs_per_cell);
1218 fe_values->present_cell.get_interpolated_dof_values(fe_function,
1219 dof_values);
1221 make_const_array_view(dof_values),
1222 fe_values->finite_element_output.shape_gradients,
1223 shape_function_data,
1224 divergences);
1225 }
1226
1227
1228
1229 template <int dim, int spacedim>
1230 template <class InputVector>
1231 void
1233 const InputVector &dof_values,
1235 &divergences) const
1236 {
1237 Assert(fe_values->update_flags & update_gradients,
1239 "update_gradients")));
1240 Assert(fe_values->present_cell.is_initialized(),
1242 AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
1243
1245 make_const_array_view(dof_values),
1246 fe_values->finite_element_output.shape_gradients,
1247 shape_function_data,
1248 divergences);
1249 }
1250
1251
1252
1253 template <int dim, int spacedim>
1254 template <typename Number>
1255 void
1257 const ReadVector<Number> &fe_function,
1258 std::vector<solution_gradient_type<Number>> &gradients) const
1259 {
1260 Assert(fe_values->update_flags & update_gradients,
1262 "update_gradients")));
1263 Assert(fe_values->present_cell.is_initialized(),
1265 AssertDimension(fe_function.size(),
1266 fe_values->present_cell.n_dofs_for_dof_handler());
1267
1268 // get function values of dofs
1269 // on this cell
1270 ::Vector<Number> dof_values(fe_values->dofs_per_cell);
1271 fe_values->present_cell.get_interpolated_dof_values(fe_function,
1272 dof_values);
1274 make_const_array_view(dof_values),
1275 fe_values->finite_element_output.shape_gradients,
1276 shape_function_data,
1277 gradients);
1278 }
1279
1280
1281
1282 template <int dim, int spacedim>
1283 template <class InputVector>
1284 void
1286 const InputVector &dof_values,
1288 &gradients) const
1289 {
1290 Assert(fe_values->update_flags & update_gradients,
1292 "update_gradients")));
1293 Assert(fe_values->present_cell.is_initialized(),
1295 AssertDimension(dof_values.size(), fe_values->dofs_per_cell);
1296
1298 make_const_array_view(dof_values),
1299 fe_values->finite_element_output.shape_gradients,
1300 shape_function_data,
1301 gradients);
1302 }
1303} // namespace FEValuesViews
1304
1305
1306namespace internal
1307{
1308 namespace FEValuesViews
1309 {
1310 template <int dim, int spacedim>
1312 {
1313 const FiniteElement<dim, spacedim> &fe = fe_values.get_fe();
1314
1315 const unsigned int n_scalars = fe.n_components();
1316 scalars.resize(n_scalars);
1317
1318 // compute number of vectors that we can fit into this finite element.
1319 // note that this is based on the dimensionality 'dim' of the manifold,
1320 // not 'spacedim' of the output vector
1321 const unsigned int n_vectors =
1324 1 :
1325 0);
1326 vectors.resize(n_vectors);
1327
1328 // compute number of symmetric tensors in the same way as above
1329 const unsigned int n_symmetric_second_order_tensors =
1330 (fe.n_components() >=
1332 fe.n_components() -
1334 0);
1335 symmetric_second_order_tensors.resize(n_symmetric_second_order_tensors);
1336
1337 // compute number of symmetric tensors in the same way as above
1338 const unsigned int n_second_order_tensors =
1341 1 :
1342 0);
1343 second_order_tensors.resize(n_second_order_tensors);
1344 }
1345 } // namespace FEValuesViews
1346} // namespace internal
1347
1348/*------------------------------- Explicit Instantiations -------------*/
1349
1350#include "fe_values_views.inst"
1351
auto make_const_array_view(const Container &container) -> decltype(make_array_view(container))
const SmartPointer< const FiniteElement< dim, spacedim >, FEValuesBase< dim, spacedim > > fe
const FiniteElement< dim, spacedim > & get_fe() 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_laplacians(const ReadVector< Number > &fe_function, std::vector< solution_laplacian_type< Number > > &laplacians) const
typename ProductType< Number, value_type >::type solution_laplacian_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_values_from_local_dof_values(const InputVector &dof_values, std::vector< solution_value_type< typename InputVector::value_type > > &values) const
std::vector< ShapeFunctionData > shape_function_data
void get_function_gradients(const ReadVector< Number > &fe_function, std::vector< solution_gradient_type< Number > > &gradients) const
typename ProductType< Number, gradient_type >::type solution_gradient_type
typename ProductType< Number, value_type >::type solution_value_type
void get_function_values(const ReadVector< Number > &fe_function, std::vector< solution_value_type< Number > > &values) 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_gradients_from_local_dof_values(const InputVector &dof_values, std::vector< solution_gradient_type< typename InputVector::value_type > > &gradients) const
typename ProductType< Number, hessian_type >::type solution_hessian_type
void get_function_third_derivatives(const ReadVector< Number > &fe_function, std::vector< solution_third_derivative_type< Number > > &third_derivatives) const
typename ProductType< Number, third_derivative_type >::type solution_third_derivative_type
void get_function_hessians(const ReadVector< Number > &fe_function, std::vector< solution_hessian_type< Number > > &hessians) 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
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
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_laplacians(const ReadVector< Number > &fe_function, std::vector< solution_laplacian_type< Number > > &laplacians) const
unsigned int first_vector_component
void get_function_gradients(const ReadVector< Number > &fe_function, std::vector< solution_gradient_type< Number > > &gradients) const
typename ProductType< Number, value_type >::type solution_laplacian_type
void get_function_symmetric_gradients(const ReadVector< Number > &fe_function, std::vector< solution_symmetric_gradient_type< Number > > &symmetric_gradients) const
typename ProductType< Number, third_derivative_type >::type solution_third_derivative_type
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_hessians(const ReadVector< Number > &fe_function, std::vector< solution_hessian_type< Number > > &hessians) const
typename ProductType< Number, divergence_type >::type solution_divergence_type
typename ProductType< Number, value_type >::type solution_value_type
void get_function_third_derivatives(const ReadVector< Number > &fe_function, std::vector< solution_third_derivative_type< Number > > &third_derivatives) const
void get_function_values(const ReadVector< Number > &fe_function, std::vector< solution_value_type< Number > > &values) const
void get_function_curls_from_local_dof_values(const InputVector &dof_values, std::vector< solution_curl_type< typename InputVector::value_type > > &curls) const
typename ProductType< Number, gradient_type >::type solution_gradient_type
typename ProductType< Number, curl_type >::type solution_curl_type
typename ProductType< Number, symmetric_gradient_type >::type solution_symmetric_gradient_type
std::vector< ShapeFunctionData > shape_function_data
void get_function_curls(const ReadVector< Number > &fe_function, std::vector< solution_curl_type< Number > > &curls) 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_from_local_dof_values(const InputVector &dof_values, std::vector< solution_value_type< typename InputVector::value_type > > &values) 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_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_divergences(const ReadVector< Number > &fe_function, std::vector< solution_divergence_type< Number > > &divergences) const
unsigned int n_dofs_per_cell() const
unsigned int n_components() const
const ComponentMask & get_nonzero_components(const unsigned int i) const
bool is_primitive() const
std::pair< unsigned int, unsigned int > system_to_component_index(const unsigned int index) const
unsigned int n_nonzero_components(const unsigned int i) const
virtual size_type size() const =0
DEAL_II_HOST constexpr SymmetricTensor()=default
friend class Tensor
Definition tensor.h:882
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:503
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:504
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcIndexRange(std::size_t arg1, std::size_t arg2, std::size_t arg3)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
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.
void do_function_divergences(const ArrayView< const Number > &dof_values, const Table< 2, ::Tensor< 1, spacedim > > &shape_gradients, const std::vector< typename Vector< dim, spacedim >::ShapeFunctionData > &shape_function_data, std::vector< typename Vector< dim, spacedim >::template solution_divergence_type< Number > > &divergences)
void do_function_symmetric_gradients(const ArrayView< const Number > &dof_values, const Table< 2, ::Tensor< 1, spacedim > > &shape_gradients, const std::vector< typename Vector< dim, spacedim >::ShapeFunctionData > &shape_function_data, std::vector< typename ProductType< Number, ::SymmetricTensor< 2, spacedim > >::type > &symmetric_gradients)
void do_function_derivatives(const ArrayView< const Number > &dof_values, const Table< 2, ::Tensor< order, spacedim > > &shape_derivatives, const std::vector< typename Scalar< dim, spacedim >::ShapeFunctionData > &shape_function_data, std::vector< typename ProductType< Number, ::Tensor< order, spacedim > >::type > &derivatives)
void do_function_curls(const ArrayView< const Number > &dof_values, const Table< 2, ::Tensor< 1, spacedim > > &shape_gradients, const std::vector< typename Vector< dim, spacedim >::ShapeFunctionData > &shape_function_data, std::vector< typename ProductType< Number, typename ::internal::CurlType< spacedim >::type >::type > &curls)
void do_function_gradients(const ArrayView< const Number > &dof_values, const Table< 2, ::Tensor< 1, spacedim > > &shape_gradients, const std::vector< typename Tensor< 2, dim, spacedim >::ShapeFunctionData > &shape_function_data, std::vector< typename Tensor< 2, dim, spacedim >::template solution_gradient_type< Number > > &gradients)
void do_function_values(const ArrayView< const Number > &dof_values, const Table< 2, double > &shape_values, const std::vector< typename Scalar< dim, spacedim >::ShapeFunctionData > &shape_function_data, std::vector< typename ProductType< Number, double >::type > &values)
void do_function_laplacians(const ArrayView< const Number > &dof_values, const Table< 2, ::Tensor< 2, spacedim > > &shape_hessians, const std::vector< typename Scalar< dim, spacedim >::ShapeFunctionData > &shape_function_data, std::vector< typename Scalar< dim, spacedim >::template solution_laplacian_type< Number > > &laplacians)
std::vector< unsigned int > make_shape_function_to_row_table(const FiniteElement< dim, spacedim > &fe)
Definition fe_values.cc:49
static const unsigned int invalid_unsigned_int
Definition types.h:220
Cache(const FEValuesBase< dim, spacedim > &fe_values)