ASPECT
introspection.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 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 
22 #ifndef _aspect_introspection_h
23 #define _aspect_introspection_h
24 
25 #include <deal.II/base/index_set.h>
29 #include <deal.II/fe/fe.h>
30 
32 #include <aspect/parameters.h>
33 
34 #include <map>
35 
36 namespace aspect
37 {
42  template <int dim>
43  std::vector<VariableDeclaration<dim>>
44  construct_default_variables (const Parameters<dim> &parameters);
45 
46 
53  {
57  enum Type
58  {
60  stress = 1,
61  strain = 2,
63  porosity = 4,
64  density = 5,
65  entropy = 6,
67  generic = 8,
69  } type;
70 
74  constexpr static unsigned int n_types = 9;
75 
80  static
81  Type
82  parse_type(const std::string &input)
83  {
84  if (input == "chemical composition")
86  else if (input == "stress")
88  else if (input == "strain")
90  else if (input == "grain size")
92  else if (input == "porosity")
94  else if (input == "density")
96  else if (input == "entropy")
98  else if (input == "reaction progress")
100  else if (input == "generic")
102  else if (input == "unspecified")
104  else
105  AssertThrow(false, ExcMessage("Unknown compositional field type."));
106 
108  }
109 
114  static
115  std::string
117  {
118  switch (type)
119  {
121  return "chemical composition";
122  case stress:
123  return "stress";
124  case strain:
125  return "strain";
126  case grain_size:
127  return "grain size";
128  case porosity:
129  return "porosity";
130  case density:
131  return "density";
132  case entropy:
133  return "entropy";
134  case generic:
135  return "generic";
136  case unspecified:
137  return "unspecified";
138  default:
139  AssertThrow(false, ExcInternalError());
140  }
141 
142  return "";
143  }
144  };
145 
163  template <int dim>
165  {
166  public:
170  Introspection (const std::vector<VariableDeclaration<dim>> &variables,
171  const Parameters<dim> &parameters);
172 
173 
186  const unsigned int n_components;
187 
191  const unsigned int n_compositional_fields;
192 
198 
204 
210  {
211  std::array<unsigned int, dim> velocities;
212  unsigned int pressure;
213  unsigned int temperature;
214  std::vector<unsigned int> compositional_fields;
215  };
221 
227  const unsigned int n_blocks;
228 
234  {
235  unsigned int velocities;
236  unsigned int pressure;
237  unsigned int temperature;
238  std::vector<unsigned int> compositional_fields;
239 
247  std::vector<unsigned int> compositional_field_sparsity_pattern;
248  };
249 
255 
260  struct Extractors
261  {
262  Extractors (const ComponentIndices &component_indices);
263 
267  const std::vector<FEValuesExtractors::Scalar> compositional_fields;
268  };
269 
275 
286  {
287  unsigned int velocities;
288  unsigned int pressure;
289  unsigned int temperature;
290  std::vector<unsigned int> compositional_fields;
291  };
292 
298 
307  {
308  unsigned int max_degree;
309  unsigned int velocities;
310  unsigned int temperature;
311  std::vector<unsigned int> compositional_fields;
313  };
314 
320 
340  struct Quadratures
341  {
346  std::vector<Quadrature<dim>> compositional_fields;
348  };
349 
355 
365  {
371  };
372 
378 
385  {
387 
392 
397 
402 
409  std::vector<ComponentMask> compositional_fields;
410 
416  };
417 
424 
438  std::vector<types::global_dof_index> system_dofs_per_block;
439 
444  {
445  unsigned int local_dof_index;
446  unsigned int component_index;
447  };
448 
458  std::vector<StokesDoFInfo> stokes_dof_info;
459 
465  struct IndexSets
466  {
474 
482  std::vector<IndexSet> system_partitioning;
483 
492  std::vector<IndexSet> system_relevant_partitioning;
493 
499  std::vector<IndexSet> stokes_partitioning;
500 
508 
514 
520  };
521 
528 
534 
541 
558  const std::vector<unsigned int> &
559  get_composition_base_element_indices() const;
560 
568  const std::vector<unsigned int> &
569  get_compositional_field_indices_with_base_element(const unsigned int base_element_index) const;
570 
579  unsigned int
580  compositional_index_for_name (const std::string &name) const;
581 
588  std::string
589  name_for_compositional_index (const unsigned int index) const;
590 
594  const std::vector<std::string> &
595  get_composition_names () const;
596 
601  const std::vector<CompositionalFieldDescription> &
602  get_composition_descriptions () const;
603 
611  const std::vector<std::string> &
612  chemical_composition_field_names () const;
613 
621  const std::vector<unsigned int> &
622  chemical_composition_field_indices () const;
623 
631  unsigned int
632  n_chemical_composition_fields () const;
633 
642  bool
643  composition_type_exists (const CompositionalFieldDescription::Type &type) const;
644 
654  unsigned int
655  find_composition_type (const CompositionalFieldDescription::Type &type) const;
656 
665  bool
666  compositional_name_exists (const std::string &name) const;
667 
672  const std::vector<unsigned int> &
673  get_indices_for_fields_of_type (const CompositionalFieldDescription::Type &type) const;
674 
679  const std::vector<std::string> &
680  get_names_for_fields_of_type (const CompositionalFieldDescription::Type &type) const;
681 
686  unsigned int
687  get_number_of_fields_of_type (const CompositionalFieldDescription::Type &type) const;
688 
696  bool
697  is_stokes_component (const unsigned int component_index) const;
698 
708  void
709  initialize_stokes_dof_info (const FiniteElement<dim> &finite_element);
710 
718  bool
719  is_composition_component (const unsigned int component_index) const;
720 
721  private:
726  std::vector<std::string> composition_names;
727 
733  std::vector<CompositionalFieldDescription> composition_descriptions;
734 
740  std::vector<std::vector<std::string>> composition_names_for_type;
741 
747  std::vector<std::vector<unsigned int>> composition_indices_for_type;
748 
753  std::vector<unsigned int> composition_base_element_indices;
754 
760  std::map<unsigned int, std::vector<unsigned int>> compositional_field_indices_with_base_element;
761  };
762 }
763 
764 
765 #endif
std::vector< IndexSet > system_relevant_partitioning
const std::vector< bool > use_discontinuous_composition_discretization
std::map< unsigned int, std::vector< unsigned int > > compositional_field_indices_with_base_element
const FEValuesExtractors::Vector velocities
Quadrature< dim > compositional_field_max
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
std::vector< Quadrature< dim > > compositional_fields
#define AssertThrow(cond, exc)
const BaseElements base_elements
const PolynomialDegree polynomial_degree
const FEValuesExtractors::Scalar temperature
static ::ExceptionBase & ExcInternalError()
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
enum aspect::CompositionalFieldDescription::Type type
std::vector< std::vector< std::string > > composition_names_for_type
const unsigned int n_compositional_fields
const ComponentIndices component_indices
std::vector< unsigned int > compositional_fields
std::vector< unsigned int > compositional_fields
static ::ExceptionBase & ExcMessage(std::string arg1)
const bool use_discontinuous_temperature_discretization
std::array< unsigned int, dim > velocities
std::vector< StokesDoFInfo > stokes_dof_info
const FaceQuadratures face_quadratures
const Quadratures quadratures
const BlockIndices block_indices
std::vector< unsigned int > compositional_field_sparsity_pattern
static std::string type_to_string(const Type type)
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
static constexpr unsigned int n_types
Definition: introspection.h:74
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:82