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>
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 
201  const FEVariable<dim> &variable(const std::string &name) const;
202 
206  std::vector<const FEVariable<dim>*> variables_with_name(const std::string &name) const;
207 
212  bool variable_exists(const std::string &name) const;
213 
217  const std::vector<FEVariable<dim>> &get_variables() const;
218 
222  unsigned int n_components() const;
223 
227  unsigned int n_blocks() const;
228 
233  const std::vector<const FiniteElement<dim> *> &get_fes() const;
234 
239  const std::vector<unsigned int> &get_multiplicities() const;
240 
245  const std::vector<unsigned int> &get_components_to_blocks() const;
246 
247  protected:
251  std::vector<FEVariable<dim>> variables;
252 
256  unsigned int n_components_;
257 
261  unsigned int n_blocks_;
262 
272  std::vector<const FiniteElement<dim> *> fes;
273 
278  std::vector<unsigned int> multiplicities;
279 
283  std::vector<unsigned int> components_to_blocks;
284  };
285 
286 } // namespace aspect
287 
288 #endif
FEValuesExtractors::Scalar scalar_extractor
std::vector< unsigned int > multiplicities
::TrilinosWrappers::MPI::Vector Vector
Definition: global.h:256
std::vector< FEVariable< dim > > variables
std::vector< unsigned int > components_to_blocks
std::vector< const FiniteElement< dim > * > fes
std::shared_ptr< FiniteElement< dim > > fe
Definition: compat.h:59
unsigned int first_component_index
FEValuesExtractors::Vector vector_extractor
Definition: compat.h:42