Flow123d  release_3.0.0-968-gc87a28e79
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 
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  const 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  const unsigned int dim() const override { return dim_; }
75 
76  virtual ~FESystemFunctionSpace() {};
77 
78 private:
79 
80  /// Function spaces that are put together.
82 
83  /// Indices of basis functions relative to the sub-spaces.
85 
86  /// Number of basis functions.
87  unsigned int dim_;
88 
89 };
90 
91 
92 
93 /**
94  * @brief Compound finite element on @p dim dimensional simplex.
95  *
96  * This type of FE is used for vector-valued functions and for systems of equations.
97  */
98 template <unsigned int dim>
99 class FESystem : public FiniteElement<dim>
100 {
101 public:
102 
103  /**
104  * @brief Constructor for FEVectorContravariant and FEVectorPiola.
105  * @param fe Base finite element class (must be scalar).
106  * @param t Type (must be FEVectorContravariant or FEVectorPiola).
107  */
108  FESystem(std::shared_ptr<FiniteElement<dim> > fe, FEType t);
109 
110  /**
111  * @brief Constructor for FEVector, FETensor and FEMixedSystem.
112  * If @p t == FEVector then @p n must be the space dimension into which
113  * the reference cell will be mapped and that @p fe is scalar.
114  * If @p t == FETensor then @p n must be square of the space dimension into which
115  * the reference cell will be mapped and that @p fe is scalar.
116  * If @p t == FEMixedSystem, then @p n is the number of components.
117  * @param fe Base finite element class (must be scalar if @p t is FEVector or FETensor).
118  * @param t Type of FESystem (must be either FEVector, FETensor or FEMixedSystem).
119  * @param n Multiplicity (number of components).
120  */
121  FESystem(const std::shared_ptr<FiniteElement<dim> > &fe, FEType t, unsigned int n);
122 
123  /**
124  * @brief Constructor. FESystem for mixed elements.
125  * @param fe Base finite element classes.
126  */
127  FESystem(std::vector<std::shared_ptr<FiniteElement<dim> > > fe);
128 
130  { return scalar_components_; }
131 
133  { return vector_components_; }
134 
136  { return tensor_components_; }
137 
138  UpdateFlags update_each(UpdateFlags flags) override;
139 
141  { return fe_; }
142 
143 
144 private:
145 
146  /// Initialization of the internal structures from the vector of base FE.
147  void initialize();
148 
149  void compute_node_matrix() override;
150 
151  /// Pointers to base FE objects.
153 
157 
158 };
159 
160 
161 
162 
163 
164 
165 #endif /* FE_SYSTEM_HH_ */
FESystem::fe
const std::vector< std::shared_ptr< FiniteElement< dim > > > & fe()
Definition: fe_system.hh:140
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:76
FESystemFunctionSpace::dim_
unsigned int dim_
Number of basis functions.
Definition: fe_system.hh:87
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:155
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:234
FESystem::get_tensor_components
std::vector< unsigned int > get_tensor_components() const
Definition: fe_system.hh:135
FEType
FEType
Definition: finite_element.hh:203
FESystemFunctionSpace::dof_indices_
std::vector< DofComponentData > dof_indices_
Indices of basis functions relative to the sub-spaces.
Definition: fe_system.hh:84
FunctionSpace
Definition: finite_element.hh:125
DofComponentData::basis_index
unsigned int basis_index
Index of basis function in the base FE.
Definition: fe_system.hh:48
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:152
FESystemFunctionSpace::dim
const unsigned int dim() const override
Dimension of function space (number of basis functions).
Definition: fe_system.hh:74
FESystem::get_scalar_components
std::vector< unsigned int > get_scalar_components() const
Definition: fe_system.hh:129
FESystem::tensor_components_
std::vector< unsigned int > tensor_components_
Definition: fe_system.hh:156
FESystem::scalar_components_
std::vector< unsigned int > scalar_components_
Definition: fe_system.hh:154
FiniteElement
Abstract class for the description of a general finite element on a reference simplex in dim dimensio...
Definition: discrete_space.hh:25
FESystemFunctionSpace::basis_value
const 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
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:76
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::get_vector_components
std::vector< unsigned int > get_vector_components() const
Definition: fe_system.hh:132
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
FESystem
Compound finite element on dim dimensional simplex.
Definition: fe_system.hh:99