New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compositing MaterialModel #1602
Changes from 1 commit
b6d822d
ea6db00
6c50b94
26cbbf1
31d7bca
dc466bf
0865a13
f49e1e1
7fce6ce
407daeb
16829aa
f5d4b3e
4dfd451
fcc426c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,12 +18,7 @@ | |
<http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <deal.II/base/std_cxx11/array.h> | ||
#include <aspect/material_model/compositing.h> | ||
#include <utility> | ||
#include <limits> | ||
|
||
using namespace dealii; | ||
|
||
namespace aspect | ||
{ | ||
|
@@ -34,15 +29,12 @@ namespace aspect | |
Property::MaterialProperty | ||
Compositing<dim>::parse_property_name(const std::string &s) | ||
{ | ||
if (Property::property_map.count(s) == 0) | ||
AssertThrow (false, | ||
ExcMessage ("The value <" + s + "> for a material " | ||
"property is not one of the valid values.")); | ||
return Property::viscosity; | ||
AssertThrow (Property::property_map.count(s) == 0, | ||
ExcMessage ("The value <" + s + "> for a material " | ||
"property is not one of the valid values.")); | ||
return Property::property_map.at(s); | ||
} | ||
|
||
//Copy the requested data for one model | ||
template <int dim> | ||
void | ||
Compositing<dim>::copy_required_properties(const unsigned int model_index, | ||
|
@@ -95,8 +87,10 @@ namespace aspect | |
std::map<std::string, Property::MaterialProperty>::const_iterator prop_it = Property::property_map.begin(); | ||
for (; prop_it != Property::property_map.end(); ++prop_it) | ||
{ | ||
prm.declare_entry(prop_it->first, "compositing", | ||
Patterns::Selection(MaterialModel::get_valid_model_names_pattern<dim>()), | ||
prm.declare_entry(prop_it->first, "unspecified", | ||
Patterns::Selection( | ||
MaterialModel::get_valid_model_names_pattern<dim>()+"|unspecified" | ||
), | ||
"Material model to use for " + prop_it->first +". Valid values for this " | ||
"parameter are the names of models that are also valid for the " | ||
"``Material models/Model name'' parameter. See the documentation for " | ||
|
@@ -129,44 +123,37 @@ namespace aspect | |
AssertThrow(model_name != "compositing", | ||
ExcMessage("You may not use ``compositing'' as the base model for the " | ||
+ prop_it->first +" property of a compositing material model.")); | ||
unsigned int model_ind; | ||
for (model_ind=0; model_ind < model_names.size(); ++model_ind) | ||
std::vector<std::string>::iterator model_position = std::find(model_names.begin(), model_names.end(), model_name); | ||
if ( model_position == model_names.end() ) | ||
{ | ||
if (model_names[model_ind] == model_name) | ||
break; | ||
model_property_map[prop] = model_names.size(); | ||
model_names.push_back(model_name); | ||
} | ||
if (model_ind == model_names.size()) | ||
model_names.push_back(model_name); | ||
|
||
model_property_map[prop] = model_ind; | ||
else | ||
model_property_map[prop] = std::distance(model_names.begin(), model_position); | ||
} | ||
models.resize(model_names.size()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be great if you could write a comment about what the code above does. |
||
|
||
// create the model and initialize their SimulatorAccess base | ||
// class; it will get a chance to read its parameters below after we | ||
// leave the current section | ||
for (unsigned int i=0; i<model_names.size(); ++i) | ||
{ | ||
models.at(i).reset(create_material_model<dim>(model_names[i])); | ||
if (SimulatorAccess<dim> *sim = dynamic_cast<SimulatorAccess<dim>*>(models.at(i).get())) | ||
sim->initialize_simulator (this->get_simulator()); | ||
} | ||
} | ||
prm.leave_subsection(); | ||
} | ||
prm.leave_subsection(); | ||
|
||
/* After parsing the parameters for averaging, it is essential to parse | ||
parameters related to the base model. */ | ||
// create the models and initialize their SimulatorAccess base | ||
// After parsing the parameters for averaging, it is essential to parse | ||
// parameters related to the base models | ||
for (unsigned int i=0; i<model_names.size(); ++i) | ||
{ | ||
models.at(i).reset(create_material_model<dim>(model_names[i])); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One more nitpick (I just mention it because I have the above comment anyway): Now you resize
|
||
if (SimulatorAccess<dim> *sim = dynamic_cast<SimulatorAccess<dim>*>(models.at(i).get())) | ||
sim->initialize_simulator (this->get_simulator()); | ||
models[i]->parse_parameters(prm); | ||
// All models will need to compute all quantities, so do so | ||
this -> model_dependence.viscosity |= models[i]->get_model_dependence().viscosity; | ||
this -> model_dependence.density |= models[i]->get_model_dependence().density; | ||
this -> model_dependence.compressibility |= models[i]->get_model_dependence().compressibility; | ||
this -> model_dependence.specific_heat |= models[i]->get_model_dependence().specific_heat; | ||
this -> model_dependence.thermal_conductivity |= models[i]->get_model_dependence().thermal_conductivity; | ||
this->model_dependence.viscosity |= models[i]->get_model_dependence().viscosity; | ||
this->model_dependence.density |= models[i]->get_model_dependence().density; | ||
this->model_dependence.compressibility |= models[i]->get_model_dependence().compressibility; | ||
this->model_dependence.specific_heat |= models[i]->get_model_dependence().specific_heat; | ||
this->model_dependence.thermal_conductivity |= models[i]->get_model_dependence().thermal_conductivity; | ||
} | ||
} | ||
|
||
|
@@ -175,7 +162,7 @@ namespace aspect | |
Compositing<dim>:: | ||
is_compressible () const | ||
{ | ||
unsigned int ind = model_property_map.at(Property::compressibility); | ||
const unsigned int ind = model_property_map.at(Property::compressibility); | ||
return models[ind]->is_compressible(); | ||
} | ||
|
||
|
@@ -184,7 +171,7 @@ namespace aspect | |
Compositing<dim>:: | ||
reference_viscosity() const | ||
{ | ||
unsigned int ind = model_property_map.at(Property::viscosity); | ||
const unsigned int ind = model_property_map.at(Property::viscosity); | ||
return models[ind]->reference_viscosity(); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it not be
Property::property_map.count(s) > 0
?