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 
26 
27 #include <map>
28 #include <vector>
29 
30 
31 namespace aspect
32 {
33  namespace MaterialModel
34  {
35  namespace Property
36  {
41  {
51  };
52  }
53 
61  template <int dim>
63  {
64  public:
68  void
69  initialize () override;
70 
74  void
75  evaluate (const typename Interface<dim>::MaterialModelInputs &in,
76  typename Interface<dim>::MaterialModelOutputs &out) const override;
77 
82  void
83  create_additional_named_outputs (typename Interface<dim>::MaterialModelOutputs &outputs) const override;
84 
88  static void
89  declare_parameters (ParameterHandler &prm);
90 
94  void
95  parse_parameters (ParameterHandler &prm) override;
96 
102  bool is_compressible () const override;
103 
107  const Interface<dim> &
108  get_model_for_property(const Property::MaterialProperty property) const;
109 
110 
111  private:
120  void
121  copy_required_properties(const unsigned int model_index,
122  const typename Interface<dim>::MaterialModelOutputs &base_output,
123  typename Interface<dim>::MaterialModelOutputs &out) const;
124 
129  std::map<Property::MaterialProperty, unsigned int> model_property_map;
130 
135  std::vector<std::string> model_names;
136  std::vector<std::unique_ptr<Interface<dim>>> models;
137  };
138 
139 
143  template <typename TestType, int dim>
144  inline
145  bool
147  const Property::MaterialProperty property)
148  {
149  // Direct match
150  if (Plugins::plugin_type_matches<TestType>(plugin))
151  return true;
152 
153  // Search inside compositing material model
154  if (const auto *compositing =
155  dynamic_cast<const MaterialModel::Compositing<dim> *>(&plugin))
156  {
157  const auto &submodel = compositing->get_model_for_property(property);
158  if (Plugins::plugin_type_matches<TestType>(submodel))
159  return true;
160  }
161 
162  return false;
163  }
164 
165 
169  template <typename TestType, int dim>
170  inline
171  const TestType &
173  const Property::MaterialProperty property)
174  {
175  // Direct match
176  if (Plugins::plugin_type_matches<TestType>(plugin))
177  return Plugins::get_plugin_as_type<TestType>(plugin);
178 
179  // Search inside compositing material model
180  if (const auto *compositing =
181  dynamic_cast<const MaterialModel::Compositing<dim> *>(&plugin))
182  {
183  const auto &submodel = compositing->get_model_for_property(property);
184  return Plugins::get_plugin_as_type<TestType>(submodel);
185  }
186 
187  AssertThrow(false,
188  ExcMessage("Could not find requested plugin type."));
189 
190  return *static_cast<const TestType *>(nullptr);
191  }
192 
193  }
194 }
195 
196 #endif
const TestType & get_material_model_matches_or_uses(const MaterialModel::Interface< dim > &plugin, const Property::MaterialProperty property)
Definition: compositing.h:172
bool material_model_matches_or_uses(const MaterialModel::Interface< dim > &plugin, const Property::MaterialProperty property)
Definition: compositing.h:146
std::vector< std::string > model_names
Definition: compositing.h:135
std::map< Property::MaterialProperty, unsigned int > model_property_map
Definition: compositing.h:129
void declare_parameters(ParameterHandler &prm)
std::vector< std::unique_ptr< Interface< dim > > > models
Definition: compositing.h:136