Flow123d  release_3.0.0-1105-g32a483d
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  const std::vector<DofComponentData> &dof_indices() { return dof_indices_; }
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 
143  { return fe_; }
144 
145 
146 private:
147 
148  /// Initialization of the internal structures from the vector of base FE.
149  void initialize();
150 
151  void compute_node_matrix() override;
152 
153  /// Pointers to base FE objects.
155 
159 
160 };
161 
162 
163 
164 
165 
166 
167 #endif /* FE_SYSTEM_HH_ */
UpdateFlags
Enum type UpdateFlags indicates which quantities are to be recomputed on each finite element cell...
Definition: update_flags.hh:67
const std::vector< std::shared_ptr< FiniteElement< dim > > > & fe()
Definition: fe_system.hh:142
std::vector< unsigned int > get_tensor_components() const
Definition: fe_system.hh:137
const unsigned int dim() const override
Dimension of function space (number of basis functions).
Definition: fe_system.hh:74
unsigned int component_offset
Component index in the FESystem.
Definition: fe_system.hh:50
std::vector< DofComponentData > dof_indices_
Indices of basis functions relative to the sub-spaces.
Definition: fe_system.hh:86
virtual ~FESystemFunctionSpace()
Definition: fe_system.hh:78
DofComponentData(unsigned int fei, unsigned int bi, unsigned co)
Definition: fe_system.hh:39
unsigned int dim_
Number of basis functions.
Definition: fe_system.hh:89
std::vector< unsigned int > vector_components_
Definition: fe_system.hh:157
Class FEValues calculates finite element data on the actual cells such as shape function values...
FEType
std::vector< unsigned int > get_scalar_components() const
Definition: fe_system.hh:131
std::vector< std::shared_ptr< FiniteElement< dim > > > fe_
Pointers to base FE objects.
Definition: fe_system.hh:154
std::vector< unsigned int > get_vector_components() const
Definition: fe_system.hh:134
Compound finite element on dim dimensional simplex.
Definition: fe_system.hh:101
unsigned int basis_index
Index of basis function in the base FE.
Definition: fe_system.hh:48
unsigned int fe_index
Index of base FE class in the vector fe_.
Definition: fe_system.hh:43
const std::vector< DofComponentData > & dof_indices()
Definition: fe_system.hh:76
Abstract class for description of finite elements.
Abstract class for the description of a general finite element on a reference simplex in dim dimensio...
std::vector< unsigned int > tensor_components_
Definition: fe_system.hh:158
std::vector< unsigned int > scalar_components_
Definition: fe_system.hh:156