deal.II version GIT relicensing-6846-gd1ccc50c04 2026-10-05 21:50:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
integration_info.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2009 - 2024 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13
14#ifndef dealii_mesh_worker_integration_info_h
15#define dealii_mesh_worker_integration_info_h
16
17#include <deal.II/base/config.h>
18
20
22
24
28
29#include <memory>
30
32
33namespace MeshWorker
34{
73 template <int dim, int spacedim = dim>
75 {
76 private:
78 std::vector<std::shared_ptr<FEValuesBase<dim, spacedim>>> fevalv;
79
80 public:
81 static constexpr unsigned int dimension = dim;
82 static constexpr unsigned int space_dimension = spacedim;
83
88
93
112 template <class FEVALUES>
113 void
115 const Mapping<dim, spacedim> &mapping,
117 const UpdateFlags flags,
118 const BlockInfo *local_block_info = nullptr);
119
123 void
125
129 void
131
138
142
148 fe_values() const;
149
151
156 fe_values(const unsigned int i) const;
157
166 std::vector<std::vector<std::vector<double>>> values;
167
176 std::vector<std::vector<std::vector<Tensor<1, spacedim>>>> gradients;
177
186 std::vector<std::vector<std::vector<Tensor<2, spacedim>>>> hessians;
187
191 template <typename number>
192 void
194
199 template <typename number>
200 void
202 bool split_fevalues);
203
208 std::shared_ptr<VectorDataBase<dim, spacedim>> global_data;
209
213 std::size_t
215
216 private:
223
229 template <typename TYPE>
230 void
231 fill_local_data(std::vector<std::vector<std::vector<TYPE>>> &data,
232 VectorSelector &selector,
233 bool split_fevalues) const;
237 unsigned int n_components;
238 };
239
293 template <int dim, int spacedim = dim>
295 {
296 public:
301
306
314 void
316 const Mapping<dim, spacedim> &mapping,
317 const BlockInfo *block_info = nullptr);
318
326 template <typename VectorType>
327 void
329 const Mapping<dim, spacedim> &mapping,
330 const AnyData &data,
331 const VectorType &dummy,
332 const BlockInfo *block_info = nullptr);
340 template <typename VectorType>
341 void
343 const Mapping<dim, spacedim> &mapping,
344 const AnyData &data,
345 const MGLevelObject<VectorType> &dummy,
346 const BlockInfo *block_info = nullptr);
362 void
363 initialize_update_flags(bool neighbor_geometry = false);
364
369 void
370 add_update_flags_all(const UpdateFlags flags);
371
375 void
376 add_update_flags_cell(const UpdateFlags flags);
377
381 void
382 add_update_flags_boundary(const UpdateFlags flags);
383
387 void
388 add_update_flags_face(const UpdateFlags flags);
389
396 void
398 const bool cell = true,
399 const bool boundary = true,
400 const bool face = true,
401 const bool neighbor = true);
402
412 void
413 initialize_gauss_quadrature(unsigned int n_cell_points,
414 unsigned int n_boundary_points,
415 unsigned int n_face_points,
416 const bool force = true);
417
421 std::size_t
423
436
443
451
456
461
487
493
499
500 std::shared_ptr<MeshWorker::VectorDataBase<dim, spacedim>> cell_data;
501 std::shared_ptr<MeshWorker::VectorDataBase<dim, spacedim>> boundary_data;
502 std::shared_ptr<MeshWorker::VectorDataBase<dim, spacedim>> face_data;
526 template <class DOFINFO>
527 void
528 post_cell(const DoFInfoBox<dim, DOFINFO> &);
529
546 template <class DOFINFO>
547 void
548 post_faces(const DoFInfoBox<dim, DOFINFO> &);
549
571
573 };
574
575
576 //----------------------------------------------------------------------//
577
578 template <int dim, int sdim>
580 : fevalv(0)
581 , multigrid(false)
582 , global_data(std::make_shared<VectorDataBase<dim, sdim>>())
583 , n_components(numbers::invalid_unsigned_int)
584 {}
585
586#ifndef DOXYGEN
587 template <int dim, int sdim>
589 const IntegrationInfo<dim, sdim> &other)
590 : multigrid(other.multigrid)
591 , values(other.values)
592 , gradients(other.gradients)
593 , hessians(other.hessians)
594 , global_data(other.global_data)
595 , fe_pointer(other.fe_pointer)
596 , n_components(other.n_components)
597 {
598 fevalv.resize(other.fevalv.size());
599 for (unsigned int i = 0; i < other.fevalv.size(); ++i)
600 {
601 const FEValuesBase<dim, sdim> &p = *other.fevalv[i];
602 const FEValues<dim, sdim> *pc =
603 dynamic_cast<const FEValues<dim, sdim> *>(&p);
604 const FEFaceValues<dim, sdim> *pf =
605 dynamic_cast<const FEFaceValues<dim, sdim> *>(&p);
607 dynamic_cast<const FESubfaceValues<dim, sdim> *>(&p);
608
609 if (pc != nullptr)
610 fevalv[i] =
611 std::make_shared<FEValues<dim, sdim>>(pc->get_mapping(),
612 pc->get_fe(),
613 pc->get_quadrature(),
614 pc->get_update_flags());
615 else if (pf != nullptr)
616 fevalv[i] =
617 std::make_shared<FEFaceValues<dim, sdim>>(pf->get_mapping(),
618 pf->get_fe(),
619 pf->get_quadrature(),
620 pf->get_update_flags());
621 else if (ps != nullptr)
622 fevalv[i] = std::make_shared<FESubfaceValues<dim, sdim>>(
623 ps->get_mapping(),
624 ps->get_fe(),
625 ps->get_quadrature(),
626 ps->get_update_flags());
627 else
629 }
630 }
631#endif
632
633
634
635 template <int dim, int sdim>
636 template <class FEVALUES>
637 inline void
639 const FiniteElement<dim, sdim> &el,
640 const Mapping<dim, sdim> &mapping,
642 const UpdateFlags flags,
643 const BlockInfo *block_info)
644 {
645 fe_pointer = &el;
646 if (block_info == nullptr || block_info->local().size() == 0)
647 {
648 fevalv.resize(1);
649 fevalv[0] = std::make_shared<FEVALUES>(mapping, el, quadrature, flags);
650 }
651 else
652 {
653 fevalv.resize(el.n_base_elements());
654 for (unsigned int i = 0; i < fevalv.size(); ++i)
655 fevalv[i] = std::make_shared<FEVALUES>(mapping,
656 el.base_element(i),
657 quadrature,
658 flags);
659 }
660 n_components = el.n_components();
661 }
662
663
664 template <int dim, int spacedim>
665 inline const FiniteElement<dim, spacedim> &
667 {
668 Assert(fe_pointer != nullptr, ExcNotInitialized());
669 return *fe_pointer;
670 }
671
672 template <int dim, int spacedim>
673 inline const FEValuesBase<dim, spacedim> &
675 {
676 AssertDimension(fevalv.size(), 1);
677 return *fevalv[0];
678 }
679
680
681 template <int dim, int spacedim>
682 inline const FEValuesBase<dim, spacedim> &
684 {
685 AssertIndexRange(i, fevalv.size());
686 return *fevalv[i];
687 }
688
689
690 template <int dim, int spacedim>
691 template <typename number>
692 inline void
695 {
696 for (unsigned int i = 0; i < fevalv.size(); ++i)
697 {
698 FEValuesBase<dim, spacedim> &febase = *fevalv[i];
700 {
701 // This is a subface
703 dynamic_cast<FESubfaceValues<dim, spacedim> &>(febase);
704 fe.reinit(info.cell, info.face_number, info.sub_number);
705 }
707 {
708 // This is a face
710 dynamic_cast<FEFaceValues<dim, spacedim> &>(febase);
711 fe.reinit(info.cell, info.face_number);
712 }
713 else
714 {
715 // This is a cell
717 dynamic_cast<FEValues<dim, spacedim> &>(febase);
718 fe.reinit(info.cell);
719 }
720 }
721
722 const bool split_fevalues = info.block_info != nullptr;
723 if (!global_data->empty())
724 fill_local_data(info, split_fevalues);
725 }
726
727
728
729 //----------------------------------------------------------------------//
730
731 template <int dim, int sdim>
732 inline void
734 unsigned int bp,
735 unsigned int fp,
736 bool force)
737 {
738 if (force || cell_quadrature.empty())
739 cell_quadrature = QGauss<dim>(cp);
740 if (force || boundary_quadrature.empty())
741 boundary_quadrature = QGauss<dim - 1>(bp);
742 if (force || face_quadrature.empty())
743 face_quadrature = QGauss<dim - 1>(fp);
744 }
745
746
747 template <int dim, int sdim>
748 inline void
750 {
751 add_update_flags(flags, true, true, true, true);
752 }
753
754
755 template <int dim, int sdim>
756 inline void
758 {
759 add_update_flags(flags, true, false, false, false);
760 }
761
762
763 template <int dim, int sdim>
764 inline void
766 const UpdateFlags flags)
767 {
768 add_update_flags(flags, false, true, false, false);
769 }
770
771
772 template <int dim, int sdim>
773 inline void
775 {
776 add_update_flags(flags, false, false, true, true);
777 }
778
779
780#ifndef DOXYGEN
781 template <int dim, int sdim>
782 inline void
784 const Mapping<dim, sdim> &mapping,
785 const BlockInfo *block_info)
786 {
787 initialize_update_flags();
788 initialize_gauss_quadrature((cell_flags & update_values) ?
789 (el.tensor_degree() + 1) :
790 el.tensor_degree(),
791 (boundary_flags & update_values) ?
792 (el.tensor_degree() + 1) :
793 el.tensor_degree(),
794 (face_flags & update_values) ?
795 (el.tensor_degree() + 1) :
796 el.tensor_degree(),
797 false);
798
799 cell.template initialize<FEValues<dim, sdim>>(
800 el, mapping, cell_quadrature, cell_flags, block_info);
801 boundary.template initialize<FEFaceValues<dim, sdim>>(
802 el, mapping, boundary_quadrature, boundary_flags, block_info);
803 face.template initialize<FEFaceValues<dim, sdim>>(
804 el, mapping, face_quadrature, face_flags, block_info);
805 subface.template initialize<FESubfaceValues<dim, sdim>>(
806 el, mapping, face_quadrature, face_flags, block_info);
807 neighbor.template initialize<FEFaceValues<dim, sdim>>(
808 el, mapping, face_quadrature, neighbor_flags, block_info);
809 }
810#endif
811
812
813 template <int dim, int sdim>
814 template <typename VectorType>
815 void
817 const Mapping<dim, sdim> &mapping,
818 const AnyData &data,
819 const VectorType &,
820 const BlockInfo *block_info)
821 {
822 initialize(el, mapping, block_info);
823 std::shared_ptr<VectorData<VectorType, dim, sdim>> p;
825
826 p = std::make_shared<VectorData<VectorType, dim, sdim>>(cell_selector);
827 // Public member function of parent class was not found without
828 // explicit cast
829 pp = &*p;
830 pp->initialize(data);
831 cell_data = p;
832 cell.initialize_data(p);
833
834 p = std::make_shared<VectorData<VectorType, dim, sdim>>(boundary_selector);
835 pp = &*p;
836 pp->initialize(data);
837 boundary_data = p;
838 boundary.initialize_data(p);
839
840 p = std::make_shared<VectorData<VectorType, dim, sdim>>(face_selector);
841 pp = &*p;
842 pp->initialize(data);
843 face_data = p;
844 face.initialize_data(p);
845 subface.initialize_data(p);
846 neighbor.initialize_data(p);
847 }
848
849 template <int dim, int sdim>
850 template <typename VectorType>
851 void
853 const Mapping<dim, sdim> &mapping,
854 const AnyData &data,
856 const BlockInfo *block_info)
857 {
858 initialize(el, mapping, block_info);
859 std::shared_ptr<MGVectorData<VectorType, dim, sdim>> p;
861
862 p = std::make_shared<MGVectorData<VectorType, dim, sdim>>(cell_selector);
863 // Public member function of parent class was not found without
864 // explicit cast
865 pp = &*p;
866 pp->initialize(data);
867 cell_data = p;
868 cell.initialize_data(p);
869
870 p =
871 std::make_shared<MGVectorData<VectorType, dim, sdim>>(boundary_selector);
872 pp = &*p;
873 pp->initialize(data);
874 boundary_data = p;
875 boundary.initialize_data(p);
876
877 p = std::make_shared<MGVectorData<VectorType, dim, sdim>>(face_selector);
878 pp = &*p;
879 pp->initialize(data);
880 face_data = p;
881 face.initialize_data(p);
882 subface.initialize_data(p);
883 neighbor.initialize_data(p);
884 }
885
886 template <int dim, int sdim>
887 template <class DOFINFO>
888 void
891
892
893 template <int dim, int sdim>
894 template <class DOFINFO>
895 void
898
899
900} // namespace MeshWorker
901
903
904#endif
unsigned int size() const
A small class collecting the different BlockIndices involved in global, multilevel and local computat...
Definition block_info.h:94
const BlockIndices & local() const
Definition block_info.h:227
const Quadrature< dim - 1 > & get_quadrature() const
void reinit(const TriaIterator< DoFCellAccessor< dim, spacedim, level_dof_access > > &cell, const unsigned int face_no)
void reinit(const TriaIterator< DoFCellAccessor< dim, spacedim, level_dof_access > > &cell, const unsigned int face_no, const unsigned int subface_no)
UpdateFlags get_update_flags() const
const Mapping< dim, spacedim > & get_mapping() const
const FiniteElement< dim, spacedim > & get_fe() const
const Quadrature< dim > & get_quadrature() const
void reinit(const TriaIterator< DoFCellAccessor< dim, spacedim, level_dof_access > > &cell)
unsigned int tensor_degree() const
unsigned int n_components() const
virtual const FiniteElement< dim, spacedim > & base_element(const unsigned int index) const
unsigned int n_base_elements() const
Abstract base class for mapping classes.
Definition mapping.h:318
unsigned int sub_number
Definition dof_info.h:95
ObserverPointer< const BlockInfo, DoFInfo< dim, spacedim > > block_info
The block structure of the system.
Definition dof_info.h:169
unsigned int face_number
Definition dof_info.h:87
Triangulation< dim, spacedim >::cell_iterator cell
The current cell.
Definition dof_info.h:76
std::size_t memory_consumption() const
void initialize_update_flags(bool neighbor_geometry=false)
void initialize_gauss_quadrature(unsigned int n_cell_points, unsigned int n_boundary_points, unsigned int n_face_points, const bool force=true)
void post_cell(const DoFInfoBox< dim, DOFINFO > &)
void initialize(const FiniteElement< dim, spacedim > &el, const Mapping< dim, spacedim > &mapping, const BlockInfo *block_info=nullptr)
void add_update_flags_all(const UpdateFlags flags)
MeshWorker::VectorSelector boundary_selector
void add_update_flags(const UpdateFlags flags, const bool cell=true, const bool boundary=true, const bool face=true, const bool neighbor=true)
std::shared_ptr< MeshWorker::VectorDataBase< dim, spacedim > > face_data
std::shared_ptr< MeshWorker::VectorDataBase< dim, spacedim > > boundary_data
std::shared_ptr< MeshWorker::VectorDataBase< dim, spacedim > > cell_data
void initialize(const FiniteElement< dim, spacedim > &el, const Mapping< dim, spacedim > &mapping, const AnyData &data, const MGLevelObject< VectorType > &dummy, const BlockInfo *block_info=nullptr)
Quadrature< dim - 1 > boundary_quadrature
void initialize(const FiniteElement< dim, spacedim > &el, const Mapping< dim, spacedim > &mapping, const AnyData &data, const VectorType &dummy, const BlockInfo *block_info=nullptr)
void add_update_flags_cell(const UpdateFlags flags)
Quadrature< dim - 1 > face_quadrature
MeshWorker::VectorSelector face_selector
void post_faces(const DoFInfoBox< dim, DOFINFO > &)
MeshWorker::VectorSelector cell_selector
void add_update_flags_face(const UpdateFlags flags)
void add_update_flags_boundary(const UpdateFlags flags)
std::vector< std::vector< std::vector< Tensor< 2, spacedim > > > > hessians
std::size_t memory_consumption() const
const FEValuesBase< dim, spacedim > & fe_values(const unsigned int i) const
Access to finite elements.
const FiniteElement< dim, spacedim > & finite_element() const
IntegrationInfo(const IntegrationInfo< dim, spacedim > &other)
const FEValuesBase< dim, spacedim > & fe_values() const
Access to finite element.
void fill_local_data(std::vector< std::vector< std::vector< TYPE > > > &data, VectorSelector &selector, bool split_fevalues) const
bool multigrid
This is true if we are assembling for multigrid.
std::shared_ptr< VectorDataBase< dim, spacedim > > global_data
ObserverPointer< const FiniteElement< dim, spacedim >, IntegrationInfo< dim, spacedim > > fe_pointer
void reinit(const DoFInfo< dim, spacedim, number > &i)
void fill_local_data(const DoFInfo< dim, spacedim, number > &info, bool split_fevalues)
std::vector< std::vector< std::vector< Tensor< 1, spacedim > > > > gradients
std::vector< std::shared_ptr< FEValuesBase< dim, spacedim > > > fevalv
vector of FEValues objects
void initialize(const FiniteElement< dim, spacedim > &el, const Mapping< dim, spacedim > &mapping, const Quadrature< FEVALUES::integral_dimension > &quadrature, const UpdateFlags flags, const BlockInfo *local_block_info=nullptr)
void initialize_data(const std::shared_ptr< VectorDataBase< dim, spacedim > > &data)
std::vector< std::vector< std::vector< double > > > values
void initialize(const AnyData &)
#define DEAL_II_DEPRECATED
Definition config.h:294
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define DEAL_II_ASSERT_UNREACHABLE()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcNotInitialized()
UpdateFlags
@ update_values
Shape function values.
std::vector< index_type > data
Definition mpi.cc:734
constexpr unsigned int invalid_unsigned_int
Definition types.h:228
STL namespace.