Reference documentation for deal.II version GIT bcacb256b7 2023-01-31 02:10: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\}}\)
fe_enriched.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2016 - 2020 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_fe_enriched_h
17 #define dealii_fe_enriched_h
18 
19 #include <deal.II/base/config.h>
20 
21 #include <deal.II/base/function.h>
24 
26 
27 #include <deal.II/fe/fe.h>
28 #include <deal.II/fe/fe_nothing.h>
29 #include <deal.II/fe/fe_q.h>
30 #include <deal.II/fe/fe_system.h>
32 
34 
35 #include <map>
36 #include <numeric>
37 #include <utility>
38 #include <vector>
39 
41 
175 template <int dim, int spacedim = dim>
176 class FE_Enriched : public FiniteElement<dim, spacedim>
177 {
178 public:
187  const FiniteElement<dim, spacedim> &fe_enriched,
188  const Function<spacedim> * enrichment_function);
189 
201 
249  FE_Enriched(
250  const FiniteElement<dim, spacedim> * fe_base,
251  const std::vector<const FiniteElement<dim, spacedim> *> &fe_enriched,
252  const std::vector<std::vector<std::function<const Function<spacedim> *(
254  &functions);
255 
256 private:
263  FE_Enriched(
264  const std::vector<const FiniteElement<dim, spacedim> *> &fes,
265  const std::vector<unsigned int> & multiplicities,
266  const std::vector<std::vector<std::function<const Function<spacedim> *(
268  &functions);
269 
270 public:
271  virtual std::unique_ptr<FiniteElement<dim, spacedim>>
272  clone() const override;
273 
274  virtual UpdateFlags
275  requires_update_flags(const UpdateFlags update_flags) const override;
276 
280  virtual std::string
281  get_name() const override;
282 
289  virtual const FiniteElement<dim, spacedim> &
290  base_element(const unsigned int index) const override;
291 
300  virtual double
301  shape_value(const unsigned int i, const Point<dim> &p) const override;
302 
314  virtual const FullMatrix<double> &
316  const unsigned int child,
317  const RefinementCase<dim> &refinement_case =
319 
326  virtual const FullMatrix<double> &
328  const unsigned int child,
329  const RefinementCase<dim> &refinement_case =
331 
345  virtual bool
346  hp_constraints_are_implemented() const override;
347 
360  virtual void
363  const unsigned int face_no = 0) const override;
364 
377  virtual void
379  const FiniteElement<dim, spacedim> &source,
380  const unsigned int subface,
382  const unsigned int face_no = 0) const override;
383 
399  virtual std::vector<std::pair<unsigned int, unsigned int>>
401  const FiniteElement<dim, spacedim> &fe_other) const override;
402 
407  virtual std::vector<std::pair<unsigned int, unsigned int>>
409  const FiniteElement<dim, spacedim> &fe_other) const override;
410 
415  virtual std::vector<std::pair<unsigned int, unsigned int>>
417  const unsigned int face_no = 0) const override;
418 
424  const unsigned int codim = 0) const override final;
425 
432  const std::vector<std::vector<std::function<const Function<spacedim> *(
434  get_enrichments() const;
435 
440  get_fe_system() const;
441 
442 protected:
447  class InternalData : public FiniteElement<dim, spacedim>::InternalDataBase
448  {
449  public:
456  {
457  std::vector<double> values;
458  std::vector<Tensor<1, spacedim>> gradients;
459  std::vector<SymmetricTensor<2, spacedim>> hessians;
460  };
461 
472  InternalData(std::unique_ptr<typename FESystem<dim, spacedim>::InternalData>
473  fesystem_data);
474 
480  get_fe_data(const unsigned int base_no) const;
481 
488  get_fe_output_object(const unsigned int base_no) const;
489 
494  std::unique_ptr<typename FESystem<dim, spacedim>::InternalData>
496 
512  mutable std::vector<std::vector<EnrichmentValues>> enrichment;
513  };
514 
521  std::vector<std::vector<std::vector<unsigned int>>>
523 
531  const std::vector<std::vector<std::function<const Function<spacedim> *(
534 
544  const bool is_enriched;
545 
556  template <int dim_1>
557  std::unique_ptr<typename FiniteElement<dim, spacedim>::InternalDataBase>
558  setup_data(
559  std::unique_ptr<typename FESystem<dim, spacedim>::InternalData> fes_data,
560  const UpdateFlags flags,
561  const Quadrature<dim_1> &quadrature) const;
562 
569  virtual std::unique_ptr<
571  get_data(
572  const UpdateFlags flags,
573  const Mapping<dim, spacedim> &mapping,
574  const Quadrature<dim> & quadrature,
576  spacedim>
577  &output_data) const override;
578 
580 
581  virtual std::unique_ptr<
584  const UpdateFlags update_flags,
585  const Mapping<dim, spacedim> & mapping,
586  const hp::QCollection<dim - 1> &quadrature,
588  spacedim>
589  &output_data) const override;
590 
591  virtual std::unique_ptr<
594  const UpdateFlags update_flags,
595  const Mapping<dim, spacedim> &mapping,
596  const Quadrature<dim - 1> & quadrature,
598  spacedim>
599  &output_data) const override;
600 
601  virtual void
603  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
604  const CellSimilarity::Similarity cell_similarity,
605  const Quadrature<dim> & quadrature,
606  const Mapping<dim, spacedim> & mapping,
607  const typename Mapping<dim, spacedim>::InternalDataBase &mapping_internal,
609  & mapping_data,
610  const typename FiniteElement<dim, spacedim>::InternalDataBase &fe_internal,
612  spacedim>
613  &output_data) const override;
614 
616 
617  virtual void
619  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
620  const unsigned int face_no,
621  const hp::QCollection<dim - 1> & quadrature,
622  const Mapping<dim, spacedim> & mapping,
623  const typename Mapping<dim, spacedim>::InternalDataBase &mapping_internal,
625  & mapping_data,
626  const typename FiniteElement<dim, spacedim>::InternalDataBase &fe_internal,
628  spacedim>
629  &output_data) const override;
630 
631  virtual void
633  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
634  const unsigned int face_no,
635  const unsigned int sub_no,
636  const Quadrature<dim - 1> & quadrature,
637  const Mapping<dim, spacedim> & mapping,
638  const typename Mapping<dim, spacedim>::InternalDataBase &mapping_internal,
640  & mapping_data,
641  const typename FiniteElement<dim, spacedim>::InternalDataBase &fe_internal,
643  spacedim>
644  &output_data) const override;
645 
646 private:
651  void
652  initialize(const std::vector<const FiniteElement<dim, spacedim> *> &fes,
653  const std::vector<unsigned int> &multiplicities);
654 
658  const std::unique_ptr<const FESystem<dim, spacedim>> fe_system;
659 
665  template <int dim_1>
666  void
668  const Quadrature<dim_1> &quadrature,
669  const InternalData & fe_data,
671  & mapping_data,
672  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
674  &output_data) const;
675 };
676 
677 
678 
689 namespace ColorEnriched
690 {
698  template <int dim, int spacedim = dim>
699  using predicate_function = std::function<bool(
701 
702 #ifndef DOXYGEN
703  namespace internal
704  {
751  template <int dim, int spacedim>
752  bool
754  const DoFHandler<dim, spacedim> & dof_handler,
755  const predicate_function<dim, spacedim> &predicate_1,
756  const predicate_function<dim, spacedim> &predicate_2);
757 
770  template <int dim, int spacedim>
771  unsigned int
773  const DoFHandler<dim, spacedim> & dof_handler,
774  const std::vector<predicate_function<dim, spacedim>> &predicates,
775  std::vector<unsigned int> & predicate_colors);
776 
817  template <int dim, int spacedim>
818  void
820  DoFHandler<dim, spacedim> & dof_handler,
821  const std::vector<predicate_function<dim, spacedim>> &predicates,
822  const std::vector<unsigned int> & predicate_colors,
823  std::map<unsigned int, std::map<unsigned int, unsigned int>>
824  & cellwise_color_predicate_map,
825  std::vector<std::set<unsigned int>> &fe_sets);
826 
850  template <int dim, int spacedim>
851  void
853  const unsigned int n_colors,
854  const std::vector<std::shared_ptr<Function<spacedim>>> &enrichments,
855  const std::map<unsigned int, std::map<unsigned int, unsigned int>>
856  &cellwise_color_predicate_map,
857  std::vector<std::function<const Function<spacedim> *(
859  &color_enrichments);
860 
861 
876  template <int dim, int spacedim>
877  void
879  const unsigned int n_colors,
880  const std::vector<std::set<unsigned int>>
881  &fe_sets, // total list of color sets possible
882  const std::vector<std::function<const Function<spacedim> *(
884  &color_enrichments, // color wise enrichment functions
885  const FiniteElement<dim, spacedim> &fe_base, // basic FE element
887  &fe_enriched, // FE multiplied by enrichment function
888  const FE_Nothing<dim, spacedim> &fe_nothing,
889  hp::FECollection<dim, spacedim> &fe_collection);
890  } // namespace internal
891 #endif // DOXYGEN
892 
893 
894 
1061  template <int dim, int spacedim = dim>
1062  struct Helper
1063  {
1076  const std::vector<predicate_function<dim, spacedim>> & predicates,
1077  const std::vector<std::shared_ptr<Function<spacedim>>> &enrichments);
1078 
1090 
1091  private:
1097 
1103 
1109 
1116 
1122  const std::vector<predicate_function<dim, spacedim>> predicates;
1123 
1129  const std::vector<std::shared_ptr<Function<spacedim>>> enrichments;
1130 
1140  using cell_iterator_function = std::function<const Function<spacedim> *(
1142 
1152  std::vector<cell_iterator_function> color_enrichments;
1153 
1159  std::vector<unsigned int> predicate_colors;
1160 
1164  unsigned int n_colors;
1165 
1171  std::map<unsigned int, std::map<unsigned int, unsigned int>>
1173 
1178  std::vector<std::set<unsigned int>> fe_sets;
1179  };
1180 } // namespace ColorEnriched
1181 
1183 
1184 #endif // dealii_fe_enriched_h
std::vector< std::vector< EnrichmentValues > > enrichment
Definition: fe_enriched.h:512
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
Definition: fe_enriched.h:495
virtual std::string get_name() const override
Definition: fe_enriched.cc:497
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
Definition: fe_enriched.cc:326
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
Definition: fe_enriched.cc:979
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
Definition: fe_enriched.cc:596
std::vector< std::vector< std::vector< unsigned int > > > base_no_mult_local_enriched_dofs
Definition: fe_enriched.h:522
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
Definition: fe_enriched.cc:633
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
Definition: fe_enriched.cc:409
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
Definition: fe_enriched.cc:368
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
Definition: fe_enriched.cc:560
virtual FiniteElementDomination::Domination compare_for_domination(const FiniteElement< dim, spacedim > &fe_other, const unsigned int codim=0) const override final
Definition: fe_enriched.cc:999
const std::vector< std::vector< std::function< const Function< spacedim > *(const typename Triangulation< dim, spacedim >::cell_iterator &)> > > get_enrichments() const
Definition: fe_enriched.cc:263
virtual double shape_value(const unsigned int i, const Point< dim > &p) const override
Definition: fe_enriched.cc:271
const bool is_enriched
Definition: fe_enriched.h:544
virtual std::unique_ptr< FiniteElement< dim, spacedim > > clone() const override
Definition: fe_enriched.cc:284
virtual bool hp_constraints_are_implemented() const override
Definition: fe_enriched.cc:885
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
Definition: fe_enriched.cc:389
void initialize(const std::vector< const FiniteElement< dim, spacedim > * > &fes, const std::vector< unsigned int > &multiplicities)
Definition: fe_enriched.cc:427
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_vertex_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
Definition: fe_enriched.cc:943
const FESystem< dim, spacedim > & get_fe_system() const
Definition: fe_enriched.cc:877
virtual const FiniteElement< dim, spacedim > & base_element(const unsigned int index) const override
Definition: fe_enriched.cc:518
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_line_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
Definition: fe_enriched.cc:961
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
Definition: fe_enriched.cc:526
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
Definition: fe_enriched.cc:893
FE_Enriched(const FiniteElement< dim, spacedim > &fe_base, const FiniteElement< dim, spacedim > &fe_enriched, const Function< spacedim > *enrichment_function)
Definition: fe_enriched.cc:147
virtual UpdateFlags requires_update_flags(const UpdateFlags update_flags) const override
Definition: fe_enriched.cc:302
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
Definition: fe_enriched.cc:917
const std::vector< std::vector< std::function< const Function< spacedim > *(const typename Triangulation< dim, spacedim >::cell_iterator &)> > > enrichments
Definition: fe_enriched.h:533
const std::unique_ptr< const FESystem< dim, spacedim > > fe_system
Definition: fe_enriched.h:658
friend class InternalDataBase
Definition: fe.h:3061
Definition: point.h:111
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:461
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:462
UpdateFlags
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)
unsigned int color_predicates(const DoFHandler< dim, spacedim > &mesh, const std::vector< predicate_function< dim, spacedim >> &predicates, std::vector< unsigned int > &predicate_colors)
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)
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)
std::function< bool(const typename Triangulation< dim, spacedim >::cell_iterator &)> predicate_function
Definition: fe_enriched.h:700
@ matrix
Contents is actually a matrix.
int(&) functions(const void *v1, const void *v2)
hp::FECollection< dim, spacedim > fe_collection
Definition: fe_enriched.h:1096
std::map< unsigned int, std::map< unsigned int, unsigned int > > cellwise_color_predicate_map
Definition: fe_enriched.h:1172
unsigned int n_colors
Definition: fe_enriched.h:1164
const hp::FECollection< dim, spacedim > & build_fe_collection(DoFHandler< dim, spacedim > &dof_handler)
std::vector< std::set< unsigned int > > fe_sets
Definition: fe_enriched.h:1178
const FiniteElement< dim, spacedim > & fe_enriched
Definition: fe_enriched.h:1108
std::vector< unsigned int > predicate_colors
Definition: fe_enriched.h:1159
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)
const std::vector< predicate_function< dim, spacedim > > predicates
Definition: fe_enriched.h:1122
const FE_Nothing< dim, spacedim > fe_nothing
Definition: fe_enriched.h:1115
std::function< const Function< spacedim > *(const typename Triangulation< dim, spacedim >::cell_iterator &)> cell_iterator_function
Definition: fe_enriched.h:1141
const std::vector< std::shared_ptr< Function< spacedim > > > enrichments
Definition: fe_enriched.h:1129
const FiniteElement< dim, spacedim > & fe_base
Definition: fe_enriched.h:1102
std::vector< cell_iterator_function > color_enrichments
Definition: fe_enriched.h:1152
std::vector< SymmetricTensor< 2, spacedim > > hessians
Definition: fe_enriched.h:459
std::vector< Tensor< 1, spacedim > > gradients
Definition: fe_enriched.h:458