ASPECT
fe_variable_collection.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2016 - 2021 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>
25 #include <deal.II/fe/component_mask.h>
26 #include <deal.II/fe/fe_values_extractors.h>
27 #include <deal.II/fe/fe.h>
28 
29 namespace aspect
30 {
31  using namespace dealii;
32 
48  template <int dim>
50  {
68  VariableDeclaration(const std::string &name,
69  const std::shared_ptr<FiniteElement<dim>> &fe,
70  const unsigned int multiplicity,
71  const unsigned int n_blocks);
72 
77 
81  unsigned int n_components() const;
82 
86  std::string name;
87 
91  std::shared_ptr<FiniteElement<dim>> fe;
92 
96  unsigned int multiplicity;
97 
102  unsigned int n_blocks;
103  };
104 
110  template <int dim>
111  struct FEVariable: public VariableDeclaration<dim>
112  {
117  FEVariable(const VariableDeclaration<dim> &fe_variable,
118  const unsigned int component_index,
119  const unsigned int block_index,
120  const unsigned int base_index);
121 
126  unsigned int first_component_index;
127 
132  unsigned int block_index;
138  unsigned int base_index;
139 
143  ComponentMask component_mask;
144 
148  const FEValuesExtractors::Scalar &extractor_scalar() const;
149 
153  const FEValuesExtractors::Vector &extractor_vector() const;
154 
155  private:
159  FEValuesExtractors::Scalar scalar_extractor;
160 
165  };
166 
167 
175  template <int dim>
177  {
178  public:
183 
188  FEVariableCollection(const std::vector<VariableDeclaration<dim>> &variable_definitions);
189 
193  void initialize(const std::vector<VariableDeclaration<dim>> &variable_definitions);
194 
199  const FEVariable<dim> &variable(const std::string &name) const;
200 
205  bool variable_exists(const std::string &name) const;
206 
210  const std::vector<FEVariable<dim>> &get_variables() const;
211 
215  unsigned int n_components() const;
216 
220  unsigned int n_blocks() const;
221 
226  const std::vector<const FiniteElement<dim> *> &get_fes() const;
227 
232  const std::vector<unsigned int> &get_multiplicities() const;
233 
238  const std::vector<unsigned int> &get_components_to_blocks() const;
239 
240  protected:
244  std::vector<FEVariable<dim>> variables;
245 
249  unsigned int n_components_;
250 
254  unsigned int n_blocks_;
255 
265  std::vector<const FiniteElement<dim> *> fes;
266 
271  std::vector<unsigned int> multiplicities;
272 
276  std::vector<unsigned int> components_to_blocks;
277  };
278 
279 } // namespace aspect
280 
281 #endif
FEValuesExtractors::Scalar scalar_extractor
std::vector< unsigned int > multiplicities
::TrilinosWrappers::MPI::Vector Vector
Definition: global.h:233
std::vector< FEVariable< dim > > variables
std::vector< unsigned int > components_to_blocks
std::vector< const FiniteElement< dim > * > fes
std::shared_ptr< FiniteElement< dim > > fe
unsigned int first_component_index
FEValuesExtractors::Vector vector_extractor
Definition: compat.h:42