ASPECT
compositing.h
Go to the documentation of this file.
1 // ------------------------------------------------------
2 //
3 // SPDX-License-Identifier: GPL-2.0-or-later
4 //
5 // SPDX-FileCopyrightText: Copyright (C) 2011-2026 by the ASPECT authors.
6 //
7 // This file is part of ASPECT.
8 //
9 // Detailed license information governing the source code and
10 // contributions can be found in the folder LICENSES and in
11 // LICENSE and CONTRIBUTING.md at the top level directory.
12 //
13 // ------------------------------------------------------
14 
15 #ifndef _aspect_material_model_compositing_h
16 #define _aspect_material_model_compositing_h
17 
21 
22 #include <map>
23 #include <vector>
24 
25 
26 namespace aspect
27 {
28  namespace MaterialModel
29  {
30  namespace Property
31  {
36  {
46  };
47  }
48 
56  template <int dim>
58  {
59  public:
63  void
64  initialize () override;
65 
69  void
70  evaluate (const typename Interface<dim>::MaterialModelInputs &in,
71  typename Interface<dim>::MaterialModelOutputs &out) const override;
72 
77  void
78  create_additional_named_outputs (typename Interface<dim>::MaterialModelOutputs &outputs) const override;
79 
83  static void
85 
89  void
90  parse_parameters (ParameterHandler &prm) override;
91 
97  bool is_compressible () const override;
98 
102  const Interface<dim> &
103  get_model_for_property(const Property::MaterialProperty property) const;
104 
105 
106  private:
115  void
116  copy_required_properties(const unsigned int model_index,
117  const typename Interface<dim>::MaterialModelOutputs &base_output,
118  typename Interface<dim>::MaterialModelOutputs &out) const;
119 
124  std::map<Property::MaterialProperty, unsigned int> model_property_map;
125 
130  std::vector<std::string> model_names;
131  std::vector<std::unique_ptr<Interface<dim>>> models;
132  };
133 
134 
138  template <typename TestType, int dim>
139  inline
140  bool
142  const Property::MaterialProperty property)
143  {
144  // Direct match
145  if (Plugins::plugin_type_matches<TestType>(plugin))
146  return true;
147 
148  // Search inside compositing material model
149  if (const auto *compositing =
150  dynamic_cast<const MaterialModel::Compositing<dim> *>(&plugin))
151  {
152  const auto &submodel = compositing->get_model_for_property(property);
153  if (Plugins::plugin_type_matches<TestType>(submodel))
154  return true;
155  }
156 
157  // Search inside a reactive fluid transport wrapper, which holds a single
158  // base model that provides all solid properties (the property argument
159  // is irrelevant here).
160  if (const auto *reactive_fluid =
161  dynamic_cast<const MaterialModel::ReactiveFluidTransport<dim> *>(&plugin))
162  {
163  if (Plugins::plugin_type_matches<TestType>(reactive_fluid->get_base_model()))
164  return true;
165  }
166 
167  return false;
168  }
169 
170 
174  template <typename TestType, int dim>
175  inline
176  const TestType &
178  const Property::MaterialProperty property)
179  {
180  // Direct match
181  if (Plugins::plugin_type_matches<TestType>(plugin))
182  return Plugins::get_plugin_as_type<TestType>(plugin);
183 
184  // Search inside compositing material model
185  if (const auto *compositing =
186  dynamic_cast<const MaterialModel::Compositing<dim> *>(&plugin))
187  {
188  const auto &submodel = compositing->get_model_for_property(property);
189  return Plugins::get_plugin_as_type<TestType>(submodel);
190  }
191 
192  // Search inside a reactive fluid transport wrapper (single base model).
193  if (const auto *reactive_fluid =
194  dynamic_cast<const MaterialModel::ReactiveFluidTransport<dim> *>(&plugin))
195  return Plugins::get_plugin_as_type<TestType>(reactive_fluid->get_base_model());
196 
197  AssertThrow(false,
198  ExcMessage("Could not find requested plugin type."));
199 
200  return *static_cast<const TestType *>(nullptr);
201  }
202 
203  }
204 }
205 
206 #endif
const TestType & get_material_model_matches_or_uses(const MaterialModel::Interface< dim > &plugin, const Property::MaterialProperty property)
Definition: compositing.h:177
bool material_model_matches_or_uses(const MaterialModel::Interface< dim > &plugin, const Property::MaterialProperty property)
Definition: compositing.h:141
std::vector< std::string > model_names
Definition: compositing.h:130
#define AssertThrow(cond, exc)
std::map< Property::MaterialProperty, unsigned int > model_property_map
Definition: compositing.h:124
void declare_parameters(ParameterHandler &prm)
std::vector< std::unique_ptr< Interface< dim > > > models
Definition: compositing.h:131
static ::ExceptionBase & ExcMessage(std::string arg1)