ASPECT
introspection.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2023 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 
22 #ifndef _aspect_introspection_h
23 #define _aspect_introspection_h
24 
25 #include <deal.II/base/index_set.h>
26 #include <deal.II/base/quadrature.h>
27 #include <deal.II/fe/component_mask.h>
28 #include <deal.II/fe/fe_values_extractors.h>
29 #include <deal.II/fe/fe.h>
30 
32 #include <aspect/parameters.h>
33 
34 #include <map>
35 
36 namespace aspect
37 {
38  using namespace dealii;
39 
44  template <int dim>
45  std::vector<VariableDeclaration<dim>>
46  construct_default_variables (const Parameters<dim> &parameters);
47 
48 
55  {
59  enum Type
60  {
61  chemical_composition = 0,
62  stress = 1,
63  strain = 2,
64  grain_size = 3,
65  porosity = 4,
66  density = 5,
67  entropy = 6,
68  generic = 7,
69  unspecified = 8
70  } type;
71 
75  constexpr static unsigned int n_types = 9;
76 
81  static
82  Type
83  parse_type(const std::string &input)
84  {
85  if (input == "chemical composition")
87  else if (input == "stress")
89  else if (input == "strain")
91  else if (input == "grain size")
93  else if (input == "porosity")
95  else if (input == "density")
97  else if (input == "entropy")
99  else if (input == "generic")
101  else if (input == "unspecified")
103  else
104  AssertThrow(false, ExcNotImplemented());
105 
107  }
108  };
109 
127  template <int dim>
129  {
130  public:
134  Introspection (const std::vector<VariableDeclaration<dim>> &variables,
135  const Parameters<dim> &parameters);
136 
140  ~Introspection ();
141 
142 
143 
156  const unsigned int n_components;
157 
161  const unsigned int n_compositional_fields;
162 
168 
174 
180  {
181  unsigned int velocities[dim];
182  unsigned int pressure;
183  unsigned int temperature;
184  std::vector<unsigned int> compositional_fields;
185  };
191 
197  const unsigned int n_blocks;
198 
204  {
205  unsigned int velocities;
206  unsigned int pressure;
207  unsigned int temperature;
208  std::vector<unsigned int> compositional_fields;
209 
217  std::vector<unsigned int> compositional_field_sparsity_pattern;
218  };
219 
225 
230  struct Extractors
231  {
232  Extractors (const ComponentIndices &component_indices);
233 
235  const FEValuesExtractors::Scalar pressure;
236  const FEValuesExtractors::Scalar temperature;
237  const std::vector<FEValuesExtractors::Scalar> compositional_fields;
238  };
239 
245 
256  {
257  unsigned int velocities;
258  unsigned int pressure;
259  unsigned int temperature;
260  std::vector<unsigned int> compositional_fields;
261  };
262 
268 
277  {
278  unsigned int velocities;
279  unsigned int temperature;
280  unsigned int compositional_fields;
281  };
282 
288 
308  struct Quadratures
309  {
310  Quadrature<dim> velocities;
311  Quadrature<dim> pressure;
312  Quadrature<dim> temperature;
313  Quadrature<dim> compositional_fields;
314  Quadrature<dim> system;
315  };
316 
322 
332  {
333  Quadrature<dim-1> velocities;
334  Quadrature<dim-1> pressure;
335  Quadrature<dim-1> temperature;
336  Quadrature<dim-1> compositional_fields;
337  Quadrature<dim-1> system;
338  };
339 
345 
352  {
354 
355  ComponentMask velocities;
356  ComponentMask pressure;
357  ComponentMask temperature;
358  std::vector<ComponentMask> compositional_fields;
359  };
360 
367 
381  std::vector<types::global_dof_index> system_dofs_per_block;
382 
388  struct IndexSets
389  {
397 
405  std::vector<IndexSet> system_partitioning;
406 
415  std::vector<IndexSet> system_relevant_partitioning;
416 
422  std::vector<IndexSet> stokes_partitioning;
423 
431 
437 
443  };
444 
451 
457 
464 
481  const std::vector<unsigned int> &
482  get_composition_base_element_indices() const;
483 
491  const std::vector<unsigned int> &
492  get_compositional_field_indices_with_base_element(const unsigned int base_element_index) const;
493 
502  unsigned int
503  compositional_index_for_name (const std::string &name) const;
504 
511  std::string
512  name_for_compositional_index (const unsigned int index) const;
513 
517  const std::vector<std::string> &
518  get_composition_names () const;
519 
524  const std::vector<CompositionalFieldDescription> &
525  get_composition_descriptions () const;
526 
534  const std::vector<std::string> &
535  chemical_composition_field_names () const;
536 
544  const std::vector<unsigned int> &
545  chemical_composition_field_indices () const;
546 
554  unsigned int
555  n_chemical_composition_fields () const;
556 
565  bool
566  composition_type_exists (const CompositionalFieldDescription::Type &type) const;
567 
577  unsigned int
578  find_composition_type (const CompositionalFieldDescription::Type &type) const;
579 
588  bool
589  compositional_name_exists (const std::string &name) const;
590 
595  const std::vector<unsigned int> &
596  get_indices_for_fields_of_type (const CompositionalFieldDescription::Type &type) const;
597 
602  const std::vector<std::string> &
603  get_names_for_fields_of_type (const CompositionalFieldDescription::Type &type) const;
604 
609  unsigned int
610  get_number_of_fields_of_type (const CompositionalFieldDescription::Type &type) const;
611 
619  bool
620  is_stokes_component (const unsigned int component_index) const;
621 
629  bool
630  is_composition_component (const unsigned int component_index) const;
631 
632  private:
637  std::vector<std::string> composition_names;
638 
644  std::vector<CompositionalFieldDescription> composition_descriptions;
645 
651  std::vector<std::vector<std::string>> composition_names_for_type;
652 
658  std::vector<std::vector<unsigned int>> composition_indices_for_type;
659 
664  std::vector<unsigned int> composition_base_element_indices;
665 
671  std::map<unsigned int, std::vector<unsigned int>> compositional_field_indices_with_base_element;
672  };
673 }
674 
675 
676 #endif
std::vector< IndexSet > system_relevant_partitioning
std::map< unsigned int, std::vector< unsigned int > > compositional_field_indices_with_base_element
const FEValuesExtractors::Vector velocities
std::vector< VariableDeclaration< dim > > construct_default_variables(const Parameters< dim > &parameters)
Parameters< dim >::AdvectionFieldMethod::Kind temperature_method
std::vector< unsigned int > compositional_fields
std::vector< unsigned int > compositional_fields
const unsigned int n_blocks
std::vector< std::vector< unsigned int > > composition_indices_for_type
const bool use_discontinuous_composition_discretization
::TrilinosWrappers::MPI::Vector Vector
Definition: global.h:233
const BaseElements base_elements
const PolynomialDegree polynomial_degree
const FEValuesExtractors::Scalar temperature
const unsigned int n_components
const Extractors extractors
std::vector< IndexSet > system_partitioning
std::vector< typename Parameters< dim >::AdvectionFieldMethod::Kind > compositional_field_methods
std::vector< CompositionalFieldDescription > composition_descriptions
Quadrature< dim > compositional_fields
std::vector< std::vector< std::string > > composition_names_for_type
const unsigned int n_compositional_fields
const ComponentIndices component_indices
Definition: compat.h:59
std::vector< unsigned int > compositional_fields
const bool use_discontinuous_temperature_discretization
const FaceQuadratures face_quadratures
const Quadratures quadratures
const BlockIndices block_indices
std::vector< unsigned int > compositional_field_sparsity_pattern
const std::vector< FEValuesExtractors::Scalar > compositional_fields
const FEValuesExtractors::Scalar pressure
const ComponentMasks component_masks
std::vector< types::global_dof_index > system_dofs_per_block
Definition: compat.h:42
std::vector< unsigned int > composition_base_element_indices
std::vector< std::string > composition_names
std::vector< ComponentMask > compositional_fields
std::vector< IndexSet > stokes_partitioning
static Type parse_type(const std::string &input)
Definition: introspection.h:83