Reference documentation for deal.II version Git 4fbb5374f0 2021-01-22 15:02:13 -0500
\(\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 
25 #include <deal.II/fe/fe.h>
26 #include <deal.II/fe/fe_nothing.h>
27 #include <deal.II/fe/fe_q.h>
28 #include <deal.II/fe/fe_system.h>
30 
31 #include <deal.II/hp/dof_handler.h>
33 
34 #include <map>
35 #include <numeric>
36 #include <utility>
37 #include <vector>
38 
40 
174 template <int dim, int spacedim = dim>
175 class FE_Enriched : public FiniteElement<dim, spacedim>
176 {
177 public:
186  const FiniteElement<dim, spacedim> &fe_enriched,
187  const Function<spacedim> * enrichment_function);
188 
200 
248  FE_Enriched(
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 
255 private:
262  FE_Enriched(
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 
269 public:
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 
332 
344  virtual bool
345  hp_constraints_are_implemented() const override;
346 
359  virtual void
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 
426 
427 
431  const std::vector<std::vector<std::function<const Function<spacedim> *(
433  get_enrichments() const;
434 
439  get_fe_system() const;
440 
441 protected:
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 
471  InternalData(std::unique_ptr<typename FESystem<dim, spacedim>::InternalData>
472  fesystem_data);
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>
557  setup_data(
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 
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
602  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
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,
607  const ::internal::FEValuesImplementation::MappingRelatedData<dim,
608  spacedim>
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,
624  const ::internal::FEValuesImplementation::MappingRelatedData<dim,
625  spacedim>
626  & mapping_data,
627  const typename FiniteElement<dim, spacedim>::InternalDataBase &fe_internal,
629  spacedim>
630  &output_data) const override;
631 
632  virtual void
634  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
635  const unsigned int face_no,
636  const unsigned int sub_no,
637  const Quadrature<dim - 1> & quadrature,
638  const Mapping<dim, spacedim> & mapping,
639  const typename Mapping<dim, spacedim>::InternalDataBase &mapping_internal,
640  const ::internal::FEValuesImplementation::MappingRelatedData<dim,
641  spacedim>
642  & mapping_data,
643  const typename FiniteElement<dim, spacedim>::InternalDataBase &fe_internal,
645  spacedim>
646  &output_data) const override;
647 
648 private:
653  void
654  initialize(const std::vector<const FiniteElement<dim, spacedim> *> &fes,
655  const std::vector<unsigned int> &multiplicities);
656 
660  const std::unique_ptr<const FESystem<dim, spacedim>> fe_system;
661 
667  template <int dim_1>
668  void
670  const Quadrature<dim_1> &quadrature,
671  const InternalData & fe_data,
673  & mapping_data,
674  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
676  &output_data) const;
677 };
678 
679 
680 
691 namespace ColorEnriched
692 {
700  template <int dim, int spacedim = dim>
701  using predicate_function = std::function<bool(
703 
704 #ifndef DOXYGEN
705  namespace internal
706  {
753  template <int dim, int spacedim>
754  bool
756  const DoFHandler<dim, spacedim> & dof_handler,
757  const predicate_function<dim, spacedim> &predicate_1,
758  const predicate_function<dim, spacedim> &predicate_2);
759 
772  template <int dim, int spacedim>
773  unsigned int
775  const DoFHandler<dim, spacedim> & dof_handler,
776  const std::vector<predicate_function<dim, spacedim>> &predicates,
777  std::vector<unsigned int> & predicate_colors);
778 
819  template <int dim, int spacedim>
820  void
822  DoFHandler<dim, spacedim> & dof_handler,
823  const std::vector<predicate_function<dim, spacedim>> &predicates,
824  const std::vector<unsigned int> & predicate_colors,
825  std::map<unsigned int, std::map<unsigned int, unsigned int>>
826  & cellwise_color_predicate_map,
827  std::vector<std::set<unsigned int>> &fe_sets);
828 
852  template <int dim, int spacedim>
853  void
855  const unsigned int n_colors,
856  const std::vector<std::shared_ptr<Function<spacedim>>> &enrichments,
857  const std::map<unsigned int, std::map<unsigned int, unsigned int>>
858  &cellwise_color_predicate_map,
859  std::vector<std::function<const Function<spacedim> *(
861  &color_enrichments);
862 
863 
878  template <int dim, int spacedim>
879  void
881  const unsigned int n_colors,
882  const std::vector<std::set<unsigned int>>
883  &fe_sets, // total list of color sets possible
884  const std::vector<std::function<const Function<spacedim> *(
886  &color_enrichments, // color wise enrichment functions
887  const FiniteElement<dim, spacedim> &fe_base, // basic FE element
889  &fe_enriched, // FE multiplied by enrichment function
890  const FE_Nothing<dim, spacedim> &fe_nothing,
891  hp::FECollection<dim, spacedim> &fe_collection);
892  } // namespace internal
893 #endif // DOXYGEN
894 
895 
896 
1063  template <int dim, int spacedim = dim>
1064  struct Helper
1065  {
1076  Helper(const FiniteElement<dim, spacedim> & fe_base,
1077  const FiniteElement<dim, spacedim> & fe_enriched,
1078  const std::vector<predicate_function<dim, spacedim>> & predicates,
1079  const std::vector<std::shared_ptr<Function<spacedim>>> &enrichments);
1080 
1091  build_fe_collection(DoFHandler<dim, spacedim> &dof_handler);
1092 
1093  private:
1099 
1105 
1111 
1118 
1124  const std::vector<predicate_function<dim, spacedim>> predicates;
1125 
1131  const std::vector<std::shared_ptr<Function<spacedim>>> enrichments;
1132 
1142  using cell_iterator_function = std::function<const Function<spacedim> *(
1144 
1154  std::vector<cell_iterator_function> color_enrichments;
1155 
1161  std::vector<unsigned int> predicate_colors;
1162 
1166  unsigned int n_colors;
1167 
1173  std::map<unsigned int, std::map<unsigned int, unsigned int>>
1175 
1180  std::vector<std::set<unsigned int>> fe_sets;
1181  };
1182 } // namespace ColorEnriched
1183 
1185 
1186 #endif // dealii_fe_enriched_h
virtual FiniteElementDomination::Domination compare_for_domination(const FiniteElement< dim, spacedim > &fe_other, const unsigned int codim=0) const override final
virtual const FiniteElement< dim, spacedim > & base_element(const unsigned int index) const override
Definition: fe_enriched.cc:517
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)
const std::vector< std::vector< std::function< const Function< spacedim > *(const typename Triangulation< dim, spacedim >::cell_iterator &)> > > get_enrichments() const
Definition: fe_enriched.cc:262
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:963
Contents is actually a matrix.
virtual const FullMatrix< double > & get_restriction_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) const override
InternalData(std::unique_ptr< typename FESystem< dim, spacedim >::InternalData > fesystem_data)
FE_Enriched(const FiniteElement< dim, spacedim > &fe_base, const FiniteElement< dim, spacedim > &fe_enriched, const Function< spacedim > *enrichment_function)
Definition: fe_enriched.cc:146
void initialize(const std::vector< const FiniteElement< dim, spacedim > *> &fes, const std::vector< unsigned int > &multiplicities)
Definition: fe_enriched.cc:426
const FiniteElement< dim, spacedim > & fe_enriched
Definition: fe_enriched.h:1110
internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > & get_fe_output_object(const unsigned int base_no) const
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::vector< std::vector< EnrichmentValues > > enrichment
Definition: fe_enriched.h:511
unsigned int n_colors
Definition: fe_enriched.h:1166
std::function< bool(const typename Triangulation< dim, spacedim >::cell_iterator &)> predicate_function
Definition: fe_enriched.h:702
hp::FECollection< dim, spacedim > fe_collection
Definition: fe_enriched.h:1098
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:635
const bool is_enriched
Definition: fe_enriched.h:543
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:945
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:367
virtual std::string get_name() const override
Definition: fe_enriched.cc:496
const std::vector< std::vector< std::function< const Function< spacedim > *(const typename Triangulation< dim, spacedim >::cell_iterator &)> > > enrichments
Definition: fe_enriched.h:532
const FESystem< dim, spacedim > & get_fe_system() const
Definition: fe_enriched.cc:879
std::unique_ptr< typename FESystem< dim, spacedim >::InternalData > fesystem_data
Definition: fe_enriched.h:494
const std::unique_ptr< const FESystem< dim, spacedim > > fe_system
Definition: fe_enriched.h:660
UpdateFlags
FiniteElement< dim, spacedim >::InternalDataBase & get_fe_data(const unsigned int base_no) const
Abstract base class for mapping classes.
Definition: mapping.h:303
Definition: fe.h:44
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:380
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)
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:919
std::vector< std::set< unsigned int > > fe_sets
Definition: fe_enriched.h:1180
std::vector< SymmetricTensor< 2, spacedim > > hessians
Definition: fe_enriched.h:458
std::vector< unsigned int > predicate_colors
Definition: fe_enriched.h:1161
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)
unsigned int color_predicates(const DoFHandler< dim, spacedim > &mesh, const std::vector< predicate_function< dim, spacedim >> &predicates, std::vector< unsigned int > &predicate_colors)
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:388
virtual double shape_value(const unsigned int i, const Point< dim > &p) const override
Definition: fe_enriched.cc:270
virtual UpdateFlags requires_update_flags(const UpdateFlags update_flags) const override
Definition: fe_enriched.cc:301
const FiniteElement< dim, spacedim > & fe_base
Definition: fe_enriched.h:1104
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:895
const std::vector< predicate_function< dim, spacedim > > predicates
Definition: fe_enriched.h:1124
virtual const FullMatrix< double > & get_prolongation_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) 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
Definition: fe_enriched.cc:560
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:408
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:379
std::vector< std::vector< std::vector< unsigned int > > > base_no_mult_local_enriched_dofs
Definition: fe_enriched.h:521
std::vector< Tensor< 1, spacedim > > gradients
Definition: fe_enriched.h:457
std::vector< cell_iterator_function > color_enrichments
Definition: fe_enriched.h:1154
std::function< const Function< spacedim > *(const typename Triangulation< dim, spacedim >::cell_iterator &)> cell_iterator_function
Definition: fe_enriched.h:1143
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:325
virtual std::unique_ptr< FiniteElement< dim, spacedim > > clone() const override
Definition: fe_enriched.cc:283
std::map< unsigned int, std::map< unsigned int, unsigned int > > cellwise_color_predicate_map
Definition: fe_enriched.h:1174
const std::vector< std::shared_ptr< Function< spacedim > > > enrichments
Definition: fe_enriched.h:1131
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:525
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:597
const FE_Nothing< dim, spacedim > fe_nothing
Definition: fe_enriched.h:1117
virtual bool hp_constraints_are_implemented() const override
Definition: fe_enriched.cc:887
int(&) functions(const void *v1, const void *v2)
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:981