Reference documentation for deal.II version 9.3.3
\(\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
24
25#include <deal.II/fe/fe.h>
27#include <deal.II/fe/fe_q.h>
30
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
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,
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
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,
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
615 using FiniteElement<dim, spacedim>::fill_fe_face_values;
616
617 virtual void
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
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
648private:
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,
676 &output_data) const;
677};
678
679
680
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 {
1078 const std::vector<predicate_function<dim, spacedim>> & predicates,
1079 const std::vector<std::shared_ptr<Function<spacedim>>> &enrichments);
1080
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
std::vector< std::vector< EnrichmentValues > > enrichment
Definition: fe_enriched.h:511
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:494
virtual std::string get_name() const override
Definition: fe_enriched.cc:496
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::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
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
std::vector< std::vector< std::vector< unsigned int > > > base_no_mult_local_enriched_dofs
Definition: fe_enriched.h:521
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
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
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 FiniteElementDomination::Domination compare_for_domination(const FiniteElement< dim, spacedim > &fe_other, const unsigned int codim=0) const override final
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 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
virtual double shape_value(const unsigned int i, const Point< dim > &p) const override
Definition: fe_enriched.cc:270
const bool is_enriched
Definition: fe_enriched.h:543
virtual std::unique_ptr< FiniteElement< dim, spacedim > > clone() const override
Definition: fe_enriched.cc:283
virtual bool hp_constraints_are_implemented() const override
Definition: fe_enriched.cc:887
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
void initialize(const std::vector< const FiniteElement< dim, spacedim > * > &fes, const std::vector< unsigned int > &multiplicities)
Definition: fe_enriched.cc:426
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 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
const FESystem< dim, spacedim > & get_fe_system() const
Definition: fe_enriched.cc:879
virtual const FiniteElement< dim, spacedim > & base_element(const unsigned int index) const override
Definition: fe_enriched.cc:517
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
virtual const FullMatrix< double > & get_restriction_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) 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
Definition: fe_enriched.cc:895
FE_Enriched(const FiniteElement< dim, spacedim > &fe_base, const FiniteElement< dim, spacedim > &fe_enriched, const Function< spacedim > *enrichment_function)
Definition: fe_enriched.cc:146
virtual UpdateFlags requires_update_flags(const UpdateFlags update_flags) const override
Definition: fe_enriched.cc:301
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
const std::vector< std::vector< std::function< const Function< spacedim > *(const typename Triangulation< dim, spacedim >::cell_iterator &)> > > enrichments
Definition: fe_enriched.h:532
const std::unique_ptr< const FESystem< dim, spacedim > > fe_system
Definition: fe_enriched.h:660
friend class InternalDataBase
Definition: fe.h:3066
Definition: point.h:111
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:402
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:403
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
Definition: fe_enriched.h:702
@ matrix
Contents is actually a matrix.
int(&) functions(const void *v1, const void *v2)
hp::FECollection< dim, spacedim > fe_collection
Definition: fe_enriched.h:1098
std::map< unsigned int, std::map< unsigned int, unsigned int > > cellwise_color_predicate_map
Definition: fe_enriched.h:1174
unsigned int n_colors
Definition: fe_enriched.h:1166
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:1180
const FiniteElement< dim, spacedim > & fe_enriched
Definition: fe_enriched.h:1110
std::vector< unsigned int > predicate_colors
Definition: fe_enriched.h:1161
const std::vector< predicate_function< dim, spacedim > > predicates
Definition: fe_enriched.h:1124
const FE_Nothing< dim, spacedim > fe_nothing
Definition: fe_enriched.h:1117
std::function< const Function< spacedim > *(const typename Triangulation< dim, spacedim >::cell_iterator &)> cell_iterator_function
Definition: fe_enriched.h:1143
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< std::shared_ptr< Function< spacedim > > > enrichments
Definition: fe_enriched.h:1131
const FiniteElement< dim, spacedim > & fe_base
Definition: fe_enriched.h:1104
std::vector< cell_iterator_function > color_enrichments
Definition: fe_enriched.h:1154
std::vector< SymmetricTensor< 2, spacedim > > hessians
Definition: fe_enriched.h:458
std::vector< Tensor< 1, spacedim > > gradients
Definition: fe_enriched.h:457