Reference documentation for deal.II version 9.5.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// Copyright (C) 2016 - 2022 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
26
27#include <deal.II/fe/fe.h>
29#include <deal.II/fe/fe_q.h>
32
34
35#include <map>
36#include <numeric>
37#include <utility>
38#include <vector>
39
41
175template <int dim, int spacedim = dim>
176class FE_Enriched : public FiniteElement<dim, spacedim>
177{
178public:
187 const FiniteElement<dim, spacedim> &fe_enriched,
188 const Function<spacedim> * enrichment_function);
189
201
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
256private:
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
270public:
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
362 FullMatrix<double> & matrix,
363 const unsigned int face_no = 0) const override;
364
377 virtual void
379 const FiniteElement<dim, spacedim> &source,
380 const unsigned int subface,
381 FullMatrix<double> & matrix,
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
442protected:
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
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>
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
579 using FiniteElement<dim, spacedim>::get_face_data;
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
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
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,
625 & mapping_data,
626 const typename FiniteElement<dim, spacedim>::InternalDataBase &fe_internal,
628 spacedim>
629 &output_data) const override;
630
631 virtual void
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
646private:
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,
674 &output_data) const;
675};
676
677
678
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
internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > & get_fe_output_object(const unsigned int base_no) const
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
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
const std::vector< std::vector< std::function< const Function< spacedim > *(const typename Triangulation< dim, spacedim >::cell_iterator &)> > > get_enrichments() const
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
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
Abstract base class for mapping classes.
Definition mapping.h:317
Definition point.h:112
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
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
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