ASPECT
compositing.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2022 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_material_model_compositing_h
22 #define _aspect_material_model_compositing_h
23 
27 
28 #include <map>
29 #include <vector>
30 
31 
32 namespace aspect
33 {
34  namespace MaterialModel
35  {
36  namespace Property
37  {
42  {
52  };
53  }
54 
62  template <int dim>
64  {
65  public:
69  void
70  initialize () override;
71 
75  void
76  evaluate (const typename Interface<dim>::MaterialModelInputs &in,
77  typename Interface<dim>::MaterialModelOutputs &out) const override;
78 
83  void
84  create_additional_named_outputs (typename Interface<dim>::MaterialModelOutputs &outputs) const override;
85 
89  static void
91 
95  void
96  parse_parameters (ParameterHandler &prm) override;
97 
103  bool is_compressible () const override;
104 
108  const Interface<dim> &
109  get_model_for_property(const Property::MaterialProperty property) const;
110 
111 
112  private:
121  void
122  copy_required_properties(const unsigned int model_index,
123  const typename Interface<dim>::MaterialModelOutputs &base_output,
124  typename Interface<dim>::MaterialModelOutputs &out) const;
125 
130  std::map<Property::MaterialProperty, unsigned int> model_property_map;
131 
136  std::vector<std::string> model_names;
137  std::vector<std::unique_ptr<Interface<dim>>> models;
138  };
139 
140 
144  template <typename TestType, int dim>
145  inline
146  bool
148  const Property::MaterialProperty property)
149  {
150  // Direct match
151  if (Plugins::plugin_type_matches<TestType>(plugin))
152  return true;
153 
154  // Search inside compositing material model
155  if (const auto *compositing =
156  dynamic_cast<const MaterialModel::Compositing<dim> *>(&plugin))
157  {
158  const auto &submodel = compositing->get_model_for_property(property);
159  if (Plugins::plugin_type_matches<TestType>(submodel))
160  return true;
161  }
162 
163  // Search inside a reactive fluid transport wrapper, which holds a single
164  // base model that provides all solid properties (the property argument
165  // is irrelevant here).
166  if (const auto *reactive_fluid =
167  dynamic_cast<const MaterialModel::ReactiveFluidTransport<dim> *>(&plugin))
168  {
169  if (Plugins::plugin_type_matches<TestType>(reactive_fluid->get_base_model()))
170  return true;
171  }
172 
173  return false;
174  }
175 
176 
180  template <typename TestType, int dim>
181  inline
182  const TestType &
184  const Property::MaterialProperty property)
185  {
186  // Direct match
187  if (Plugins::plugin_type_matches<TestType>(plugin))
188  return Plugins::get_plugin_as_type<TestType>(plugin);
189 
190  // Search inside compositing material model
191  if (const auto *compositing =
192  dynamic_cast<const MaterialModel::Compositing<dim> *>(&plugin))
193  {
194  const auto &submodel = compositing->get_model_for_property(property);
195  return Plugins::get_plugin_as_type<TestType>(submodel);
196  }
197 
198  // Search inside a reactive fluid transport wrapper (single base model).
199  if (const auto *reactive_fluid =
200  dynamic_cast<const MaterialModel::ReactiveFluidTransport<dim> *>(&plugin))
201  return Plugins::get_plugin_as_type<TestType>(reactive_fluid->get_base_model());
202 
203  AssertThrow(false,
204  ExcMessage("Could not find requested plugin type."));
205 
206  return *static_cast<const TestType *>(nullptr);
207  }
208 
209  }
210 }
211 
212 #endif
const TestType & get_material_model_matches_or_uses(const MaterialModel::Interface< dim > &plugin, const Property::MaterialProperty property)
Definition: compositing.h:183
bool material_model_matches_or_uses(const MaterialModel::Interface< dim > &plugin, const Property::MaterialProperty property)
Definition: compositing.h:147
std::vector< std::string > model_names
Definition: compositing.h:136
#define AssertThrow(cond, exc)
std::map< Property::MaterialProperty, unsigned int > model_property_map
Definition: compositing.h:130
void declare_parameters(ParameterHandler &prm)
std::vector< std::unique_ptr< Interface< dim > > > models
Definition: compositing.h:137
static ::ExceptionBase & ExcMessage(std::string arg1)