Flow123d  JS_before_hm-1830-gb19ac973c
fe_system.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file fe_system.hh
15  * @brief Class FESystem for compound finite elements.
16  * @author Jan Stebel
17  */
18 
19 #ifndef FE_SYSTEM_HH_
20 #define FE_SYSTEM_HH_
21 
22 #include <vector>
23 #include <memory>
24 
25 #include "fem/finite_element.hh"
26 #include "fem/fe_values.hh"
27 #include "tools/mixed.hh"
28 
29 
30 /**
31 * Auxiliary class that stores the relation of dofs in the FESystem to the base FE class.
32 * For each dof in FESystem it provides:
33 * - base FE class,
34 * - index of the basis function within base FE,
35 * - component index of the dof in FESystem.
36 */
38 
39  DofComponentData(unsigned int fei, unsigned int bi, unsigned co)
40  : fe_index(fei),
41  basis_index(bi),
43  {};
44 
45  /// Index of base FE class in the vector fe_.
46  unsigned int fe_index;
47  /// Index of basis function in the base FE.
48  unsigned int basis_index;
49  /// Component index in the FESystem.
50  unsigned int component_offset;
51 };
52 
53 
54 
56 {
57 public:
58 
59  /**
60  * @brief Constructor.
61  */
62  FESystemFunctionSpace(const std::vector<std::shared_ptr<FunctionSpace> > &fs_vector);
63 
64  double basis_value(unsigned int basis_index,
65  const arma::vec &point,
66  unsigned int comp_index = 0
67  ) const override;
68 
69  const arma::vec basis_grad(unsigned int basis_index,
70  const arma::vec &point,
71  unsigned int comp_index = 0
72  ) const override;
73 
74  unsigned int dim() const override { return dim_; }
75 
77 
78  virtual ~FESystemFunctionSpace() {};
79 
80 private:
81 
82  /// Function spaces that are put together.
84 
85  /// Indices of basis functions relative to the sub-spaces.
87 
88  /// Number of basis functions.
89  unsigned int dim_;
90 
91 };
92 
93 
94 
95 /**
96  * @brief Compound finite element on @p dim dimensional simplex.
97  *
98  * This type of FE is used for vector-valued functions and for systems of equations.
99  */
100 template <unsigned int dim>
101 class FESystem : public FiniteElement<dim>
102 {
103 public:
104 
105  /**
106  * @brief Constructor for FEVectorContravariant and FEVectorPiola.
107  * @param fe Base finite element class (must be scalar).
108  * @param t Type (must be FEVectorContravariant or FEVectorPiola).
109  */
110  FESystem(std::shared_ptr<FiniteElement<dim> > fe, FEType t);
111 
112  /**
113  * @brief Constructor for FEVector, FETensor and FEMixedSystem.
114  * If @p t == FEVector then @p n must be the space dimension into which
115  * the reference cell will be mapped and that @p fe is scalar.
116  * If @p t == FETensor then @p n must be square of the space dimension into which
117  * the reference cell will be mapped and that @p fe is scalar.
118  * If @p t == FEMixedSystem, then @p n is the number of components.
119  * @param fe Base finite element class (must be scalar if @p t is FEVector or FETensor).
120  * @param t Type of FESystem (must be either FEVector, FETensor or FEMixedSystem).
121  * @param n Multiplicity (number of components).
122  */
123  FESystem(const std::shared_ptr<FiniteElement<dim> > &fe, FEType t, unsigned int n);
124 
125  /**
126  * @brief Constructor. FESystem for mixed elements.
127  * @param fe Base finite element classes.
128  */
129  FESystem(std::vector<std::shared_ptr<FiniteElement<dim> > > fe);
130 
132  { return scalar_components_; }
133 
135  { return vector_components_; }
136 
138  { return tensor_components_; }
139 
140  UpdateFlags update_each(UpdateFlags flags) override;
141 
142  /// Get barycentric coordinates of the points on the reference element associated with the dofs.
143  /// Used in BDDC for unknown reason.
145 
146 
148  { return fe_; }
149 
150  /// Return dof indices belonging to given sub-FE.
151  std::vector<unsigned int> fe_dofs(unsigned int fe_index);
152 
153  /// Return function space casting to FESystemFunctionSpace type.
154  inline std::shared_ptr<FESystemFunctionSpace> function_space() const {
155  return std::dynamic_pointer_cast<FESystemFunctionSpace>(this->function_space_);
156  }
157 
158 
159 private:
160 
161  /// Initialization of the internal structures from the vector of base FE.
162  void initialize();
163 
164  void compute_node_matrix() override;
165 
166  /// Pointers to base FE objects.
168 
172 
173 };
174 
175 template<class... Args>
177 {
178  return MixedPtr<FESystem>(
179  std::make_shared<FESystem<0>>(fe[0_d], std::forward<Args>(args)...),
180  std::make_shared<FESystem<1>>(fe[1_d], std::forward<Args>(args)...),
181  std::make_shared<FESystem<2>>(fe[2_d], std::forward<Args>(args)...),
182  std::make_shared<FESystem<3>>(fe[3_d], std::forward<Args>(args)...)
183  );
184 }
185 
186 
187 
188 
189 #endif /* FE_SYSTEM_HH_ */
FESystem::FESystem
FESystem(std::shared_ptr< FiniteElement< dim > > fe, FEType t)
Constructor for FEVectorContravariant and FEVectorPiola.
Definition: fe_system.cc:102
DofComponentData::DofComponentData
DofComponentData(unsigned int fei, unsigned int bi, unsigned co)
Definition: fe_system.hh:39
FESystemFunctionSpace::~FESystemFunctionSpace
virtual ~FESystemFunctionSpace()
Definition: fe_system.hh:78
FESystemFunctionSpace::dim_
unsigned int dim_
Number of basis functions.
Definition: fe_system.hh:89
Armor::vec
ArmaVec< double, N > vec
Definition: armor.hh:885
DofComponentData::component_offset
unsigned int component_offset
Component index in the FESystem.
Definition: fe_system.hh:50
FESystem::vector_components_
std::vector< unsigned int > vector_components_
Definition: fe_system.hh:170
fe_values.hh
Class FEValues calculates finite element data on the actual cells such as shape function values,...
FESystemFunctionSpace::FESystemFunctionSpace
FESystemFunctionSpace(const std::vector< std::shared_ptr< FunctionSpace > > &fs_vector)
Constructor.
Definition: fe_system.cc:48
FESystemFunctionSpace
Definition: fe_system.hh:55
std::vector
Definition: doxy_dummy_defs.hh:7
FESystem::compute_node_matrix
void compute_node_matrix() override
Initializes the node_matrix for computing the coefficients of the shape functions in the raw basis of...
Definition: fe_system.cc:246
FESystem::get_tensor_components
std::vector< unsigned int > get_tensor_components() const
Definition: fe_system.hh:137
FEType
FEType
Definition: finite_element.hh:199
FESystemFunctionSpace::dof_indices_
std::vector< DofComponentData > dof_indices_
Indices of basis functions relative to the sub-spaces.
Definition: fe_system.hh:86
FESystemFunctionSpace::dof_indices
const std::vector< DofComponentData > & dof_indices()
Definition: fe_system.hh:76
FunctionSpace
Definition: finite_element.hh:121
DofComponentData::basis_index
unsigned int basis_index
Index of basis function in the base FE.
Definition: fe_system.hh:48
FESystem::fe
const std::vector< std::shared_ptr< FiniteElement< dim > > > & fe() const
Definition: fe_system.hh:147
finite_element.hh
Abstract class for description of finite elements.
FESystem::fe_
std::vector< std::shared_ptr< FiniteElement< dim > > > fe_
Pointers to base FE objects.
Definition: fe_system.hh:167
mixed_fe_system
MixedPtr< FESystem > mixed_fe_system(MixedPtr< FiniteElement > fe, Args &&... args)
Definition: fe_system.hh:176
FESystem::get_scalar_components
std::vector< unsigned int > get_scalar_components() const
Definition: fe_system.hh:131
FESystem::tensor_components_
std::vector< unsigned int > tensor_components_
Definition: fe_system.hh:171
FESystemFunctionSpace::basis_value
double basis_value(unsigned int basis_index, const arma::vec &point, unsigned int comp_index=0) const override
Value of the i th basis function at point point.
Definition: fe_system.cc:67
FESystem::scalar_components_
std::vector< unsigned int > scalar_components_
Definition: fe_system.hh:169
FiniteElement
Abstract class for the description of a general finite element on a reference simplex in dim dimensio...
Definition: discrete_space.hh:26
DofComponentData
Definition: fe_system.hh:37
FESystem::update_each
UpdateFlags update_each(UpdateFlags flags) override
Decides which additional quantities have to be computed for each cell.
Definition: fe_system.cc:222
FESystemFunctionSpace::fs_
std::vector< std::shared_ptr< FunctionSpace > > fs_
Function spaces that are put together.
Definition: fe_system.hh:78
FESystem::initialize
void initialize()
Initialization of the internal structures from the vector of base FE.
Definition: fe_system.cc:140
FESystemFunctionSpace::basis_grad
const arma::vec basis_grad(unsigned int basis_index, const arma::vec &point, unsigned int comp_index=0) const override
Gradient of the i th basis function at point point.
Definition: fe_system.cc:83
FESystem::fe_dofs
std::vector< unsigned int > fe_dofs(unsigned int fe_index)
Return dof indices belonging to given sub-FE.
Definition: fe_system.cc:267
FESystem::get_vector_components
std::vector< unsigned int > get_vector_components() const
Definition: fe_system.hh:134
MixedPtr
Definition: mixed.hh:247
FESystem::dof_points
virtual std::vector< arma::vec::fixed< dim+1 > > dof_points() const
Definition: fe_system.cc:233
FiniteElement::function_space_
std::shared_ptr< FunctionSpace > function_space_
Function space defining the FE.
Definition: finite_element.hh:385
UpdateFlags
UpdateFlags
Enum type UpdateFlags indicates which quantities are to be recomputed on each finite element cell.
Definition: update_flags.hh:67
DofComponentData::fe_index
unsigned int fe_index
Index of base FE class in the vector fe_.
Definition: fe_system.hh:43
mixed.hh
FESystem
Compound finite element on dim dimensional simplex.
Definition: fe_system.hh:101
FESystem::function_space
std::shared_ptr< FESystemFunctionSpace > function_space() const
Return function space casting to FESystemFunctionSpace type.
Definition: fe_system.hh:154
FESystemFunctionSpace::dim
unsigned int dim() const override
Dimension of function space (number of basis functions).
Definition: fe_system.hh:74