Flow123d  release_2.2.0-914-gf1a3a4f
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  * @brief Compound finite element on @p dim dimensional simplex.
32  *
33  * This type of FE is used for vector-valued functions and for systems of equations.
34  */
35 template <unsigned int dim, unsigned int spacedim>
36 class FESystem : public FiniteElement<dim,spacedim>
37 {
38 public:
39 
40  /**
41  * @brief Constructor. FESystem for vector or tensor created from a scalar FE.
42  * @param fe Base finite element class.
43  * @param t Type (vector or tensor).
44  */
45  FESystem(std::shared_ptr<FiniteElement<dim,spacedim> > fe, FEType t);
46 
47  /**
48  * @brief Constructor. FESystem with @p n components created from a scalar FE.
49  * @param fe Base finite element class.
50  * @param n Multiplicity (number of components).
51  */
52  FESystem(const std::shared_ptr<FiniteElement<dim,spacedim> > &fe, unsigned int n);
53 
54  /**
55  * @brief Constructor. FESystem for mixed elements.
56  * @param fe Base finite element classes.
57  */
58  FESystem(std::vector<std::shared_ptr<FiniteElement<dim,spacedim> > > fe);
59 
61  { return scalar_components_; }
62 
64  { return vector_components_; }
65 
66  /**
67  * @brief The vector variant of basis_value must be implemented but need not be used.
68  */
69  double basis_value(const unsigned int i,
70  const arma::vec::fixed<dim> &p,
71  const unsigned int comp) const override;
72 
73  /**
74  * @brief The vector variant of basis_grad must be implemented but need not be used.
75  */
76  arma::vec::fixed<dim> basis_grad(const unsigned int i,
77  const arma::vec::fixed<dim> &p,
78  const unsigned int comp) const override;
79 
80  unsigned int n_components() const override { return n_components_; }
81 
82  UpdateFlags update_each(UpdateFlags flags) override;
83 
84 
85 private:
86 
87  /**
88  * Auxiliary class that stores the relation of dofs in the FESystem to the base FE class.
89  * For each dof in FESystem it provides:
90  * - base FE class,
91  * - index of the basis function within base FE,
92  * - component index of the dof in FESystem.
93  */
95 
96  DofComponentData(unsigned int fei, unsigned int bi, unsigned co)
97  : fe_index(fei),
98  basis_index(bi),
100  {};
101 
102  /// Index of base FE class in the vector fe_.
103  unsigned int fe_index;
104  /// Index of basis function in the base FE.
105  unsigned int basis_index;
106  /// Component index in the FESystem.
107  unsigned int component_offset;
108  };
109 
110  /// Initialization of the internal structures from the vector of base FE.
111  void initialize();
112 
113  FEInternalData *initialize(const Quadrature<dim> &q) override;
114 
115  void fill_fe_values(
116  const Quadrature<dim> &q,
117  FEInternalData &data,
118  FEValuesData<dim,spacedim> &fv_data) override;
119 
120  void compute_node_matrix() override;
121 
122  /// Pointers to base FE objects.
124 
125  /// Information about dofs.
127 
130 
131  unsigned int n_components_;
132 
133 };
134 
135 
136 
137 
138 
139 
140 #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
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:189
std::vector< unsigned int > vector_components_
Definition: fe_system.hh:129
void fill_fe_values(const Quadrature< dim > &q, FEInternalData &data, FEValuesData< dim, spacedim > &fv_data) override
Computes the shape function values and gradients on the actual cell and fills the FEValues structure...
Definition: fe_system.cc:253
unsigned int component_offset
Component index in the FESystem.
Definition: fe_system.hh:107
Class FEValues calculates finite element data on the actual cells such as shape function values...
std::vector< unsigned int > get_vector_components() const
Definition: fe_system.hh:63
FEType
void initialize()
Initialization of the internal structures from the vector of base FE.
Definition: fe_system.cc:67
Base class for quadrature rules on simplices in arbitrary dimensions.
Definition: fe_values.hh:32
unsigned int n_components() const override
Returns numer of components of the basis function.
Definition: fe_system.hh:80
UpdateFlags update_each(UpdateFlags flags) override
Decides which additional quantities have to be computed for each cell.
Definition: fe_system.cc:177
FESystem(std::shared_ptr< FiniteElement< dim, spacedim > > fe, FEType t)
Constructor. FESystem for vector or tensor created from a scalar FE.
Definition: fe_system.cc:28
Compound finite element on dim dimensional simplex.
Definition: fe_system.hh:36
unsigned int basis_index
Index of basis function in the base FE.
Definition: fe_system.hh:105
std::vector< std::shared_ptr< FiniteElement< dim, spacedim > > > fe_
Pointers to base FE objects.
Definition: fe_system.hh:123
arma::vec::fixed< dim > basis_grad(const unsigned int i, const arma::vec::fixed< dim > &p, const unsigned int comp) const override
The vector variant of basis_grad must be implemented but need not be used.
Definition: fe_system.cc:161
double basis_value(const unsigned int i, const arma::vec::fixed< dim > &p, const unsigned int comp) const override
The vector variant of basis_value must be implemented but need not be used.
Definition: fe_system.cc:146
Class FEValuesData holds the arrays of data computed by Mapping and FiniteElement.
Definition: fe_values.hh:48
std::vector< DofComponentData > fe_dof_indices_
Information about dofs.
Definition: fe_system.hh:126
DofComponentData(unsigned int fei, unsigned int bi, unsigned co)
Definition: fe_system.hh:96
std::vector< unsigned int > scalar_components_
Definition: fe_system.hh:128
unsigned int n_components_
Definition: fe_system.hh:131
Structure for storing the precomputed finite element data.
Abstract class for description of finite elements.
Abstract class for the description of a general finite element on a reference simplex in dim dimensio...
Definition: dofhandler.hh:30
unsigned int fe_index
Index of base FE class in the vector fe_.
Definition: fe_system.hh:100
std::vector< unsigned int > get_scalar_components() const
Definition: fe_system.hh:60