Reference documentation for deal.II version 9.6.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
fe_enriched.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2016 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_fe_enriched_h
16#define dealii_fe_enriched_h
17
18#include <deal.II/base/config.h>
19
23
25
26#include <deal.II/fe/fe.h>
28#include <deal.II/fe/fe_q.h>
31
33
34#include <map>
35#include <numeric>
36#include <utility>
37#include <vector>
38
40
174template <int dim, int spacedim = dim>
175class FE_Enriched : public FiniteElement<dim, spacedim>
176{
177public:
186 const FiniteElement<dim, spacedim> &fe_enriched,
187 const Function<spacedim> *enrichment_function);
188
200
249 const FiniteElement<dim, spacedim> *fe_base,
250 const std::vector<const FiniteElement<dim, spacedim> *> &fe_enriched,
251 const std::vector<std::vector<std::function<const Function<spacedim> *(
253 &functions);
254
255private:
263 const std::vector<const FiniteElement<dim, spacedim> *> &fes,
264 const std::vector<unsigned int> &multiplicities,
265 const std::vector<std::vector<std::function<const Function<spacedim> *(
267 &functions);
268
269public:
270 virtual std::unique_ptr<FiniteElement<dim, spacedim>>
271 clone() const override;
272
273 virtual UpdateFlags
274 requires_update_flags(const UpdateFlags update_flags) const override;
275
279 virtual std::string
280 get_name() const override;
281
288 virtual const FiniteElement<dim, spacedim> &
289 base_element(const unsigned int index) const override;
290
299 virtual double
300 shape_value(const unsigned int i, const Point<dim> &p) const override;
301
313 virtual const FullMatrix<double> &
315 const unsigned int child,
316 const RefinementCase<dim> &refinement_case =
318
325 virtual const FullMatrix<double> &
327 const unsigned int child,
328 const RefinementCase<dim> &refinement_case =
330
344 virtual bool
345 hp_constraints_are_implemented() const override;
346
359 virtual void
361 FullMatrix<double> &matrix,
362 const unsigned int face_no = 0) const override;
363
376 virtual void
378 const FiniteElement<dim, spacedim> &source,
379 const unsigned int subface,
380 FullMatrix<double> &matrix,
381 const unsigned int face_no = 0) const override;
382
398 virtual std::vector<std::pair<unsigned int, unsigned int>>
400 const FiniteElement<dim, spacedim> &fe_other) const override;
401
406 virtual std::vector<std::pair<unsigned int, unsigned int>>
408 const FiniteElement<dim, spacedim> &fe_other) const override;
409
414 virtual std::vector<std::pair<unsigned int, unsigned int>>
416 const unsigned int face_no = 0) const override;
417
423 const unsigned int codim = 0) const override final;
424
431 std::vector<std::vector<std::function<const Function<spacedim> *(
433 get_enrichments() const;
434
439 get_fe_system() const;
440
441protected:
446 class InternalData : public FiniteElement<dim, spacedim>::InternalDataBase
447 {
448 public:
455 {
456 std::vector<double> values;
457 std::vector<Tensor<1, spacedim>> gradients;
458 std::vector<SymmetricTensor<2, spacedim>> hessians;
459 };
460
473
479 get_fe_data(const unsigned int base_no) const;
480
487 get_fe_output_object(const unsigned int base_no) const;
488
493 std::unique_ptr<typename FESystem<dim, spacedim>::InternalData>
495
511 mutable std::vector<std::vector<EnrichmentValues>> enrichment;
512 };
513
520 std::vector<std::vector<std::vector<unsigned int>>>
522
530 const std::vector<std::vector<std::function<const Function<spacedim> *(
533
543 const bool is_enriched;
544
555 template <int dim_1>
556 std::unique_ptr<typename FiniteElement<dim, spacedim>::InternalDataBase>
558 std::unique_ptr<typename FESystem<dim, spacedim>::InternalData> fes_data,
559 const UpdateFlags flags,
560 const Quadrature<dim_1> &quadrature) const;
561
568 virtual std::unique_ptr<
570 get_data(
571 const UpdateFlags flags,
572 const Mapping<dim, spacedim> &mapping,
573 const Quadrature<dim> &quadrature,
575 spacedim>
576 &output_data) const override;
577
578 using FiniteElement<dim, spacedim>::get_face_data;
579
580 virtual std::unique_ptr<
583 const UpdateFlags update_flags,
584 const Mapping<dim, spacedim> &mapping,
585 const hp::QCollection<dim - 1> &quadrature,
587 spacedim>
588 &output_data) const override;
589
590 virtual std::unique_ptr<
593 const UpdateFlags update_flags,
594 const Mapping<dim, spacedim> &mapping,
595 const Quadrature<dim - 1> &quadrature,
597 spacedim>
598 &output_data) const override;
599
600 virtual void
603 const CellSimilarity::Similarity cell_similarity,
604 const Quadrature<dim> &quadrature,
605 const Mapping<dim, spacedim> &mapping,
606 const typename Mapping<dim, spacedim>::InternalDataBase &mapping_internal,
608 &mapping_data,
609 const typename FiniteElement<dim, spacedim>::InternalDataBase &fe_internal,
611 spacedim>
612 &output_data) const override;
613
614 using FiniteElement<dim, spacedim>::fill_fe_face_values;
615
616 virtual void
619 const unsigned int face_no,
620 const hp::QCollection<dim - 1> &quadrature,
621 const Mapping<dim, spacedim> &mapping,
622 const typename Mapping<dim, spacedim>::InternalDataBase &mapping_internal,
624 &mapping_data,
625 const typename FiniteElement<dim, spacedim>::InternalDataBase &fe_internal,
627 spacedim>
628 &output_data) const override;
629
630 virtual void
633 const unsigned int face_no,
634 const unsigned int sub_no,
635 const Quadrature<dim - 1> &quadrature,
636 const Mapping<dim, spacedim> &mapping,
637 const typename Mapping<dim, spacedim>::InternalDataBase &mapping_internal,
639 &mapping_data,
640 const typename FiniteElement<dim, spacedim>::InternalDataBase &fe_internal,
642 spacedim>
643 &output_data) const override;
644
645private:
650 void
651 initialize(const std::vector<const FiniteElement<dim, spacedim> *> &fes,
652 const std::vector<unsigned int> &multiplicities);
653
657 const std::unique_ptr<const FESystem<dim, spacedim>> fe_system;
658
664 template <int dim_1>
665 void
667 const Quadrature<dim_1> &quadrature,
668 const InternalData &fe_data,
670 &mapping_data,
673 &output_data) const;
674};
675
676
677
689{
697 template <int dim, int spacedim = dim>
698 using predicate_function = std::function<bool(
700
701#ifndef DOXYGEN
702 namespace internal
703 {
750 template <int dim, int spacedim>
751 bool
753 const DoFHandler<dim, spacedim> &dof_handler,
754 const predicate_function<dim, spacedim> &predicate_1,
755 const predicate_function<dim, spacedim> &predicate_2);
756
769 template <int dim, int spacedim>
770 unsigned int
772 const DoFHandler<dim, spacedim> &dof_handler,
773 const std::vector<predicate_function<dim, spacedim>> &predicates,
774 std::vector<unsigned int> &predicate_colors);
775
816 template <int dim, int spacedim>
817 void
819 DoFHandler<dim, spacedim> &dof_handler,
820 const std::vector<predicate_function<dim, spacedim>> &predicates,
821 const std::vector<unsigned int> &predicate_colors,
822 std::map<unsigned int, std::map<unsigned int, unsigned int>>
823 &cellwise_color_predicate_map,
824 std::vector<std::set<unsigned int>> &fe_sets);
825
849 template <int dim, int spacedim>
850 void
852 const unsigned int n_colors,
853 const std::vector<std::shared_ptr<Function<spacedim>>> &enrichments,
854 const std::map<unsigned int, std::map<unsigned int, unsigned int>>
855 &cellwise_color_predicate_map,
856 std::vector<std::function<const Function<spacedim> *(
858 &color_enrichments);
859
860
875 template <int dim, int spacedim>
876 void
878 const unsigned int n_colors,
879 const std::vector<std::set<unsigned int>>
880 &fe_sets, // total list of color sets possible
881 const std::vector<std::function<const Function<spacedim> *(
883 &color_enrichments, // color wise enrichment functions
884 const FiniteElement<dim, spacedim> &fe_base, // basic FE element
886 &fe_enriched, // FE multiplied by enrichment function
887 const FE_Nothing<dim, spacedim> &fe_nothing,
888 hp::FECollection<dim, spacedim> &fe_collection);
889 } // namespace internal
890#endif // DOXYGEN
891
892
893
1060 template <int dim, int spacedim = dim>
1061 struct Helper
1062 {
1076 const std::vector<std::shared_ptr<Function<spacedim>>> &enrichments);
1077
1089
1090 private:
1096
1102
1108
1115
1121 const std::vector<predicate_function<dim, spacedim>> predicates;
1122
1128 const std::vector<std::shared_ptr<Function<spacedim>>> enrichments;
1129
1139 using cell_iterator_function = std::function<const Function<spacedim> *(
1141
1151 std::vector<cell_iterator_function> color_enrichments;
1152
1158 std::vector<unsigned int> predicate_colors;
1159
1163 unsigned int n_colors;
1164
1170 std::map<unsigned int, std::map<unsigned int, unsigned int>>
1172
1177 std::vector<std::set<unsigned int>> fe_sets;
1178 };
1179} // namespace ColorEnriched
1180
1182
1183#endif // dealii_fe_enriched_h
std::vector< std::vector< EnrichmentValues > > enrichment
internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > & get_fe_output_object(const unsigned int base_no) const
InternalData(std::unique_ptr< typename FESystem< dim, spacedim >::InternalData > fesystem_data)
FiniteElement< dim, spacedim >::InternalDataBase & get_fe_data(const unsigned int base_no) const
std::unique_ptr< typename FESystem< dim, spacedim >::InternalData > fesystem_data
virtual std::string get_name() const override
std::unique_ptr< typename FiniteElement< dim, spacedim >::InternalDataBase > setup_data(std::unique_ptr< typename FESystem< dim, spacedim >::InternalData > fes_data, const UpdateFlags flags, const Quadrature< dim_1 > &quadrature) const
std::vector< std::vector< std::function< const Function< spacedim > *(const typename Triangulation< dim, spacedim >::cell_iterator &)> > > get_enrichments() const
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_quad_dof_identities(const FiniteElement< dim, spacedim > &fe_other, const unsigned int face_no=0) const override
virtual void fill_fe_subface_values(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const unsigned int face_no, const unsigned int sub_no, const Quadrature< dim - 1 > &quadrature, const Mapping< dim, spacedim > &mapping, const typename Mapping< dim, spacedim >::InternalDataBase &mapping_internal, const internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &mapping_data, const typename FiniteElement< dim, spacedim >::InternalDataBase &fe_internal, ::internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > &output_data) const override
std::vector< std::vector< std::vector< unsigned int > > > base_no_mult_local_enriched_dofs
void multiply_by_enrichment(const Quadrature< dim_1 > &quadrature, const InternalData &fe_data, const internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &mapping_data, const typename Triangulation< dim, spacedim >::cell_iterator &cell, internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > &output_data) const
virtual std::unique_ptr< typename FiniteElement< dim, spacedim >::InternalDataBase > get_data(const UpdateFlags flags, const Mapping< dim, spacedim > &mapping, const Quadrature< dim > &quadrature, ::internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > &output_data) const override
virtual std::unique_ptr< typename FiniteElement< dim, spacedim >::InternalDataBase > get_face_data(const UpdateFlags update_flags, const Mapping< dim, spacedim > &mapping, const hp::QCollection< dim - 1 > &quadrature, ::internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > &output_data) const override
virtual void fill_fe_face_values(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const unsigned int face_no, const hp::QCollection< dim - 1 > &quadrature, const Mapping< dim, spacedim > &mapping, const typename Mapping< dim, spacedim >::InternalDataBase &mapping_internal, const internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &mapping_data, const typename FiniteElement< dim, spacedim >::InternalDataBase &fe_internal, ::internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > &output_data) const override
virtual FiniteElementDomination::Domination compare_for_domination(const FiniteElement< dim, spacedim > &fe_other, const unsigned int codim=0) const override final
virtual double shape_value(const unsigned int i, const Point< dim > &p) const override
const bool is_enriched
virtual std::unique_ptr< FiniteElement< dim, spacedim > > clone() const override
virtual bool hp_constraints_are_implemented() const override
virtual std::unique_ptr< typename FiniteElement< dim, spacedim >::InternalDataBase > get_subface_data(const UpdateFlags update_flags, const Mapping< dim, spacedim > &mapping, const Quadrature< dim - 1 > &quadrature, ::internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > &output_data) const override
void initialize(const std::vector< const FiniteElement< dim, spacedim > * > &fes, const std::vector< unsigned int > &multiplicities)
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_vertex_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
const FESystem< dim, spacedim > & get_fe_system() const
virtual const FiniteElement< dim, spacedim > & base_element(const unsigned int index) const override
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_line_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
virtual const FullMatrix< double > & get_restriction_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) const override
virtual void fill_fe_values(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const CellSimilarity::Similarity cell_similarity, const Quadrature< dim > &quadrature, const Mapping< dim, spacedim > &mapping, const typename Mapping< dim, spacedim >::InternalDataBase &mapping_internal, const internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &mapping_data, const typename FiniteElement< dim, spacedim >::InternalDataBase &fe_internal, ::internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > &output_data) const override
virtual const FullMatrix< double > & get_prolongation_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) const override
virtual void get_face_interpolation_matrix(const FiniteElement< dim, spacedim > &source, FullMatrix< double > &matrix, const unsigned int face_no=0) const override
FE_Enriched(const FiniteElement< dim, spacedim > &fe_base, const FiniteElement< dim, spacedim > &fe_enriched, const Function< spacedim > *enrichment_function)
virtual UpdateFlags requires_update_flags(const UpdateFlags update_flags) const override
virtual void get_subface_interpolation_matrix(const FiniteElement< dim, spacedim > &source, const unsigned int subface, FullMatrix< double > &matrix, const unsigned int face_no=0) const override
const std::vector< std::vector< std::function< const Function< spacedim > *(const typename Triangulation< dim, spacedim >::cell_iterator &)> > > enrichments
const std::unique_ptr< const FESystem< dim, spacedim > > fe_system
friend class InternalDataBase
Definition fe.h:3075
Abstract base class for mapping classes.
Definition mapping.h:318
Definition point.h:111
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:503
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:504
UpdateFlags
void set_cellwise_color_set_and_fe_index(DoFHandler< dim, spacedim > &dof_handler, const std::vector< predicate_function< dim, spacedim > > &predicates, const std::vector< unsigned int > &predicate_colors, std::map< unsigned int, std::map< unsigned int, unsigned int > > &cellwise_color_predicate_map, std::vector< std::set< unsigned int > > &fe_sets)
unsigned int color_predicates(const DoFHandler< dim, spacedim > &mesh, const std::vector< predicate_function< dim, spacedim > > &predicates, std::vector< unsigned int > &predicate_colors)
void make_colorwise_enrichment_functions(const unsigned int n_colors, const std::vector< std::shared_ptr< Function< spacedim > > > &enrichments, const std::map< unsigned int, std::map< unsigned int, unsigned int > > &cellwise_color_predicate_map, std::vector< std::function< const Function< spacedim > *(const typename Triangulation< dim, spacedim >::cell_iterator &)> > &color_enrichments)
bool find_connection_between_subdomains(const DoFHandler< dim, spacedim > &dof_handler, const predicate_function< dim, spacedim > &predicate_1, const predicate_function< dim, spacedim > &predicate_2)
void make_fe_collection_from_colored_enrichments(const unsigned int n_colors, const std::vector< std::set< unsigned int > > &fe_sets, const std::vector< std::function< const Function< spacedim > *(const typename Triangulation< dim, spacedim >::cell_iterator &)> > &color_enrichments, const FiniteElement< dim, spacedim > &fe_base, const FiniteElement< dim, spacedim > &fe_enriched, const FE_Nothing< dim, spacedim > &fe_nothing, hp::FECollection< dim, spacedim > &fe_collection)
std::function< bool( const typename Triangulation< dim, spacedim >::cell_iterator &)> predicate_function
hp::FECollection< dim, spacedim > fe_collection
std::map< unsigned int, std::map< unsigned int, unsigned int > > cellwise_color_predicate_map
const hp::FECollection< dim, spacedim > & build_fe_collection(DoFHandler< dim, spacedim > &dof_handler)
std::vector< std::set< unsigned int > > fe_sets
const FiniteElement< dim, spacedim > & fe_enriched
std::vector< unsigned int > predicate_colors
const std::vector< predicate_function< dim, spacedim > > predicates
const FE_Nothing< dim, spacedim > fe_nothing
Helper(const FiniteElement< dim, spacedim > &fe_base, const FiniteElement< dim, spacedim > &fe_enriched, const std::vector< predicate_function< dim, spacedim > > &predicates, const std::vector< std::shared_ptr< Function< spacedim > > > &enrichments)
std::function< const Function< spacedim > *( const typename Triangulation< dim, spacedim >::cell_iterator &)> cell_iterator_function
const std::vector< std::shared_ptr< Function< spacedim > > > enrichments
const FiniteElement< dim, spacedim > & fe_base
std::vector< cell_iterator_function > color_enrichments
std::vector< SymmetricTensor< 2, spacedim > > hessians
std::vector< Tensor< 1, spacedim > > gradients