ASPECT
fe_variable_collection.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2016 - 2024 by the authors of the ASPECT code.
3 
4  This file is part of ASPECT.
5 
6  ASPECT is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2, or (at your option)
9  any later version.
10 
11  ASPECT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with ASPECT; see the file LICENSE. If not see
18  <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef _aspect_fe_variable_system_h
22 #define _aspect_fe_variable_system_h
23 
24 #include <aspect/global.h>
27 #include <deal.II/fe/fe.h>
28 
29 namespace aspect
30 {
46  template <int dim>
48  {
66  VariableDeclaration(const std::string &name,
67  const std::shared_ptr<FiniteElement<dim>> &fe,
68  const unsigned int multiplicity,
69  const unsigned int n_blocks);
70 
75 
79  unsigned int n_components() const;
80 
84  std::string name;
85 
89  std::shared_ptr<FiniteElement<dim>> fe;
90 
94  unsigned int multiplicity;
95 
100  unsigned int n_blocks;
101  };
102 
108  template <int dim>
109  struct FEVariable: public VariableDeclaration<dim>
110  {
116  const unsigned int component_index,
117  const unsigned int block_index,
118  const unsigned int base_index);
119 
124  unsigned int first_component_index;
125 
130  unsigned int block_index;
136  unsigned int base_index;
137 
142 
147 
152 
153  private:
158 
163  };
164 
165 
173  template <int dim>
175  {
176  public:
181 
186  FEVariableCollection(const std::vector<VariableDeclaration<dim>> &variable_definitions);
187 
191  void initialize(const std::vector<VariableDeclaration<dim>> &variable_definitions);
192 
199  const FEVariable<dim> &variable(const std::string &name) const;
200 
204  std::vector<const FEVariable<dim>*> variables_with_name(const std::string &name) const;
205 
210  bool variable_exists(const std::string &name) const;
211 
215  const std::vector<FEVariable<dim>> &get_variables() const;
216 
220  unsigned int n_components() const;
221 
225  unsigned int n_blocks() const;
226 
231  const std::vector<const FiniteElement<dim> *> &get_fes() const;
232 
237  const std::vector<unsigned int> &get_multiplicities() const;
238 
243  const std::vector<unsigned int> &get_components_to_blocks() const;
244 
245  protected:
249  std::vector<FEVariable<dim>> variables;
250 
254  unsigned int n_components_;
255 
259  unsigned int n_blocks_;
260 
270  std::vector<const FiniteElement<dim> *> fes;
271 
276  std::vector<unsigned int> multiplicities;
277 
281  std::vector<unsigned int> components_to_blocks;
282  };
283 
284 } // namespace aspect
285 
286 #endif
const FEVariable< dim > & variable(const std::string &name) const
unsigned int n_blocks() const
void initialize(const std::vector< VariableDeclaration< dim >> &variable_definitions)
std::vector< unsigned int > multiplicities
std::vector< const FiniteElement< dim > * > fes
std::vector< FEVariable< dim > > variables
const std::vector< FEVariable< dim > > & get_variables() const
const std::vector< const FiniteElement< dim > * > & get_fes() const
const std::vector< unsigned int > & get_components_to_blocks() const
unsigned int n_components() const
bool variable_exists(const std::string &name) const
std::vector< unsigned int > components_to_blocks
const std::vector< unsigned int > & get_multiplicities() const
std::vector< const FEVariable< dim > * > variables_with_name(const std::string &name) const
FEVariableCollection(const std::vector< VariableDeclaration< dim >> &variable_definitions)
unsigned int first_component_index
FEValuesExtractors::Vector vector_extractor
FEValuesExtractors::Scalar scalar_extractor
const FEValuesExtractors::Vector & extractor_vector() const
FEVariable(const VariableDeclaration< dim > &fe_variable, const unsigned int component_index, const unsigned int block_index, const unsigned int base_index)
const FEValuesExtractors::Scalar & extractor_scalar() const
VariableDeclaration(const std::string &name, const std::shared_ptr< FiniteElement< dim >> &fe, const unsigned int multiplicity, const unsigned int n_blocks)
unsigned int n_components() const
std::shared_ptr< FiniteElement< dim > > fe