Debian Codegraph @

include/deal.II/fe/fe_interface_values.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2019 - 2025 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
15 #ifndef dealii_fe_interface_values_h
16 #define dealii_fe_interface_values_h
17
18 #include <deal.II/base/config.h>
19
20 #include <deal.II/base/std_cxx20/iota_view.h>
21
22 #include <deal.II/fe/fe_values.h>
23 #include <deal.II/fe/mapping.h>
24
25 #include <deal.II/hp/fe_collection.h>
26 #include <deal.II/hp/fe_values.h>
27 #include <deal.II/hp/q_collection.h>
28
29 DEAL_II_NAMESPACE_OPEN
30
31 #ifndef DOXYGEN
32 template <int dim, int spacedim>
33 class FEInterfaceValues;
34 #endif
35
36 /**
37 * Namespace for views you get from accessing FEInterfaceValues using an
38 * extractor.
39 */
40 namespace FEInterfaceViews
41 {
42 /**
43 * The base class for the views.
44 */
45 template <int dim, int spacedim = dim>
46 class Base
47 {
48 public:
49 /**
50 * The constructor.
51 */
52 Base(const FEInterfaceValues<dim, spacedim> &fe_interface);
53
54 protected:
55 /**
56 * Store a pointer to the FEInterfaceValues instance.
57 */
58 const FEInterfaceValues<dim, spacedim> *fe_interface;
59
60 /**
61 * Get the local degree-of-freedom values associated with the internally
62 * initialized cell interface.
63 */
64 template <class InputVector, class OutputVector>
65 void
66 get_local_dof_values(const InputVector &dof_values,
67 OutputVector &local_dof_values) const;
68 };
69
70
71
72 /**
73 * The view of a scalar variable for FEInterfaceValues.
74 */
75 template <int dim, int spacedim = dim>
76 class Scalar : public Base<dim, spacedim>
77 {
78 public:
79 /**
80 * This is the type returned for values.
81 */
82 using value_type = double;
83
84 /**
85 * This is the type returned for gradients, for example from
86 * average_of_gradients().
87 */
88 using gradient_type =
89 typename FEValuesViews::Scalar<dim, spacedim>::gradient_type;
90
91 /**
92 * This is the type returned for hessians, for example from
93 * jump_in_hessians().
94 */
95 using hessian_type =
96 typename FEValuesViews::Scalar<dim, spacedim>::hessian_type;
97
98 /**
99 * This is the type returned for third derivatives, for example from
100 * jump_in_hessians().
101 */
102 using third_derivative_type =
103 typename FEValuesViews::Scalar<dim, spacedim>::third_derivative_type;
104
105 /**
106 * An alias for the data type of the product of a @p Number and the
107 * values of the view this class provides. This is the data type of
108 * scalar components of a finite element field whose degrees of
109 * freedom are described by a vector with elements of type @p Number.
110 */
111 template <typename Number>
112 using solution_value_type = typename ProductType<Number, value_type>::type;
113
114 /**
115 * An alias for the data type of the product of a @p Number and the
116 * gradients of the view this class provides. This is the data type of
117 * scalar components of a finite element field whose degrees of
118 * freedom are described by a vector with elements of type @p Number.
119 */
120 template <typename Number>
121 using solution_gradient_type =
122 typename ProductType<Number, gradient_type>::type;
123
124 /**
125 * An alias for the data type of the product of a @p Number and the
126 * Hessians of the view this class provides. This is the data type of
127 * scalar components of a finite element field whose degrees of
128 * freedom are described by a vector with elements of type @p Number.
129 */
130 template <typename Number>
131 using solution_hessian_type =
132 typename ProductType<Number, hessian_type>::type;
133
134 /**
135 * An alias for the data type of the product of a @p Number and the
136 * third derivatives of the view this class provides. This is the data type
137 * of scalar components of a finite element field whose degrees of
138 * freedom are described by a vector with elements of type @p Number.
139 */
140 template <typename Number>
141 using solution_third_derivative_type =
142 typename ProductType<Number, third_derivative_type>::type;
143
144 /**
145 * Constructor for an object that represents a single scalar component
146 */
147 Scalar(const FEInterfaceValues<dim, spacedim> &fe_interface,
148 const unsigned int component);
149
150 /**
151 * @name Access to shape functions
152 */
153 /** @{ */
154
155 /**
156 * Return the value of the shape function
157 * with interface dof index @p interface_dof_index in
158 * quadrature point @p q_point of the component selected by this view.
159 *
160 * The argument @p here_or_there selects between the upstream value and
161 * the downstream value as defined by the direction of the normal vector
162 * in this quadrature point. If @p here_or_there is true, the shape
163 * functions from the first cell of the interface is used.
164 *
165 * In other words, this function returns the limit of the value of the shape
166 * function in the given quadrature point when approaching it from one of
167 * the two cells of the interface.
168 *
169 * @note This function is typically used to pick the upstream or downstream
170 * value based on a direction. This can be achieved by using
171 * <code>(direction * normal)>0</code> as the first argument of this
172 * function.
173 */
174 value_type
175 value(const bool here_or_there,
176 const unsigned int interface_dof_index,
177 const unsigned int q_point) const;
178
179 /** @} */
180
181 /**
182 * @name Access to jumps in shape functions and their derivatives
183 */
184 /** @{ */
185
186 /**
187 * Return the jump $\jump{u}=u_1 - u_2$ on the interface for the shape
188 * function
189 * @p interface_dof_index in the quadrature point @p q_point
190 * of the component selected by this view.
191 *
192 * @note The name of the function is supposed to be read as "the jump
193 * (singular) in the values (plural: one or two possible values) of
194 * the shape function (singular)".
195 */
196 value_type
197 jump_in_values(const unsigned int interface_dof_index,
198 const unsigned int q_point) const;
199
200 /**
201 * Return the jump of the gradient $\jump{nabla u}$ on the interface for
202 * the shape
203 * function @p interface_dof_index in the quadrature point @p q_point
204 * of the component selected by this view.
205 *
206 * @note The name of the function is supposed to be read as "the jump
207 * (singular) in the gradients (plural: one or two possible gradients)
208 * of the shape function (singular)".
209 */
210 gradient_type
211 jump_in_gradients(const unsigned int interface_dof_index,
212 const unsigned int q_point) const;
213
214 /**
215 * Return the jump in the gradient $\jump{\nabla u}=\nabla u_{\text{cell0}}
216 * - \nabla u_{\text{cell1}}$ on the interface for the shape function @p
217 * interface_dof_index at the quadrature point @p q_point of
218 * the component selected by this view.
219 *
220 * @note The name of the function is supposed to be read as "the jump
221 * (singular) in the Hessians (plural: one or two possible values
222 * for the second derivative) of the shape function (singular)".
223 */
224 hessian_type
225 jump_in_hessians(const unsigned int interface_dof_index,
226 const unsigned int q_point) const;
227
228 /**
229 * Return the jump in the third derivative $\jump{\nabla^3 u} = \nabla^3
230 * u_{\text{cell0}} - \nabla^3 u_{\text{cell1}}$ on the interface for the
231 * shape function @p interface_dof_index at the quadrature point @p q_point of
232 * the component selected by this view.
233 *
234 * @note The name of the function is supposed to be read as "the jump
235 * (singular) in the third derivatives (plural: one or two possible values
236 * for the third derivative) of the shape function (singular)".
237 */
238 third_derivative_type
239 jump_in_third_derivatives(const unsigned int interface_dof_index,
240 const unsigned int q_point) const;
241
242 /** @} */
243
244 /**
245 * @name Access to the average of shape functions and their derivatives
246 */
247 /** @{ */
248
249 /**
250 * Return the average value $\average{u}=\frac{1}{2}(u_1 + u_2)$ on the
251 * interface for the shape
252 * function @p interface_dof_index in the quadrature point @p q_point
253 * of the component selected by this view.
254 *
255 * @note The name of the function is supposed to be read as "the average
256 * (singular) of the values (plural: one or two possible values) of
257 * the shape function (singular)".
258 */
259 value_type
260 average_of_values(const unsigned int interface_dof_index,
261 const unsigned int q_point) const;
262
263 /**
264 * Return the average of the gradient $\average{\nabla u}$ on the interface
265 * for the shape
266 * function @p interface_dof_index in the quadrature point @p q_point
267 * of the component selected by this view.
268 *
269 * @note The name of the function is supposed to be read as "the average
270 * (singular) of the gradients (plural: one or two possible values of
271 * the derivative) of the shape function (singular)".
272 */
273 gradient_type
274 average_of_gradients(const unsigned int interface_dof_index,
275 const unsigned int q_point) const;
276
277 /**
278 * Return the average of the Hessian $\average{\nabla^2 u} =
279 * \frac{1}{2}\nabla^2 u_{\text{cell0}} + \frac{1}{2} \nabla^2
280 * u_{\text{cell1}}$ on the interface
281 * for the shape function @p interface_dof_index at the quadrature point @p
282 * q_point of the component selected by this view.
283 *
284 * @note The name of the function is supposed to be read as "the average
285 * (singular) in the Hessians (plural: one or two possible values of
286 * the second derivative) of the shape function (singular)".
287 */
288 hessian_type
289 average_of_hessians(const unsigned int interface_dof_index,
290 const unsigned int q_point) const;
291
292 /** @} */
293
294 /**
295 * @name Access to values of global finite element fields
296 */
297 /** @{ */
298
299 /**
300 * Return the values of the selected scalar component of the finite
301 * element function characterized by <tt>fe_function</tt> at the
302 * quadrature points of the cell interface selected the last time
303 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
304 *
305 * The argument @p here_or_there selects between the value on cell 0 (here, @p true)
306 * and cell 1 (there, @p false). You can also interpret it as "upstream" (@p true)
307 * and "downstream" (@p false) as defined by the direction of the normal
308 * vector in this quadrature point. If @p here_or_there is true, the values
309 * from the first cell of the interface is used.
310 *
311 * The data type stored by the output vector must be what you get when you
312 * multiply the values of shape functions (i.e., @p value_type) times the
313 * type used to store the values of the unknowns $U_j$ of your finite
314 * element vector $U$ (represented by the @p fe_function argument).
315 *
316 * @dealiiRequiresUpdateFlags{update_values}
317 */
318 template <class InputVector>
319 void
320 get_function_values(
321 const bool here_or_there,
322 const InputVector &fe_function,
323 std::vector<solution_value_type<typename InputVector::value_type>>
324 &values) const;
325
326 /**
327 * Same as above, but using a vector of local degree-of-freedom values. In
328 * other words, instead of extracting the nodal values of the degrees of
329 * freedom located on the current cell interface from a global vector
330 * associated with a DoFHandler object (as the function above does), this
331 * function instead takes these local nodal values through its first
332 * argument.
333 *
334 * @param[in] here_or_there Same as the one in the above function.
335 *
336 * @param[in] local_dof_values A vector of local nodal values. This vector
337 * must have a length equal to number of DoFs on the current cell, and
338 * must be ordered in the same order as degrees of freedom are numbered on
339 * the reference cell.
340 *
341 * @param[out] values A vector of values of the given finite element field,
342 * at the quadrature points on the current object.
343 *
344 * @tparam InputVector The @p InputVector type must allow creation
345 * of an ArrayView object from it; this is satisfied by the
346 * `std::vector` class, among others.
347 */
348 template <class InputVector>
349 void
350 get_function_values_from_local_dof_values(
351 const bool here_or_there,
352 const InputVector &local_dof_values,
353 std::vector<solution_value_type<typename InputVector::value_type>>
354 &values) const;
355
356 /** @} */
357
358 /**
359 * @name Access to jumps in global finite element fields
360 */
361 /** @{ */
362
363 /**
364 * Return the jump in the values of the selected scalar component of the
365 * finite element function characterized by <tt>fe_function</tt> at the
366 * quadrature points of the cell interface selected the last time
367 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
368 *
369 * The data type stored by the output vector must be what you get when you
370 * multiply the values of shape functions (i.e., @p value_type) times the
371 * type used to store the values of the unknowns $U_j$ of your finite
372 * element vector $U$ (represented by the @p fe_function argument).
373 *
374 * @dealiiRequiresUpdateFlags{update_values}
375 */
376 template <class InputVector>
377 void
378 get_jump_in_function_values(
379 const InputVector &fe_function,
380 std::vector<solution_value_type<typename InputVector::value_type>>
381 &values) const;
382
383 /**
384 * This function relates to get_jump_in_function_values() in the same way
385 * as get_function_values_from_local_dof_values() relates to
386 * get_function_values(). See the documentation of
387 * get_function_values_from_local_dof_values() for more
388 * information.
389 */
390 template <class InputVector>
391 void
392 get_jump_in_function_values_from_local_dof_values(
393 const InputVector &local_dof_values,
394 std::vector<solution_value_type<typename InputVector::value_type>>
395 &values) const;
396
397 /**
398 * Return the jump in the gradients of the selected scalar components of the
399 * finite element function characterized by <tt>fe_function</tt> at the
400 * quadrature points of the cell interface selected the last time
401 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
402 *
403 * The data type stored by the output vector must be what you get when you
404 * multiply the gradients of shape functions (i.e., @p gradient_type)
405 * times the type used to store the values of the unknowns $U_j$ of your
406 * finite element vector $U$ (represented by the @p fe_function argument).
407 *
408 * @dealiiRequiresUpdateFlags{update_gradients}
409 */
410 template <class InputVector>
411 void
412 get_jump_in_function_gradients(
413 const InputVector &fe_function,
414 std::vector<solution_gradient_type<typename InputVector::value_type>>
415 &gradients) const;
416
417 /**
418 * This function relates to get_jump_in_function_gradients() in the same way
419 * as get_function_values_from_local_dof_values() relates to
420 * get_function_values(). See the documentation of
421 * get_function_values_from_local_dof_values() for more
422 * information.
423 */
424 template <class InputVector>
425 void
426 get_jump_in_function_gradients_from_local_dof_values(
427 const InputVector &local_dof_values,
428 std::vector<solution_gradient_type<typename InputVector::value_type>>
429 &gradients) const;
430
431 /**
432 * Return the jump in the Hessians of the selected scalar component of the
433 * finite element function characterized by <tt>fe_function</tt> at the
434 * quadrature points of the cell, face or subface selected the last time
435 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
436 *
437 * The data type stored by the output vector must be what you get when you
438 * multiply the Hessians of shape functions (i.e., @p hessian_type) times
439 * the type used to store the values of the unknowns $U_j$ of your finite
440 * element vector $U$ (represented by the @p fe_function argument).
441 *
442 * @dealiiRequiresUpdateFlags{update_hessians}
443 */
444 template <class InputVector>
445 void
446 get_jump_in_function_hessians(
447 const InputVector &fe_function,
448 std::vector<solution_hessian_type<typename InputVector::value_type>>
449 &hessians) const;
450
451 /**
452 * This function relates to get_jump_in_function_hessians() in the same way
453 * as get_function_values_from_local_dof_values() relates to
454 * get_function_values(). See the documentation of
455 * get_function_values_from_local_dof_values() for more
456 * information.
457 */
458 template <class InputVector>
459 void
460 get_jump_in_function_hessians_from_local_dof_values(
461 const InputVector &local_dof_values,
462 std::vector<solution_hessian_type<typename InputVector::value_type>>
463 &hessians) const;
464
465 /**
466 * Return the jump in the third derivatives of the selected scalar component
467 * of the finite element function characterized by <tt>fe_function</tt> at
468 * the quadrature points of the cell, face or subface selected the last time
469 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
470 *
471 * The data type stored by the output vector must be what you get when you
472 * multiply the third derivatives of shape functions (i.e., @p
473 * third_derivative_type) times the type used to store the values of the
474 * unknowns $U_j$ of your finite element vector $U$ (represented by the @p
475 * fe_function argument).
476 *
477 * @dealiiRequiresUpdateFlags{update_third_derivatives}
478 */
479 template <class InputVector>
480 void
481 get_jump_in_function_third_derivatives(
482 const InputVector &fe_function,
483 std::vector<
484 solution_third_derivative_type<typename InputVector::value_type>>
485 &third_derivatives) const;
486
487 /**
488 * This function relates to get_jump_in_function_third_derivatives() in the
489 * same way as get_function_values_from_local_dof_values() relates
490 * to get_function_values(). See the documentation of
491 * get_function_values_from_local_dof_values() for more
492 * information.
493 */
494 template <class InputVector>
495 void
496 get_jump_in_function_third_derivatives_from_local_dof_values(
497 const InputVector &local_dof_values,
498 std::vector<
499 solution_third_derivative_type<typename InputVector::value_type>>
500 &third_derivatives) const;
501
502 /** @} */
503
504 /**
505 * @name Access to the average of global finite element fields
506 */
507 /** @{ */
508
509 /**
510 * Return the average of the values of the selected scalar component of the
511 * finite element function characterized by <tt>fe_function</tt> at the
512 * quadrature points of the cell interface selected the last time
513 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
514 *
515 * The data type stored by the output vector must be what you get when you
516 * multiply the values of shape functions (i.e., @p value_type) times the
517 * type used to store the values of the unknowns $U_j$ of your finite
518 * element vector $U$ (represented by the @p fe_function argument).
519 *
520 * @dealiiRequiresUpdateFlags{update_values}
521 */
522 template <class InputVector>
523 void
524 get_average_of_function_values(
525 const InputVector &fe_function,
526 std::vector<solution_value_type<typename InputVector::value_type>>
527 &values) const;
528
529 /**
530 * This function relates to get_average_of_function_values() in the same way
531 * as get_function_values_from_local_dof_values() relates to
532 * get_function_values(). See the documentation of
533 * get_function_values_from_local_dof_values() for more
534 * information.
535 */
536 template <class InputVector>
537 void
538 get_average_of_function_values_from_local_dof_values(
539 const InputVector &local_dof_values,
540 std::vector<solution_value_type<typename InputVector::value_type>>
541 &values) const;
542
543 /**
544 * Return the average of the gradients of the selected scalar components of
545 * the finite element function characterized by <tt>fe_function</tt> at the
546 * quadrature points of the cell interface selected the last time
547 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
548 *
549 * The data type stored by the output vector must be what you get when you
550 * multiply the gradients of shape functions (i.e., @p gradient_type)
551 * times the type used to store the values of the unknowns $U_j$ of your
552 * finite element vector $U$ (represented by the @p fe_function argument).
553 *
554 * @dealiiRequiresUpdateFlags{update_gradients}
555 */
556 template <class InputVector>
557 void
558 get_average_of_function_gradients(
559 const InputVector &fe_function,
560 std::vector<solution_gradient_type<typename InputVector::value_type>>
561 &gradients) const;
562
563 /**
564 * This function relates to get_average_of_function_gradients() in the same
565 * way as get_function_values_from_local_dof_values() relates to
566 * get_function_values(). See the documentation of
567 * get_function_values_from_local_dof_values() for more
568 * information.
569 */
570 template <class InputVector>
571 void
572 get_average_of_function_gradients_from_local_dof_values(
573 const InputVector &local_dof_values,
574 std::vector<solution_gradient_type<typename InputVector::value_type>>
575 &gradients) const;
576
577 /**
578 * Return the average of the Hessians of the selected scalar component of
579 * the finite element function characterized by <tt>fe_function</tt> at the
580 * quadrature points of the cell, face or subface selected the last time
581 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
582 *
583 * The data type stored by the output vector must be what you get when you
584 * multiply the Hessians of shape functions (i.e., @p hessian_type) times
585 * the type used to store the values of the unknowns $U_j$ of your finite
586 * element vector $U$ (represented by the @p fe_function argument).
587 *
588 * @dealiiRequiresUpdateFlags{update_hessians}
589 */
590 template <class InputVector>
591 void
592 get_average_of_function_hessians(
593 const InputVector &fe_function,
594 std::vector<solution_hessian_type<typename InputVector::value_type>>
595 &hessians) const;
596
597 /**
598 * This function relates to get_average_of_function_hessians() in the same
599 * way as get_function_values_from_local_dof_values() relates to
600 * get_function_values(). See the documentation of
601 * get_function_values_from_local_dof_values() for more
602 * information.
603 */
604 template <class InputVector>
605 void
606 get_average_of_function_hessians_from_local_dof_values(
607 const InputVector &local_dof_values,
608 std::vector<solution_hessian_type<typename InputVector::value_type>>
609 &hessians) const;
610
611 /** @} */
612
613 private:
614 /**
615 * The extractor for this view.
616 */
617 const FEValuesExtractors::Scalar extractor;
618 };
619
620
621
622 /**
623 * The view of a vector-valued variable for FEInterfaceValues.
624 */
625 template <int dim, int spacedim = dim>
626 class Vector : public Base<dim, spacedim>
627 {
628 public:
629 /**
630 * This is the type returned for values.
631 */
632 using value_type =
633 typename FEValuesViews::Vector<dim, spacedim>::value_type;
634
635 /**
636 * This is the type returned for gradients, for example from
637 * average_of_gradients().
638 */
639 using gradient_type =
640 typename FEValuesViews::Vector<dim, spacedim>::gradient_type;
641
642 /**
643 * An alias for the type of second derivatives of the view this class
644 * represents. Here, for a set of <code>dim</code> components of the
645 * finite element, the Hessian is a <code>Tensor@<3,dim@></code>.
646 */
647 using hessian_type =
648 typename FEValuesViews::Vector<dim, spacedim>::hessian_type;
649
650 /**
651 * An alias for the type of third derivatives of the view this class
652 * represents. Here, for a set of <code>dim</code> components of the
653 * finite element, the third derivative is a <code>Tensor@<4,dim@></code>.
654 */
655 using third_derivative_type =
656 typename FEValuesViews::Vector<dim, spacedim>::third_derivative_type;
657
658 /**
659 * An alias for the data type of the product of a @p Number and the
660 * values of the view this class provides. This is the data type of
661 * vector components of a finite element field whose degrees of
662 * freedom are described by a vector with elements of type @p Number.
663 */
664 template <typename Number>
665 using solution_value_type = typename ProductType<Number, value_type>::type;
666
667 /**
668 * An alias for the data type of the product of a @p Number and the
669 * gradients of the view this class provides. This is the data type of
670 * vector components of a finite element field whose degrees of
671 * freedom are described by a vector with elements of type @p Number.
672 */
673 template <typename Number>
674 using solution_gradient_type =
675 typename ProductType<Number, gradient_type>::type;
676
677 /**
678 * An alias for the data type of the product of a @p Number and the
679 * Hessians of the view this class provides. This is the data type of
680 * vector components of a finite element field whose degrees of
681 * freedom are described by a vector with elements of type @p Number.
682 */
683 template <typename Number>
684 using solution_hessian_type =
685 typename ProductType<Number, hessian_type>::type;
686
687 /**
688 * An alias for the data type of the product of a @p Number and the
689 * third derivatives of the view this class provides. This is the data type
690 * of vector components of a finite element field whose degrees of
691 * freedom are described by a vector with elements of type @p Number.
692 */
693 template <typename Number>
694 using solution_third_derivative_type =
695 typename ProductType<Number, third_derivative_type>::type;
696
697 /**
698 * Constructor for an object that represents a vector component
699 */
700 Vector(const FEInterfaceValues<dim, spacedim> &fe_interface,
701 const unsigned int first_vector_component);
702
703 /**
704 * @name Access to shape functions
705 */
706 /** @{ */
707
708 /**
709 * Return the value of the vector components selected by this view
710 * with interface dof index @p interface_dof_index in
711 * quadrature point @p q_point.
712 *
713 * The argument @p here_or_there selects between the upstream value and
714 * the downstream value as defined by the direction of the normal vector
715 * in this quadrature point. If @p here_or_there is true, the shape
716 * functions from the first cell of the interface is used.
717 *
718 * In other words, this function returns the limit of the value of the shape
719 * function in the given quadrature point when approaching it from one of
720 * the two cells of the interface.
721 *
722 * @note This function is typically used to pick the upstream or downstream
723 * value based on a direction. This can be achieved by using
724 * <code>(direction * normal)>0</code> as the first argument of this
725 * function.
726 */
727 value_type
728 value(const bool here_or_there,
729 const unsigned int interface_dof_index,
730 const unsigned int q_point) const;
731
732 /** @} */
733
734 /**
735 * @name Access to jumps in shape functions and their derivatives
736 */
737 /** @{ */
738
739 /**
740 * Return the jump vector $[\mathbf{u}]=\mathbf{u_1} - \mathbf{u_2}$ on the
741 * interface for the shape function
742 * @p interface_dof_index in the quadrature point @p q_point.
743 *
744 * @note The name of the function is supposed to be read as "the jump
745 * (singular) in the values (plural: one or two possible values) of
746 * the shape function (singular)".
747 */
748 value_type
749 jump_in_values(const unsigned int interface_dof_index,
750 const unsigned int q_point) const;
751
752 /**
753 * Return the jump of the gradient (a tensor of rank 2) $\jump{\nabla
754 * \mathbf{u}}$ on the interface for the shape
755 * function @p interface_dof_index in the quadrature point @p q_point.
756 *
757 * @note The name of the function is supposed to be read as "the jump
758 * (singular) in the gradients (plural: one or two possible gradients)
759 * of the shape function (singular)".
760 */
761 gradient_type
762 jump_in_gradients(const unsigned int interface_dof_index,
763 const unsigned int q_point) const;
764
765 /**
766 * The same as above.
767 *
768 * @deprecated Use the average_of_gradients() function instead.
769 */
770 gradient_type
771 jump_gradient(const unsigned int interface_dof_index,
772 const unsigned int q_point) const;
773
774 /**
775 * Return the jump in the gradient $\jump{\nabla u}=\nabla u_{\text{cell0}}
776 * - \nabla u_{\text{cell1}}$ on the interface for the shape function @p
777 * interface_dof_index at the quadrature point @p q_point of
778 * the component selected by this view.
779 *
780 * @note The name of the function is supposed to be read as "the jump
781 * (singular) in the Hessians (plural: one or two possible values
782 * for the second derivative) of the shape function (singular)".
783 */
784 hessian_type
785 jump_in_hessians(const unsigned int interface_dof_index,
786 const unsigned int q_point) const;
787
788 /**
789 * The same as above.
790 *
791 * @deprecated Use the average_of_hessians() function instead.
792 */
793 hessian_type
794 jump_hessian(const unsigned int interface_dof_index,
795 const unsigned int q_point) const;
796
797 /**
798 * Return the jump in the third derivative $\jump{\nabla^3 u} = \nabla^3
799 * u_{\text{cell0}} - \nabla^3 u_{\text{cell1}}$ on the interface for the
800 * shape function @p interface_dof_index at the quadrature point @p q_point of
801 * the component selected by this view.
802 *
803 * @note The name of the function is supposed to be read as "the jump
804 * (singular) in the third derivatives (plural: one or two possible values
805 * for the third derivative) of the shape function (singular)".
806 */
807 third_derivative_type
808 jump_in_third_derivatives(const unsigned int interface_dof_index,
809 const unsigned int q_point) const;
810
811 /** @} */
812
813 /**
814 * @name Access to the average of shape functions and their derivatives
815 */
816 /** @{ */
817
818 /**
819 * Return the average vector $\average{\mathbf{u}}=\frac{1}{2}(\mathbf{u_1}
820 * + \mathbf{u_2})$ on the interface for the shape
821 * function @p interface_dof_index in the quadrature point @p q_point.
822 *
823 * @note The name of the function is supposed to be read as "the average
824 * (singular) of the values (plural: one or two possible values) of
825 * the shape function (singular)".
826 */
827 value_type
828 average_of_values(const unsigned int interface_dof_index,
829 const unsigned int q_point) const;
830
831 /**
832 * Return the average of the gradient (a tensor of rank 2) $\average{\nabla
833 * \mathbf{u}}$ on the interface for the shape
834 * function @p interface_dof_index in the quadrature point @p q_point.
835 *
836 * @note The name of the function is supposed to be read as "the average
837 * (singular) of the gradients (plural: one or two possible values
838 * of the derivative) of the shape function (singular)".
839 */
840 gradient_type
841 average_of_gradients(const unsigned int interface_dof_index,
842 const unsigned int q_point) const;
843
844 /**
845 * Return the average of the Hessian $\average{\nabla^2 u} =
846 * \frac{1}{2}\nabla^2 u_{\text{cell0}} + \frac{1}{2} \nabla^2
847 * u_{\text{cell1}}$ on the interface
848 * for the shape function @p interface_dof_index at the quadrature point @p
849 * q_point of the component selected by this view.
850 *
851 * @note The name of the function is supposed to be read as "the average
852 * (singular) in the Hessians (plural: one or two possible values of
853 * the second derivative) of the shape function (singular)".
854 */
855 hessian_type
856 average_of_hessians(const unsigned int interface_dof_index,
857 const unsigned int q_point) const;
858
859 /**
860 * The same as above.
861 *
862 * @deprecated Use the average_of_hessians() function instead.
863 */
864 hessian_type
865 average_hessian(const unsigned int interface_dof_index,
866 const unsigned int q_point) const;
867
868 /** @} */
869
870 /**
871 * @name Access to values of global finite element fields
872 */
873 /** @{ */
874
875 /**
876 * Return the values of the selected vector component of the finite
877 * element function characterized by <tt>fe_function</tt> at the
878 * quadrature points of the cell interface selected the last time
879 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
880 *
881 * The argument @p here_or_there selects between the value on cell 0 (here, @p true)
882 * and cell 1 (there, @p false). You can also interpret it as "upstream" (@p true)
883 * and "downstream" (@p false) as defined by the direction of the normal
884 * vector in this quadrature point. If @p here_or_there is true, the values
885 * from the first cell of the interface is used.
886 *
887 * The data type stored by the output vector must be what you get when you
888 * multiply the values of shape functions (i.e., @p value_type) times the
889 * type used to store the values of the unknowns $U_j$ of your finite
890 * element vector $U$ (represented by the @p fe_function argument).
891 *
892 * @dealiiRequiresUpdateFlags{update_values}
893 */
894 template <class InputVector>
895 void
896 get_function_values(
897 const bool here_or_there,
898 const InputVector &fe_function,
899 std::vector<solution_value_type<typename InputVector::value_type>>
900 &values) const;
901
902 /**
903 * Same as above, but using a vector of local degree-of-freedom values. In
904 * other words, instead of extracting the nodal values of the degrees of
905 * freedom located on the current cell interface from a global vector
906 * associated with a DoFHandler object (as the function above does), this
907 * function instead takes these local nodal values through its first
908 * argument.
909 *
910 * @param[in] here_or_there Same as the one in the above function.
911 *
912 * @param[in] local_dof_values A vector of local nodal values. This vector
913 * must have a length equal to number of DoFs on the current cell, and
914 * must be ordered in the same order as degrees of freedom are numbered on
915 * the reference cell.
916 *
917 * @param[out] values A vector of values of the given finite element field,
918 * at the quadrature points on the current object.
919 *
920 * @tparam InputVector The @p InputVector type must allow creation
921 * of an ArrayView object from it; this is satisfied by the
922 * `std::vector` class, among others.
923 */
924 template <class InputVector>
925 void
926 get_function_values_from_local_dof_values(
927 const bool here_or_there,
928 const InputVector &local_dof_values,
929 std::vector<solution_value_type<typename InputVector::value_type>>
930 &values) const;
931
932 /** @} */
933
934 /**
935 * @name Access to jumps in global finite element fields
936 */
937 /** @{ */
938
939 /**
940 * Return the jump in the values of the selected vector component of the
941 * finite element function characterized by <tt>fe_function</tt> at the
942 * quadrature points of the cell interface selected the last time
943 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
944 *
945 * The data type stored by the output vector must be what you get when you
946 * multiply the values of shape functions (i.e., @p value_type) times the
947 * type used to store the values of the unknowns $U_j$ of your finite
948 * element vector $U$ (represented by the @p fe_function argument).
949 *
950 * @dealiiRequiresUpdateFlags{update_values}
951 */
952 template <class InputVector>
953 void
954 get_jump_in_function_values(
955 const InputVector &fe_function,
956 std::vector<solution_value_type<typename InputVector::value_type>>
957 &values) const;
958
959 /**
960 * This function relates to get_jump_in_function_values() in the same way
961 * as get_function_values_from_local_dof_values() relates to
962 * get_function_values(). See the documentation of
963 * get_function_values_from_local_dof_values() for more
964 * information.
965 */
966 template <class InputVector>
967 void
968 get_jump_in_function_values_from_local_dof_values(
969 const InputVector &local_dof_values,
970 std::vector<solution_value_type<typename InputVector::value_type>>
971 &values) const;
972
973 /**
974 * Return the jump in the gradients of the selected vector components of the
975 * finite element function characterized by <tt>fe_function</tt> at the
976 * quadrature points of the cell interface selected the last time
977 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
978 *
979 * The data type stored by the output vector must be what you get when you
980 * multiply the gradients of shape functions (i.e., @p gradient_type)
981 * times the type used to store the values of the unknowns $U_j$ of your
982 * finite element vector $U$ (represented by the @p fe_function argument).
983 *
984 * @dealiiRequiresUpdateFlags{update_gradients}
985 */
986 template <class InputVector>
987 void
988 get_jump_in_function_gradients(
989 const InputVector &fe_function,
990 std::vector<solution_gradient_type<typename InputVector::value_type>>
991 &gradients) const;
992
993 /**
994 * This function relates to get_jump_in_function_gradients() in the same way
995 * as get_function_values_from_local_dof_values() relates to
996 * get_function_values(). See the documentation of
997 * get_function_values_from_local_dof_values() for more
998 * information.
999 */
1000 template <class InputVector>
1001 void
1002 get_jump_in_function_gradients_from_local_dof_values(
1003 const InputVector &local_dof_values,
1004 std::vector<solution_gradient_type<typename InputVector::value_type>>
1005 &gradients) const;
1006
1007 /**
1008 * Return the jump in the Hessians of the selected vector component of the
1009 * finite element function characterized by <tt>fe_function</tt> at the
1010 * quadrature points of the cell, face or subface selected the last time
1011 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
1012 *
1013 * The data type stored by the output vector must be what you get when you
1014 * multiply the Hessians of shape functions (i.e., @p hessian_type) times
1015 * the type used to store the values of the unknowns $U_j$ of your finite
1016 * element vector $U$ (represented by the @p fe_function argument).
1017 *
1018 * @dealiiRequiresUpdateFlags{update_hessians}
1019 */
1020 template <class InputVector>
1021 void
1022 get_jump_in_function_hessians(
1023 const InputVector &fe_function,
1024 std::vector<solution_hessian_type<typename InputVector::value_type>>
1025 &hessians) const;
1026
1027 /**
1028 * This function relates to get_jump_in_function_hessians() in the same way
1029 * as get_function_values_from_local_dof_values() relates to
1030 * get_function_values(). See the documentation of
1031 * get_function_values_from_local_dof_values() for more
1032 * information.
1033 */
1034 template <class InputVector>
1035 void
1036 get_jump_in_function_hessians_from_local_dof_values(
1037 const InputVector &local_dof_values,
1038 std::vector<solution_hessian_type<typename InputVector::value_type>>
1039 &hessians) const;
1040
1041 /**
1042 * Return the jump in the third derivatives of the selected vector component
1043 * of the finite element function characterized by <tt>fe_function</tt> at
1044 * the quadrature points of the cell, face or subface selected the last time
1045 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
1046 *
1047 * The data type stored by the output vector must be what you get when you
1048 * multiply the third derivatives of shape functions (i.e., @p
1049 * third_derivative_type) times the type used to store the values of the
1050 * unknowns $U_j$ of your finite element vector $U$ (represented by the @p
1051 * fe_function argument).
1052 *
1053 * @dealiiRequiresUpdateFlags{update_third_derivatives}
1054 */
1055 template <class InputVector>
1056 void
1057 get_jump_in_function_third_derivatives(
1058 const InputVector &fe_function,
1059 std::vector<
1060 solution_third_derivative_type<typename InputVector::value_type>>
1061 &third_derivatives) const;
1062
1063 /**
1064 * This function relates to get_jump_in_function_third_derivatives() in the
1065 * same way as get_function_values_from_local_dof_values() relates
1066 * to get_function_values(). See the documentation of
1067 * get_function_values_from_local_dof_values() for more
1068 * information.
1069 */
1070 template <class InputVector>
1071 void
1072 get_jump_in_function_third_derivatives_from_local_dof_values(
1073 const InputVector &local_dof_values,
1074 std::vector<
1075 solution_third_derivative_type<typename InputVector::value_type>>
1076 &third_derivatives) const;
1077
1078 /** @} */
1079
1080 /**
1081 * @name Access to the average of global finite element fields
1082 */
1083 /** @{ */
1084
1085 /**
1086 * Return the average of the values of the selected vector component of the
1087 * finite element function characterized by <tt>fe_function</tt> at the
1088 * quadrature points of the cell interface selected the last time
1089 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
1090 *
1091 * The data type stored by the output vector must be what you get when you
1092 * multiply the values of shape functions (i.e., @p value_type) times the
1093 * type used to store the values of the unknowns $U_j$ of your finite
1094 * element vector $U$ (represented by the @p fe_function argument).
1095 *
1096 * @dealiiRequiresUpdateFlags{update_values}
1097 */
1098 template <class InputVector>
1099 void
1100 get_average_of_function_values(
1101 const InputVector &fe_function,
1102 std::vector<solution_value_type<typename InputVector::value_type>>
1103 &values) const;
1104
1105 /**
1106 * This function relates to get_average_of_function_values() in the same way
1107 * as get_function_values_from_local_dof_values() relates to
1108 * get_function_values(). See the documentation of
1109 * get_function_values_from_local_dof_values() for more
1110 * information.
1111 */
1112 template <class InputVector>
1113 void
1114 get_average_of_function_values_from_local_dof_values(
1115 const InputVector &local_dof_values,
1116 std::vector<solution_value_type<typename InputVector::value_type>>
1117 &values) const;
1118
1119 /**
1120 * Return the average of the gradients of the selected vector components of
1121 * the finite element function characterized by <tt>fe_function</tt> at the
1122 * quadrature points of the cell interface selected the last time
1123 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
1124 *
1125 * The data type stored by the output vector must be what you get when you
1126 * multiply the gradients of shape functions (i.e., @p gradient_type)
1127 * times the type used to store the values of the unknowns $U_j$ of your
1128 * finite element vector $U$ (represented by the @p fe_function argument).
1129 *
1130 * @dealiiRequiresUpdateFlags{update_gradients}
1131 */
1132 template <class InputVector>
1133 void
1134 get_average_of_function_gradients(
1135 const InputVector &fe_function,
1136 std::vector<solution_gradient_type<typename InputVector::value_type>>
1137 &gradients) const;
1138
1139 /**
1140 * This function relates to get_average_of_function_gradients() in the same
1141 * way as get_function_values_from_local_dof_values() relates to
1142 * get_function_values(). See the documentation of
1143 * get_function_values_from_local_dof_values() for more
1144 * information.
1145 */
1146 template <class InputVector>
1147 void
1148 get_average_of_function_gradients_from_local_dof_values(
1149 const InputVector &local_dof_values,
1150 std::vector<solution_gradient_type<typename InputVector::value_type>>
1151 &gradients) const;
1152
1153 /**
1154 * Return the average of the Hessians of the selected vector component of
1155 * the finite element function characterized by <tt>fe_function</tt> at the
1156 * quadrature points of the cell, face or subface selected the last time
1157 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
1158 *
1159 * The data type stored by the output vector must be what you get when you
1160 * multiply the Hessians of shape functions (i.e., @p hessian_type) times
1161 * the type used to store the values of the unknowns $U_j$ of your finite
1162 * element vector $U$ (represented by the @p fe_function argument).
1163 *
1164 * @dealiiRequiresUpdateFlags{update_hessians}
1165 */
1166 template <class InputVector>
1167 void
1168 get_average_of_function_hessians(
1169 const InputVector &fe_function,
1170 std::vector<solution_hessian_type<typename InputVector::value_type>>
1171 &hessians) const;
1172
1173 /**
1174 * This function relates to get_average_of_function_hessians() in the same
1175 * way as get_function_values_from_local_dof_values() relates to
1176 * get_function_values(). See the documentation of
1177 * get_function_values_from_local_dof_values() for more
1178 * information.
1179 */
1180 template <class InputVector>
1181 void
1182 get_average_of_function_hessians_from_local_dof_values(
1183 const InputVector &local_dof_values,
1184 std::vector<solution_hessian_type<typename InputVector::value_type>>
1185 &hessians) const;
1186
1187 /** @} */
1188
1189 private:
1190 /**
1191 * The extractor for this view.
1192 */
1193 const FEValuesExtractors::Vector extractor;
1194 };
1195 } // namespace FEInterfaceViews
1196
1197
1198 namespace internal
1199 {
1200 namespace FEInterfaceViews
1201 {
1202 /**
1203 * A class whose specialization is used to define what FEInterfaceViews
1204 * object corresponds to the given FEValuesExtractors object.
1205 */
1206 template <int dim, int spacedim, typename Extractor>
1207 struct ViewType
1208 {};
1209
1210 /**
1211 * A class whose specialization is used to define what FEInterfaceViews
1212 * object corresponds to the given FEValuesExtractors object.
1213 *
1214 * When using FEValuesExtractors::Scalar, the corresponding view is an
1215 * FEInterfaceViews::Scalar<dim, spacedim>.
1216 */
1217 template <int dim, int spacedim>
1218 struct ViewType<dim, spacedim, FEValuesExtractors::Scalar>
1219 {
1220 using type = typename dealii::FEInterfaceViews::Scalar<dim, spacedim>;
1221 };
1222
1223 /**
1224 * A class whose specialization is used to define what FEInterfaceViews
1225 * object corresponds to the given FEValuesExtractors object.
1226 *
1227 * When using FEValuesExtractors::Vector, the corresponding view is an
1228 * FEInterfaceViews::Vector<dim, spacedim>.
1229 */
1230 template <int dim, int spacedim>
1231 struct ViewType<dim, spacedim, FEValuesExtractors::Vector>
1232 {
1233 using type = typename dealii::FEInterfaceViews::Vector<dim, spacedim>;
1234 };
1235 } // namespace FEInterfaceViews
1236 } // namespace internal
1237
1238 namespace FEInterfaceViews
1239 {
1240 /**
1241 * A templated alias that associates to a given Extractor class
1242 * the corresponding view in FEInterfaceViews.
1243 */
1244 template <int dim, int spacedim, typename Extractor>
1245 using View = typename dealii::internal::FEInterfaceViews::
1246 ViewType<dim, spacedim, Extractor>::type;
1247 } // namespace FEInterfaceViews
1248
1249
1250
1251 /**
1252 * FEInterfaceValues is a data structure to access and assemble finite element
1253 * data on interfaces between two cells of a mesh.
1254 *
1255 * It provides a way to access averages, jump terms, and similar operations used
1256 * in Discontinuous Galerkin methods on a face between two neighboring cells.
1257 * This allows the computation of typical mesh-dependent linear or bilinear
1258 * forms in a similar way as FEValues does for cells and FEFaceValues does for
1259 * faces. In
1260 * the literature, the faces between neighboring cells are called "inner
1261 * interfaces" or "facets".
1262 *
1263 * Internally, this class provides an abstraction for two FEFaceValues
1264 * objects (or FESubfaceValues when using adaptive refinement). The class
1265 * introduces a new "interface dof index" that walks over
1266 * the union of the dof indices of the two FEFaceValues objects. Helper
1267 * functions allow translating between the new "interface dof index" and the
1268 * corresponding "cell index" (0 for the first cell, 1 for the second cell)
1269 * and "dof index" within that cell.
1270 *
1271 * The class is made to be used inside MeshWorker::mesh_loop(). It is intended
1272 * to be a low level replacement for MeshWorker and LocalIntegrators and a
1273 * higher level abstraction compared to assembling face terms manually.
1274 */
1275 template <int dim, int spacedim = dim>
1276 class FEInterfaceValues
1277 {
1278 public:
1279 /**
1280 * Number of quadrature points.
1281 */
1282 const unsigned int n_quadrature_points;
1283
1284 /**
1285 * Construct the FEInterfaceValues with a single FiniteElement (same on both
1286 * sides of the facet). The FEFaceValues objects will be initialized with
1287 * the given @p mapping, @p quadrature, and @p update_flags.
1288 */
1289 FEInterfaceValues(const Mapping<dim, spacedim> &mapping,
1290 const FiniteElement<dim, spacedim> &fe,
1291 const Quadrature<dim - 1> &quadrature,
1292 const UpdateFlags update_flags);
1293
1294 /**
1295 * The same as above but taking a collection of quadrature rules
1296 * so that different quadrature rules can be assigned to different
1297 * faces.
1298 */
1299 FEInterfaceValues(const Mapping<dim, spacedim> &mapping,
1300 const FiniteElement<dim, spacedim> &fe,
1301 const hp::QCollection<dim - 1> &quadrature,
1302 const UpdateFlags update_flags);
1303
1304 /**
1305 * Construct the FEInterfaceValues with a single FiniteElement and
1306 * a Q1 Mapping.
1307 *
1308 * See the constructor above.
1309 */
1310 FEInterfaceValues(const FiniteElement<dim, spacedim> &fe,
1311 const Quadrature<dim - 1> &quadrature,
1312 const UpdateFlags update_flags);
1313
1314 /**
1315 * Construct the FEInterfaceValues object with different FiniteElements
1316 * assigned to different faces.
1317 */
1318 FEInterfaceValues(
1319 const hp::MappingCollection<dim, spacedim> &mapping_collection,
1320 const hp::FECollection<dim, spacedim> &fe_collection,
1321 const hp::QCollection<dim - 1> &quadrature_collection,
1322 const UpdateFlags update_flags);
1323
1324 /**
1325 * Same as above, but using the default linear mapping.
1326 */
1327 FEInterfaceValues(const hp::FECollection<dim, spacedim> &fe_collection,
1328 const hp::QCollection<dim - 1> &quadrature_collection,
1329 const UpdateFlags update_flags);
1330
1331 /**
1332 * Re-initialize this object to be used on a new interface given by two faces
1333 * of two neighboring cells. The `cell` and `cell_neighbor` cells will be
1334 * referred to through `cell_index` zero and one after this call in all places
1335 * where one needs to identify the two cells adjacent to the interface.
1336 *
1337 * Use numbers::invalid_unsigned_int for @p sub_face_no or @p
1338 * sub_face_no_neighbor to indicate that you want to work on the entire face,
1339 * not a sub-face.
1340 *
1341 * The arguments (including their order) are identical to the @p face_worker
1342 * arguments in MeshWorker::mesh_loop().
1343 *
1344 * In order to do integration on a face or sub-face, this object will have to
1345 * choose what quadrature formula to use. This is simple if you initialized
1346 * the current FEInterfaceValues object with just a single FiniteElement and
1347 * a single (face) Quadrature object, because in that case there is only one
1348 * element and quadrature that will be used for all interfaces. But it is not
1349 * so simple in the hp case where there may be different elements used on
1350 * different cells, and different quadrature formulas should be used on
1351 * different faces; one may also want to use a different mapping for different
1352 * faces. As a consequence, you would have initialized the current object
1353 * with a hp::FECollection, hp::QCollection, and possible an
1354 * hp::MappingCollection object. The question then is: For a given face or
1355 * subface, which quadrature and mapping should be used? The following
1356 * decision tree will then be used:
1357 * -# If the `q_index` and `mapping_index` arguments to this function are
1358 * explicitly specified (rather than leaving them at their default
1359 * values), then these indices will be used to select which element
1360 * of the hp::QCollection and hp::MappingCollection passed to the
1361 * constructor should serve as the quadrature and mapping to be used.
1362 * -# If one of these arguments is left at its default value, then the
1363 * function will need to choose a quadrature and/or mapping that is
1364 * appropriate for the two finite element spaces used on the two cells
1365 * adjacent to the current interface. As the first choice, if the
1366 * quadrature or mapping collection we are considering has only one
1367 * element, then that is clearly the one that should be used.
1368 * -# If the quadrature or mapping collection have multiple elements,
1369 * then we need to dig further. For quadrature objects, we can
1370 * compare whether the two quadrature objects that correspond to
1371 * the `active_fe_index` values of the two adjacent cells are
1372 * identical (i.e., have quadrature points at the same locations,
1373 * and have the same weights). If this is so, then it does not
1374 * matter which one of the two we take, and we choose one or the
1375 * other.
1376 * -# If this has still not helped, we try to find out
1377 * which of the two finite element spaces on the two adjacent cells
1378 * is "larger" (say, if you had used $Q_2$
1379 * and $Q_4$ elements on the two adjacent cells, then the $Q_4$
1380 * element is the larger one); the determination of which space
1381 * is "larger" is made using the hp::FECollection::find_dominated_fe()
1382 * function, which is not necessarily intended for this kind of query,
1383 * but yields a result that serves just fine for our purposes here.
1384 * We then operate on the assumption that the quadrature object
1385 * associated with the "larger" of the two spaces is the appropriate
1386 * one to use for the face that separates these two spaces.
1387 * - If this function returns that one of the two elements in question
1388 * is dominated by the other, then presumably it is "larger" one and
1389 * we take the quadrature formula and mapping that corresponds
1390 * to this "larger" element is. For example, for the $Q_2$ element
1391 * mentioned above, one would generally use a QGauss(3) quadrature
1392 * formula, whereas for the $Q_4$ element, one would use QGauss(5).
1393 * To integrate jump and average terms on the interface between
1394 * cells using these two elements, QGauss(5) is appropriate. Because,
1395 * typically, people will order elements
1396 * in the hp::FECollection in the same order as the quadrature and
1397 * mapping objects in hp::QCollection and hp::MappingCollection, this
1398 * function will use the index of the "larger" element in the
1399 * hp::FECollection to also index into the hp::QCollection and
1400 * hp::MappingCollection to retrieve quadrature and mapping objects
1401 * appropriate for the current face.
1402 * - There are cases where neither element dominates the other. For
1403 * example, if one uses $Q_2\times Q_1$ and $Q_1\times Q_2$ elements on
1404 * neighboring cells, neither of the two spaces dominates the other --
1405 * or, in the context of the current function, neither space is "larger"
1406 * than the other. In that case, there is no way for the current function
1407 * to determine quadrature and mapping objects associated with the two
1408 * elements are the appropriate ones. If that happens, you will get an
1409 * error -- and the only way to avoid the error is to explicitly specify
1410 * for these interfaces which quadrature and mapping objects you want
1411 * to use, by providing non-default values for the @p q_index and
1412 * @p mapping_index arguments to this function.
1413 *
1414 * @param[in] cell An iterator to the first cell adjacent to the interface.
1415 * @param[in] face_no An integer identifying which face of the first cell the
1416 * interface is on.
1417 * @param[in] sub_face_no An integer identifying the subface (child) of the
1418 * face (identified by the previous two arguments) that the interface
1419 * corresponds to. If equal to numbers::invalid_unsigned_int, then the
1420 * interface is considered to be the entire face.
1421 * @param[in] cell_neighbor An iterator to the second cell adjacent to
1422 * the interface. The type of this iterator does not have to equal that
1423 * of `cell`, but must be convertible to it. This allows using an
1424 * active cell iterator for `cell`, and `cell->neighbor(f)` for
1425 * `cell_neighbor`, since the return type of `cell->neighbor(f)` is
1426 * simply a cell iterator (not necessarily an active cell iterator).
1427 * @param[in] face_no_neighbor Like `face_no`, just for the neighboring
1428 * cell.
1429 * @param[in] sub_face_no_neighbor Like `sub_face_no`, just for the
1430 * neighboring cell.
1431 * @param[in] q_index The index of the quadrature object within the
1432 * hp::QCollection passed to the constructor to use on the current
1433 * interface. See the documentation above what happens if this argument
1434 * is not explicitly provided but left at its default value.
1435 * @param[in] mapping_index The index of the mapping object within the
1436 * hp::MappingCollection passed to the constructor to use on the current
1437 * interface. See the documentation above what happens if this argument
1438 * is not explicitly provided but left at its default value.
1439 * @param[in] fe_index If left at its default, use the finite element within
1440 * the hp::FECollection passed to the constructor as given by the dominating
1441 * finite element across the interface (only used if the FEInterface object
1442 * is initialized with an hp::FECollection, an hp::QCollection, and possibly
1443 * an hp::MappingCollection).
1444 * @param[in] fe_index_neighbor Active fe index of neighboring cell. Useful
1445 * if hp capabilities are used and for non-DoFHandler iterators.
1446 */
1447 template <typename CellIteratorType, typename CellNeighborIteratorType>
1448 void
1449 reinit(const CellIteratorType &cell,
1450 const unsigned int face_no,
1451 const unsigned int sub_face_no,
1452 const CellNeighborIteratorType &cell_neighbor,
1453 const unsigned int face_no_neighbor,
1454 const unsigned int sub_face_no_neighbor,
1455 const unsigned int q_index = numbers::invalid_unsigned_int,
1456 const unsigned int mapping_index = numbers::invalid_unsigned_int,
1457 const unsigned int fe_index = numbers::invalid_unsigned_int,
1458 const unsigned int fe_index_neighbor = numbers::invalid_unsigned_int);
1459
1460 /**
1461 * Re-initialize this object to be used on an interface given by a single face
1462 * @p face_no of the cell @p cell. This is useful to use FEInterfaceValues
1463 * on boundaries of the domain.
1464 *
1465 * As a consequence, members like jump() will assume a value of zero for the
1466 * values on the "other" side. Note that no sub_face_number is needed as a
1467 * boundary face can not neighbor a finer cell.
1468 *
1469 * After calling this function at_boundary() will return true.
1470 *
1471 * @param[in] cell An iterator to the first cell adjacent to the interface.
1472 * @param[in] face_no An integer identifying which face of the first cell the
1473 * interface is on.
1474 * @param[in] q_index This argument selects which quadrature formula to use
1475 * See the discussion in the documentation of the other reinit() function
1476 * for what happens when this argument is left at its default value.
1477 * @param[in] mapping_index This argument selects which mapping to use
1478 * See the discussion in the documentation of the other reinit() function
1479 * for what happens when this argument is left at its default value.
1480 * @param[in] fe_index If left at its default, use the finite element within
1481 * the hp::FECollection passed to the constructor as given by the dominating
1482 * finite element across the interface (only used if the FEInterface object
1483 * is initialized with an hp::FECollection, an hp::QCollection, and possibly
1484 * an hp::MappingCollection).
1485 */
1486 template <typename CellIteratorType>
1487 void
1488 reinit(const CellIteratorType &cell,
1489 const unsigned int face_no,
1490 const unsigned int q_index = numbers::invalid_unsigned_int,
1491 const unsigned int mapping_index = numbers::invalid_unsigned_int,
1492 const unsigned int fe_index = numbers::invalid_unsigned_int);
1493
1494 /**
1495 * Return a reference to the FEFaceValues or FESubfaceValues object
1496 * of the specified cell of the interface.
1497 *
1498 * The @p cell_index is either 0 or 1 and corresponds to the cell index
1499 * returned by interface_dof_to_cell_and_dof_index().
1500 */
1501 const FEFaceValuesBase<dim, spacedim> &
1502 get_fe_face_values(const unsigned int cell_index) const;
1503
1504 /**
1505 * Constant reference to the selected mapping object.
1506 */
1507 const Mapping<dim, spacedim> &
1508 get_mapping() const;
1509
1510 /**
1511 * Constant reference to the selected finite element object.
1512 */
1513 const FiniteElement<dim, spacedim> &
1514 get_fe() const;
1515
1516 /**
1517 * Return a reference to the quadrature object in use.
1518 */
1519 const Quadrature<dim - 1> &
1520 get_quadrature() const;
1521
1522 /**
1523 * Return a reference to the used mapping.
1524 */
1525 const hp::MappingCollection<dim, spacedim> &
1526 get_mapping_collection() const;
1527
1528 /**
1529 * Return a reference to the selected finite element object.
1530 */
1531 const hp::FECollection<dim, spacedim> &
1532 get_fe_collection() const;
1533
1534 /**
1535 * Return a reference to the face quadrature object in use.
1536 */
1537 const hp::QCollection<dim - 1> &
1538 get_quadrature_collection() const;
1539
1540 /**
1541 * Returns a boolean indicating whether or not this FEInterfaceValues object
1542 * has hp-capabilities enabled.
1543 */
1544 bool
1545 has_hp_capabilities() const;
1546
1547 /**
1548 * Return the update flags set.
1549 */
1550 UpdateFlags
1551 get_update_flags() const;
1552
1553 /**
1554 * Return a triangulation iterator to the current cell of the interface.
1555 *
1556 * The @p cell_index is either 0 or 1 and corresponds to the cell index
1557 * returned by interface_dof_to_cell_and_dof_index().
1558 */
1559 typename Triangulation<dim, spacedim>::cell_iterator
1560 get_cell(const unsigned int cell_index) const;
1561
1562 /**
1563 * Return the number of the face on the interface selected the last time
1564 * the reinit() function was called.
1565 *
1566 * The @p cell_index is either 0 or 1 and corresponds to the cell index
1567 * returned by interface_dof_to_cell_and_dof_index().
1568 */
1569 unsigned int
1570 get_face_number(const unsigned int cell_index) const;
1571
1572 /**
1573 * @name Functions to query information on a given interface
1574 * @{
1575 */
1576
1577 /**
1578 * Return if the current interface is a boundary face or an internal
1579 * face with two adjacent cells.
1580 *
1581 * See the corresponding reinit() functions for details.
1582 */
1583 bool
1584 at_boundary() const;
1585
1586 /**
1587 * Mapped quadrature weight. This value equals the
1588 * mapped surface element times the weight of the quadrature
1589 * point.
1590 *
1591 * You can think of the quantity returned by this function as the
1592 * surface element $ds$ in the integral that we implement here by
1593 * quadrature.
1594 *
1595 * @dealiiRequiresUpdateFlags{update_JxW_values}
1596 */
1597 double
1598 JxW(const unsigned int quadrature_point) const;
1599
1600 /**
1601 * Return the vector of JxW values for each quadrature point.
1602 *
1603 * @dealiiRequiresUpdateFlags{update_JxW_values}
1604 */
1605 const std::vector<double> &
1606 get_JxW_values() const;
1607
1608 /**
1609 * Return the normal in a given quadrature point.
1610 *
1611 * The normal points in outwards direction as seen from the first cell of
1612 * this interface.
1613 *
1614 * @deprecated Use the function normal_vector().
1615 *
1616 * @dealiiRequiresUpdateFlags{update_normal_vectors}
1617 */
1618 DEAL_II_DEPRECATED_EARLY_WITH_COMMENT("Use the function normal_vector().")
1619 Tensor<1, spacedim>
1620 normal(const unsigned int q_point_index) const;
1621
1622 /**
1623 * Return the normal in a given quadrature point.
1624 *
1625 * The normal points in outwards direction as seen from the first cell of
1626 * this interface.
1627 *
1628 * @dealiiRequiresUpdateFlags{update_normal_vectors}
1629 */
1630 Tensor<1, spacedim>
1631 normal_vector(const unsigned int q_point_index) const;
1632
1633 /**
1634 * Return the normal vector of the interface in each quadrature point.
1635 *
1636 * The return value is identical to get_fe_face_values(0).get_normal_vectors()
1637 * and therefore, are outside normal vectors from the perspective of the
1638 * first cell of this interface.
1639 *
1640 * @dealiiRequiresUpdateFlags{update_normal_vectors}
1641 */
1642 const std::vector<Tensor<1, spacedim>> &
1643 get_normal_vectors() const;
1644
1645 /**
1646 * Return an object that can be thought of as an array containing all
1647 * indices from zero to `n_quadrature_points`. This allows to write code
1648 * using range-based `for` loops.
1649 *
1650 * @see CPP11
1651 */
1652 std_cxx20::ranges::iota_view<unsigned int, unsigned int>
1653 quadrature_point_indices() const;
1654
1655 /**
1656 * Return the location of the <tt>q_point</tt>th quadrature point in
1657 * real space.
1658 *
1659 * @dealiiRequiresUpdateFlags{update_quadrature_points}
1660 */
1661 const Point<spacedim> &
1662 quadrature_point(const unsigned int q_point) const;
1663
1664 /**
1665 * Return a reference to the quadrature points in real space.
1666 *
1667 * @dealiiRequiresUpdateFlags{update_quadrature_points}
1668 */
1669 const std::vector<Point<spacedim>> &
1670 get_quadrature_points() const;
1671
1672 /**
1673 * Return the number of DoFs (or shape functions) on the current interface.
1674 *
1675 * @note This number is only available after a call to reinit() and can change
1676 * from one call to reinit() to the next. For example, on a boundary interface
1677 * it is equal to the number of dofs of the single FEFaceValues object, while
1678 * it is twice that for an interior interface for a DG element. For a
1679 * continuous element, it is slightly smaller because the two cells on the
1680 * interface share some of the dofs.
1681 */
1682 unsigned
1683 n_current_interface_dofs() const;
1684
1685 /**
1686 * Return an object that can be thought of as an array containing all
1687 * indices from zero (inclusive) to `n_current_interface_dofs()` (exclusive).
1688 * This allows one to write code using range-based `for` loops of the
1689 * following kind:
1690 * @code
1691 * FEInterfaceValues<dim> fe_iv (...);
1692 * FullMatrix<double> cell_matrix (...);
1693 *
1694 * for (auto &cell : dof_handler.active_cell_iterators())
1695 * {
1696 * cell_matrix = 0;
1697 * for (const auto &face : cell->face_iterators())
1698 * {
1699 * fe_iv.values.reinit(cell, face, ...);
1700 * for (const auto q : fe_iv.quadrature_point_indices())
1701 * for (const auto i : fe_iv.dof_indices())
1702 * for (const auto j : fe_iv.dof_indices())
1703 * cell_matrix(i,j) += ...; // Do something for DoF indices
1704 * // (i,j) at quadrature point q
1705 * }
1706 * }
1707 * @endcode
1708 * Here, we are looping over all degrees of freedom on all cell interfaces,
1709 * with `i` and `j` taking on all valid indices for interface degrees of
1710 * freedom, as defined by the finite element passed to `fe_iv`.
1711 */
1712 std_cxx20::ranges::iota_view<unsigned int, unsigned int>
1713 dof_indices() const;
1714
1715 /**
1716 * Return the set of joint DoF indices. This includes indices from both cells.
1717 * If reinit was called with an active cell iterator, the indices are based
1718 * on the active indices (returned by `DoFCellAccessor::get_dof_indices()` ),
1719 * in case of level cell (that is, if is_level_cell() return true )
1720 * the mg dof indices are returned.
1721 *
1722 * @note This function is only available after a call to reinit() and can
1723 * change from one call to reinit() to the next.
1724 */
1725 std::vector<types::global_dof_index>
1726 get_interface_dof_indices() const;
1727
1728 /**
1729 * Convert an interface dof index into the corresponding local DoF indices of
1730 * the two cells. If an interface DoF is only active on one of the
1731 * cells, the other index will be numbers::invalid_unsigned_int.
1732 *
1733 * For discontinuous finite elements, each interface dof is located on exactly
1734 * one side of the interface and, consequently, only one of the two values
1735 * returned is valid (i.e., different from numbers::invalid_unsigned_int).
1736 *
1737 * @note This function is only available after a call to reinit() and the
1738 * returned values may change from one call to reinit() to the next.
1739 */
1740 std::array<unsigned int, 2>
1741 interface_dof_to_dof_indices(const unsigned int interface_dof_index) const;
1742
1743 /**
1744 * @}
1745 */
1746
1747 /**
1748 * @name Access to shape functions and their derivatives
1749 * @{
1750 */
1751
1752 /**
1753 * Return component @p component of the value of the shape function
1754 * with interface dof index @p interface_dof_index in
1755 * quadrature point @p q_point.
1756 *
1757 * The argument @p here_or_there selects between the value on cell 0 (here, @p true)
1758 * and cell 1 (there, @p false). You can also interpret it as "upstream" (@p true)
1759 * and "downstream" (@p false) as defined by the direction of the normal
1760 * vector
1761 * in this quadrature point. If @p here_or_there is true, the shape
1762 * functions from the first cell of the interface is used.
1763 *
1764 * In other words, this function returns the limit of the value of the shape
1765 * function in the given quadrature point when approaching it from one of the
1766 * two cells of the interface.
1767 *
1768 * @note This function is typically used to pick the upstream or downstream
1769 * value based on a direction. This can be achieved by using
1770 * <code>(direction * normal)>0</code> as the first argument of this
1771 * function.
1772 */
1773 double
1774 shape_value(const bool here_or_there,
1775 const unsigned int interface_dof_index,
1776 const unsigned int q_point,
1777 const unsigned int component = 0) const;
1778
1779 /**
1780 * Return component @p component of the gradient of the shape function
1781 * with interface dof index @p interface_dof_index in
1782 * quadrature point @p q_point.
1783 *
1784 * Similar to @p shape_value() , the argument @p here_or_there selects between
1785 * the gradient on cell 0 (here, @p true) and cell 1 (there, @p false)
1786 * at this quadrature point.
1787 */
1788 Tensor<1, spacedim>
1789 shape_grad(const bool here_or_there,
1790 const unsigned int interface_dof_index,
1791 const unsigned int q_point,
1792 const unsigned int component = 0) const;
1793
1794 /**
1795 * @}
1796 */
1797
1798 /**
1799 * @name Access to jumps in shape function values and their derivatives
1800 * @{
1801 */
1802
1803 /**
1804 * Return the jump $\jump{u}=u_{\text{cell0}} - u_{\text{cell1}}$ on the
1805 * interface
1806 * for the shape function @p interface_dof_index at the quadrature point
1807 * @p q_point of component @p component.
1808 *
1809 * Note that one can define the jump in
1810 * different ways (the value "there" minus the value "here", or the other way
1811 * around; both are used in the finite element literature). The definition
1812 * here uses "value here minus value there", as seen from the first cell.
1813 *
1814 * If this is a boundary face (at_boundary() returns true), then
1815 * $\jump{u}=u_{\text{cell0}}$, that is "the value here (minus zero)".
1816 *
1817 * @note The name of the function is supposed to be read as "the jump
1818 * (singular) in the values (plural: one or two possible values)
1819 * of the shape function (singular)".
1820 */
1821 double
1822 jump_in_shape_values(const unsigned int interface_dof_index,
1823 const unsigned int q_point,
1824 const unsigned int component = 0) const;
1825
1826 /**
1827 * Return the jump in the gradient $\jump{\nabla u}=\nabla u_{\text{cell0}} -
1828 * \nabla u_{\text{cell1}}$ on the interface for the shape function @p
1829 * interface_dof_index at the quadrature point @p q_point of component @p
1830 * component.
1831 *
1832 * If this is a boundary face (at_boundary() returns true), then
1833 * $\jump{\nabla u}=\nabla u_{\text{cell0}}$.
1834 *
1835 * @note The name of the function is supposed to be read as "the jump
1836 * (singular) in the gradients (plural: one or two possible gradients)
1837 * of the shape function (singular)".
1838 */
1839 Tensor<1, spacedim>
1840 jump_in_shape_gradients(const unsigned int interface_dof_index,
1841 const unsigned int q_point,
1842 const unsigned int component = 0) const;
1843
1844 /**
1845 * Return the jump in the Hessian $\jump{\nabla^2 u} = \nabla^2
1846 * u_{\text{cell0}} - \nabla^2 u_{\text{cell1}}$ on the interface for the
1847 * shape function
1848 * @p interface_dof_index at the quadrature point @p q_point of component
1849 * @p component.
1850 *
1851 * If this is a boundary face (at_boundary() returns true), then
1852 * $\jump{\nabla^2 u} = \nabla^2 u_{\text{cell0}}$.
1853 *
1854 * @note The name of the function is supposed to be read as "the jump
1855 * (singular) in the Hessians (plural: one or two possible values
1856 * for the derivative) of the shape function (singular)".
1857 */
1858 Tensor<2, spacedim>
1859 jump_in_shape_hessians(const unsigned int interface_dof_index,
1860 const unsigned int q_point,
1861 const unsigned int component = 0) const;
1862
1863 /**
1864 * Return the jump in the third derivative $\jump{\nabla^3 u} = \nabla^3
1865 * u_{\text{cell0}} - \nabla^3 u_{\text{cell1}}$ on the interface for the
1866 * shape function @p interface_dof_index at the quadrature point @p q_point of
1867 * component @p component.
1868 *
1869 * If this is a boundary face (at_boundary() returns true), then
1870 * $\jump{\nabla^3 u} = \nabla^3 u_{\text{cell0}}$.
1871 *
1872 * @note The name of the function is supposed to be read as "the jump
1873 * (singular) in the third derivatives (plural: one or two possible values
1874 * for the derivative) of the shape function (singular)".
1875 */
1876 Tensor<3, spacedim>
1877 jump_in_shape_3rd_derivatives(const unsigned int interface_dof_index,
1878 const unsigned int q_point,
1879 const unsigned int component = 0) const;
1880
1881 /**
1882 * @}
1883 */
1884
1885 /**
1886 * @name Access to the average of shape function values and their derivatives
1887 * @{
1888 */
1889
1890 /**
1891 * Return the average $\average{u}=\frac{1}{2}u_{\text{cell0}} +
1892 * \frac{1}{2}u_{\text{cell1}}$ on the interface
1893 * for the shape function @p interface_dof_index at the quadrature point
1894 * @p q_point of component @p component.
1895 *
1896 * If this is a boundary face (at_boundary() returns true), then
1897 * $\average{u}=u_{\text{cell0}}$.
1898 *
1899 * @note The name of the function is supposed to be read as "the average
1900 * (singular) of the values (plural: one or two possible values)
1901 * of the shape function (singular)".
1902 */
1903 double
1904 average_of_shape_values(const unsigned int interface_dof_index,
1905 const unsigned int q_point,
1906 const unsigned int component = 0) const;
1907
1908 /**
1909 * Return the average of the gradient $\average{\nabla u} = \frac{1}{2}\nabla
1910 * u_{\text{cell0}} + \frac{1}{2} \nabla u_{\text{cell1}}$ on the interface
1911 * for the shape function @p interface_dof_index at the quadrature point @p
1912 * q_point of component @p component.
1913 *
1914 * If this is a boundary face (at_boundary() returns true), then
1915 * $\average{\nabla u}=\nabla u_{\text{cell0}}$.
1916 *
1917 * @note The name of the function is supposed to be read as "the average
1918 * (singular) of the gradients (plural: one or two possible values
1919 * for the gradient) of the shape function (singular)".
1920 */
1921 Tensor<1, spacedim>
1922 average_of_shape_gradients(const unsigned int interface_dof_index,
1923 const unsigned int q_point,
1924 const unsigned int component = 0) const;
1925
1926 /**
1927 * Return the average of the Hessian $\average{\nabla^2 u} =
1928 * \frac{1}{2}\nabla^2 u_{\text{cell0}} + \frac{1}{2} \nabla^2
1929 * u_{\text{cell1}}$ on the interface
1930 * for the shape function @p interface_dof_index at the quadrature point @p
1931 * q_point of component @p component.
1932 *
1933 * If this is a boundary face (at_boundary() returns true), then
1934 * $\average{\nabla^2 u}=\nabla^2 u_{\text{cell0}}$.
1935 *
1936 * @note The name of the function is supposed to be read as "the average
1937 * (singular) of the Hessians (plural: one or two possible values
1938 * for the second derivatives) of the shape function (singular)".
1939 */
1940 Tensor<2, spacedim>
1941 average_of_shape_hessians(const unsigned int interface_dof_index,
1942 const unsigned int q_point,
1943 const unsigned int component = 0) const;
1944
1945 /**
1946 * @}
1947 */
1948
1949
1950
1951 /**
1952 * @name Access to jumps in the function values and derivatives
1953 * @{
1954 */
1955
1956 /**
1957 * Return the jump in the values of the
1958 * finite element function characterized by <tt>fe_function</tt> at the
1959 * quadrature points of the cell interface selected the last time
1960 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
1961 *
1962 * @dealiiRequiresUpdateFlags{update_values}
1963 */
1964 template <class InputVector>
1965 void
1966 get_jump_in_function_values(
1967 const InputVector &fe_function,
1968 std::vector<typename InputVector::value_type> &values) const;
1969
1970 /**
1971 * Return the jump in the gradients of the
1972 * finite element function characterized by <tt>fe_function</tt> at the
1973 * quadrature points of the cell interface selected the last time
1974 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
1975 *
1976 * @dealiiRequiresUpdateFlags{update_gradients}
1977 */
1978 template <class InputVector>
1979 void
1980 get_jump_in_function_gradients(
1981 const InputVector &fe_function,
1982 std::vector<Tensor<1, spacedim, typename InputVector::value_type>>
1983 &gradients) const;
1984
1985 /**
1986 * Return the jump in the Hessians of the
1987 * finite element function characterized by <tt>fe_function</tt> at the
1988 * quadrature points of the cell interface selected the last time
1989 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
1990 * @dealiiRequiresUpdateFlags{update_hessians}
1991 */
1992 template <class InputVector>
1993 void
1994 get_jump_in_function_hessians(
1995 const InputVector &fe_function,
1996 std::vector<Tensor<2, spacedim, typename InputVector::value_type>>
1997 &hessians) const;
1998
1999 /**
2000 * Return the jump in the third derivatives of the
2001 * finite element function characterized by <tt>fe_function</tt> at
2002 * the quadrature points of the cell interface selected the last time
2003 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
2004 *
2005 * @dealiiRequiresUpdateFlags{update_third_derivatives}
2006 */
2007 template <class InputVector>
2008 void
2009 get_jump_in_function_third_derivatives(
2010 const InputVector &fe_function,
2011 std::vector<Tensor<3, spacedim, typename InputVector::value_type>>
2012 &third_derivatives) const;
2013
2014 /** @} */
2015
2016 /**
2017 * @name Access to the average of the function values and derivatives
2018 */
2019 /** @{ */
2020
2021 /**
2022 * Return the average of the values of the
2023 * finite element function characterized by <tt>fe_function</tt> at the
2024 * quadrature points of the cell interface selected the last time
2025 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
2026 *
2027 * @dealiiRequiresUpdateFlags{update_values}
2028 */
2029 template <class InputVector>
2030 void
2031 get_average_of_function_values(
2032 const InputVector &fe_function,
2033 std::vector<typename InputVector::value_type> &values) const;
2034
2035 /**
2036 * Return the average of the gradients of the
2037 * finite element function characterized by <tt>fe_function</tt> at the
2038 * quadrature points of the cell interface selected the last time
2039 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
2040 * @dealiiRequiresUpdateFlags{update_gradients}
2041 */
2042 template <class InputVector>
2043 void
2044 get_average_of_function_gradients(
2045 const InputVector &fe_function,
2046 std::vector<Tensor<1, spacedim, typename InputVector::value_type>>
2047 &gradients) const;
2048
2049 /**
2050 * Return the average of the Hessians of the
2051 * finite element function characterized by <tt>fe_function</tt> at the
2052 * quadrature points of the cell interface selected the last time
2053 * the <tt>reinit</tt> function of the FEInterfaceValues object was called.
2054 * @dealiiRequiresUpdateFlags{update_hessians}
2055 */
2056 template <class InputVector>
2057 void
2058 get_average_of_function_hessians(
2059 const InputVector &fe_function,
2060 std::vector<Tensor<2, spacedim, typename InputVector::value_type>>
2061 &hessians) const;
2062
2063 /**
2064 * @}
2065 */
2066
2067
2068
2069 /**
2070 * @name Extractors Methods to extract individual components
2071 * @{
2072 */
2073
2074 /**
2075 * Create a view of the current FEInterfaceValues object that represents a
2076 * particular scalar component of the possibly vector-valued finite element.
2077 * The concept of views is explained in the documentation of the namespace
2078 * FEValuesViews.
2079 */
2080 FEInterfaceViews::Scalar<dim, spacedim>
2081 operator[](const FEValuesExtractors::Scalar &scalar) const;
2082
2083 /**
2084 * Create a view of the current FEInterfaceValues object that represents a set
2085 * of <code>dim</code> scalar components (i.e. a vector) of the vector-valued
2086 * finite element. The concept of views is explained in the documentation of
2087 * the namespace FEValuesViews.
2088 */
2089 FEInterfaceViews::Vector<dim, spacedim>
2090 operator[](const FEValuesExtractors::Vector &vector) const;
2091
2092 /**
2093 * @}
2094 */
2095
2096 private:
2097 /**
2098 * The list of DoF indices for the current interface, filled in reinit().
2099 */
2100 std::vector<types::global_dof_index> interface_dof_indices;
2101
2102 /**
2103 * The mapping from interface dof to the two local dof indices of the
2104 * FEFaceValues objects. If an interface DoF is only active on one of the
2105 * cells, the other one will have numbers::invalid_unsigned_int.
2106 */
2107 std::vector<std::array<unsigned int, 2>> dofmap;
2108
2109 /**
2110 * Pointer to internal_fe_face_values or internal_fe_subface_values,
2111 * respectively as determined in reinit().
2112 */
2113 FEFaceValuesBase<dim, spacedim> *fe_face_values;
2114
2115 /**
2116 * Pointer to internal_fe_face_values_neighbor,
2117 * internal_fe_subface_values_neighbor, or nullptr, respectively
2118 * as determined in reinit().
2119 */
2120 FEFaceValuesBase<dim, spacedim> *fe_face_values_neighbor;
2121
2122 /**
2123 * @name Data that supports the standard FE implementation
2124 */
2125 /** @{ */ // non-hp data
2126
2127 /**
2128 * The FEFaceValues object for the current cell.
2129 */
2130 std::unique_ptr<FEFaceValues<dim, spacedim>> internal_fe_face_values;
2131
2132 /**
2133 * The FEFaceValues object for the current cell if the cell is refined.
2134 */
2135 std::unique_ptr<FESubfaceValues<dim, spacedim>> internal_fe_subface_values;
2136
2137 /**
2138 * The FEFaceValues object for the neighboring cell.
2139 */
2140 std::unique_ptr<FEFaceValues<dim, spacedim>> internal_fe_face_values_neighbor;
2141
2142 /**
2143 * The FEFaceValues object for the neighboring cell if the cell is refined.
2144 */
2145 std::unique_ptr<FESubfaceValues<dim, spacedim>>
2146 internal_fe_subface_values_neighbor;
2147
2148 /** @} */ // non-hp data
2149
2150 /**
2151 * @name Data that supports the hp-FE implementation
2152 */
2153 /** @{ */ // hp data
2154
2155 /**
2156 * An hp::FEValues object for the FEFaceValues on the
2157 * present cell.
2158 */
2159 std::unique_ptr<hp::FEFaceValues<dim, spacedim>> internal_hp_fe_face_values;
2160
2161 /**
2162 * An hp::FEValues object for the FESubfaceValues on the
2163 * present cell.
2164 */
2165 std::unique_ptr<hp::FESubfaceValues<dim, spacedim>>
2166 internal_hp_fe_subface_values;
2167
2168 /**
2169 * An hp::FEValues object for the FEFaceValues on the
2170 * neighbor of the present cell.
2171 */
2172 std::unique_ptr<hp::FEFaceValues<dim, spacedim>>
2173 internal_hp_fe_face_values_neighbor;
2174
2175 /**
2176 * An hp::FEValues object for the FESubfaceValues on the
2177 * neighboring cell.
2178 */
2179 std::unique_ptr<hp::FESubfaceValues<dim, spacedim>>
2180 internal_hp_fe_subface_values_neighbor;
2181
2182 /**
2183 * Exception used when a certain feature doesn't make sense when
2184 * FEInterfaceValues does has hp-capabilities enabled.
2185 *
2186 * @ingroup Exceptions
2187 */
2188 DeclExceptionMsg(ExcOnlyAvailableWithoutHP,
2189 "The current function doesn't make sense when used with a "
2190 "FEInterfaceValues object with hp-capabilities.");
2191
2192 /**
2193 * Exception used when a certain feature doesn't make sense when
2194 * FEInterfaceValues does not have hp-capabilities enabled.
2195 *
2196 * @ingroup Exceptions
2197 */
2198 DeclExceptionMsg(ExcOnlyAvailableWithHP,
2199 "The current function doesn't make sense when used with a "
2200 "FEInterfaceValues object without hp-capabilities.");
2201
2202 /** @} */ // hp data
2203
2204 /*
2205 * Make the view classes friends of this class, since they
2206 * access internal data.
2207 */
2208 template <int, int>
2209 friend class FEInterfaceViews::Scalar;
2210 template <int, int>
2211 friend class FEInterfaceViews::Vector;
2212 };
2213
2214
2215
2216 #ifndef DOXYGEN
2217
2218 /*---------------------- Inline functions ---------------------*/
2219
2220 template <int dim, int spacedim>
2221 FEInterfaceValues<dim, spacedim>::FEInterfaceValues(
2222 const Mapping<dim, spacedim> &mapping,
2223 const FiniteElement<dim, spacedim> &fe,
2224 const Quadrature<dim - 1> &quadrature,
2225 const UpdateFlags update_flags)
2226 : n_quadrature_points(quadrature.size())
2227 , fe_face_values(nullptr)
2228 , fe_face_values_neighbor(nullptr)
2229 , internal_fe_face_values(
2230 std::make_unique<FEFaceValues<dim, spacedim>>(mapping,
2231 fe,
2232 quadrature,
2233 update_flags))
2234 , internal_fe_subface_values(
2235 std::make_unique<FESubfaceValues<dim, spacedim>>(mapping,
2236 fe,
2237 quadrature,
2238 update_flags))
2239 , internal_fe_face_values_neighbor(
2240 std::make_unique<FEFaceValues<dim, spacedim>>(mapping,
2241 fe,
2242 quadrature,
2243 update_flags))
2244 , internal_fe_subface_values_neighbor(
2245 std::make_unique<FESubfaceValues<dim, spacedim>>(mapping,
2246 fe,
2247 quadrature,
2248 update_flags))
2249 {}
2250
2251
2252
2253 template <int dim, int spacedim>
2254 FEInterfaceValues<dim, spacedim>::FEInterfaceValues(
2255 const FiniteElement<dim, spacedim> &fe,
2256 const Quadrature<dim - 1> &quadrature,
2257 const UpdateFlags update_flags)
2258 : FEInterfaceValues(
2259 fe.reference_cell().template get_default_linear_mapping<dim, spacedim>(),
2260 fe,
2261 quadrature,
2262 update_flags)
2263 {}
2264
2265
2266
2267 template <int dim, int spacedim>
2268 FEInterfaceValues<dim, spacedim>::FEInterfaceValues(
2269 const Mapping<dim, spacedim> &mapping,
2270 const FiniteElement<dim, spacedim> &fe,
2271 const hp::QCollection<dim - 1> &quadrature,
2272 const UpdateFlags update_flags)
2273 : n_quadrature_points(quadrature.max_n_quadrature_points())
2274 , fe_face_values(nullptr)
2275 , fe_face_values_neighbor(nullptr)
2276 , internal_fe_face_values(
2277 std::make_unique<FEFaceValues<dim, spacedim>>(mapping,
2278 fe,
2279 quadrature,
2280 update_flags))
2281 , internal_fe_subface_values(
2282 std::make_unique<FESubfaceValues<dim, spacedim>>(mapping,
2283 fe,
2284 quadrature,
2285 update_flags))
2286 , internal_fe_face_values_neighbor(
2287 std::make_unique<FEFaceValues<dim, spacedim>>(mapping,
2288 fe,
2289 quadrature[0],
2290 update_flags))
2291 , internal_fe_subface_values_neighbor(
2292 std::make_unique<FESubfaceValues<dim, spacedim>>(mapping,
2293 fe,
2294 quadrature[0],
2295 update_flags))
2296 {}
2297
2298
2299
2300 template <int dim, int spacedim>
2301 FEInterfaceValues<dim, spacedim>::FEInterfaceValues(
2302 const hp::MappingCollection<dim, spacedim> &mapping_collection,
2303 const hp::FECollection<dim, spacedim> &fe_collection,
2304 const hp::QCollection<dim - 1> &quadrature_collection,
2305 const UpdateFlags update_flags)
2306 : n_quadrature_points(quadrature_collection.max_n_quadrature_points())
2307 , fe_face_values(nullptr)
2308 , fe_face_values_neighbor(nullptr)
2309 , internal_hp_fe_face_values(
2310 std::make_unique<hp::FEFaceValues<dim, spacedim>>(mapping_collection,
2311 fe_collection,
2312 quadrature_collection,
2313 update_flags))
2314 , internal_hp_fe_subface_values(
2315 std::make_unique<hp::FESubfaceValues<dim, spacedim>>(
2316 mapping_collection,
2317 fe_collection,
2318 quadrature_collection,
2319 update_flags))
2320 , internal_hp_fe_face_values_neighbor(
2321 std::make_unique<hp::FEFaceValues<dim, spacedim>>(mapping_collection,
2322 fe_collection,
2323 quadrature_collection,
2324 update_flags))
2325 , internal_hp_fe_subface_values_neighbor(
2326 std::make_unique<hp::FESubfaceValues<dim, spacedim>>(
2327 mapping_collection,
2328 fe_collection,
2329 quadrature_collection,
2330 update_flags))
2331 {
2332 AssertDimension(dim, spacedim);
2333 }
2334
2335
2336
2337 template <int dim, int spacedim>
2338 FEInterfaceValues<dim, spacedim>::FEInterfaceValues(
2339 const hp::FECollection<dim, spacedim> &fe_collection,
2340 const hp::QCollection<dim - 1> &quadrature_collection,
2341 const UpdateFlags update_flags)
2342 : FEInterfaceValues(fe_collection.get_reference_cell_default_linear_mapping(),
2343 fe_collection,
2344 quadrature_collection,
2345 update_flags)
2346 {}
2347
2348
2349
2350 template <int dim, int spacedim>
2351 template <typename CellIteratorType, typename CellNeighborIteratorType>
2352 void
2353 FEInterfaceValues<dim, spacedim>::reinit(
2354 const CellIteratorType &cell,
2355 const unsigned int face_no,
2356 const unsigned int sub_face_no,
2357 const CellNeighborIteratorType &cell_neighbor,
2358 const unsigned int face_no_neighbor,
2359 const unsigned int sub_face_no_neighbor,
2360 const unsigned int q_index,
2361 const unsigned int mapping_index,
2362 const unsigned int fe_index_in,
2363 const unsigned int fe_index_neighbor_in)
2364 {
2365 Assert(internal_fe_face_values || internal_hp_fe_face_values,
2366 ExcNotInitialized());
2367
2368 constexpr bool is_dof_cell_accessor =
2369 std::is_same_v<DoFCellAccessor<dim, spacedim, true>,
2370 typename CellIteratorType::AccessorType> ||
2371 std::is_same_v<DoFCellAccessor<dim, spacedim, false>,
2372 typename CellIteratorType::AccessorType>;
2373
2374 constexpr bool is_dof_cell_accessor_neighbor =
2375 std::is_same_v<DoFCellAccessor<dim, spacedim, true>,
2376 typename CellNeighborIteratorType::AccessorType> ||
2377 std::is_same_v<DoFCellAccessor<dim, spacedim, false>,
2378 typename CellNeighborIteratorType::AccessorType>;
2379
2380 unsigned int active_fe_index = 0;
2381 unsigned int active_fe_index_neighbor = 0;
2382
2383 if (internal_fe_face_values)
2384 {
2385 if (sub_face_no == numbers::invalid_unsigned_int)
2386 {
2387 internal_fe_face_values->reinit(cell, face_no);
2388 fe_face_values = internal_fe_face_values.get();
2389 }
2390 else
2391 {
2392 internal_fe_subface_values->reinit(cell, face_no, sub_face_no);
2393 fe_face_values = internal_fe_subface_values.get();
2394 }
2395 if (sub_face_no_neighbor == numbers::invalid_unsigned_int)
2396 {
2397 internal_fe_face_values_neighbor->reinit(cell_neighbor,
2398 face_no_neighbor);
2399 fe_face_values_neighbor = internal_fe_face_values_neighbor.get();
2400 }
2401 else
2402 {
2403 internal_fe_subface_values_neighbor->reinit(cell_neighbor,
2404 face_no_neighbor,
2405 sub_face_no_neighbor);
2406 fe_face_values_neighbor = internal_fe_subface_values_neighbor.get();
2407 }
2408
2409 AssertDimension(fe_face_values->n_quadrature_points,
2410 fe_face_values_neighbor->n_quadrature_points);
2411
2412 const_cast<unsigned int &>(this->n_quadrature_points) =
2413 fe_face_values->n_quadrature_points;
2414 }
2415 else if (internal_hp_fe_face_values)
2416 {
2417 active_fe_index = fe_index_in;
2418 active_fe_index_neighbor =
2419 (fe_index_neighbor_in != numbers::invalid_unsigned_int) ?
2420 fe_index_neighbor_in :
2421 fe_index_in;
2422
2423 if (active_fe_index == numbers::invalid_unsigned_int)
2424 {
2425 if constexpr (is_dof_cell_accessor)
2426 active_fe_index = cell->active_fe_index();
2427 else
2428 active_fe_index = 0;
2429 }
2430
2431 if (active_fe_index_neighbor == numbers::invalid_unsigned_int)
2432 {
2433 if constexpr (is_dof_cell_accessor_neighbor)
2434 active_fe_index_neighbor = cell_neighbor->active_fe_index();
2435 else
2436 active_fe_index_neighbor = 0;
2437 }
2438
2439 unsigned int used_q_index = q_index;
2440 unsigned int used_mapping_index = mapping_index;
2441
2442 // First check. If there is only one element in a collection, and if none
2443 // had been specified explicitly, then that's clearly the one to take:
2444 if (used_q_index == numbers::invalid_unsigned_int)
2445 if (internal_hp_fe_face_values->get_quadrature_collection().size() == 1)
2446 used_q_index = 0;
2447
2448 if (used_mapping_index == numbers::invalid_unsigned_int)
2449 if (internal_hp_fe_face_values->get_mapping_collection().size() == 1)
2450 used_mapping_index = 0;
2451
2452 // Second check: See if the two quadrature objects are the same, because
2453 // in that case it does not matter which one we use. Unfortunately, we
2454 // currently have no way of testing that two mapping objects are the
2455 // same :-(
2456 if (used_q_index == numbers::invalid_unsigned_int)
2457 if (internal_hp_fe_face_values
2458 ->get_quadrature_collection()[active_fe_index] ==
2459 internal_hp_fe_face_values
2460 ->get_quadrature_collection()[active_fe_index_neighbor])
2461 used_q_index = active_fe_index;
2462
2463 // Third check, if the above did not already suffice. We see if we
2464 // can get somewhere via the dominated's finite element index.
2465 if ((used_q_index == numbers::invalid_unsigned_int) ||
2466 (used_mapping_index == numbers::invalid_unsigned_int))
2467 {
2468 const unsigned int dominated_fe_index =
2469 ((used_q_index == numbers::invalid_unsigned_int) ||
2470 (used_mapping_index == numbers::invalid_unsigned_int) ?
2471 internal_hp_fe_face_values->get_fe_collection()
2472 .find_dominated_fe(
2473 {active_fe_index, active_fe_index_neighbor}) :
2474 numbers::invalid_unsigned_int);
2475
2476 if (used_q_index == numbers::invalid_unsigned_int)
2477 {
2478 Assert(dominated_fe_index != numbers::invalid_fe_index,
2479 ExcMessage(
2480 "You called this function with 'q_index' left at its "
2481 "default value, but this can only work if one of "
2482 "the two finite elements adjacent to this face "
2483 "dominates the other. See the documentation "
2484 "of this function for more information of how "
2485 "to deal with this situation."));
2486 used_q_index = dominated_fe_index;
2487 }
2488
2489 if (used_mapping_index == numbers::invalid_unsigned_int)
2490 {
2491 Assert(dominated_fe_index != numbers::invalid_fe_index,
2492 ExcMessage(
2493 "You called this function with 'mapping_index' left "
2494 "at its default value, but this can only work if one "
2495 "of the two finite elements adjacent to this face "
2496 "dominates the other. See the documentation "
2497 "of this function for more information of how "
2498 "to deal with this situation."));
2499 used_mapping_index = dominated_fe_index;
2500 }
2501 }
2502
2503 // Same as if above, but when hp is enabled.
2504 if (sub_face_no == numbers::invalid_unsigned_int)
2505 {
2506 internal_hp_fe_face_values->reinit(
2507 cell, face_no, used_q_index, used_mapping_index, active_fe_index);
2508 fe_face_values = &const_cast<FEFaceValues<dim, spacedim> &>(
2509 internal_hp_fe_face_values->get_present_fe_values());
2510 }
2511 else
2512 {
2513 internal_hp_fe_subface_values->reinit(cell,
2514 face_no,
2515 sub_face_no,
2516 used_q_index,
2517 used_mapping_index,
2518 active_fe_index);
2519
2520 fe_face_values = &const_cast<FESubfaceValues<dim, spacedim> &>(
2521 internal_hp_fe_subface_values->get_present_fe_values());
2522 }
2523 if (sub_face_no_neighbor == numbers::invalid_unsigned_int)
2524 {
2525 internal_hp_fe_face_values_neighbor->reinit(cell_neighbor,
2526 face_no_neighbor,
2527 used_q_index,
2528 used_mapping_index,
2529 active_fe_index_neighbor);
2530
2531 fe_face_values_neighbor = &const_cast<FEFaceValues<dim, spacedim> &>(
2532 internal_hp_fe_face_values_neighbor->get_present_fe_values());
2533 }
2534 else
2535 {
2536 internal_hp_fe_subface_values_neighbor->reinit(
2537 cell_neighbor,
2538 face_no_neighbor,
2539 sub_face_no_neighbor,
2540 used_q_index,
2541 used_mapping_index,
2542 active_fe_index_neighbor);
2543
2544 fe_face_values_neighbor =
2545 &const_cast<FESubfaceValues<dim, spacedim> &>(
2546 internal_hp_fe_subface_values_neighbor->get_present_fe_values());
2547 }
2548
2549 AssertDimension(fe_face_values->n_quadrature_points,
2550 fe_face_values_neighbor->n_quadrature_points);
2551
2552 const_cast<unsigned int &>(this->n_quadrature_points) =
2553 fe_face_values->n_quadrature_points;
2554 }
2555
2556 // Set up dof mapping and remove duplicates (for continuous elements).
2557 if constexpr (is_dof_cell_accessor_neighbor && is_dof_cell_accessor)
2558 {
2559 // Get dof indices first:
2560 std::vector<types::global_dof_index> v(
2561 fe_face_values->get_fe().n_dofs_per_cell());
2562 cell->get_active_or_mg_dof_indices(v);
2563 std::vector<types::global_dof_index> v2(
2564 fe_face_values_neighbor->get_fe().n_dofs_per_cell());
2565 cell_neighbor->get_active_or_mg_dof_indices(v2);
2566
2567 // Fill a map from the global dof index to the left and right
2568 // local index.
2569 std::map<types::global_dof_index, std::pair<unsigned int, unsigned int>>
2570 tempmap;
2571 std::pair<unsigned int, unsigned int> invalid_entry(
2572 numbers::invalid_unsigned_int, numbers::invalid_unsigned_int);
2573
2574 for (unsigned int i = 0; i < v.size(); ++i)
2575 {
2576 // If not already existing, add an invalid entry:
2577 auto result = tempmap.insert(std::make_pair(v[i], invalid_entry));
2578 result.first->second.first = i;
2579 }
2580
2581 for (unsigned int i = 0; i < v2.size(); ++i)
2582 {
2583 // If not already existing, add an invalid entry:
2584 auto result = tempmap.insert(std::make_pair(v2[i], invalid_entry));
2585 result.first->second.second = i;
2586 }
2587
2588 // Transfer from the map to the sorted std::vectors.
2589 dofmap.resize(tempmap.size());
2590 interface_dof_indices.resize(tempmap.size());
2591 unsigned int idx = 0;
2592 for (auto &x : tempmap)
2593 {
2594 interface_dof_indices[idx] = x.first;
2595 dofmap[idx] = {{x.second.first, x.second.second}};
2596 ++idx;
2597 }
2598 }
2599 else
2600 {
2601 const unsigned int n_dofs_per_cell_1 = fe_face_values->dofs_per_cell;
2602 const unsigned int n_dofs_per_cell_2 =
2603 fe_face_values_neighbor->dofs_per_cell;
2604
2605 interface_dof_indices.resize(n_dofs_per_cell_1 + n_dofs_per_cell_2);
2606 dofmap.resize(n_dofs_per_cell_1 + n_dofs_per_cell_2);
2607
2608 for (unsigned int i = 0; i < n_dofs_per_cell_1; ++i)
2609 {
2610 interface_dof_indices[i] = numbers::invalid_dof_index;
2611 dofmap[i] = {{i, numbers::invalid_unsigned_int}};
2612 }
2613
2614 for (unsigned int i = 0; i < n_dofs_per_cell_2; ++i)
2615 {
2616 interface_dof_indices[i + n_dofs_per_cell_1] =
2617 numbers::invalid_dof_index;
2618 dofmap[i + n_dofs_per_cell_1] = {{numbers::invalid_unsigned_int, i}};
2619 }
2620 }
2621 }
2622
2623
2624
2625 template <int dim, int spacedim>
2626 template <typename CellIteratorType>
2627 void
2628 FEInterfaceValues<dim, spacedim>::reinit(const CellIteratorType &cell,
2629 const unsigned int face_no,
2630 const unsigned int q_index,
2631 const unsigned int mapping_index,
2632 const unsigned int fe_index)
2633 {
2634 Assert(internal_fe_face_values || internal_hp_fe_face_values,
2635 ExcNotInitialized());
2636
2637 if (internal_fe_face_values)
2638 {
2639 Assert((q_index == 0 || q_index == numbers::invalid_unsigned_int),
2640 ExcNotImplemented());
2641 Assert((mapping_index == 0 ||
2642 mapping_index == numbers::invalid_unsigned_int),
2643 ExcNotImplemented());
2644 Assert((fe_index == 0 || fe_index == numbers::invalid_unsigned_int),
2645 ExcNotImplemented());
2646
2647 internal_fe_face_values->reinit(cell, face_no);
2648 fe_face_values = internal_fe_face_values.get();
2649 fe_face_values_neighbor = nullptr;
2650 }
2651 else if (internal_hp_fe_face_values)
2652 {
2653 internal_hp_fe_face_values->reinit(
2654 cell, face_no, q_index, mapping_index, fe_index);
2655 fe_face_values = &const_cast<FEFaceValues<dim> &>(
2656 internal_hp_fe_face_values->get_present_fe_values());
2657 fe_face_values_neighbor = nullptr;
2658 }
2659
2660 interface_dof_indices.resize(fe_face_values->get_fe().n_dofs_per_cell());
2661
2662 if constexpr (std::is_same_v<typename CellIteratorType::AccessorType,
2663 DoFCellAccessor<dim, spacedim, true>> ||
2664 std::is_same_v<typename CellIteratorType::AccessorType,
2665 DoFCellAccessor<dim, spacedim, false>>)
2666 {
2667 cell->get_active_or_mg_dof_indices(interface_dof_indices);
2668 }
2669 else
2670 {
2671 for (auto &i : interface_dof_indices)
2672 i = numbers::invalid_dof_index;
2673 }
2674
2675 dofmap.resize(interface_dof_indices.size());
2676 for (unsigned int i = 0; i < interface_dof_indices.size(); ++i)
2677 dofmap[i] = {{i, numbers::invalid_unsigned_int}};
2678 }
2679
2680
2681
2682 template <int dim, int spacedim>
2683 inline double
2684 FEInterfaceValues<dim, spacedim>::JxW(const unsigned int q) const
2685 {
2686 Assert(fe_face_values != nullptr,
2687 ExcMessage("This call requires a call to reinit() first."));
2688 return fe_face_values->JxW(q);
2689 }
2690
2691
2692
2693 template <int dim, int spacedim>
2694 const std::vector<double> &
2695 FEInterfaceValues<dim, spacedim>::get_JxW_values() const
2696 {
2697 Assert(fe_face_values != nullptr,
2698 ExcMessage("This call requires a call to reinit() first."));
2699 return fe_face_values->get_JxW_values();
2700 }
2701
2702
2703
2704 template <int dim, int spacedim>
2705 const std::vector<Tensor<1, spacedim>> &
2706 FEInterfaceValues<dim, spacedim>::get_normal_vectors() const
2707 {
2708 Assert(fe_face_values != nullptr,
2709 ExcMessage("This call requires a call to reinit() first."));
2710 return fe_face_values->get_normal_vectors();
2711 }
2712
2713
2714
2715 template <int dim, int spacedim>
2716 const Mapping<dim, spacedim> &
2717 FEInterfaceValues<dim, spacedim>::get_mapping() const
2718 {
2719 Assert(!has_hp_capabilities(), ExcOnlyAvailableWithoutHP());
2720 return internal_fe_face_values->get_mapping();
2721 }
2722
2723
2724
2725 template <int dim, int spacedim>
2726 const FiniteElement<dim, spacedim> &
2727 FEInterfaceValues<dim, spacedim>::get_fe() const
2728 {
2729 Assert(!has_hp_capabilities(), ExcOnlyAvailableWithoutHP());
2730 return internal_fe_face_values->get_fe();
2731 }
2732
2733
2734
2735 template <int dim, int spacedim>
2736 const Quadrature<dim - 1> &
2737 FEInterfaceValues<dim, spacedim>::get_quadrature() const
2738 {
2739 Assert(!has_hp_capabilities(), ExcOnlyAvailableWithoutHP());
2740 return internal_fe_face_values->get_quadrature();
2741 }
2742
2743
2744
2745 template <int dim, int spacedim>
2746 const hp::MappingCollection<dim, spacedim> &
2747 FEInterfaceValues<dim, spacedim>::get_mapping_collection() const
2748 {
2749 Assert(has_hp_capabilities(), ExcOnlyAvailableWithHP());
2750 return internal_hp_fe_face_values->get_mapping_collection();
2751 }
2752
2753
2754
2755 template <int dim, int spacedim>
2756 const hp::FECollection<dim, spacedim> &
2757 FEInterfaceValues<dim, spacedim>::get_fe_collection() const
2758 {
2759 Assert(has_hp_capabilities(), ExcOnlyAvailableWithHP());
2760 return internal_hp_fe_face_values->get_fe_collection();
2761 }
2762
2763
2764
2765 template <int dim, int spacedim>
2766 const hp::QCollection<dim - 1> &
2767 FEInterfaceValues<dim, spacedim>::get_quadrature_collection() const
2768 {
2769 Assert(has_hp_capabilities(), ExcOnlyAvailableWithHP());
2770 return internal_hp_fe_face_values->get_quadrature_collection();
2771 }
2772
2773
2774
2775 template <int dim, int spacedim>
2776 bool
2777 FEInterfaceValues<dim, spacedim>::has_hp_capabilities() const
2778 {
2779 if (internal_hp_fe_face_values || internal_hp_fe_subface_values ||
2780 internal_hp_fe_face_values_neighbor ||
2781 internal_hp_fe_subface_values_neighbor)
2782 {
2783 Assert(!internal_fe_face_values, ExcInternalError());
2784 Assert(!internal_fe_subface_values, ExcInternalError());
2785 Assert(!internal_fe_face_values_neighbor, ExcInternalError());
2786 Assert(!internal_fe_subface_values_neighbor, ExcInternalError());
2787
2788 return true;
2789 }
2790
2791 Assert(internal_fe_face_values || internal_fe_subface_values ||
2792 internal_fe_face_values_neighbor ||
2793 internal_fe_subface_values_neighbor,
2794 ExcInternalError());
2795 Assert(!internal_hp_fe_face_values, ExcInternalError());
2796 Assert(!internal_hp_fe_subface_values, ExcInternalError());
2797 Assert(!internal_hp_fe_face_values_neighbor, ExcInternalError());
2798 Assert(!internal_hp_fe_subface_values_neighbor, ExcInternalError());
2799
2800 return false;
2801 }
2802
2803
2804
2805 template <int dim, int spacedim>
2806 inline std_cxx20::ranges::iota_view<unsigned int, unsigned int>
2807 FEInterfaceValues<dim, spacedim>::quadrature_point_indices() const
2808 {
2809 return std_cxx20::ranges::iota_view<unsigned int, unsigned int>(
2810 0U, n_quadrature_points);
2811 }
2812
2813
2814
2815 template <int dim, int spacedim>
2816 const Point<spacedim> &
2817 FEInterfaceValues<dim, spacedim>::quadrature_point(
2818 const unsigned int q_point) const
2819 {
2820 Assert(fe_face_values != nullptr,
2821 ExcMessage("This call requires a call to reinit() first."));
2822 return fe_face_values->quadrature_point(q_point);
2823 }
2824
2825
2826
2827 template <int dim, int spacedim>
2828 const std::vector<Point<spacedim>> &
2829 FEInterfaceValues<dim, spacedim>::get_quadrature_points() const
2830 {
2831 Assert(fe_face_values != nullptr,
2832 ExcMessage("This call requires a call to reinit() first."));
2833 return fe_face_values->get_quadrature_points();
2834 }
2835
2836
2837
2838 template <int dim, int spacedim>
2839 UpdateFlags
2840 FEInterfaceValues<dim, spacedim>::get_update_flags() const
2841 {
2842 if (has_hp_capabilities())
2843 return internal_hp_fe_face_values->get_update_flags();
2844 else
2845 return internal_fe_face_values->get_update_flags();
2846 }
2847
2848
2849
2850 template <int dim, int spacedim>
2851 typename Triangulation<dim, spacedim>::cell_iterator
2852 FEInterfaceValues<dim, spacedim>::get_cell(const unsigned int cell_index) const
2853 {
2854 return get_fe_face_values(cell_index).get_cell();
2855 }
2856
2857
2858
2859 template <int dim, int spacedim>
2860 inline unsigned int
2861 FEInterfaceValues<dim, spacedim>::get_face_number(
2862 const unsigned int cell_index) const
2863 {
2864 return get_fe_face_values(cell_index).get_face_number();
2865 }
2866
2867
2868
2869 template <int dim, int spacedim>
2870 unsigned
2871 FEInterfaceValues<dim, spacedim>::n_current_interface_dofs() const
2872 {
2873 Assert(
2874 interface_dof_indices.size() > 0,
2875 ExcMessage(
2876 "n_current_interface_dofs() is only available after a call to reinit()."));
2877 return interface_dof_indices.size();
2878 }
2879
2880
2881
2882 template <int dim, int spacedim>
2883 inline std_cxx20::ranges::iota_view<unsigned int, unsigned int>
2884 FEInterfaceValues<dim, spacedim>::dof_indices() const
2885 {
2886 return {0U, n_current_interface_dofs()};
2887 }
2888
2889
2890
2891 template <int dim, int spacedim>
2892 bool
2893 FEInterfaceValues<dim, spacedim>::at_boundary() const
2894 {
2895 return fe_face_values_neighbor == nullptr;
2896 }
2897
2898
2899
2900 template <int dim, int spacedim>
2901 std::vector<types::global_dof_index>
2902 FEInterfaceValues<dim, spacedim>::get_interface_dof_indices() const
2903 {
2904 return interface_dof_indices;
2905 }
2906
2907
2908
2909 template <int dim, int spacedim>
2910 std::array<unsigned int, 2>
2911 FEInterfaceValues<dim, spacedim>::interface_dof_to_dof_indices(
2912 const unsigned int interface_dof_index) const
2913 {
2914 AssertIndexRange(interface_dof_index, n_current_interface_dofs());
2915 return dofmap[interface_dof_index];
2916 }
2917
2918
2919
2920 template <int dim, int spacedim>
2921 const FEFaceValuesBase<dim, spacedim> &
2922 FEInterfaceValues<dim, spacedim>::get_fe_face_values(
2923 const unsigned int cell_index) const
2924 {
2925 AssertIndexRange(cell_index, 2);
2926 Assert(
2927 cell_index == 0 || !at_boundary(),
2928 ExcMessage(
2929 "You are on a boundary, so you can only ask for the first FEFaceValues object."));
2930
2931 return (cell_index == 0) ? *fe_face_values : *fe_face_values_neighbor;
2932 }
2933
2934
2935
2936 template <int dim, int spacedim>
2937 Tensor<1, spacedim>
2938 FEInterfaceValues<dim, spacedim>::normal(const unsigned int q_point_index) const
2939 {
2940 return normal_vector(q_point_index);
2941 }
2942
2943
2944
2945 template <int dim, int spacedim>
2946 Tensor<1, spacedim>
2947 FEInterfaceValues<dim, spacedim>::normal_vector(
2948 const unsigned int q_point_index) const
2949 {
2950 return fe_face_values->normal_vector(q_point_index);
2951 }
2952
2953
2954
2955 template <int dim, int spacedim>
2956 double
2957 FEInterfaceValues<dim, spacedim>::shape_value(
2958 const bool here_or_there,
2959 const unsigned int interface_dof_index,
2960 const unsigned int q_point,
2961 const unsigned int component) const
2962 {
2963 const auto dof_pair = dofmap[interface_dof_index];
2964
2965 if (here_or_there && dof_pair[0] != numbers::invalid_unsigned_int)
2966 return get_fe_face_values(0).shape_value_component(dof_pair[0],
2967 q_point,
2968 component);
2969 if (!here_or_there && dof_pair[1] != numbers::invalid_unsigned_int)
2970 return get_fe_face_values(1).shape_value_component(dof_pair[1],
2971 q_point,
2972 component);
2973
2974 return 0.0;
2975 }
2976
2977
2978 template <int dim, int spacedim>
2979 Tensor<1, spacedim>
2980 FEInterfaceValues<dim, spacedim>::shape_grad(
2981 const bool here_or_there,
2982 const unsigned int interface_dof_index,
2983 const unsigned int q_point,
2984 const unsigned int component) const
2985 {
2986 const auto dof_pair = dofmap[interface_dof_index];
2987
2988 Tensor<1, dim> value;
2989
2990 if (here_or_there && dof_pair[0] != numbers::invalid_unsigned_int)
2991 value = get_fe_face_values(0).shape_grad_component(dof_pair[0],
2992 q_point,
2993 component);
2994 if (!here_or_there && dof_pair[1] != numbers::invalid_unsigned_int)
2995 value = get_fe_face_values(1).shape_grad_component(dof_pair[1],
2996 q_point,
2997 component);
2998
2999 return value;
3000 }
3001
3002 template <int dim, int spacedim>
3003 double
3004 FEInterfaceValues<dim, spacedim>::jump_in_shape_values(
3005 const unsigned int interface_dof_index,
3006 const unsigned int q_point,
3007 const unsigned int component) const
3008 {
3009 const auto dof_pair = dofmap[interface_dof_index];
3010
3011 double value = 0.0;
3012
3013 if (dof_pair[0] != numbers::invalid_unsigned_int)
3014 value += get_fe_face_values(0).shape_value_component(dof_pair[0],
3015 q_point,
3016 component);
3017 if (dof_pair[1] != numbers::invalid_unsigned_int)
3018 value -= get_fe_face_values(1).shape_value_component(dof_pair[1],
3019 q_point,
3020 component);
3021 return value;
3022 }
3023
3024
3025
3026 template <int dim, int spacedim>
3027 double
3028 FEInterfaceValues<dim, spacedim>::average_of_shape_values(
3029 const unsigned int interface_dof_index,
3030 const unsigned int q_point,
3031 const unsigned int component) const
3032 {
3033 const auto dof_pair = dofmap[interface_dof_index];
3034
3035 if (at_boundary())
3036 return get_fe_face_values(0).shape_value_component(dof_pair[0],
3037 q_point,
3038 component);
3039
3040 double value = 0.0;
3041
3042 if (dof_pair[0] != numbers::invalid_unsigned_int)
3043 value += 0.5 * get_fe_face_values(0).shape_value_component(dof_pair[0],
3044 q_point,
3045 component);
3046 if (dof_pair[1] != numbers::invalid_unsigned_int)
3047 value += 0.5 * get_fe_face_values(1).shape_value_component(dof_pair[1],
3048 q_point,
3049 component);
3050
3051 return value;
3052 }
3053
3054
3055
3056 template <int dim, int spacedim>
3057 Tensor<1, spacedim>
3058 FEInterfaceValues<dim, spacedim>::average_of_shape_gradients(
3059 const unsigned int interface_dof_index,
3060 const unsigned int q_point,
3061 const unsigned int component) const
3062 {
3063 const auto dof_pair = dofmap[interface_dof_index];
3064
3065 if (at_boundary())
3066 return get_fe_face_values(0).shape_grad_component(dof_pair[0],
3067 q_point,
3068 component);
3069
3070 Tensor<1, spacedim> value;
3071
3072 if (dof_pair[0] != numbers::invalid_unsigned_int)
3073 value += 0.5 * get_fe_face_values(0).shape_grad_component(dof_pair[0],
3074 q_point,
3075 component);
3076 if (dof_pair[1] != numbers::invalid_unsigned_int)
3077 value += 0.5 * get_fe_face_values(1).shape_grad_component(dof_pair[1],
3078 q_point,
3079 component);
3080
3081 return value;
3082 }
3083
3084
3085
3086 template <int dim, int spacedim>
3087 Tensor<2, spacedim>
3088 FEInterfaceValues<dim, spacedim>::average_of_shape_hessians(
3089 const unsigned int interface_dof_index,
3090 const unsigned int q_point,
3091 const unsigned int component) const
3092 {
3093 const auto dof_pair = dofmap[interface_dof_index];
3094
3095 if (at_boundary())
3096 return get_fe_face_values(0).shape_hessian_component(dof_pair[0],
3097 q_point,
3098 component);
3099
3100 Tensor<2, spacedim> value;
3101
3102 if (dof_pair[0] != numbers::invalid_unsigned_int)
3103 value += 0.5 * get_fe_face_values(0).shape_hessian_component(dof_pair[0],
3104 q_point,
3105 component);
3106 if (dof_pair[1] != numbers::invalid_unsigned_int)
3107 value += 0.5 * get_fe_face_values(1).shape_hessian_component(dof_pair[1],
3108 q_point,
3109 component);
3110
3111 return value;
3112 }
3113
3114
3115
3116 template <int dim, int spacedim>
3117 Tensor<1, spacedim>
3118 FEInterfaceValues<dim, spacedim>::jump_in_shape_gradients(
3119 const unsigned int interface_dof_index,
3120 const unsigned int q_point,
3121 const unsigned int component) const
3122 {
3123 const auto dof_pair = dofmap[interface_dof_index];
3124
3125 if (at_boundary())
3126 return get_fe_face_values(0).shape_grad_component(dof_pair[0],
3127 q_point,
3128 component);
3129
3130 Tensor<1, spacedim> value;
3131
3132 if (dof_pair[0] != numbers::invalid_unsigned_int)
3133 value += get_fe_face_values(0).shape_grad_component(dof_pair[0],
3134 q_point,
3135 component);
3136 if (dof_pair[1] != numbers::invalid_unsigned_int)
3137 value -= get_fe_face_values(1).shape_grad_component(dof_pair[1],
3138 q_point,
3139 component);
3140
3141 return value;
3142 }
3143
3144
3145
3146 template <int dim, int spacedim>
3147 Tensor<2, spacedim>
3148 FEInterfaceValues<dim, spacedim>::jump_in_shape_hessians(
3149 const unsigned int interface_dof_index,
3150 const unsigned int q_point,
3151 const unsigned int component) const
3152 {
3153 const auto dof_pair = dofmap[interface_dof_index];
3154
3155 if (at_boundary())
3156 return get_fe_face_values(0).shape_hessian_component(dof_pair[0],
3157 q_point,
3158 component);
3159
3160 Tensor<2, spacedim> value;
3161
3162 if (dof_pair[0] != numbers::invalid_unsigned_int)
3163 value += get_fe_face_values(0).shape_hessian_component(dof_pair[0],
3164 q_point,
3165 component);
3166 if (dof_pair[1] != numbers::invalid_unsigned_int)
3167 value -= get_fe_face_values(1).shape_hessian_component(dof_pair[1],
3168 q_point,
3169 component);
3170
3171 return value;
3172 }
3173
3174
3175
3176 template <int dim, int spacedim>
3177 Tensor<3, spacedim>
3178 FEInterfaceValues<dim, spacedim>::jump_in_shape_3rd_derivatives(
3179 const unsigned int interface_dof_index,
3180 const unsigned int q_point,
3181 const unsigned int component) const
3182 {
3183 const auto dof_pair = dofmap[interface_dof_index];
3184
3185 if (at_boundary())
3186 return get_fe_face_values(0).shape_3rd_derivative_component(dof_pair[0],
3187 q_point,
3188 component);
3189
3190 Tensor<3, spacedim> value;
3191
3192 if (dof_pair[0] != numbers::invalid_unsigned_int)
3193 value += get_fe_face_values(0).shape_3rd_derivative_component(dof_pair[0],
3194 q_point,
3195 component);
3196 if (dof_pair[1] != numbers::invalid_unsigned_int)
3197 value -= get_fe_face_values(1).shape_3rd_derivative_component(dof_pair[1],
3198 q_point,
3199 component);
3200
3201 return value;
3202 }
3203
3204
3205
3206 template <int dim, int spacedim>
3207 template <class InputVector>
3208 void
3209 FEInterfaceValues<dim, spacedim>::get_jump_in_function_values(
3210 const InputVector &fe_function,
3211 std::vector<typename InputVector::value_type> &values) const
3212 {
3213 AssertDimension(values.size(), n_quadrature_points);
3214
3215 const FEValuesExtractors::Scalar scalar(0);
3216 this->operator[](scalar).get_jump_in_function_values(fe_function, values);
3217 }
3218
3219
3220
3221 template <int dim, int spacedim>
3222 template <class InputVector>
3223 void
3224 FEInterfaceValues<dim, spacedim>::get_jump_in_function_gradients(
3225 const InputVector &fe_function,
3226 std::vector<Tensor<1, spacedim, typename InputVector::value_type>> &gradients)
3227 const
3228 {
3229 AssertDimension(gradients.size(), n_quadrature_points);
3230
3231 const FEValuesExtractors::Scalar scalar(0);
3232 this->operator[](scalar).get_jump_in_function_gradients(fe_function,
3233 gradients);
3234 }
3235
3236
3237
3238 template <int dim, int spacedim>
3239 template <class InputVector>
3240 void
3241 FEInterfaceValues<dim, spacedim>::get_jump_in_function_hessians(
3242 const InputVector &fe_function,
3243 std::vector<Tensor<2, spacedim, typename InputVector::value_type>> &hessians)
3244 const
3245 {
3246 AssertDimension(hessians.size(), n_quadrature_points);
3247
3248 const FEValuesExtractors::Scalar scalar(0);
3249 this->operator[](scalar).get_jump_in_function_hessians(fe_function, hessians);
3250 }
3251
3252
3253
3254 template <int dim, int spacedim>
3255 template <class InputVector>
3256 void
3257 FEInterfaceValues<dim, spacedim>::get_jump_in_function_third_derivatives(
3258 const InputVector &fe_function,
3259 std::vector<Tensor<3, spacedim, typename InputVector::value_type>>
3260 &third_derivatives) const
3261 {
3262 AssertDimension(third_derivatives.size(), n_quadrature_points);
3263
3264 const FEValuesExtractors::Scalar scalar(0);
3265 this->operator[](scalar).get_jump_in_function_third_derivatives(
3266 fe_function, third_derivatives);
3267 }
3268
3269
3270
3271 template <int dim, int spacedim>
3272 template <class InputVector>
3273 void
3274 FEInterfaceValues<dim, spacedim>::get_average_of_function_values(
3275 const InputVector &fe_function,
3276 std::vector<typename InputVector::value_type> &values) const
3277 {
3278 AssertDimension(values.size(), n_quadrature_points);
3279
3280 const FEValuesExtractors::Scalar scalar(0);
3281 this->operator[](scalar).get_average_of_function_values(fe_function, values);
3282 }
3283
3284
3285
3286 template <int dim, int spacedim>
3287 template <class InputVector>
3288 void
3289 FEInterfaceValues<dim, spacedim>::get_average_of_function_gradients(
3290 const InputVector &fe_function,
3291 std::vector<Tensor<1, spacedim, typename InputVector::value_type>> &gradients)
3292 const
3293 {
3294 AssertDimension(gradients.size(), n_quadrature_points);
3295
3296 const FEValuesExtractors::Scalar scalar(0);
3297 this->operator[](scalar).get_average_of_function_gradients(fe_function,
3298 gradients);
3299 }
3300
3301
3302
3303 template <int dim, int spacedim>
3304 template <class InputVector>
3305 void
3306 FEInterfaceValues<dim, spacedim>::get_average_of_function_hessians(
3307 const InputVector &fe_function,
3308 std::vector<Tensor<2, spacedim, typename InputVector::value_type>> &hessians)
3309 const
3310 {
3311 AssertDimension(hessians.size(), n_quadrature_points);
3312
3313 const FEValuesExtractors::Scalar scalar(0);
3314 this->operator[](scalar).get_average_of_function_hessians(fe_function,
3315 hessians);
3316 }
3317
3318
3319
3320 /*------------ Inline functions: FEInterfaceValues------------*/
3321 template <int dim, int spacedim>
3322 inline FEInterfaceViews::Scalar<dim, spacedim>
3323 FEInterfaceValues<dim, spacedim>::operator[](
3324 const FEValuesExtractors::Scalar &scalar) const
3325 {
3326 const unsigned int n_components =
3327 (this->has_hp_capabilities() ? this->get_fe_collection().n_components() :
3328 this->get_fe().n_components());
3329 (void)n_components;
3330 AssertIndexRange(scalar.component, n_components);
3331 return FEInterfaceViews::Scalar<dim, spacedim>(*this, scalar.component);
3332 }
3333
3334
3335
3336 template <int dim, int spacedim>
3337 inline FEInterfaceViews::Vector<dim, spacedim>
3338 FEInterfaceValues<dim, spacedim>::operator[](
3339 const FEValuesExtractors::Vector &vector) const
3340 {
3341 const unsigned int n_components =
3342 (this->has_hp_capabilities() ? this->get_fe_collection().n_components() :
3343 this->get_fe().n_components());
3344 const unsigned int n_vectors =
3345 (n_components >= Tensor<1, spacedim>::n_independent_components ?
3346 n_components - Tensor<1, spacedim>::n_independent_components + 1 :
3347 0);
3348 (void)n_components;
3349 (void)n_vectors;
3350 AssertIndexRange(vector.first_vector_component, n_vectors);
3351 return FEInterfaceViews::Vector<dim, spacedim>(*this,
3352 vector.first_vector_component);
3353 }
3354
3355
3356
3357 namespace FEInterfaceViews
3358 {
3359 template <int dim, int spacedim>
3360 Base<dim, spacedim>::Base(
3361 const FEInterfaceValues<dim, spacedim> &fe_interface)
3362 : fe_interface(&fe_interface)
3363 {}
3364
3365
3366
3367 template <int dim, int spacedim>
3368 Scalar<dim, spacedim>::Scalar(
3369 const FEInterfaceValues<dim, spacedim> &fe_interface,
3370 const unsigned int component)
3371 : Base<dim, spacedim>(fe_interface)
3372 , extractor(component)
3373 {}
3374
3375
3376
3377 template <int dim, int spacedim>
3378 template <class InputVector, class OutputVector>
3379 void
3380 Base<dim, spacedim>::get_local_dof_values(
3381 const InputVector &dof_values,
3382 OutputVector &local_dof_values) const
3383 {
3384 const auto &interface_dof_indices =
3385 this->fe_interface->get_interface_dof_indices();
3386
3387 AssertDimension(interface_dof_indices.size(), local_dof_values.size());
3388
3389 for (const unsigned int i : this->fe_interface->dof_indices())
3390 local_dof_values[i] = dof_values(interface_dof_indices[i]);
3391 }
3392
3393
3394
3395 template <int dim, int spacedim>
3396 typename Scalar<dim, spacedim>::value_type
3397 Scalar<dim, spacedim>::value(const bool here_or_there,
3398 const unsigned int interface_dof_index,
3399 const unsigned int q_point) const
3400 {
3401 const auto dof_pair = this->fe_interface->dofmap[interface_dof_index];
3402
3403 if (here_or_there && dof_pair[0] != numbers::invalid_unsigned_int)
3404 return (*(this->fe_interface->fe_face_values))[extractor].value(
3405 dof_pair[0], q_point);
3406
3407 if (!here_or_there && dof_pair[1] != numbers::invalid_unsigned_int)
3408 return (*(this->fe_interface->fe_face_values_neighbor))[extractor].value(
3409 dof_pair[1], q_point);
3410
3411 return 0.0;
3412 }
3413
3414
3415
3416 template <int dim, int spacedim>
3417 typename Scalar<dim, spacedim>::value_type
3418 Scalar<dim, spacedim>::jump_in_values(const unsigned int interface_dof_index,
3419 const unsigned int q_point) const
3420 {
3421 const auto dof_pair = this->fe_interface->dofmap[interface_dof_index];
3422
3423 value_type value = 0.0;
3424
3425 if (dof_pair[0] != numbers::invalid_unsigned_int)
3426 value +=
3427 (*(this->fe_interface->fe_face_values))[extractor].value(dof_pair[0],
3428 q_point);
3429
3430 if (dof_pair[1] != numbers::invalid_unsigned_int)
3431 value -=
3432 (*(this->fe_interface->fe_face_values_neighbor))[extractor].value(
3433 dof_pair[1], q_point);
3434
3435 return value;
3436 }
3437
3438
3439
3440 template <int dim, int spacedim>
3441 typename Scalar<dim, spacedim>::value_type
3442 Scalar<dim, spacedim>::average_of_values(
3443 const unsigned int interface_dof_index,
3444 const unsigned int q_point) const
3445 {
3446 const auto dof_pair = this->fe_interface->dofmap[interface_dof_index];
3447
3448 if (this->fe_interface->at_boundary())
3449 return (*(this->fe_interface->fe_face_values))[extractor].value(
3450 dof_pair[0], q_point);
3451
3452 value_type value = 0.0;
3453
3454 if (dof_pair[0] != numbers::invalid_unsigned_int)
3455 value +=
3456 0.5 *
3457 (*(this->fe_interface->fe_face_values))[extractor].value(dof_pair[0],
3458 q_point);
3459
3460 if (dof_pair[1] != numbers::invalid_unsigned_int)
3461 value +=
3462 0.5 * (*(this->fe_interface->fe_face_values_neighbor))[extractor].value(
3463 dof_pair[1], q_point);
3464
3465 return value;
3466 }
3467
3468
3469
3470 template <int dim, int spacedim>
3471 typename Scalar<dim, spacedim>::gradient_type
3472 Scalar<dim, spacedim>::average_of_gradients(
3473 const unsigned int interface_dof_index,
3474 const unsigned int q_point) const
3475 {
3476 const auto dof_pair = this->fe_interface->dofmap[interface_dof_index];
3477
3478 if (this->fe_interface->at_boundary())
3479 return (*(this->fe_interface->fe_face_values))[extractor].gradient(
3480 dof_pair[0], q_point);
3481
3482 gradient_type value;
3483
3484 if (dof_pair[0] != numbers::invalid_unsigned_int)
3485 value +=
3486 0.5 *
3487 (*(this->fe_interface->fe_face_values))[extractor].gradient(dof_pair[0],
3488 q_point);
3489
3490 if (dof_pair[1] != numbers::invalid_unsigned_int)
3491 value += 0.5 * (*(this->fe_interface->fe_face_values_neighbor))[extractor]
3492 .gradient(dof_pair[1], q_point);
3493
3494 return value;
3495 }
3496
3497
3498
3499 template <int dim, int spacedim>
3500 typename Scalar<dim, spacedim>::gradient_type
3501 Scalar<dim, spacedim>::jump_in_gradients(
3502 const unsigned int interface_dof_index,
3503 const unsigned int q_point) const
3504 {
3505 const auto dof_pair = this->fe_interface->dofmap[interface_dof_index];
3506
3507 if (this->fe_interface->at_boundary())
3508 return (*(this->fe_interface->fe_face_values))[extractor].gradient(
3509 dof_pair[0], q_point);
3510
3511 gradient_type value;
3512
3513 if (dof_pair[0] != numbers::invalid_unsigned_int)
3514 value +=
3515 (*(this->fe_interface->fe_face_values))[extractor].gradient(dof_pair[0],
3516 q_point);
3517
3518 if (dof_pair[1] != numbers::invalid_unsigned_int)
3519 value -=
3520 (*(this->fe_interface->fe_face_values_neighbor))[extractor].gradient(
3521 dof_pair[1], q_point);
3522
3523 return value;
3524 }
3525
3526
3527
3528 template <int dim, int spacedim>
3529 typename Scalar<dim, spacedim>::hessian_type
3530 Scalar<dim, spacedim>::average_of_hessians(
3531 const unsigned int interface_dof_index,
3532 const unsigned int q_point) const
3533 {
3534 const auto dof_pair = this->fe_interface->dofmap[interface_dof_index];
3535
3536 if (this->fe_interface->at_boundary())
3537 return (*(this->fe_interface->fe_face_values))[extractor].hessian(
3538 dof_pair[0], q_point);
3539
3540 hessian_type value;
3541
3542 if (dof_pair[0] != numbers::invalid_unsigned_int)
3543 value +=
3544 0.5 *
3545 (*(this->fe_interface->fe_face_values))[extractor].hessian(dof_pair[0],
3546 q_point);
3547
3548 if (dof_pair[1] != numbers::invalid_unsigned_int)
3549 value += 0.5 * (*(this->fe_interface->fe_face_values_neighbor))[extractor]
3550 .hessian(dof_pair[1], q_point);
3551
3552 return value;
3553 }
3554
3555
3556
3557 template <int dim, int spacedim>
3558 typename Scalar<dim, spacedim>::third_derivative_type
3559 Scalar<dim, spacedim>::jump_in_third_derivatives(
3560 const unsigned int interface_dof_index,
3561 const unsigned int q_point) const
3562 {
3563 const auto dof_pair = this->fe_interface->dofmap[interface_dof_index];
3564
3565 if (this->fe_interface->at_boundary())
3566 return (*(this->fe_interface->fe_face_values))[extractor]
3567 .third_derivative(dof_pair[0], q_point);
3568
3569 third_derivative_type value;
3570
3571 if (dof_pair[0] != numbers::invalid_unsigned_int)
3572 value +=
3573 (*(this->fe_interface->fe_face_values))[extractor].third_derivative(
3574 dof_pair[0], q_point);
3575
3576 if (dof_pair[1] != numbers::invalid_unsigned_int)
3577 value -= (*(this->fe_interface->fe_face_values_neighbor))[extractor]
3578 .third_derivative(dof_pair[1], q_point);
3579
3580 return value;
3581 }
3582
3583
3584
3585 template <int dim, int spacedim>
3586 typename Scalar<dim, spacedim>::hessian_type
3587 Scalar<dim, spacedim>::jump_in_hessians(
3588 const unsigned int interface_dof_index,
3589 const unsigned int q_point) const
3590 {
3591 const auto dof_pair = this->fe_interface->dofmap[interface_dof_index];
3592
3593 if (this->fe_interface->at_boundary())
3594 return (*(this->fe_interface->fe_face_values))[extractor].hessian(
3595 dof_pair[0], q_point);
3596
3597 hessian_type value;
3598
3599 if (dof_pair[0] != numbers::invalid_unsigned_int)
3600 value +=
3601 (*(this->fe_interface->fe_face_values))[extractor].hessian(dof_pair[0],
3602 q_point);
3603
3604 if (dof_pair[1] != numbers::invalid_unsigned_int)
3605 value -=
3606 (*(this->fe_interface->fe_face_values_neighbor))[extractor].hessian(
3607 dof_pair[1], q_point);
3608
3609 return value;
3610 }
3611
3612
3613
3614 template <int dim, int spacedim>
3615 template <class InputVector>
3616 void
3617 Scalar<dim, spacedim>::get_function_values_from_local_dof_values(
3618 const bool here_or_there,
3619 const InputVector &local_dof_values,
3620 std::vector<solution_value_type<typename InputVector::value_type>> &values)
3621 const
3622 {
3623 AssertDimension(values.size(), this->fe_interface->n_quadrature_points);
3624
3625 for (const auto dof_index : this->fe_interface->dof_indices())
3626 for (const auto q_index : this->fe_interface->quadrature_point_indices())
3627 {
3628 if (dof_index == 0)
3629 values[q_index] = 0.;
3630
3631 values[q_index] += local_dof_values[dof_index] *
3632 value(here_or_there, dof_index, q_index);
3633 }
3634 }
3635
3636
3637
3638 template <int dim, int spacedim>
3639 template <class InputVector>
3640 void
3641 Scalar<dim, spacedim>::get_function_values(
3642 const bool here_or_there,
3643 const InputVector &fe_function,
3644 std::vector<solution_value_type<typename InputVector::value_type>> &values)
3645 const
3646 {
3647 std::vector<typename InputVector::value_type> local_dof_values(
3648 this->fe_interface->n_current_interface_dofs());
3649 this->get_local_dof_values(fe_function, local_dof_values);
3650
3651 get_function_values_from_local_dof_values(here_or_there,
3652 local_dof_values,
3653 values);
3654 }
3655
3656
3657
3658 template <int dim, int spacedim>
3659 template <class InputVector>
3660 void
3661 Scalar<dim, spacedim>::get_jump_in_function_values_from_local_dof_values(
3662 const InputVector &local_dof_values,
3663 std::vector<solution_value_type<typename InputVector::value_type>> &values)
3664 const
3665 {
3666 AssertDimension(values.size(), this->fe_interface->n_quadrature_points);
3667
3668 for (const auto dof_index : this->fe_interface->dof_indices())
3669 for (const auto q_index : this->fe_interface->quadrature_point_indices())
3670 {
3671 if (dof_index == 0)
3672 values[q_index] = 0.;
3673
3674 values[q_index] +=
3675 local_dof_values[dof_index] * jump_in_values(dof_index, q_index);
3676 }
3677 }
3678
3679
3680
3681 template <int dim, int spacedim>
3682 template <class InputVector>
3683 void
3684 Scalar<dim, spacedim>::get_jump_in_function_values(
3685 const InputVector &fe_function,
3686 std::vector<solution_value_type<typename InputVector::value_type>> &values)
3687 const
3688 {
3689 std::vector<typename InputVector::value_type> local_dof_values(
3690 this->fe_interface->n_current_interface_dofs());
3691 this->get_local_dof_values(fe_function, local_dof_values);
3692
3693 get_jump_in_function_values_from_local_dof_values(local_dof_values, values);
3694 }
3695
3696
3697
3698 template <int dim, int spacedim>
3699 template <class InputVector>
3700 void
3701 Scalar<dim, spacedim>::get_jump_in_function_gradients_from_local_dof_values(
3702 const InputVector &local_dof_values,
3703 std::vector<solution_gradient_type<typename InputVector::value_type>>
3704 &gradients) const
3705 {
3706 AssertDimension(gradients.size(), this->fe_interface->n_quadrature_points);
3707
3708 for (const auto dof_index : this->fe_interface->dof_indices())
3709 for (const auto q_index : this->fe_interface->quadrature_point_indices())
3710 {
3711 if (dof_index == 0)
3712 gradients[q_index] = 0.;
3713
3714 gradients[q_index] +=
3715 local_dof_values[dof_index] * jump_in_gradients(dof_index, q_index);
3716 }
3717 }
3718
3719
3720
3721 template <int dim, int spacedim>
3722 template <class InputVector>
3723 void
3724 Scalar<dim, spacedim>::get_jump_in_function_gradients(
3725 const InputVector &fe_function,
3726 std::vector<solution_gradient_type<typename InputVector::value_type>>
3727 &gradients) const
3728 {
3729 std::vector<typename InputVector::value_type> local_dof_values(
3730 this->fe_interface->n_current_interface_dofs());
3731 this->get_local_dof_values(fe_function, local_dof_values);
3732
3733 get_jump_in_function_gradients_from_local_dof_values(local_dof_values,
3734 gradients);
3735 }
3736
3737
3738
3739 template <int dim, int spacedim>
3740 template <class InputVector>
3741 void
3742 Scalar<dim, spacedim>::get_average_of_function_values_from_local_dof_values(
3743 const InputVector &local_dof_values,
3744 std::vector<solution_value_type<typename InputVector::value_type>> &values)
3745 const
3746 {
3747 AssertDimension(values.size(), this->fe_interface->n_quadrature_points);
3748
3749 for (const auto dof_index : this->fe_interface->dof_indices())
3750 for (const auto q_index : this->fe_interface->quadrature_point_indices())
3751 {
3752 if (dof_index == 0)
3753 values[q_index] = 0.;
3754
3755 values[q_index] +=
3756 local_dof_values[dof_index] * average_of_values(dof_index, q_index);
3757 }
3758 }
3759
3760
3761
3762 template <int dim, int spacedim>
3763 template <class InputVector>
3764 void
3765 Scalar<dim, spacedim>::get_average_of_function_values(
3766 const InputVector &fe_function,
3767 std::vector<solution_value_type<typename InputVector::value_type>> &values)
3768 const
3769 {
3770 std::vector<typename InputVector::value_type> local_dof_values(
3771 this->fe_interface->n_current_interface_dofs());
3772 this->get_local_dof_values(fe_function, local_dof_values);
3773
3774 get_average_of_function_values_from_local_dof_values(local_dof_values,
3775 values);
3776 }
3777
3778
3779
3780 template <int dim, int spacedim>
3781 template <class InputVector>
3782 void
3783 Scalar<dim, spacedim>::
3784 get_average_of_function_gradients_from_local_dof_values(
3785 const InputVector &local_dof_values,
3786 std::vector<solution_gradient_type<typename InputVector::value_type>>
3787 &gradients) const
3788 {
3789 AssertDimension(gradients.size(), this->fe_interface->n_quadrature_points);
3790
3791 for (const auto dof_index : this->fe_interface->dof_indices())
3792 for (const auto q_index : this->fe_interface->quadrature_point_indices())
3793 {
3794 if (dof_index == 0)
3795 gradients[q_index] = 0.;
3796
3797 gradients[q_index] += local_dof_values[dof_index] *
3798 average_of_gradients(dof_index, q_index);
3799 }
3800 }
3801
3802
3803
3804 template <int dim, int spacedim>
3805 template <class InputVector>
3806 void
3807 Scalar<dim, spacedim>::get_average_of_function_gradients(
3808 const InputVector &fe_function,
3809 std::vector<solution_gradient_type<typename InputVector::value_type>>
3810 &gradients) const
3811 {
3812 std::vector<typename InputVector::value_type> local_dof_values(
3813 this->fe_interface->n_current_interface_dofs());
3814 this->get_local_dof_values(fe_function, local_dof_values);
3815
3816 get_average_of_function_gradients_from_local_dof_values(local_dof_values,
3817 gradients);
3818 }
3819
3820
3821
3822 template <int dim, int spacedim>
3823 template <class InputVector>
3824 void
3825 Scalar<dim, spacedim>::get_jump_in_function_hessians_from_local_dof_values(
3826 const InputVector &local_dof_values,
3827 std::vector<solution_hessian_type<typename InputVector::value_type>>
3828 &hessians) const
3829 {
3830 AssertDimension(hessians.size(), this->fe_interface->n_quadrature_points);
3831
3832 for (const auto dof_index : this->fe_interface->dof_indices())
3833 for (const auto q_index : this->fe_interface->quadrature_point_indices())
3834 {
3835 if (dof_index == 0)
3836 hessians[q_index] = 0.;
3837
3838 hessians[q_index] +=
3839 local_dof_values[dof_index] * jump_in_hessians(dof_index, q_index);
3840 }
3841 }
3842
3843
3844
3845 template <int dim, int spacedim>
3846 template <class InputVector>
3847 void
3848 Scalar<dim, spacedim>::get_jump_in_function_hessians(
3849 const InputVector &fe_function,
3850 std::vector<solution_hessian_type<typename InputVector::value_type>>
3851 &hessians) const
3852 {
3853 std::vector<typename InputVector::value_type> local_dof_values(
3854 this->fe_interface->n_current_interface_dofs());
3855 this->get_local_dof_values(fe_function, local_dof_values);
3856
3857 get_jump_in_function_hessians_from_local_dof_values(local_dof_values,
3858 hessians);
3859 }
3860
3861
3862
3863 template <int dim, int spacedim>
3864 template <class InputVector>
3865 void
3866 Scalar<dim, spacedim>::get_average_of_function_hessians_from_local_dof_values(
3867 const InputVector &local_dof_values,
3868 std::vector<solution_hessian_type<typename InputVector::value_type>>
3869 &hessians) const
3870 {
3871 AssertDimension(hessians.size(), this->fe_interface->n_quadrature_points);
3872
3873 for (const unsigned int dof_index : this->fe_interface->dof_indices())
3874 for (const auto q_index : this->fe_interface->quadrature_point_indices())
3875 {
3876 if (dof_index == 0)
3877 hessians[q_index] = 0.;
3878
3879 hessians[q_index] += local_dof_values[dof_index] *
3880 average_of_hessians(dof_index, q_index);
3881 }
3882 }
3883
3884
3885
3886 template <int dim, int spacedim>
3887 template <class InputVector>
3888 void
3889 Scalar<dim, spacedim>::get_average_of_function_hessians(
3890 const InputVector &fe_function,
3891 std::vector<solution_hessian_type<typename InputVector::value_type>>
3892 &hessians) const
3893 {
3894 std::vector<typename InputVector::value_type> local_dof_values(
3895 this->fe_interface->n_current_interface_dofs());
3896 this->get_local_dof_values(fe_function, local_dof_values);
3897
3898 get_average_of_function_hessians_from_local_dof_values(local_dof_values,
3899 hessians);
3900 }
3901
3902
3903
3904 template <int dim, int spacedim>
3905 template <class InputVector>
3906 void
3907 Scalar<dim, spacedim>::
3908 get_jump_in_function_third_derivatives_from_local_dof_values(
3909 const InputVector &local_dof_values,
3910 std::vector<
3911 solution_third_derivative_type<typename InputVector::value_type>>
3912 &third_derivatives) const
3913 {
3914 AssertDimension(third_derivatives.size(),
3915 this->fe_interface->n_quadrature_points);
3916
3917 for (const unsigned int dof_index : this->fe_interface->dof_indices())
3918 for (const auto q_index : this->fe_interface->quadrature_point_indices())
3919 {
3920 if (dof_index == 0)
3921 third_derivatives[q_index] = 0.;
3922
3923 third_derivatives[q_index] +=
3924 local_dof_values[dof_index] *
3925 jump_in_third_derivatives(dof_index, q_index);
3926 }
3927 }
3928
3929
3930
3931 template <int dim, int spacedim>
3932 template <class InputVector>
3933 void
3934 Scalar<dim, spacedim>::get_jump_in_function_third_derivatives(
3935 const InputVector &fe_function,
3936 std::vector<
3937 solution_third_derivative_type<typename InputVector::value_type>>
3938 &third_derivatives) const
3939 {
3940 std::vector<typename InputVector::value_type> local_dof_values(
3941 this->fe_interface->n_current_interface_dofs());
3942 this->get_local_dof_values(fe_function, local_dof_values);
3943
3944 get_jump_in_function_third_derivatives_from_local_dof_values(
3945 local_dof_values, third_derivatives);
3946 }
3947
3948
3949
3950 template <int dim, int spacedim>
3951 Vector<dim, spacedim>::Vector(
3952 const FEInterfaceValues<dim, spacedim> &fe_interface,
3953 const unsigned int first_vector_component)
3954 : Base<dim, spacedim>(fe_interface)
3955 , extractor(first_vector_component)
3956 {}
3957
3958
3959
3960 template <int dim, int spacedim>
3961 typename Vector<dim, spacedim>::value_type
3962 Vector<dim, spacedim>::value(const bool here_or_there,
3963 const unsigned int interface_dof_index,
3964 const unsigned int q_point) const
3965 {
3966 const auto dof_pair = this->fe_interface->dofmap[interface_dof_index];
3967
3968 if (here_or_there && dof_pair[0] != numbers::invalid_unsigned_int)
3969 return (*(this->fe_interface->fe_face_values))[extractor].value(
3970 dof_pair[0], q_point);
3971
3972 if (!here_or_there && dof_pair[1] != numbers::invalid_unsigned_int)
3973 return (*(this->fe_interface->fe_face_values_neighbor))[extractor].value(
3974 dof_pair[1], q_point);
3975
3976 return value_type();
3977 }
3978
3979
3980
3981 template <int dim, int spacedim>
3982 typename Vector<dim, spacedim>::value_type
3983 Vector<dim, spacedim>::jump_in_values(const unsigned int interface_dof_index,
3984 const unsigned int q_point) const
3985 {
3986 const auto dof_pair = this->fe_interface->dofmap[interface_dof_index];
3987
3988 value_type value;
3989
3990 if (dof_pair[0] != numbers::invalid_unsigned_int)
3991 value +=
3992 (*(this->fe_interface->fe_face_values))[extractor].value(dof_pair[0],
3993 q_point);
3994
3995 if (dof_pair[1] != numbers::invalid_unsigned_int)
3996 value -=
3997 (*(this->fe_interface->fe_face_values_neighbor))[extractor].value(
3998 dof_pair[1], q_point);
3999
4000 return value;
4001 }
4002
4003
4004
4005 template <int dim, int spacedim>
4006 typename Vector<dim, spacedim>::value_type
4007 Vector<dim, spacedim>::average_of_values(
4008 const unsigned int interface_dof_index,
4009 const unsigned int q_point) const
4010 {
4011 const auto dof_pair = this->fe_interface->dofmap[interface_dof_index];
4012
4013 if (this->fe_interface->at_boundary())
4014 return (*(this->fe_interface->fe_face_values))[extractor].value(
4015 dof_pair[0], q_point);
4016
4017 value_type value;
4018
4019 if (dof_pair[0] != numbers::invalid_unsigned_int)
4020 value +=
4021 0.5 *
4022 (*(this->fe_interface->fe_face_values))[extractor].value(dof_pair[0],
4023 q_point);
4024
4025 if (dof_pair[1] != numbers::invalid_unsigned_int)
4026 value +=
4027 0.5 * (*(this->fe_interface->fe_face_values_neighbor))[extractor].value(
4028 dof_pair[1], q_point);
4029
4030 return value;
4031 }
4032
4033
4034
4035 template <int dim, int spacedim>
4036 typename Vector<dim, spacedim>::gradient_type
4037 Vector<dim, spacedim>::average_of_gradients(
4038 const unsigned int interface_dof_index,
4039 const unsigned int q_point) const
4040 {
4041 const auto dof_pair = this->fe_interface->dofmap[interface_dof_index];
4042
4043 if (this->fe_interface->at_boundary())
4044 return (*(this->fe_interface->fe_face_values))[extractor].gradient(
4045 dof_pair[0], q_point);
4046
4047 gradient_type value;
4048
4049 if (dof_pair[0] != numbers::invalid_unsigned_int)
4050 value +=
4051 0.5 *
4052 (*(this->fe_interface->fe_face_values))[extractor].gradient(dof_pair[0],
4053 q_point);
4054
4055 if (dof_pair[1] != numbers::invalid_unsigned_int)
4056 value += 0.5 * (*(this->fe_interface->fe_face_values_neighbor))[extractor]
4057 .gradient(dof_pair[1], q_point);
4058
4059 return value;
4060 }
4061
4062
4063
4064 template <int dim, int spacedim>
4065 typename Vector<dim, spacedim>::gradient_type
4066 Vector<dim, spacedim>::jump_in_gradients(
4067 const unsigned int interface_dof_index,
4068 const unsigned int q_point) const
4069 {
4070 const auto dof_pair = this->fe_interface->dofmap[interface_dof_index];
4071
4072 if (this->fe_interface->at_boundary())
4073 return (*(this->fe_interface->fe_face_values))[extractor].gradient(
4074 dof_pair[0], q_point);
4075
4076 gradient_type value;
4077
4078 if (dof_pair[0] != numbers::invalid_unsigned_int)
4079 value +=
4080 (*(this->fe_interface->fe_face_values))[extractor].gradient(dof_pair[0],
4081 q_point);
4082
4083 if (dof_pair[1] != numbers::invalid_unsigned_int)
4084 value -=
4085 (*(this->fe_interface->fe_face_values_neighbor))[extractor].gradient(
4086 dof_pair[1], q_point);
4087
4088 return value;
4089 }
4090
4091
4092
4093 template <int dim, int spacedim>
4094 typename Vector<dim, spacedim>::gradient_type
4095 Vector<dim, spacedim>::jump_gradient(const unsigned int interface_dof_index,
4096 const unsigned int q_point) const
4097 {
4098 return jump_in_gradients(interface_dof_index, q_point);
4099 }
4100
4101
4102
4103 template <int dim, int spacedim>
4104 typename Vector<dim, spacedim>::hessian_type
4105 Vector<dim, spacedim>::average_of_hessians(
4106 const unsigned int interface_dof_index,
4107 const unsigned int q_point) const
4108 {
4109 const auto dof_pair = this->fe_interface->dofmap[interface_dof_index];
4110
4111 if (this->fe_interface->at_boundary())
4112 return (*(this->fe_interface->fe_face_values))[extractor].hessian(
4113 dof_pair[0], q_point);
4114
4115 hessian_type value;
4116
4117 if (dof_pair[0] != numbers::invalid_unsigned_int)
4118 value +=
4119 0.5 *
4120 (*(this->fe_interface->fe_face_values))[extractor].hessian(dof_pair[0],
4121 q_point);
4122
4123 if (dof_pair[1] != numbers::invalid_unsigned_int)
4124 value += 0.5 * (*(this->fe_interface->fe_face_values_neighbor))[extractor]
4125 .hessian(dof_pair[1], q_point);
4126
4127 return value;
4128 }
4129
4130
4131
4132 template <int dim, int spacedim>
4133 typename Vector<dim, spacedim>::hessian_type
4134 Vector<dim, spacedim>::average_hessian(const unsigned int interface_dof_index,
4135 const unsigned int q_point) const
4136 {
4137 return average_of_hessians(interface_dof_index, q_point);
4138 }
4139
4140
4141
4142 template <int dim, int spacedim>
4143 typename Vector<dim, spacedim>::hessian_type
4144 Vector<dim, spacedim>::jump_in_hessians(
4145 const unsigned int interface_dof_index,
4146 const unsigned int q_point) const
4147 {
4148 const auto dof_pair = this->fe_interface->dofmap[interface_dof_index];
4149
4150 if (this->fe_interface->at_boundary())
4151 return (*(this->fe_interface->fe_face_values))[extractor].hessian(
4152 dof_pair[0], q_point);
4153
4154 hessian_type value;
4155
4156 if (dof_pair[0] != numbers::invalid_unsigned_int)
4157 value +=
4158 (*(this->fe_interface->fe_face_values))[extractor].hessian(dof_pair[0],
4159 q_point);
4160
4161 if (dof_pair[1] != numbers::invalid_unsigned_int)
4162 value -=
4163 (*(this->fe_interface->fe_face_values_neighbor))[extractor].hessian(
4164 dof_pair[1], q_point);
4165
4166 return value;
4167 }
4168
4169
4170
4171 template <int dim, int spacedim>
4172 typename Vector<dim, spacedim>::hessian_type
4173 Vector<dim, spacedim>::jump_hessian(const unsigned int interface_dof_index,
4174 const unsigned int q_point) const
4175 {
4176 return jump_in_hessians(interface_dof_index, q_point);
4177 }
4178
4179
4180
4181 template <int dim, int spacedim>
4182 typename Vector<dim, spacedim>::third_derivative_type
4183 Vector<dim, spacedim>::jump_in_third_derivatives(
4184 const unsigned int interface_dof_index,
4185 const unsigned int q_point) const
4186 {
4187 const auto dof_pair = this->fe_interface->dofmap[interface_dof_index];
4188
4189 if (this->fe_interface->at_boundary())
4190 return (*(this->fe_interface->fe_face_values))[extractor]
4191 .third_derivative(dof_pair[0], q_point);
4192
4193 third_derivative_type value;
4194
4195 if (dof_pair[0] != numbers::invalid_unsigned_int)
4196 value +=
4197 (*(this->fe_interface->fe_face_values))[extractor].third_derivative(
4198 dof_pair[0], q_point);
4199
4200 if (dof_pair[1] != numbers::invalid_unsigned_int)
4201 value -= (*(this->fe_interface->fe_face_values_neighbor))[extractor]
4202 .third_derivative(dof_pair[1], q_point);
4203
4204 return value;
4205 }
4206
4207
4208
4209 template <int dim, int spacedim>
4210 template <class InputVector>
4211 void
4212 Vector<dim, spacedim>::get_function_values_from_local_dof_values(
4213 const bool here_or_there,
4214 const InputVector &local_dof_values,
4215 std::vector<solution_value_type<typename InputVector::value_type>> &values)
4216 const
4217 {
4218 AssertDimension(values.size(), this->fe_interface->n_quadrature_points);
4219
4220 for (const auto dof_index : this->fe_interface->dof_indices())
4221 for (const auto q_index : this->fe_interface->quadrature_point_indices())
4222 {
4223 if (dof_index == 0)
4224 values[q_index] = 0.;
4225
4226 values[q_index] += local_dof_values[dof_index] *
4227 value(here_or_there, dof_index, q_index);
4228 }
4229 }
4230
4231
4232
4233 template <int dim, int spacedim>
4234 template <class InputVector>
4235 void
4236 Vector<dim, spacedim>::get_function_values(
4237 const bool here_or_there,
4238 const InputVector &fe_function,
4239 std::vector<solution_value_type<typename InputVector::value_type>> &values)
4240 const
4241 {
4242 std::vector<typename InputVector::value_type> local_dof_values(
4243 this->fe_interface->n_current_interface_dofs());
4244 this->get_local_dof_values(fe_function, local_dof_values);
4245
4246 get_function_values_from_local_dof_values(here_or_there,
4247 local_dof_values,
4248 values);
4249 }
4250
4251
4252
4253 template <int dim, int spacedim>
4254 template <class InputVector>
4255 void
4256 Vector<dim, spacedim>::get_jump_in_function_values_from_local_dof_values(
4257 const InputVector &local_dof_values,
4258 std::vector<solution_value_type<typename InputVector::value_type>> &values)
4259 const
4260 {
4261 AssertDimension(values.size(), this->fe_interface->n_quadrature_points);
4262
4263 for (const auto dof_index : this->fe_interface->dof_indices())
4264 for (const auto q_index : this->fe_interface->quadrature_point_indices())
4265 {
4266 if (dof_index == 0)
4267 values[q_index] = 0.;
4268
4269 values[q_index] +=
4270 local_dof_values[dof_index] * jump_in_values(dof_index, q_index);
4271 }
4272 }
4273
4274
4275
4276 template <int dim, int spacedim>
4277 template <class InputVector>
4278 void
4279 Vector<dim, spacedim>::get_jump_in_function_values(
4280 const InputVector &fe_function,
4281 std::vector<solution_value_type<typename InputVector::value_type>> &values)
4282 const
4283 {
4284 std::vector<typename InputVector::value_type> local_dof_values(
4285 this->fe_interface->n_current_interface_dofs());
4286 this->get_local_dof_values(fe_function, local_dof_values);
4287
4288 get_jump_in_function_values_from_local_dof_values(local_dof_values, values);
4289 }
4290
4291
4292
4293 template <int dim, int spacedim>
4294 template <class InputVector>
4295 void
4296 Vector<dim, spacedim>::get_jump_in_function_gradients_from_local_dof_values(
4297 const InputVector &local_dof_values,
4298 std::vector<solution_gradient_type<typename InputVector::value_type>>
4299 &gradients) const
4300 {
4301 AssertDimension(gradients.size(), this->fe_interface->n_quadrature_points);
4302
4303 for (const auto dof_index : this->fe_interface->dof_indices())
4304 for (const auto q_index : this->fe_interface->quadrature_point_indices())
4305 {
4306 if (dof_index == 0)
4307 gradients[q_index] = 0.;
4308
4309 gradients[q_index] +=
4310 local_dof_values[dof_index] * jump_in_gradients(dof_index, q_index);
4311 }
4312 }
4313
4314
4315
4316 template <int dim, int spacedim>
4317 template <class InputVector>
4318 void
4319 Vector<dim, spacedim>::get_jump_in_function_gradients(
4320 const InputVector &fe_function,
4321 std::vector<solution_gradient_type<typename InputVector::value_type>>
4322 &gradients) const
4323 {
4324 std::vector<typename InputVector::value_type> local_dof_values(
4325 this->fe_interface->n_current_interface_dofs());
4326 this->get_local_dof_values(fe_function, local_dof_values);
4327
4328 get_jump_in_function_gradients_from_local_dof_values(local_dof_values,
4329 gradients);
4330 }
4331
4332
4333
4334 template <int dim, int spacedim>
4335 template <class InputVector>
4336 void
4337 Vector<dim, spacedim>::get_average_of_function_values_from_local_dof_values(
4338 const InputVector &local_dof_values,
4339 std::vector<solution_value_type<typename InputVector::value_type>> &values)
4340 const
4341 {
4342 AssertDimension(values.size(), this->fe_interface->n_quadrature_points);
4343
4344 for (const auto dof_index : this->fe_interface->dof_indices())
4345 for (const auto q_index : this->fe_interface->quadrature_point_indices())
4346 {
4347 if (dof_index == 0)
4348 values[q_index] = 0.;
4349
4350 values[q_index] +=
4351 local_dof_values[dof_index] * average_of_values(dof_index, q_index);
4352 }
4353 }
4354
4355
4356
4357 template <int dim, int spacedim>
4358 template <class InputVector>
4359 void
4360 Vector<dim, spacedim>::get_average_of_function_values(
4361 const InputVector &fe_function,
4362 std::vector<solution_value_type<typename InputVector::value_type>> &values)
4363 const
4364 {
4365 std::vector<typename InputVector::value_type> local_dof_values(
4366 this->fe_interface->n_current_interface_dofs());
4367 this->get_local_dof_values(fe_function, local_dof_values);
4368
4369 get_average_of_function_values_from_local_dof_values(local_dof_values,
4370 values);
4371 }
4372
4373
4374
4375 template <int dim, int spacedim>
4376 template <class InputVector>
4377 void
4378 Vector<dim, spacedim>::
4379 get_average_of_function_gradients_from_local_dof_values(
4380 const InputVector &local_dof_values,
4381 std::vector<solution_gradient_type<typename InputVector::value_type>>
4382 &gradients) const
4383 {
4384 AssertDimension(gradients.size(), this->fe_interface->n_quadrature_points);
4385
4386 for (const auto dof_index : this->fe_interface->dof_indices())
4387 for (const auto q_index : this->fe_interface->quadrature_point_indices())
4388 {
4389 if (dof_index == 0)
4390 gradients[q_index] = 0.;
4391
4392 gradients[q_index] += local_dof_values[dof_index] *
4393 average_of_gradients(dof_index, q_index);
4394 }
4395 }
4396
4397
4398
4399 template <int dim, int spacedim>
4400 template <class InputVector>
4401 void
4402 Vector<dim, spacedim>::get_average_of_function_gradients(
4403 const InputVector &fe_function,
4404 std::vector<solution_gradient_type<typename InputVector::value_type>>
4405 &gradients) const
4406 {
4407 std::vector<typename InputVector::value_type> local_dof_values(
4408 this->fe_interface->n_current_interface_dofs());
4409 this->get_local_dof_values(fe_function, local_dof_values);
4410
4411 get_average_of_function_gradients_from_local_dof_values(local_dof_values,
4412 gradients);
4413 }
4414
4415
4416
4417 template <int dim, int spacedim>
4418 template <class InputVector>
4419 void
4420 Vector<dim, spacedim>::get_jump_in_function_hessians_from_local_dof_values(
4421 const InputVector &local_dof_values,
4422 std::vector<solution_hessian_type<typename InputVector::value_type>>
4423 &hessians) const
4424 {
4425 AssertDimension(hessians.size(), this->fe_interface->n_quadrature_points);
4426
4427 for (const auto dof_index : this->fe_interface->dof_indices())
4428 for (const auto q_index : this->fe_interface->quadrature_point_indices())
4429 {
4430 if (dof_index == 0)
4431 hessians[q_index] = 0.;
4432
4433 hessians[q_index] +=
4434 local_dof_values[dof_index] * jump_in_hessians(dof_index, q_index);
4435 }
4436 }
4437
4438
4439
4440 template <int dim, int spacedim>
4441 template <class InputVector>
4442 void
4443 Vector<dim, spacedim>::get_jump_in_function_hessians(
4444 const InputVector &fe_function,
4445 std::vector<solution_hessian_type<typename InputVector::value_type>>
4446 &hessians) const
4447 {
4448 std::vector<typename InputVector::value_type> local_dof_values(
4449 this->fe_interface->n_current_interface_dofs());
4450 this->get_local_dof_values(fe_function, local_dof_values);
4451
4452 get_jump_in_function_hessians_from_local_dof_values(local_dof_values,
4453 hessians);
4454 }
4455
4456
4457
4458 template <int dim, int spacedim>
4459 template <class InputVector>
4460 void
4461 Vector<dim, spacedim>::get_average_of_function_hessians_from_local_dof_values(
4462 const InputVector &local_dof_values,
4463 std::vector<solution_hessian_type<typename InputVector::value_type>>
4464 &hessians) const
4465 {
4466 AssertDimension(hessians.size(), this->fe_interface->n_quadrature_points);
4467
4468 for (const unsigned int dof_index : this->fe_interface->dof_indices())
4469 for (const auto q_index : this->fe_interface->quadrature_point_indices())
4470 {
4471 if (dof_index == 0)
4472 hessians[q_index] = 0.;
4473
4474 hessians[q_index] += local_dof_values[dof_index] *
4475 average_of_hessians(dof_index, q_index);
4476 }
4477 }
4478
4479
4480
4481 template <int dim, int spacedim>
4482 template <class InputVector>
4483 void
4484 Vector<dim, spacedim>::get_average_of_function_hessians(
4485 const InputVector &fe_function,
4486 std::vector<solution_hessian_type<typename InputVector::value_type>>
4487 &hessians) const
4488 {
4489 std::vector<typename InputVector::value_type> local_dof_values(
4490 this->fe_interface->n_current_interface_dofs());
4491 this->get_local_dof_values(fe_function, local_dof_values);
4492
4493 get_average_of_function_hessians_from_local_dof_values(local_dof_values,
4494 hessians);
4495 }
4496
4497
4498
4499 template <int dim, int spacedim>
4500 template <class InputVector>
4501 void
4502 Vector<dim, spacedim>::
4503 get_jump_in_function_third_derivatives_from_local_dof_values(
4504 const InputVector &local_dof_values,
4505 std::vector<
4506 solution_third_derivative_type<typename InputVector::value_type>>
4507 &third_derivatives) const
4508 {
4509 AssertDimension(third_derivatives.size(),
4510 this->fe_interface->n_quadrature_points);
4511
4512 for (const unsigned int dof_index : this->fe_interface->dof_indices())
4513 for (const auto q_index : this->fe_interface->quadrature_point_indices())
4514 {
4515 if (dof_index == 0)
4516 third_derivatives[q_index] = 0.;
4517
4518 third_derivatives[q_index] +=
4519 local_dof_values[dof_index] *
4520 jump_in_third_derivatives(dof_index, q_index);
4521 }
4522 }
4523
4524
4525
4526 template <int dim, int spacedim>
4527 template <class InputVector>
4528 void
4529 Vector<dim, spacedim>::get_jump_in_function_third_derivatives(
4530 const InputVector &fe_function,
4531 std::vector<
4532 solution_third_derivative_type<typename InputVector::value_type>>
4533 &third_derivatives) const
4534 {
4535 std::vector<typename InputVector::value_type> local_dof_values(
4536 this->fe_interface->n_current_interface_dofs());
4537 this->get_local_dof_values(fe_function, local_dof_values);
4538
4539 get_jump_in_function_third_derivatives_from_local_dof_values(
4540 local_dof_values, third_derivatives);
4541 }
4542 } // namespace FEInterfaceViews
4543
4544 #endif // DOXYGEN
4545
4546 DEAL_II_NAMESPACE_CLOSE
4547
4548 #endif