Debian Codegraph @

include/deal.II/meshworker/scratch_data.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2019 - 2024 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_meshworker_scratch_data_h
16 #define dealii_meshworker_scratch_data_h
17
18 #include <deal.II/base/config.h>
19
20 #include <deal.II/algorithms/general_data_storage.h>
21
22 #include <deal.II/differentiation/ad.h>
23
24 #include <deal.II/fe/fe_interface_values.h>
25 #include <deal.II/fe/fe_values.h>
26
27 #include <deal.II/hp/fe_values.h>
28 #include <deal.II/hp/mapping_collection.h>
29 #include <deal.II/hp/q_collection.h>
30
31 #include <boost/any.hpp>
32
33 #include <algorithm>
34 #include <vector>
35
36 DEAL_II_NAMESPACE_OPEN
37
38 namespace MeshWorker
39 {
40 /**
41 * A helper class to simplify the parallel assembly of linear and non-linear
42 * problems, and the evaluation of finite element fields.
43 *
44 * This class is a drop in ScratchData to use with the WorkStream::run()
45 * function and with the MeshWorker::mesh_loop() function.
46 *
47 * The ScratchData class has three main goals:
48 * - to create FEValues, FEFaceValues, FESubfaceValues, and FEInterfaceValues
49 * for the current cell and for its neighbor cell *on demand* (only if they
50 * are necessary for the algorithm provided by the user), and to provide a
51 * uniform interface to access the FEValues objects when assembling cell,
52 * face, or subface contributions
53 * - to store arbitrary data types (or references to arbitrary data types),
54 * that can be retrieved by name (for example, when the assembly needs to
55 * make reference to other objects such as previous time steps' solution
56 * vectors, previous nonlinear iteration vectors, geometry descriptions,
57 * etc.) in an object of type
58 * - to provide a reasonable interface for those use cases where the user may
59 * need temporary vectors of data at quadrature points, allowing the
60 * construction of these temporaries *on demand*, and easy access to
61 * values, gradients, etc., of already computed solution vectors.
62 *
63 * The methods in the section "Methods to work on current cell"
64 * initialize on demand internal FEValues, FEFaceValues, FESubfaceValues, and
65 * FEInterfaceValues objects on the current cell, allowing the use of this
66 * class as a single substitute for four different objects used to integrate
67 * and query finite element values on cells, faces, and subfaces.
68 *
69 * Similarly, the methods in the section "Methods to work on neighbor cell"
70 * initialize on demand
71 * (different) internal FEValues, FEFaceValues, and FESubfaceValues, on
72 * neighbor cells, allowing the use of this class also as a single substitute
73 * for the additional three objects you would typically need to integrate on
74 * the neighbor cell, and on its faces and subfaces (for example, in
75 * discontinuous Galerkin methods).
76 *
77 * If you need to retrieve values or gradients of finite element solution
78 * vectors, on the cell, face, or subface that has just been initialized
79 * with one of the functions in the section "Methods to work on current cell",
80 * you can use the methods in the section "Evaluation of finite element fields
81 * and their derivatives on the current cell".
82 *
83 * An example usage for this class is given by the following snippet of code:
84 *
85 * @code
86 * ScratchData<dim,spacedim> scratch(fe,
87 * cell_quadrature,
88 * update_values | update_gradients);
89 *
90 * FEValuesExtractors::Vector velocity(0);
91 * FEValuesExtractors::Scalar pressure(dim);
92 *
93 * ...
94 *
95 * for(const auto &cell : dof_handler.active_cell_iterators())
96 * {
97 * const auto &fe_values = scratch.reinit(cell);
98 * scratch.extract_local_dof_values("current_solution",
99 * current_solution);
100 *
101 * scratch.extract_local_dof_values("previous_solution",
102 * previous_solution);
103 *
104 * const auto &local_solution_values =
105 * scratch.get_local_dof_values("current_solution",
106 * current_solution);
107 *
108 * const auto &local_previous_solution_values =
109 * scratch.get_local_dof_values("previous_solution",
110 * previous_solution);
111 *
112 * const auto &previous_solution_values_velocity =
113 * scratch.get_values("previous_solution", velocity);
114 * const auto &previous_solution_values_pressure =
115 * scratch.get_values("previous_solution", pressure);
116 *
117 * const auto &solution_values_velocity =
118 * scratch.get_values("solution", velocity);
119 * const auto &solution_values_pressure =
120 * scratch.get_values("solution", pressure);
121 *
122 * const auto &solution_symmetric_gradients_velocity =
123 * scratch.get_symmetric_gradients("solution", velocity);
124 *
125 * // Do something with the above.
126 * }
127 * @endcode
128 *
129 * The order in which you call functions of this class matters: if you call
130 * the ScratchData::reinit() function that takes an active cell iterator,
131 * then subsequent calls to methods that internally need an FEValuesBase
132 * object will use the internal FEValues object initialized with the given
133 * cell to perform their calculations. On the other hand, if you have called
134 * the ScratchData::reinit() method that also takes a face index, all
135 * subsequent calls to methods that need an FEValuesBase object, will use an
136 * internally stored FEFaceValues object, initialized with the cell and face
137 * index passed to the ScratchData::reinit() function. The same applies for
138 * the ScratchData::reinit() method that takes three arguments: the cell, the
139 * face index, and the subface index.
140 *
141 * The user code should be structured without interleaving work on cells and
142 * work on faces.
143 *
144 * Consider, for example, the following snippet of code:
145 *
146 * @code
147 * ScratchData<dim,spacedim> scratch(...);
148 * FEValuesExtractors::Scalar temperature(0);
149 *
150 * for(const auto &cell : dof_handler.active_cell_iterators())
151 * {
152 * const auto &fe_values = scratch.reinit(cell);
153 * const auto &local_dof_values =
154 * scratch.extract_local_dof_values("solution", solution);
155 *
156 * // This will contain all values of the temperature on the cell
157 * // quadrature points
158 * const auto &solution_values_cell =
159 * scratch.get_values("solution", temperature);
160 *
161 * // Do something with values on the cell
162 * ...
163 *
164 * // Now start working on the faces
165 * for(unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
166 * {
167 * const auto &fe_face_values = scratch.reinit(cell, f);
168 *
169 * // Now we'll have access to the values of the temperature on the faces
170 * const auto &solution_values_face =
171 * scratch.get_values("solution", temperature);
172 *
173 * // Notice how the function call is the same, but the result depends
174 * // on what was the last reinit() function that was called. In this
175 * // case, we called reinit(cell, f), triggering internal work on
176 * // faces.
177 * }
178 *
179 * // At this point, we would like to go back and work on cells,
180 * // for example querying the values of the gradients:
181 * const auto &solution_gradients =
182 * scratch.get_gradients("solution", temperature);
183 *
184 * // This assertion would be triggered in debug mode
185 * AssertDimension(solution_gradients.size(), quadrature_cell.size());
186 *
187 * // However, with the above call the content of solution_gradients is the
188 * // gradient of the temperature on the quadrature points of the last face
189 * // visited in the previous loop.
190 * // If you really want to have the values of the gradients on the cell,
191 * // at this point your only option is to call
192 * scratch.reinit(cell);
193 *
194 * // (again) before querying for the gradients:
195 * const auto &solution_gradients_cell =
196 * scratch.get_gradients("solution", temperature);
197 *
198 * // The call to reinit(cell), however, is an expensive one. You
199 * // should make sure you only call it once per cell by grouping together
200 * // all queries that concern cells in the same place (right after you
201 * // call the reinit(cell) method).
202 * // A similar argument holds for all calls on each face and subface.
203 * }
204 * @endcode
205 *
206 * When using this class, please cite @cite SartoriGiulianiBardelloni-2018-a.
207 */
208 template <int dim, int spacedim = dim>
209 class ScratchData
210 {
211 public:
212 /**
213 * Create an empty ScratchData object. A ObserverPointer pointing to
214 * @p mapping and @p fe is stored internally. Make sure they live longer
215 * than this class instance.
216 *
217 * The constructor does not initialize any of the internal FEValues objects.
218 * These are initialized the first time one of the reinit() functions is
219 * called, using the arguments passed here.
220 *
221 * @param mapping The mapping to use in the internal FEValues objects
222 * @param fe The finite element
223 * @param quadrature The cell quadrature
224 * @param update_flags UpdateFlags for the current cell FEValues and
225 * neighbor cell FEValues
226 * @param face_quadrature Face quadrature, used for FEFaceValues and
227 * FESubfaceValues for both the current cell and the neighbor cell
228 * @param face_update_flags UpdateFlags used for FEFaceValues and
229 * FESubfaceValues for both the current cell and the neighbor cell
230 */
231 ScratchData(
232 const Mapping<dim, spacedim> &mapping,
233 const FiniteElement<dim, spacedim> &fe,
234 const Quadrature<dim> &quadrature,
235 const UpdateFlags &update_flags,
236 const Quadrature<dim - 1> &face_quadrature = Quadrature<dim - 1>(),
237 const UpdateFlags &face_update_flags = update_default);
238
239 /**
240 * Similar to the other constructor, but this one allows to specify
241 * different flags for neighbor cells and faces.
242 *
243 * @param mapping The mapping to use in the internal FEValues objects
244 * @param fe The finite element
245 * @param quadrature The cell quadrature
246 * @param update_flags UpdateFlags for the current cell FEValues
247 * @param neighbor_update_flags UpdateFlags for the neighbor cell FEValues
248 * @param face_quadrature Face quadrature, used for FEFaceValues and
249 * FESubfaceValues for both the current cell and the neighbor cell
250 * @param face_update_flags UpdateFlags used for FEFaceValues and
251 * FESubfaceValues for the current cell
252 * @param neighbor_face_update_flags UpdateFlags used for FEFaceValues and
253 * FESubfaceValues for the neighbor cell
254 */
255 ScratchData(
256 const Mapping<dim, spacedim> &mapping,
257 const FiniteElement<dim, spacedim> &fe,
258 const Quadrature<dim> &quadrature,
259 const UpdateFlags &update_flags,
260 const UpdateFlags &neighbor_update_flags,
261 const Quadrature<dim - 1> &face_quadrature = Quadrature<dim - 1>(),
262 const UpdateFlags &face_update_flags = update_default,
263 const UpdateFlags &neighbor_face_update_flags = update_default);
264
265 /**
266 * Same as the other constructor, using the default linear mapping.
267 *
268 * @param fe The finite element
269 * @param quadrature The cell quadrature
270 * @param update_flags UpdateFlags for the current cell FEValues and
271 * neighbor cell FEValues
272 * @param face_quadrature Face quadrature, used for FEFaceValues and
273 * FESubfaceValues for both the current cell and the neighbor cell
274 * @param face_update_flags UpdateFlags used for FEFaceValues and
275 * FESubfaceValues for both the current cell and the neighbor cell
276 */
277 ScratchData(
278 const FiniteElement<dim, spacedim> &fe,
279 const Quadrature<dim> &quadrature,
280 const UpdateFlags &update_flags,
281 const Quadrature<dim - 1> &face_quadrature = Quadrature<dim - 1>(),
282 const UpdateFlags &face_update_flags = update_default);
283
284 /**
285 * Same as the other constructor, using the default linear mapping.
286 *
287 * @param fe The finite element
288 * @param quadrature The cell quadrature
289 * @param update_flags UpdateFlags for the current cell FEValues
290 * @param neighbor_update_flags UpdateFlags for the neighbor cell FEValues
291 * @param face_quadrature Face quadrature, used for FEFaceValues and
292 * FESubfaceValues for both the current cell and the neighbor cell
293 * @param face_update_flags UpdateFlags used for FEFaceValues and
294 * FESubfaceValues for the current cell
295 * @param neighbor_face_update_flags UpdateFlags used for FEFaceValues and
296 * FESubfaceValues for the neighbor cell
297 */
298 ScratchData(
299 const FiniteElement<dim, spacedim> &fe,
300 const Quadrature<dim> &quadrature,
301 const UpdateFlags &update_flags,
302 const UpdateFlags &neighbor_update_flags,
303 const Quadrature<dim - 1> &face_quadrature = Quadrature<dim - 1>(),
304 const UpdateFlags &face_update_flags = update_default,
305 const UpdateFlags &neighbor_face_update_flags = update_default);
306
307 /**
308 * Create an empty ScratchData object. A ObserverPointer pointing to
309 * @p mapping_collection and @p fe_collection is stored internally. Make sure they live longer
310 * than this class instance.
311 *
312 * The constructor does not initialize any of the internal hp::FEValues
313 * objects. These are initialized the first time one of the reinit()
314 * functions is called, using the arguments passed here.
315 *
316 * @param mapping_collection The mapping collection to use in the internal hp::FEValues objects
317 * @param fe_collection The finite element collection
318 * @param cell_quadrature_collection The cell quadrature collection
319 * @param cell_update_flags UpdateFlags for the current cell hp::FEValues and
320 * neighbor cell hp::FEValues
321 * @param face_quadrature_collection The face quadrature collection, used for hp::FEFaceValues and
322 * hp::FESubfaceValues for both the current cell and the neighbor cell
323 * @param face_update_flags UpdateFlags used for FEFaceValues and
324 * hp::FESubfaceValues for both the current cell and the neighbor cell
325 */
326 ScratchData(const hp::MappingCollection<dim, spacedim> &mapping_collection,
327 const hp::FECollection<dim, spacedim> &fe_collection,
328 const hp::QCollection<dim> &cell_quadrature_collection,
329 const UpdateFlags &cell_update_flags,
330 const hp::QCollection<dim - 1> &face_quadrature_collection =
331 hp::QCollection<dim - 1>(),
332 const UpdateFlags &face_update_flags = update_default);
333
334 /**
335 * Similar to the other constructor, but this one allows to specify
336 * different flags for neighbor cells and faces.
337 *
338 * @param mapping_collection The mapping collection to use in the internal hp::FEValues objects
339 * @param fe_collection The finite element collection
340 * @param cell_quadrature_collection The cell quadrature collection
341 * @param cell_update_flags UpdateFlags for the current cell hp::FEValues
342 * @param neighbor_cell_update_flags UpdateFlags for the neighbor cell hp::FEValues
343 * @param face_quadrature_collection The face quadrature collection, used for hp::FEFaceValues and
344 * hp::FESubfaceValues for both the current cell and the neighbor cell
345 * @param face_update_flags UpdateFlags used for FEFaceValues and
346 * hp::FESubfaceValues for the current cell
347 * @param neighbor_face_update_flags UpdateFlags used for hp::FEFaceValues and
348 * hp::FESubfaceValues for the neighbor cell
349 */
350 ScratchData(const hp::MappingCollection<dim, spacedim> &mapping_collection,
351 const hp::FECollection<dim, spacedim> &fe_collection,
352 const hp::QCollection<dim> &cell_quadrature_collection,
353 const UpdateFlags &cell_update_flags,
354 const UpdateFlags &neighbor_cell_update_flags,
355 const hp::QCollection<dim - 1> &face_quadrature_collection =
356 hp::QCollection<dim - 1>(),
357 const UpdateFlags &face_update_flags = update_default,
358 const UpdateFlags &neighbor_face_update_flags = update_default);
359
360 /**
361 * Same as the other constructor, using the default linear mapping.
362 *
363 * @param fe_collection The finite element collection
364 * @param cell_quadrature_collection The cell quadrature collection
365 * @param cell_update_flags UpdateFlags for the current cell hp::FEValues and
366 * neighbor cell hp::FEValues
367 * @param face_quadrature_collection The face quadrature collection, used for hp::FEFaceValues and
368 * hp::FESubfaceValues for both the current cell and the neighbor cell
369 * @param face_update_flags UpdateFlags used for FEFaceValues and
370 * hp::FESubfaceValues for both the current cell and the neighbor cell
371 */
372 ScratchData(const hp::FECollection<dim, spacedim> &fe_collection,
373 const hp::QCollection<dim> &cell_quadrature_collection,
374 const UpdateFlags &cell_update_flags,
375 const hp::QCollection<dim - 1> &face_quadrature_collection =
376 hp::QCollection<dim - 1>(),
377 const UpdateFlags &face_update_flags = update_default);
378
379 /**
380 * Same as the other constructor, using the default linear mapping.
381 *
382 * @param fe_collection The finite element collection
383 * @param cell_quadrature_collection The cell quadrature collection
384 * @param cell_update_flags UpdateFlags for the current cell hp::FEValues
385 * @param neighbor_cell_update_flags UpdateFlags for the neighbor cell hp::FEValues
386 * @param face_quadrature_collection The face quadrature collection, used for hp::FEFaceValues and
387 * hp::FESubfaceValues for both the current cell and the neighbor cell
388 * @param face_update_flags UpdateFlags used for FEFaceValues and
389 * hp::FESubfaceValues for the current cell
390 * @param neighbor_face_update_flags UpdateFlags used for hp::FEFaceValues and
391 * hp::FESubfaceValues for the neighbor cell
392 */
393 ScratchData(const hp::FECollection<dim, spacedim> &fe_collection,
394 const hp::QCollection<dim> &cell_quadrature_collection,
395 const UpdateFlags &cell_update_flags,
396 const UpdateFlags &neighbor_cell_update_flags,
397 const hp::QCollection<dim - 1> &face_quadrature_collection =
398 hp::QCollection<dim - 1>(),
399 const UpdateFlags &face_update_flags = update_default,
400 const UpdateFlags &neighbor_face_update_flags = update_default);
401
402 /**
403 * Deep copy constructor. FEValues objects are not copied.
404 */
405 ScratchData(const ScratchData<dim, spacedim> &scratch);
406
407 /**
408 * @name Methods to work on current cell
409 * @{
410 */
411
412 /**
413 * Initialize the internal FEValues with the given @p cell, and return
414 * a reference to it.
415 *
416 * After calling this function, get_current_fe_values() will return the
417 * same object of this method, as an FEValuesBase reference.
418 */
419 const FEValues<dim, spacedim> &
420 reinit(
421 const typename DoFHandler<dim, spacedim>::active_cell_iterator &cell);
422
423 /**
424 * Initialize the internal FEFaceValues to use the given @p face_no on the given
425 * @p cell, and return a reference to it.
426 *
427 * After calling this function, get_current_fe_values() will return the
428 * same object of this method, as an FEValuesBase reference.
429 */
430 const FEFaceValues<dim, spacedim> &
431 reinit(const typename DoFHandler<dim, spacedim>::active_cell_iterator &cell,
432 const unsigned int face_no);
433
434 /**
435 * Initialize the internal FESubfaceValues to use the given @p subface_no,
436 * on @p face_no, on the given @p cell, and return a reference to it.
437 *
438 * After calling this function, get_current_fe_values() will return the
439 * same object of this method, as an FEValuesBase reference.
440 *
441 * If @p subface_no is numbers::invalid_unsigned_int, the reinit() function
442 * that takes only the @p cell and the @p face_no is called.
443 */
444 const FEFaceValuesBase<dim, spacedim> &
445 reinit(const typename DoFHandler<dim, spacedim>::active_cell_iterator &cell,
446 const unsigned int face_no,
447 const unsigned int subface_no);
448
449 /**
450 * Initialize the internal FEInterfaceValues with the given arguments, and
451 * return a reference to it.
452 *
453 * After calling this function, get_local_dof_indices(),
454 * get_quadrature_points(), get_normal_vectors(), and get_JxW_values() will
455 * be forwarded to the local FEInterfaceValues object. The methods
456 * get_current_fe_values() will return the FEValuesBase associated to the
457 * current cell, while get_neighbor_fe_values() will be associated with the
458 * neighbor cell. The method get_local_dof_indices() will return the
459 * same result of FEInterfaceValues::get_interface_dof_indices(),
460 * while the get_neighbor_dof_indices() will return the local dof indices
461 * of the neighbor cell.
462 */
463 const FEInterfaceValues<dim, spacedim> &
464 reinit(const typename DoFHandler<dim, spacedim>::active_cell_iterator &cell,
465 const unsigned int face_no,
466 const typename DoFHandler<dim, spacedim>::active_cell_iterator
467 &cell_neighbor,
468 const unsigned int face_no_neighbor);
469
470 /**
471 * Initialize the internal FEInterfaceValues with the given arguments, and
472 * return a reference to it.
473 *
474 * After calling this function, get_local_dof_indices(),
475 * get_quadrature_points(), get_normal_vectors(), and get_JxW_values() will
476 * be forwarded to the local FEInterfaceValues object. The methods
477 * get_current_fe_values() will return the FEValuesBase associated to the
478 * current cell, while get_neighbor_fe_values() will be associated with the
479 * neighbor cell. The method get_local_dof_indices() will return the
480 * same result of FEInterfaceValues::get_interface_dof_indices(),
481 * while the get_neighbor_dof_indices() will return the local dof indices
482 * of the neighbor cell.
483 */
484 const FEInterfaceValues<dim, spacedim> &
485 reinit(const typename DoFHandler<dim, spacedim>::active_cell_iterator &cell,
486 const unsigned int face_no,
487 const unsigned int sub_face_no,
488 const typename DoFHandler<dim, spacedim>::active_cell_iterator
489 &cell_neighbor,
490 const unsigned int face_no_neighbor,
491 const unsigned int sub_face_no_neighbor);
492
493 /**
494 * Get the currently initialized FEValues.
495 *
496 * This function will return the internal FEValues if the
497 * reinit(cell) function was called last. If the reinit(cell, face_no)
498 * function was called, then this function returns the internal
499 * FEFaceValues, and if the reinit(cell, face_no, subface_no) function was
500 * called (with a valid @p subface_no argument), it returns the internal
501 * FESubfaceValues object.
502 */
503 const FEValuesBase<dim, spacedim> &
504 get_current_fe_values() const;
505
506 /**
507 * Get the currently initialized FEInterfaceValues.
508 */
509 const FEInterfaceValues<dim, spacedim> &
510 get_current_interface_fe_values() const;
511
512 /**
513 * Return the quadrature points of the internal FEValues object.
514 */
515 const std::vector<Point<spacedim>> &
516 get_quadrature_points() const;
517
518 /**
519 * Return the JxW values of the internal FEValues object.
520 */
521 const std::vector<double> &
522 get_JxW_values() const;
523
524 /**
525 * Return the last computed normal vectors.
526 */
527 const std::vector<Tensor<1, spacedim>> &
528 get_normal_vectors() const;
529
530 /**
531 * Return the local dof indices for the cell passed the last time the
532 * reinit() function was called.
533 */
534 const std::vector<types::global_dof_index> &
535 get_local_dof_indices() const;
536
537 /**
538 * Return the number of local dof indices for the cell passed the last time
539 * the reinit() function was called.
540 */
541 unsigned int
542 n_dofs_per_cell() const;
543
544 /** @} */ // CurrentCellMethods
545
546 /**
547 * @name Methods to work on neighbor cell
548 * @{
549 */
550
551 /**
552 * Initialize the internal neighbor FEValues to use the given @p cell, and
553 * return a reference to it.
554 *
555 * After calling this function, get_current_neighbor_fe_values() will return
556 * the same object of this method, as an FEValuesBase reference.
557 */
558 const FEValues<dim, spacedim> &
559 reinit_neighbor(
560 const typename DoFHandler<dim, spacedim>::active_cell_iterator &cell);
561
562 /**
563 * Initialize the internal FEFaceValues to use the given @p face_no on the
564 * given @p cell, and return a reference to it.
565 *
566 * After calling this function, get_current_neighbor_fe_values() will return
567 * the same object of this method, as an FEValuesBase reference.
568 */
569 const FEFaceValues<dim, spacedim> &
570 reinit_neighbor(
571 const typename DoFHandler<dim, spacedim>::active_cell_iterator &cell,
572 const unsigned int face_no);
573
574 /**
575 * Initialize the internal FESubfaceValues to use the given @p subface_no,
576 * on @p face_no, on the given @p cell, and return a reference to it.
577 *
578 * After calling this function, get_current_neighbor_fe_values() will return
579 * the same object of this method, as an FEValuesBase reference.
580 *
581 * If @p subface_no is numbers::invalid_unsigned_int, the reinit() function
582 * that takes only the @p cell and the @p face_no is called.
583 */
584 const FEFaceValuesBase<dim, spacedim> &
585 reinit_neighbor(
586 const typename DoFHandler<dim, spacedim>::active_cell_iterator &cell,
587 const unsigned int face_no,
588 const unsigned int subface_no);
589
590 /**
591 * Get the currently initialized neighbor FEValues.
592 *
593 * This function will return the neighbor FEValues if the
594 * reinit_neighbor(cell) function was called last. If the
595 * reinit_neighbor(cell, face_no) function was called, then this function
596 * returns the internal neighbor FEFaceValues, and if the
597 * reinit_neighbor(cell, face_no, subface_no) function was
598 * called (with a valid @p subface_no argument), it returns the internal neighbor
599 * FESubfaceValues object.
600 */
601 const FEValuesBase<dim, spacedim> &
602 get_current_neighbor_fe_values() const;
603
604 /**
605 * Return the JxW values of the neighbor FEValues object.
606 */
607 const std::vector<double> &
608 get_neighbor_JxW_values() const;
609
610 /**
611 * Return the last computed normal vectors on the neighbor.
612 */
613 const std::vector<Tensor<1, spacedim>> &
614 get_neighbor_normal_vectors();
615
616 /**
617 * Return the local dof indices of the neighbor passed the last time the
618 * reinit_neighbor() function was called.
619 */
620 const std::vector<types::global_dof_index> &
621 get_neighbor_dof_indices() const;
622
623 /**
624 * Return the number of local dof indices for the neighbor passed the last
625 * time the reinit_neighbor() function was called.
626 */
627 unsigned int
628 n_neighbor_dofs_per_cell() const;
629
630 /** @} */ // NeighborCellMethods
631
632 /**
633 * @name hp-compatible methods to work on cells and neighbor cells
634 */
635 /** @{ */ // hpCellMethods
636
637 /**
638 * Initialize the internal FEFaceValues to use the given @p face_no on the given
639 * @p cell, and return a reference to it.
640 *
641 * This variant of the reinit() function compares the active finite element
642 * on each cell, and chooses the dominated finite element's index to select
643 * the quadrature rule and mapping for the returned FEFaceValues object.
644 * This is useful in instances where the shape functions of the elements on
645 * either side of a face are being evaluated at the same time (such as is
646 * done in DG methods). See FECollection::find_dominated_fe() for more
647 * information on the selection process.
648 *
649 * After calling this function, get_current_fe_values() will return the
650 * same object of this method, as an FEValuesBase reference.
651 */
652 const FEFaceValues<dim, spacedim> &
653 reinit(const typename DoFHandler<dim, spacedim>::active_cell_iterator &cell,
654 const typename DoFHandler<dim, spacedim>::active_cell_iterator
655 &neighbor_cell,
656 const unsigned int face_no);
657
658 /**
659 * Initialize the internal FESubfaceValues to use the given @p subface_no,
660 * on @p face_no, on the given @p cell, and return a reference to it.
661 *
662 * This variant of the reinit() function compares the active finite element
663 * on each cell, and chooses the dominated finite element's index to select
664 * the quadrature rule and mapping for the returned FEFaceValues object.
665 * This is useful in instances where the shape functions of the elements on
666 * either side of a face are being evaluated at the same time (such as is
667 * done in DG methods). See FECollection::find_dominated_fe() for more
668 * information on the selection process.
669 *
670 * After calling this function, get_current_fe_values() will return the
671 * same object of this method, as an FEValuesBase reference.
672 *
673 * If @p subface_no is numbers::invalid_unsigned_int, the reinit() function
674 * that takes only the @p cell and the @p face_no is called.
675 */
676 const FEFaceValuesBase<dim, spacedim> &
677 reinit(const typename DoFHandler<dim, spacedim>::active_cell_iterator &cell,
678 const typename DoFHandler<dim, spacedim>::active_cell_iterator
679 &neighbor_cell,
680 const unsigned int face_no,
681 const unsigned int subface_no);
682
683 /**
684 * Initialize the internal FEFaceValues to use the given @p face_no on the
685 * given @p neighbor_cell, and return a reference to it.
686 *
687 * This variant of the reinit() function compares the active finite element
688 * on each cell, and chooses the dominated finite element's index to select
689 * the quadrature rule and mapping for the returned FEFaceValues object.
690 * This is useful in instances where the shape functions of the elements on
691 * either side of a face are being evaluated at the same time (such as is
692 * done in DG methods). See FECollection::find_dominated_fe() for more
693 * information on the selection process.
694 *
695 * After calling this function, get_current_neighbor_fe_values() will return
696 * the same object of this method, as an FEValuesBase reference.
697 */
698 const FEFaceValues<dim, spacedim> &
699 reinit_neighbor(
700 const typename DoFHandler<dim, spacedim>::active_cell_iterator &cell,
701 const typename DoFHandler<dim, spacedim>::active_cell_iterator
702 &neighbor_cell,
703 const unsigned int face_no);
704
705 /**
706 * Initialize the internal FESubfaceValues to use the given @p subface_no,
707 * on @p face_no, on the given @p neighbor_cell, and return a reference to it.
708 *
709 * This variant of the reinit() function compares the active finite element
710 * on each cell, and chooses the dominated finite element's index to select
711 * the quadrature rule and mapping for the returned FEFaceValues object.
712 * This is useful in instances where the shape functions of the elements on
713 * either side of a face are being evaluated at the same time (such as is
714 * done in DG methods). See FECollection::find_dominated_fe() for more
715 * information on the selection process.
716 *
717 * After calling this function, get_current_neighbor_fe_values() will return
718 * the same object of this method, as an FEValuesBase reference.
719 *
720 * If @p subface_no is numbers::invalid_unsigned_int, the reinit() function
721 * that takes only the @p neighbor_cell and the @p face_no is called.
722 */
723 const FEFaceValuesBase<dim, spacedim> &
724 reinit_neighbor(
725 const typename DoFHandler<dim, spacedim>::active_cell_iterator &cell,
726 const typename DoFHandler<dim, spacedim>::active_cell_iterator
727 &neighbor_cell,
728 const unsigned int face_no,
729 const unsigned int subface_no);
730
731 /** @} */ // hpCellMethods
732
733 /**
734 * Return a GeneralDataStorage object that can be used to store any amount
735 * of data, of any type, which is then made accessible by an identifier
736 * string.
737 */
738 GeneralDataStorage &
739 get_general_data_storage();
740
741 /**
742 * Return a GeneralDataStorage object that can be used to store any amount
743 * of data, of any type, which is then made accessible by an identifier
744 * string.
745 */
746 const GeneralDataStorage &
747 get_general_data_storage() const;
748
749 /**
750 * Return a reference to the used mapping.
751 */
752 const Mapping<dim, spacedim> &
753 get_mapping() const;
754
755 /**
756 * Return a reference to the selected finite element object.
757 */
758 const FiniteElement<dim, spacedim> &
759 get_fe() const;
760
761 /**
762 * Return a reference to the cell quadrature object in use.
763 */
764 const Quadrature<dim> &
765 get_cell_quadrature() const;
766
767 /**
768 * Return a reference to the face quadrature object in use.
769 */
770 const Quadrature<dim - 1> &
771 get_face_quadrature() const;
772
773 /**
774 * Return a reference to the used mapping.
775 */
776 const hp::MappingCollection<dim, spacedim> &
777 get_mapping_collection() const;
778
779 /**
780 * Return a reference to the selected finite element object.
781 */
782 const hp::FECollection<dim, spacedim> &
783 get_fe_collection() const;
784
785 /**
786 * Return a reference to the cell quadrature object in use.
787 */
788 const hp::QCollection<dim> &
789 get_cell_quadrature_collection() const;
790
791 /**
792 * Return a reference to the face quadrature object in use.
793 */
794 const hp::QCollection<dim - 1> &
795 get_face_quadrature_collection() const;
796
797 /**
798 * Returns a boolean indicating whether or not this ScratchData object has
799 * hp-capabilities enabled.
800 */
801 bool
802 has_hp_capabilities() const;
803
804 /**
805 * Return the cell update flags set.
806 */
807 UpdateFlags
808 get_cell_update_flags() const;
809
810 /**
811 * Return the neighbor cell update flags set.
812 */
813 UpdateFlags
814 get_neighbor_cell_update_flags() const;
815
816 /**
817 * Return the face update flags set.
818 */
819 UpdateFlags
820 get_face_update_flags() const;
821
822 /**
823 * Return the neighbor face update flags set.
824 */
825 UpdateFlags
826 get_neighbor_face_update_flags() const;
827
828 /**
829 * @name Evaluation of finite element fields and their derivatives on the current cell
830 */
831 /** @{ */ // CurrentCellEvaluation
832
833 /**
834 * Extract the local dof values associated with the internally initialized
835 * cell.
836 *
837 * Before you call this function, you have to make sure you have previously
838 * called one of the reinit() functions.
839 *
840 * At every call of this function, a new vector of dof values is generated
841 * and stored internally, unless a previous vector with the same name is
842 * found. If this is the case, the content of that vector is overwritten.
843 *
844 * If you give a unique @p global_vector_name, then for each cell you are
845 * guaranteed to get a unique vector of independent dofs of the same type
846 * as the dummy variable. If you use an automatic differentiation number
847 * type (like Sacado::Fad::DFad<double>,
848 * Sacado::Fad::DFad<Sacado::Fad::DFad<double>>, etc.) this method will
849 * also initialize the independent variables internally, allowing you
850 * to perform automatic differentiation.
851 *
852 * You can access the extracted local dof values by calling the method
853 * get_local_dof_values() with the same @p global_vector_name argument
854 * you passed here.
855 *
856 * Notice that using this initialization strategy renders the use of this
857 * ScratchData object incompatible with the AD helper classes (since they
858 * do their own data management). In particular, it is necessary for the
859 * user to manage all of the AD data themselves (both before and after this
860 * call).
861 */
862 template <typename VectorType, typename Number = double>
863 void
864 extract_local_dof_values(const std::string &global_vector_name,
865 const VectorType &input_vector,
866 const Number dummy = Number(0));
867
868 /**
869 * After calling extract_local_dof_values(), you can retrieve the stored
870 * information through this method.
871 *
872 * Both the argument @p global_vector_name and the type of the @p dummy
873 * variable should match the ones you passed to the
874 * extract_local_dof_values() function.
875 */
876 template <typename Number = double>
877 const std::vector<Number> &
878 get_local_dof_values(const std::string &global_vector_name,
879 Number dummy = Number(0)) const;
880
881 /**
882 * For the solution vector identified by @p global_vector_name, compute
883 * the values of the function at the quadrature points, and return a
884 * vector with the correct type deduced by the Extractor you passed as the
885 * @p variable argument.
886 *
887 * Before you can call this method, you need to call the
888 * extract_local_dof_values() method at least once, passing the same
889 * @p global_vector_name string, and the same type for the variable @p dummy.
890 *
891 * If you have not previously called the extract_local_dof_values() method,
892 * this function will throw an exception.
893 *
894 * For this function to work properly, the underlying FEValues,
895 * FEFaceValues, or FESubfaceValues object for which you called one of the
896 * reinit() functions, must have computed the information you are
897 * requesting. To do so, the update_values flag must be an element of the
898 * list of UpdateFlags that you passed to the constructor of this object.
899 * See "The interplay of UpdateFlags, Mapping, and FiniteElement" in
900 * the documentation of the FEValues class for more information.
901 */
902 template <typename Extractor, typename Number = double>
903 const std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
904 template solution_value_type<Number>> &
905 get_values(const std::string &global_vector_name,
906 const Extractor &variable,
907 const Number dummy = Number(0));
908
909 /**
910 * For the solution vector identified by @p global_vector_name, compute
911 * the gradients of the function at the quadrature points, and return a
912 * vector with the correct type deduced by the Extractor you passed as the
913 * @p variable argument.
914 *
915 * Before you can call this method, you need to call the
916 * extract_local_dof_values() method at least once, passing the same
917 * @p global_vector_name string, and the same type for the variable @p dummy.
918 *
919 * If you have not previously called the extract_local_dof_values() method,
920 * this function will throw an exception.
921 *
922 * For this function to work properly, the underlying FEValues,
923 * FEFaceValues, or FESubfaceValues object for which you called one of the
924 * reinit() functions, must have computed the information you are
925 * requesting. To do so, the update_gradients flag must be an element of the
926 * list of UpdateFlags that you passed to the constructor of this object.
927 * See "The interplay of UpdateFlags, Mapping, and FiniteElement" in
928 * the documentation of the FEValues class for more information.
929 */
930 template <typename Extractor, typename Number = double>
931 const std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
932 template solution_gradient_type<Number>> &
933 get_gradients(const std::string &global_vector_name,
934 const Extractor &variable,
935 const Number dummy = Number(0));
936
937 /**
938 * For the solution vector identified by @p global_vector_name, compute
939 * the symmetric gradients of the function at the quadrature points, and
940 * return a vector with the correct type deduced by the Extractor you passed
941 * as the
942 * @p variable argument.
943 *
944 * Before you can call this method, you need to call the
945 * extract_local_dof_values() method at least once, passing the same
946 * @p global_vector_name string, and the same type for the variable @p dummy.
947 *
948 * If you have not previously called the extract_local_dof_values() method,
949 * this function will throw an exception.
950 *
951 * For this function to work properly, the underlying FEValues,
952 * FEFaceValues, or FESubfaceValues object for which you called one of the
953 * reinit() functions, must have computed the information you are
954 * requesting. To do so, the update_gradients flag must be an element of the
955 * list of UpdateFlags that you passed to the constructor of this object.
956 * See "The interplay of UpdateFlags, Mapping, and FiniteElement" in
957 * the documentation of the FEValues class for more information.
958 */
959 template <typename Extractor, typename Number = double>
960 const std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
961 template solution_symmetric_gradient_type<Number>> &
962 get_symmetric_gradients(const std::string &global_vector_name,
963 const Extractor &variable,
964 const Number dummy = Number(0));
965
966 /**
967 * For the solution vector identified by @p global_vector_name, compute
968 * the divergences of the function at the quadrature points, and return a
969 * vector with the correct type deduced by the Extractor you passed as the
970 * @p variable argument.
971 *
972 * Before you can call this method, you need to call the
973 * extract_local_dof_values() method at least once, passing the same
974 * @p global_vector_name string, and the same type for the variable @p dummy.
975 *
976 * If you have not previously called the extract_local_dof_values() method,
977 * this function will throw an exception.
978 *
979 * For this function to work properly, the underlying FEValues,
980 * FEFaceValues, or FESubfaceValues object for which you called one of the
981 * reinit() functions, must have computed the information you are
982 * requesting. To do so, the update_gradients flag must be an element of the
983 * list of UpdateFlags that you passed to the constructor of this object.
984 * See "The interplay of UpdateFlags, Mapping, and FiniteElement" in
985 * the documentation of the FEValues class for more information.
986 */
987 template <typename Extractor, typename Number = double>
988 const std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
989 template solution_divergence_type<Number>> &
990 get_divergences(const std::string &global_vector_name,
991 const Extractor &variable,
992 const Number dummy = Number(0));
993
994 /**
995 * For the solution vector identified by @p global_vector_name, compute
996 * the curls of the function at the quadrature points, and return a
997 * vector with the correct type deduced by the Extractor you passed as the
998 * @p variable argument.
999 *
1000 * Before you can call this method, you need to call the
1001 * extract_local_dof_values() method at least once, passing the same
1002 * @p global_vector_name string, and the same type for the variable @p dummy.
1003 *
1004 * If you have not previously called the extract_local_dof_values() method,
1005 * this function will throw an exception.
1006 *
1007 * For this function to work properly, the underlying FEValues,
1008 * FEFaceValues, or FESubfaceValues object for which you called one of the
1009 * reinit() functions, must have computed the information you are
1010 * requesting. To do so, the update_gradients flag must be an element of the
1011 * list of UpdateFlags that you passed to the constructor of this object.
1012 * See "The interplay of UpdateFlags, Mapping, and FiniteElement" in
1013 * the documentation of the FEValues class for more information.
1014 */
1015 template <typename Extractor, typename Number = double>
1016 const std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1017 template solution_curl_type<Number>> &
1018 get_curls(const std::string &global_vector_name,
1019 const Extractor &variable,
1020 const Number dummy = Number(0));
1021
1022 /**
1023 * For the solution vector identified by @p global_vector_name, compute
1024 * the Hessians of the function at the quadrature points, and return a
1025 * vector with the correct type deduced by the Extractor you passed as the
1026 * @p variable argument.
1027 *
1028 * Before you can call this method, you need to call the
1029 * extract_local_dof_values() method at least once, passing the same
1030 * @p global_vector_name string, and the same type for the variable @p dummy.
1031 *
1032 * If you have not previously called the extract_local_dof_values() method,
1033 * this function will throw an exception.
1034 *
1035 * For this function to work properly, the underlying FEValues,
1036 * FEFaceValues, or FESubfaceValues object for which you called one of the
1037 * reinit() functions, must have computed the information you are
1038 * requesting. To do so, the update_hessians flag must be an element of the
1039 * list of UpdateFlags that you passed to the constructor of this object.
1040 * See "The interplay of UpdateFlags, Mapping, and FiniteElement" in
1041 * the documentation of the FEValues class for more information.
1042 */
1043 template <typename Extractor, typename Number = double>
1044 const std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1045 template solution_hessian_type<Number>> &
1046 get_hessians(const std::string &global_vector_name,
1047 const Extractor &variable,
1048 const Number dummy = Number(0));
1049
1050 /**
1051 * For the solution vector identified by @p global_vector_name, compute
1052 * the Laplacians of the function at the quadrature points, and return a
1053 * vector with the correct type deduced by the Extractor you passed as the
1054 * @p variable argument.
1055 *
1056 * Before you can call this method, you need to call the
1057 * extract_local_dof_values() method at least once, passing the same
1058 * @p global_vector_name string, and the same type for the variable @p dummy.
1059 *
1060 * If you have not previously called the extract_local_dof_values() method,
1061 * this function will throw an exception.
1062 *
1063 * For this function to work properly, the underlying FEValues,
1064 * FEFaceValues, or FESubfaceValues object for which you called one of the
1065 * reinit() functions, must have computed the information you are
1066 * requesting. To do so, the update_hessians flag must be an element of the
1067 * list of UpdateFlags that you passed to the constructor of this object.
1068 * See "The interplay of UpdateFlags, Mapping, and FiniteElement" in
1069 * the documentation of the FEValues class for more information.
1070 */
1071 template <typename Extractor, typename Number = double>
1072 const std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1073 template solution_laplacian_type<Number>> &
1074 get_laplacians(const std::string &global_vector_name,
1075 const Extractor &variable,
1076 const Number dummy = Number(0));
1077
1078 /**
1079 * For the solution vector identified by @p global_vector_name, compute
1080 * the third derivatives of the function at the quadrature points, and
1081 * return a vector with the correct type deduced by the Extractor you passed
1082 * as the @p variable argument.
1083 *
1084 * Before you can call this method, you need to call the
1085 * extract_local_dof_values() method at least once, passing the same
1086 * @p global_vector_name string, and the same type for the variable @p dummy.
1087 *
1088 * If you have not previously called the extract_local_dof_values() method,
1089 * this function will throw an exception.
1090 *
1091 * For this function to work properly, the underlying FEValues,
1092 * FEFaceValues, or FESubfaceValues object for which you called one of the
1093 * reinit() functions, must have computed the information you are
1094 * requesting. To do so, the update_3rd_derivatives flag must be an
1095 * element of the list of UpdateFlags that you passed to the constructor of
1096 * this object. See "The interplay of UpdateFlags, Mapping, and
1097 * FiniteElement" in the documentation of the FEValues for more information.
1098 */
1099 template <typename Extractor, typename Number = double>
1100 const std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1101 template solution_third_derivative_type<Number>> &
1102 get_third_derivatives(const std::string &global_vector_name,
1103 const Extractor &variable,
1104 const Number dummy = Number(0));
1105
1106 /** @} */ // CurrentCellEvaluation
1107
1108 /**
1109 * @name Evaluation of jumps in finite element fields and their derivatives on the current interface
1110 */
1111 /** @{ */ // CurrentInterfaceJumpEvaluation
1112
1113 /**
1114 * For the solution vector identified by @p global_vector_name, compute
1115 * the jumps in the values of the function at the quadrature points, and
1116 * return a vector with the correct type deduced by the interface Extractor
1117 * you passed as the
1118 * @p variable argument.
1119 *
1120 * Before you can call this method, you need to call the
1121 * extract_local_dof_values() method at least once, passing the same
1122 * @p global_vector_name string, and the same type for the variable @p dummy.
1123 *
1124 * If you have not previously called the extract_local_dof_values() method,
1125 * this function will throw an exception.
1126 *
1127 * For this function to work properly, the underlying FEInterfaceValues
1128 * object for which you called one of the reinit() functions, must have
1129 * computed the information you are requesting. To do so, the update_values
1130 * flag must be an element of the list of UpdateFlags that you passed to the
1131 * constructor of this object. See "The interplay of UpdateFlags, Mapping,
1132 * and FiniteElement" in the documentation of the FEValues class for more
1133 * information.
1134 */
1135 template <typename Extractor, typename Number = double>
1136 const std::vector<
1137 typename FEInterfaceViews::View<dim, spacedim, Extractor>::
1138 template solution_value_type<Number>> &
1139 get_jumps_in_values(const std::string &global_vector_name,
1140 const Extractor &variable,
1141 const Number dummy = Number(0));
1142
1143 /**
1144 * For the solution vector identified by @p global_vector_name, compute
1145 * the jumps in the gradients of the function at the quadrature points, and
1146 * return a vector with the correct type deduced by the interface Extractor
1147 * you passed as the
1148 * @p variable argument.
1149 *
1150 * Before you can call this method, you need to call the
1151 * extract_local_dof_values() method at least once, passing the same
1152 * @p global_vector_name string, and the same type for the variable @p dummy.
1153 *
1154 * If you have not previously called the extract_local_dof_values() method,
1155 * this function will throw an exception.
1156 *
1157 * For this function to work properly, the underlying FEInterfaceValues
1158 * object for which you called one of the reinit() functions, must have
1159 * computed the information you are requesting. To do so, the
1160 * update_gradients flag must be an element of the list of UpdateFlags that
1161 * you passed to the constructor of this object. See "The interplay of
1162 * UpdateFlags, Mapping, and FiniteElement" in the documentation of the
1163 * FEValues class for more information.
1164 */
1165 template <typename Extractor, typename Number = double>
1166 const std::vector<
1167 typename FEInterfaceViews::View<dim, spacedim, Extractor>::
1168 template solution_gradient_type<Number>> &
1169 get_jumps_in_gradients(const std::string &global_vector_name,
1170 const Extractor &variable,
1171 const Number dummy = Number(0));
1172
1173 /**
1174 * For the solution vector identified by @p global_vector_name, compute
1175 * the jumps in the Hessians of the function at the quadrature points, and
1176 * return a vector with the correct type deduced by the interface Extractor
1177 * you passed as the
1178 * @p variable argument.
1179 *
1180 * Before you can call this method, you need to call the
1181 * extract_local_dof_values() method at least once, passing the same
1182 * @p global_vector_name string, and the same type for the variable @p dummy.
1183 *
1184 * If you have not previously called the extract_local_dof_values() method,
1185 * this function will throw an exception.
1186 *
1187 * For this function to work properly, the underlying FEInterfaceValues
1188 * object for which you called one of the reinit() functions, must have
1189 * computed the information you are requesting. To do so, the
1190 * update_hessians flag must be an element of the list of UpdateFlags that
1191 * you passed to the constructor of this object. See "The interplay of
1192 * UpdateFlags, Mapping, and FiniteElement" in the documentation of the
1193 * FEValues class for more information.
1194 */
1195 template <typename Extractor, typename Number = double>
1196 const std::vector<
1197 typename FEInterfaceViews::View<dim, spacedim, Extractor>::
1198 template solution_hessian_type<Number>> &
1199 get_jumps_in_hessians(const std::string &global_vector_name,
1200 const Extractor &variable,
1201 const Number dummy = Number(0));
1202
1203 /**
1204 * For the solution vector identified by @p global_vector_name, compute
1205 * the jumps in the third derivatives of the function at the quadrature
1206 * points, and return a vector with the correct type deduced by the
1207 * interface Extractor you passed
1208 * as the @p variable argument.
1209 *
1210 * Before you can call this method, you need to call the
1211 * extract_local_dof_values() method at least once, passing the same
1212 * @p global_vector_name string, and the same type for the variable @p dummy.
1213 *
1214 * If you have not previously called the extract_local_dof_values() method,
1215 * this function will throw an exception.
1216 *
1217 * For this function to work properly, the underlying FEInterfaceValues
1218 * object for which you called one of the reinit() functions, must have
1219 * computed the information you are requesting. To do so, the
1220 * update_3rd_derivatives flag must be an element of the list of UpdateFlags
1221 * that you passed to the constructor of this object. See "The interplay of
1222 * UpdateFlags, Mapping, and FiniteElement" in the documentation of the
1223 * FEValues for more information.
1224 */
1225 template <typename Extractor, typename Number = double>
1226 const std::vector<
1227 typename FEInterfaceViews::View<dim, spacedim, Extractor>::
1228 template solution_third_derivative_type<Number>> &
1229 get_jumps_in_third_derivatives(const std::string &global_vector_name,
1230 const Extractor &variable,
1231 const Number dummy = Number(0));
1232
1233 /** @} */ // CurrentInterfaceJumpEvaluation
1234
1235 /**
1236 * @name Evaluation of averages of finite element fields and their derivatives on the current interface
1237 */
1238 /** @{ */ // CurrentInterfaceAverageEvaluation
1239
1240 /**
1241 * For the solution vector identified by @p global_vector_name, compute
1242 * the averages of the values of the function at the quadrature points, and
1243 * return a vector with the correct type deduced by the interface Extractor
1244 * you passed as the
1245 * @p variable argument.
1246 *
1247 * Before you can call this method, you need to call the
1248 * extract_local_dof_values() method at least once, passing the same
1249 * @p global_vector_name string, and the same type for the variable @p dummy.
1250 *
1251 * If you have not previously called the extract_local_dof_values() method,
1252 * this function will throw an exception.
1253 *
1254 * For this function to work properly, the underlying FEInterfaceValues
1255 * object for which you called one of the reinit() functions, must have
1256 * computed the information you are requesting. To do so, the update_values
1257 * flag must be an element of the list of UpdateFlags that you passed to the
1258 * constructor of this object. See "The interplay of UpdateFlags, Mapping,
1259 * and FiniteElement" in the documentation of the FEValues class for more
1260 * information.
1261 */
1262 template <typename Extractor, typename Number = double>
1263 const std::vector<
1264 typename FEInterfaceViews::View<dim, spacedim, Extractor>::
1265 template solution_value_type<Number>> &
1266 get_averages_of_values(const std::string &global_vector_name,
1267 const Extractor &variable,
1268 const Number dummy = Number(0));
1269
1270 /**
1271 * For the solution vector identified by @p global_vector_name, compute
1272 * the averages of the gradients of the function at the quadrature points,
1273 * and return a vector with the correct type deduced by the interface
1274 * Extractor you passed as the
1275 * @p variable argument.
1276 *
1277 * Before you can call this method, you need to call the
1278 * extract_local_dof_values() method at least once, passing the same
1279 * @p global_vector_name string, and the same type for the variable @p dummy.
1280 *
1281 * If you have not previously called the extract_local_dof_values() method,
1282 * this function will throw an exception.
1283 *
1284 * For this function to work properly, the underlying FEInterfaceValues
1285 * object for which you called one of the reinit() functions, must have
1286 * computed the information you are requesting. To do so, the
1287 * update_gradients flag must be an element of the list of UpdateFlags that
1288 * you passed to the constructor of this object. See "The interplay of
1289 * UpdateFlags, Mapping, and FiniteElement" in the documentation of the
1290 * FEValues class for more information.
1291 */
1292 template <typename Extractor, typename Number = double>
1293 const std::vector<
1294 typename FEInterfaceViews::View<dim, spacedim, Extractor>::
1295 template solution_gradient_type<Number>> &
1296 get_averages_of_gradients(const std::string &global_vector_name,
1297 const Extractor &variable,
1298 const Number dummy = Number(0));
1299
1300 /**
1301 * For the solution vector identified by @p global_vector_name, compute
1302 * the averages of the Hessians of the function at the quadrature points,
1303 * and return a vector with the correct type deduced by the interface
1304 * Extractor you passed as the
1305 * @p variable argument.
1306 *
1307 * Before you can call this method, you need to call the
1308 * extract_local_dof_values() method at least once, passing the same
1309 * @p global_vector_name string, and the same type for the variable @p dummy.
1310 *
1311 * If you have not previously called the extract_local_dof_values() method,
1312 * this function will throw an exception.
1313 *
1314 * For this function to work properly, the underlying FEInterfaceValues
1315 * object for which you called one of the reinit() functions, must have
1316 * computed the information you are requesting. To do so, the
1317 * update_hessians flag must be an element of the list of UpdateFlags that
1318 * you passed to the constructor of this object. See "The interplay of
1319 * UpdateFlags, Mapping, and FiniteElement" in the documentation of the
1320 * FEValues class for more information.
1321 */
1322 template <typename Extractor, typename Number = double>
1323 const std::vector<
1324 typename FEInterfaceViews::View<dim, spacedim, Extractor>::
1325 template solution_hessian_type<Number>> &
1326 get_averages_of_hessians(const std::string &global_vector_name,
1327 const Extractor &variable,
1328 const Number dummy = Number(0));
1329
1330 /** @} */ // CurrentInterfaceAverageEvaluation
1331
1332 private:
1333 /**
1334 * Construct a unique name to store vectors of values, gradients,
1335 * divergences, etc., in the internal GeneralDataStorage object.
1336 */
1337 template <typename Extractor, typename Number = double>
1338 std::string
1339 get_unique_name(const std::string &global_vector_name,
1340 const Extractor &variable,
1341 const std::string &object_type,
1342 const unsigned int size,
1343 const Number &exemplar_number) const;
1344
1345 /**
1346 * Construct a unique name to store local dof values.
1347 */
1348 template <typename Number = double>
1349 std::string
1350 get_unique_dofs_name(const std::string &global_vector_name,
1351 const unsigned int size,
1352 const Number &exemplar_number) const;
1353
1354 /**
1355 * @name Data that supports the standard FE implementation
1356 */
1357 /** @{ */ // non-hp data
1358
1359 /**
1360 * The mapping used by the internal FEValues. Make sure it lives
1361 * longer than this class.
1362 */
1363 ObserverPointer<const Mapping<dim, spacedim>> mapping;
1364
1365 /**
1366 * The finite element used by the internal FEValues. Make sure it lives
1367 * longer than this class.
1368 */
1369 ObserverPointer<const FiniteElement<dim, spacedim>> fe;
1370
1371 /**
1372 * Quadrature formula used to integrate on the current cell, and on its
1373 * neighbor.
1374 */
1375 Quadrature<dim> cell_quadrature;
1376
1377 /**
1378 * Quadrature formula used to integrate on faces, subfaces, and neighbor
1379 * faces and subfaces.
1380 */
1381 Quadrature<dim - 1> face_quadrature;
1382
1383 /**
1384 * Finite element values on the current cell.
1385 */
1386 std::unique_ptr<FEValues<dim, spacedim>> fe_values;
1387
1388 /**
1389 * Finite element values on the current face.
1390 */
1391 std::unique_ptr<FEFaceValues<dim, spacedim>> fe_face_values;
1392
1393 /**
1394 * Finite element values on the current subface.
1395 */
1396 std::unique_ptr<FESubfaceValues<dim, spacedim>> fe_subface_values;
1397
1398 /**
1399 * Finite element values on the neighbor cell.
1400 */
1401 std::unique_ptr<FEValues<dim, spacedim>> neighbor_fe_values;
1402
1403 /**
1404 * Finite element values on the neighbor face.
1405 */
1406 std::unique_ptr<FEFaceValues<dim, spacedim>> neighbor_fe_face_values;
1407
1408 /**
1409 * Finite element values on the neighbor subface.
1410 */
1411 std::unique_ptr<FESubfaceValues<dim, spacedim>> neighbor_fe_subface_values;
1412
1413 /**
1414 * Interface values on facets.
1415 */
1416 // The FEInterfaceValues class supports initialization with hp objects
1417 // as well.
1418 std::unique_ptr<FEInterfaceValues<dim, spacedim>> interface_fe_values;
1419
1420 /** @} */ // non-hp data
1421
1422 /**
1423 * @name Data that supports the hp-FE implementation
1424 */
1425 /** @{ */ // hp data
1426
1427 /**
1428 * The mapping collection used by the internal hp::FEValues. Make sure it
1429 * lives longer than this class.
1430 */
1431 ObserverPointer<const hp::MappingCollection<dim, spacedim>>
1432 mapping_collection;
1433
1434 /**
1435 * The finite element used by the internal FEValues. Make sure it lives
1436 * longer than this class.
1437 */
1438 ObserverPointer<const hp::FECollection<dim, spacedim>> fe_collection;
1439
1440 /**
1441 * Quadrature formula used to integrate on the current cell, and on its
1442 * neighbor.
1443 */
1444 hp::QCollection<dim> cell_quadrature_collection;
1445
1446 /**
1447 * Quadrature formula used to integrate on faces, subfaces, and neighbor
1448 * faces and subfaces.
1449 */
1450 hp::QCollection<dim - 1> face_quadrature_collection;
1451
1452 /**
1453 * Boolean indicating whether or not the current ScratchData has
1454 * hp-capabilities.
1455 */
1456 bool hp_capability_enabled;
1457
1458 /**
1459 * Finite element values on the current cell.
1460 */
1461 std::unique_ptr<hp::FEValues<dim, spacedim>> hp_fe_values;
1462
1463 /**
1464 * Finite element values on the current face.
1465 */
1466 std::unique_ptr<hp::FEFaceValues<dim, spacedim>> hp_fe_face_values;
1467
1468 /**
1469 * Finite element values on the current subface.
1470 */
1471 std::unique_ptr<hp::FESubfaceValues<dim, spacedim>> hp_fe_subface_values;
1472
1473 /**
1474 * Finite element values on the neighbor cell.
1475 */
1476 std::unique_ptr<hp::FEValues<dim, spacedim>> neighbor_hp_fe_values;
1477
1478 /**
1479 * Finite element values on the neighbor face.
1480 */
1481 std::unique_ptr<hp::FEFaceValues<dim, spacedim>> neighbor_hp_fe_face_values;
1482
1483 /**
1484 * Finite element values on the neighbor subface.
1485 */
1486 std::unique_ptr<hp::FESubfaceValues<dim, spacedim>>
1487 neighbor_hp_fe_subface_values;
1488
1489 /**
1490 * Exception used when a certain feature doesn't make sense when
1491 * ScratchData does has hp-capabilities enabled.
1492 *
1493 * @ingroup Exceptions
1494 */
1495 DeclExceptionMsg(ExcOnlyAvailableWithoutHP,
1496 "The current function doesn't make sense when used with a "
1497 "ScratchData object with hp-capabilities.");
1498
1499 /**
1500 * Exception used when a certain feature doesn't make sense when
1501 * ScratchData does not have hp-capabilities enabled.
1502 *
1503 * @ingroup Exceptions
1504 */
1505 DeclExceptionMsg(ExcOnlyAvailableWithHP,
1506 "The current function doesn't make sense when used with a "
1507 "ScratchData object without hp-capabilities.");
1508
1509 /** @} */ // hp data
1510
1511 /**
1512 * UpdateFlags to use when initializing the cell FEValues object.
1513 */
1514 UpdateFlags cell_update_flags;
1515
1516 /**
1517 * UpdateFlags to use when initializing the neighbor cell FEValues objects.
1518 */
1519 UpdateFlags neighbor_cell_update_flags;
1520
1521 /**
1522 * UpdateFlags to use when initializing FEFaceValues and FESubfaceValues
1523 * objects.
1524 */
1525 UpdateFlags face_update_flags;
1526
1527 /**
1528 * UpdateFlags to use when initializing neighbor FEFaceValues and
1529 * FESubfaceValues objects.
1530 */
1531 UpdateFlags neighbor_face_update_flags;
1532
1533 /**
1534 * Dof indices on the current cell.
1535 */
1536 std::vector<types::global_dof_index> local_dof_indices;
1537
1538 /**
1539 * Dof indices on the neighbor cell.
1540 */
1541 std::vector<types::global_dof_index> neighbor_dof_indices;
1542
1543 /**
1544 * User data storage.
1545 */
1546 GeneralDataStorage user_data_storage;
1547
1548 /**
1549 * Internal data storage.
1550 */
1551 GeneralDataStorage internal_data_storage;
1552
1553 /**
1554 * A pointer to the last used FEValues/FEFaceValues, or FESubfaceValues
1555 * object on this cell.
1556 */
1557 ObserverPointer<const FEValuesBase<dim, spacedim>> current_fe_values;
1558
1559 /**
1560 * A pointer to the last used FEValues/FEFaceValues, or FESubfaceValues
1561 * object on the neighbor cell.
1562 */
1563 ObserverPointer<const FEValuesBase<dim, spacedim>>
1564 current_neighbor_fe_values;
1565 };
1566
1567 #ifndef DOXYGEN
1568 template <int dim, int spacedim>
1569 template <typename Extractor, typename Number>
1570 std::string
1571 ScratchData<dim, spacedim>::get_unique_name(
1572 const std::string &global_vector_name,
1573 const Extractor &variable,
1574 const std::string &object_type,
1575 const unsigned int size,
1576 const Number &exemplar_number) const
1577 {
1578 return global_vector_name + "_" + variable.get_name() + "_" + object_type +
1579 "_" + Utilities::int_to_string(size) + "_" +
1580 Utilities::type_to_string(exemplar_number);
1581 }
1582
1583
1584
1585 template <int dim, int spacedim>
1586 template <typename Number>
1587 std::string
1588 ScratchData<dim, spacedim>::get_unique_dofs_name(
1589 const std::string &global_vector_name,
1590 const unsigned int size,
1591 const Number &exemplar_number) const
1592 {
1593 return global_vector_name + "_independent_local_dofs_" +
1594 Utilities::int_to_string(size) + "_" +
1595 Utilities::type_to_string(exemplar_number);
1596 }
1597
1598
1599
1600 template <int dim, int spacedim>
1601 template <typename VectorType, typename Number>
1602 void
1603 ScratchData<dim, spacedim>::extract_local_dof_values(
1604 const std::string &global_vector_name,
1605 const VectorType &input_vector,
1606 const Number dummy)
1607 {
1608 const unsigned int n_dofs = local_dof_indices.size();
1609
1610 const std::string name =
1611 get_unique_dofs_name(global_vector_name, n_dofs, dummy);
1612
1613 auto &independent_local_dofs =
1614 internal_data_storage
1615 .template get_or_add_object_with_name<std::vector<Number>>(name,
1616 n_dofs);
1617
1618 AssertDimension(independent_local_dofs.size(), n_dofs);
1619
1620 if (Differentiation::AD::is_tapeless_ad_number<Number>::value == true)
1621 for (unsigned int i = 0; i < n_dofs; ++i)
1622 Differentiation::AD::internal::Marking<Number>::independent_variable(
1623 input_vector(local_dof_indices[i]),
1624 i,
1625 n_dofs,
1626 independent_local_dofs[i]);
1627 else
1628 for (unsigned int i = 0; i < n_dofs; ++i)
1629 independent_local_dofs[i] = input_vector(local_dof_indices[i]);
1630 }
1631
1632
1633
1634 template <int dim, int spacedim>
1635 template <typename Number>
1636 const std::vector<Number> &
1637 ScratchData<dim, spacedim>::get_local_dof_values(
1638 const std::string &global_vector_name,
1639 Number dummy) const
1640 {
1641 const unsigned int n_dofs = local_dof_indices.size();
1642
1643 const std::string dofs_name =
1644 get_unique_dofs_name(global_vector_name, n_dofs, dummy);
1645
1646 Assert(
1647 internal_data_storage.stores_object_with_name(dofs_name),
1648 ExcMessage(
1649 "You did not call yet extract_local_dof_values with the right types!"));
1650
1651 return internal_data_storage
1652 .template get_object_with_name<std::vector<Number>>(dofs_name);
1653 }
1654
1655
1656
1657 template <int dim, int spacedim>
1658 template <typename Extractor, typename Number>
1659 const std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1660 template solution_value_type<Number>> &
1661 ScratchData<dim, spacedim>::get_values(const std::string &global_vector_name,
1662 const Extractor &variable,
1663 const Number dummy)
1664 {
1665 const std::vector<Number> &independent_local_dofs =
1666 get_local_dof_values(global_vector_name, dummy);
1667
1668 const FEValuesBase<dim, spacedim> &fev = get_current_fe_values();
1669
1670 const unsigned int n_q_points = fev.n_quadrature_points;
1671
1672 const std::string name = get_unique_name(
1673 global_vector_name, variable, "_values_q", n_q_points, dummy);
1674
1675 // Now build the return type
1676 using RetType =
1677 std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1678 template solution_value_type<Number>>;
1679
1680 RetType &ret =
1681 internal_data_storage.template get_or_add_object_with_name<RetType>(
1682 name, n_q_points);
1683
1684 AssertDimension(ret.size(), n_q_points);
1685
1686 fev[variable].get_function_values_from_local_dof_values(
1687 independent_local_dofs, ret);
1688 return ret;
1689 }
1690
1691
1692
1693 template <int dim, int spacedim>
1694 template <typename Extractor, typename Number>
1695 const std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1696 template solution_gradient_type<Number>> &
1697 ScratchData<dim, spacedim>::get_gradients(
1698 const std::string &global_vector_name,
1699 const Extractor &variable,
1700 const Number dummy)
1701 {
1702 const std::vector<Number> &independent_local_dofs =
1703 get_local_dof_values(global_vector_name, dummy);
1704
1705 const FEValuesBase<dim, spacedim> &fev = get_current_fe_values();
1706
1707 const unsigned int n_q_points = fev.n_quadrature_points;
1708
1709 const std::string name = get_unique_name(
1710 global_vector_name, variable, "_gradients_q", n_q_points, dummy);
1711
1712 // Now build the return type
1713 using RetType =
1714 std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1715 template solution_gradient_type<Number>>;
1716
1717 RetType &ret =
1718 internal_data_storage.template get_or_add_object_with_name<RetType>(
1719 name, n_q_points);
1720
1721 AssertDimension(ret.size(), n_q_points);
1722
1723 fev[variable].get_function_gradients_from_local_dof_values(
1724 independent_local_dofs, ret);
1725 return ret;
1726 }
1727
1728
1729
1730 template <int dim, int spacedim>
1731 template <typename Extractor, typename Number>
1732 const std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1733 template solution_hessian_type<Number>> &
1734 ScratchData<dim, spacedim>::get_hessians(
1735 const std::string &global_vector_name,
1736 const Extractor &variable,
1737 const Number dummy)
1738 {
1739 const std::vector<Number> &independent_local_dofs =
1740 get_local_dof_values(global_vector_name, dummy);
1741
1742 const FEValuesBase<dim, spacedim> &fev = get_current_fe_values();
1743
1744 const unsigned int n_q_points = fev.n_quadrature_points;
1745
1746 const std::string name = get_unique_name(
1747 global_vector_name, variable, "_hessians_q", n_q_points, dummy);
1748
1749 // Now build the return type
1750 using RetType =
1751 std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1752 template solution_hessian_type<Number>>;
1753
1754 RetType &ret =
1755 internal_data_storage.template get_or_add_object_with_name<RetType>(
1756 name, n_q_points);
1757
1758
1759 AssertDimension(ret.size(), n_q_points);
1760
1761 fev[variable].get_function_hessians_from_local_dof_values(
1762 independent_local_dofs, ret);
1763 return ret;
1764 }
1765
1766
1767
1768 template <int dim, int spacedim>
1769 template <typename Extractor, typename Number>
1770 const std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1771 template solution_laplacian_type<Number>> &
1772 ScratchData<dim, spacedim>::get_laplacians(
1773 const std::string &global_vector_name,
1774 const Extractor &variable,
1775 const Number dummy)
1776 {
1777 const std::vector<Number> &independent_local_dofs =
1778 get_local_dof_values(global_vector_name, dummy);
1779
1780 const FEValuesBase<dim, spacedim> &fev = get_current_fe_values();
1781
1782 const unsigned int n_q_points = fev.n_quadrature_points;
1783
1784 const std::string name = get_unique_name(
1785 global_vector_name, variable, "_laplacians_q", n_q_points, dummy);
1786
1787 // Now build the return type
1788 using RetType =
1789 std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1790 template solution_laplacian_type<Number>>;
1791
1792 RetType &ret =
1793 internal_data_storage.template get_or_add_object_with_name<RetType>(
1794 name, n_q_points);
1795
1796
1797 AssertDimension(ret.size(), n_q_points);
1798
1799 fev[variable].get_function_laplacians_from_local_dof_values(
1800 independent_local_dofs, ret);
1801 return ret;
1802 }
1803
1804
1805
1806 template <int dim, int spacedim>
1807 template <typename Extractor, typename Number>
1808 const std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1809 template solution_third_derivative_type<Number>> &
1810 ScratchData<dim, spacedim>::get_third_derivatives(
1811 const std::string &global_vector_name,
1812 const Extractor &variable,
1813 const Number dummy)
1814 {
1815 const std::vector<Number> &independent_local_dofs =
1816 get_local_dof_values(global_vector_name, dummy);
1817
1818 const FEValuesBase<dim, spacedim> &fev = get_current_fe_values();
1819
1820 const unsigned int n_q_points = fev.n_quadrature_points;
1821
1822 const std::string name = get_unique_name(
1823 global_vector_name, variable, "_third_derivatives_q", n_q_points, dummy);
1824
1825 // Now build the return type
1826 using RetType =
1827 std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1828 template solution_third_derivative_type<Number>>;
1829
1830 RetType &ret =
1831 internal_data_storage.template get_or_add_object_with_name<RetType>(
1832 name, n_q_points);
1833
1834
1835 AssertDimension(ret.size(), n_q_points);
1836
1837 fev[variable].get_function_third_derivatives_from_local_dof_values(
1838 independent_local_dofs, ret);
1839 return ret;
1840 }
1841
1842
1843
1844 template <int dim, int spacedim>
1845 template <typename Extractor, typename Number>
1846 const std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1847 template solution_symmetric_gradient_type<Number>> &
1848 ScratchData<dim, spacedim>::get_symmetric_gradients(
1849 const std::string &global_vector_name,
1850 const Extractor &variable,
1851 const Number dummy)
1852 {
1853 const std::vector<Number> &independent_local_dofs =
1854 get_local_dof_values(global_vector_name, dummy);
1855
1856 const FEValuesBase<dim, spacedim> &fev = get_current_fe_values();
1857
1858 const unsigned int n_q_points = fev.n_quadrature_points;
1859
1860 const std::string name = get_unique_name(
1861 global_vector_name, variable, "_symmetric_gradient_q", n_q_points, dummy);
1862
1863
1864 // Now build the return type
1865 using RetType =
1866 std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1867 template solution_symmetric_gradient_type<Number>>;
1868
1869 RetType &ret =
1870 internal_data_storage.template get_or_add_object_with_name<RetType>(
1871 name, n_q_points);
1872
1873
1874 AssertDimension(ret.size(), n_q_points);
1875
1876 fev[variable].get_function_symmetric_gradients_from_local_dof_values(
1877 independent_local_dofs, ret);
1878 return ret;
1879 }
1880
1881
1882 template <int dim, int spacedim>
1883 template <typename Extractor, typename Number>
1884 const std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1885 template solution_divergence_type<Number>> &
1886 ScratchData<dim, spacedim>::get_divergences(
1887 const std::string &global_vector_name,
1888 const Extractor &variable,
1889 const Number dummy)
1890 {
1891 const std::vector<Number> &independent_local_dofs =
1892 get_local_dof_values(global_vector_name, dummy);
1893
1894 const FEValuesBase<dim, spacedim> &fev = get_current_fe_values();
1895
1896 const unsigned int n_q_points = fev.n_quadrature_points;
1897
1898 const std::string name = get_unique_name(
1899 global_vector_name, variable, "_divergence_q", n_q_points, dummy);
1900
1901 // Now build the return type
1902 using RetType =
1903 std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1904 template solution_divergence_type<Number>>;
1905
1906 RetType &ret =
1907 internal_data_storage.template get_or_add_object_with_name<RetType>(
1908 name, n_q_points);
1909
1910
1911 AssertDimension(ret.size(), n_q_points);
1912
1913 fev[variable].get_function_divergences_from_local_dof_values(
1914 independent_local_dofs, ret);
1915 return ret;
1916 }
1917
1918
1919
1920 template <int dim, int spacedim>
1921 template <typename Extractor, typename Number>
1922 const std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1923 template solution_curl_type<Number>> &
1924 ScratchData<dim, spacedim>::get_curls(const std::string &global_vector_name,
1925 const Extractor &variable,
1926 const Number dummy)
1927 {
1928 const std::vector<Number> &independent_local_dofs =
1929 get_local_dof_values(global_vector_name, dummy);
1930
1931 const FEValuesBase<dim, spacedim> &fev = get_current_fe_values();
1932
1933 const unsigned int n_q_points = fev.n_quadrature_points;
1934
1935 const std::string name = get_unique_name(
1936 global_vector_name, variable, "_curl_q", n_q_points, dummy);
1937
1938 // Now build the return type
1939 using RetType =
1940 std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1941 template solution_curl_type<Number>>;
1942
1943 RetType &ret =
1944 internal_data_storage.template get_or_add_object_with_name<RetType>(
1945 name, n_q_points);
1946
1947 AssertDimension(ret.size(), n_q_points);
1948
1949 fev[variable].get_function_curls_from_local_dof_values(
1950 independent_local_dofs, ret);
1951 return ret;
1952 }
1953
1954
1955
1956 template <int dim, int spacedim>
1957 template <typename Extractor, typename Number>
1958 const std::vector<typename FEInterfaceViews::View<dim, spacedim, Extractor>::
1959 template solution_value_type<Number>> &
1960 ScratchData<dim, spacedim>::get_jumps_in_values(
1961 const std::string &global_vector_name,
1962 const Extractor &variable,
1963 const Number dummy)
1964 {
1965 const std::vector<Number> &independent_local_dofs =
1966 get_local_dof_values(global_vector_name, dummy);
1967
1968 const FEInterfaceValues<dim, spacedim> &feiv =
1969 get_current_interface_fe_values();
1970
1971 AssertDimension(independent_local_dofs.size(),
1972 feiv.n_current_interface_dofs());
1973
1974 const unsigned int n_q_points = feiv.n_quadrature_points;
1975
1976 const std::string name = get_unique_name(
1977 global_vector_name, variable, "_jump_values_q", n_q_points, dummy);
1978
1979 // Now build the return type
1980 using RetType =
1981 std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
1982 template solution_value_type<Number>>;
1983
1984 RetType &ret =
1985 internal_data_storage.template get_or_add_object_with_name<RetType>(
1986 name, n_q_points);
1987
1988 AssertDimension(ret.size(), n_q_points);
1989
1990 feiv[variable].get_jump_in_function_values_from_local_dof_values(
1991 independent_local_dofs, ret);
1992 return ret;
1993 }
1994
1995
1996
1997 template <int dim, int spacedim>
1998 template <typename Extractor, typename Number>
1999 const std::vector<typename FEInterfaceViews::View<dim, spacedim, Extractor>::
2000 template solution_gradient_type<Number>> &
2001 ScratchData<dim, spacedim>::get_jumps_in_gradients(
2002 const std::string &global_vector_name,
2003 const Extractor &variable,
2004 const Number dummy)
2005 {
2006 const std::vector<Number> &independent_local_dofs =
2007 get_local_dof_values(global_vector_name, dummy);
2008
2009 const FEInterfaceValues<dim, spacedim> &feiv =
2010 get_current_interface_fe_values();
2011
2012 AssertDimension(independent_local_dofs.size(),
2013 feiv.n_current_interface_dofs());
2014
2015 const unsigned int n_q_points = feiv.n_quadrature_points;
2016
2017 const std::string name = get_unique_name(
2018 global_vector_name, variable, "_jump_gradients_q", n_q_points, dummy);
2019
2020 // Now build the return type
2021 using RetType =
2022 std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
2023 template solution_gradient_type<Number>>;
2024
2025 RetType &ret =
2026 internal_data_storage.template get_or_add_object_with_name<RetType>(
2027 name, n_q_points);
2028
2029 AssertDimension(ret.size(), n_q_points);
2030
2031 feiv[variable].get_jump_in_function_gradients_from_local_dof_values(
2032 independent_local_dofs, ret);
2033 return ret;
2034 }
2035
2036
2037
2038 template <int dim, int spacedim>
2039 template <typename Extractor, typename Number>
2040 const std::vector<typename FEInterfaceViews::View<dim, spacedim, Extractor>::
2041 template solution_hessian_type<Number>> &
2042 ScratchData<dim, spacedim>::get_jumps_in_hessians(
2043 const std::string &global_vector_name,
2044 const Extractor &variable,
2045 const Number dummy)
2046 {
2047 const std::vector<Number> &independent_local_dofs =
2048 get_local_dof_values(global_vector_name, dummy);
2049
2050 const FEInterfaceValues<dim, spacedim> &feiv =
2051 get_current_interface_fe_values();
2052
2053 AssertDimension(independent_local_dofs.size(),
2054 feiv.n_current_interface_dofs());
2055
2056 const unsigned int n_q_points = feiv.n_quadrature_points;
2057
2058 const std::string name = get_unique_name(
2059 global_vector_name, variable, "_jump_hessians_q", n_q_points, dummy);
2060
2061 // Now build the return type
2062 using RetType =
2063 std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
2064 template solution_hessian_type<Number>>;
2065
2066 RetType &ret =
2067 internal_data_storage.template get_or_add_object_with_name<RetType>(
2068 name, n_q_points);
2069
2070 AssertDimension(ret.size(), n_q_points);
2071
2072 feiv[variable].get_jump_in_function_hessians_from_local_dof_values(
2073 independent_local_dofs, ret);
2074 return ret;
2075 }
2076
2077
2078
2079 template <int dim, int spacedim>
2080 template <typename Extractor, typename Number>
2081 const std::vector<typename FEInterfaceViews::View<dim, spacedim, Extractor>::
2082 template solution_third_derivative_type<Number>> &
2083 ScratchData<dim, spacedim>::get_jumps_in_third_derivatives(
2084 const std::string &global_vector_name,
2085 const Extractor &variable,
2086 const Number dummy)
2087 {
2088 const std::vector<Number> &independent_local_dofs =
2089 get_local_dof_values(global_vector_name, dummy);
2090
2091 const FEInterfaceValues<dim, spacedim> &feiv =
2092 get_current_interface_fe_values();
2093
2094 AssertDimension(independent_local_dofs.size(),
2095 feiv.n_current_interface_dofs());
2096
2097 const unsigned int n_q_points = feiv.n_quadrature_points;
2098
2099 const std::string name = get_unique_name(global_vector_name,
2100 variable,
2101 "_jump_third_derivatives_q",
2102 n_q_points,
2103 dummy);
2104
2105 // Now build the return type
2106 using RetType =
2107 std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
2108 template solution_third_derivative_type<Number>>;
2109
2110 RetType &ret =
2111 internal_data_storage.template get_or_add_object_with_name<RetType>(
2112 name, n_q_points);
2113
2114 AssertDimension(ret.size(), n_q_points);
2115
2116 feiv[variable].get_jump_in_function_third_derivatives_from_local_dof_values(
2117 independent_local_dofs, ret);
2118 return ret;
2119 }
2120
2121
2122
2123 template <int dim, int spacedim>
2124 template <typename Extractor, typename Number>
2125 const std::vector<typename FEInterfaceViews::View<dim, spacedim, Extractor>::
2126 template solution_value_type<Number>> &
2127 ScratchData<dim, spacedim>::get_averages_of_values(
2128 const std::string &global_vector_name,
2129 const Extractor &variable,
2130 const Number dummy)
2131 {
2132 const std::vector<Number> &independent_local_dofs =
2133 get_local_dof_values(global_vector_name, dummy);
2134
2135 const FEInterfaceValues<dim, spacedim> &feiv =
2136 get_current_interface_fe_values();
2137
2138 AssertDimension(independent_local_dofs.size(),
2139 feiv.n_current_interface_dofs());
2140
2141 const unsigned int n_q_points = feiv.n_quadrature_points;
2142
2143 const std::string name = get_unique_name(
2144 global_vector_name, variable, "_average_values_q", n_q_points, dummy);
2145
2146 // Now build the return type
2147 using RetType =
2148 std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
2149 template solution_value_type<Number>>;
2150
2151 RetType &ret =
2152 internal_data_storage.template get_or_add_object_with_name<RetType>(
2153 name, n_q_points);
2154
2155 AssertDimension(ret.size(), n_q_points);
2156
2157 feiv[variable].get_average_of_function_values_from_local_dof_values(
2158 independent_local_dofs, ret);
2159 return ret;
2160 }
2161
2162
2163
2164 template <int dim, int spacedim>
2165 template <typename Extractor, typename Number>
2166 const std::vector<typename FEInterfaceViews::View<dim, spacedim, Extractor>::
2167 template solution_gradient_type<Number>> &
2168 ScratchData<dim, spacedim>::get_averages_of_gradients(
2169 const std::string &global_vector_name,
2170 const Extractor &variable,
2171 const Number dummy)
2172 {
2173 const std::vector<Number> &independent_local_dofs =
2174 get_local_dof_values(global_vector_name, dummy);
2175
2176 const FEInterfaceValues<dim, spacedim> &feiv =
2177 get_current_interface_fe_values();
2178
2179 AssertDimension(independent_local_dofs.size(),
2180 feiv.n_current_interface_dofs());
2181
2182 const unsigned int n_q_points = feiv.n_quadrature_points;
2183
2184 const std::string name = get_unique_name(
2185 global_vector_name, variable, "_average_gradients_q", n_q_points, dummy);
2186
2187 // Now build the return type
2188 using RetType =
2189 std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
2190 template solution_gradient_type<Number>>;
2191
2192 RetType &ret =
2193 internal_data_storage.template get_or_add_object_with_name<RetType>(
2194 name, n_q_points);
2195
2196 AssertDimension(ret.size(), n_q_points);
2197
2198 feiv[variable].get_average_of_function_gradients_from_local_dof_values(
2199 independent_local_dofs, ret);
2200 return ret;
2201 }
2202
2203
2204
2205 template <int dim, int spacedim>
2206 template <typename Extractor, typename Number>
2207 const std::vector<typename FEInterfaceViews::View<dim, spacedim, Extractor>::
2208 template solution_hessian_type<Number>> &
2209 ScratchData<dim, spacedim>::get_averages_of_hessians(
2210 const std::string &global_vector_name,
2211 const Extractor &variable,
2212 const Number dummy)
2213 {
2214 const std::vector<Number> &independent_local_dofs =
2215 get_local_dof_values(global_vector_name, dummy);
2216
2217 const FEInterfaceValues<dim, spacedim> &feiv =
2218 get_current_interface_fe_values();
2219
2220 AssertDimension(independent_local_dofs.size(),
2221 feiv.n_current_interface_dofs());
2222
2223 const unsigned int n_q_points = feiv.n_quadrature_points;
2224
2225 const std::string name = get_unique_name(
2226 global_vector_name, variable, "_average_hessians_q", n_q_points, dummy);
2227
2228 // Now build the return type
2229 using RetType =
2230 std::vector<typename FEValuesViews::View<dim, spacedim, Extractor>::
2231 template solution_hessian_type<Number>>;
2232
2233 RetType &ret =
2234 internal_data_storage.template get_or_add_object_with_name<RetType>(
2235 name, n_q_points);
2236
2237 AssertDimension(ret.size(), n_q_points);
2238
2239 feiv[variable].get_average_of_function_hessians_from_local_dof_values(
2240 independent_local_dofs, ret);
2241 return ret;
2242 }
2243
2244
2245 #endif
2246
2247 } // namespace MeshWorker
2248
2249 DEAL_II_NAMESPACE_CLOSE
2250
2251 #endif