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
Conversation
970d399
to
b6d822d
Compare
@jdannberg ? |
source/material_model/compositing.cc
Outdated
if (model_property_map.at(Property::entropy_derivative_temperature) == model_index) | ||
out.entropy_derivative_temperature = evaluated.entropy_derivative_temperature; | ||
if (model_property_map.at(Property::reaction_terms) == model_index) | ||
out.reaction_terms == evaluated.reaction_terms; |
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.
this looks incorrect.
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.
It would also be great if you could add at least one test for your new material model (one idea would be just copying an existing test and getting all properties from the original model, and then the test results should stay exactly the same). That would also show how the input parameters for the new models would look like.
And thanks for doing this!
source/material_model/compositing.cc
Outdated
ASPECT_REGISTER_MATERIAL_MODEL(Compositing, | ||
"compositing", | ||
"The ``compositing'' Material model selects material model properties from a " | ||
"given set of other material models." |
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.
It would be great if you could explain a bit more what this material model does and how exactly it achieves this (and what all of the input options are).
* Obtain the output properties from the component material models | ||
*/ | ||
void | ||
composite(const unsigned int model_index, |
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.
I feel this name does not describe very well what the function does. Maybe get_properties_from_base_models
?
And can you document the arguments of the function?
|
||
/** | ||
* Map specifying which components a material model is responsible for | ||
*/ |
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.
Maybe you can make this a bit more specific.
source/material_model/compositing.cc
Outdated
prm.declare_entry("Models", "", | ||
Patterns::Map(Patterns::Selection("viscosity|density|thermal expansion coefficient|specific heat|compressibility|entropy derivative pressure|entropy derivative temperature|reaction terms"), | ||
Patterns::Selection(MaterialModel::get_valid_model_names_pattern<dim>())), | ||
"The material property and material model associations used for this composite material model"); |
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.
In the Depth dependent model we call this parameter Base models
, so we should make that consistent. And can you also document how exactly the input format has to look like?
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.
This has been altered to be a list of properties (generated from a static const map listing names and the corresponding enum) which should be much more readable and robust.
source/material_model/compositing.cc
Outdated
= Utilities::split_string_list | ||
(prm.get("Models")); | ||
for (std::vector<std::string>::const_iterator p = x_models.begin(); | ||
p != x_models.end(); ++p) |
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.
In general, it would be great if the variable names could be more descriptive than x_models and p.
source/material_model/compositing.cc
Outdated
AssertThrow(split_parts[1] != "compositing", | ||
ExcMessage("You may not use ``compositing'' as the base model for " | ||
"a compositing material model.")); | ||
unsigned int model_ind; |
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.
Same here, just call it model index.
source/material_model/compositing.cc
Outdated
typename Interface<dim>::MaterialModelOutputs &out) const | ||
{ | ||
typename Interface<dim>::MaterialModelOutputs evaluated(out.viscosities.size(), | ||
this->introspection().n_compositional_fields); |
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.
Maybe call those base_outputs instead of evaluated?
source/material_model/compositing.cc
Outdated
|
||
model_property_map[prop] = model_ind; | ||
} | ||
models.resize(model_names.size()); |
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.
It would be great if you could write a comment about what the code above does.
I have added a test that is failing despite copying all of the input and output from simple_incompressible. I will work on identifying the source of the issue, though my guess is that it originates from how I am copying the outputs. |
Take a look at the diff file generated by the tester. All of these changes are expected (a different output directory, and no basic statistics output anymore, because that one is only computed if you use the simple material model) |
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.
A lot of comments, but only one is maybe a bug. I like the concept, and have mostly style comments. Thanks for working on this 👍
<http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef _aspect_material_model_averaging_h |
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.
please update the include guard, this looks like copy-pasted from averaging? or did you mean compositing?
{ | ||
namespace MaterialModel | ||
{ | ||
using namespace dealii; |
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.
do you need this? If not remove it.
* | ||
* @param model_index Internal index for pointer to the material model evaluated | ||
* @param base_output Properties generated by the material model specified | ||
* @out MaterialModelOutputs to be used. |
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.
From the description I do not quite follow what this function does. Please extend the first sentence a bit. E.g. which material model? Supposedly not this object, but one of the models responsible for one of the properties?
After looking at the parameters closer, I think I got its purpose. Probably it copies all properties that are requested from one particular (sub)-model into the final MaterialModelOutputs object?
source/material_model/compositing.cc
Outdated
<http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <deal.II/base/std_cxx11/array.h> |
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.
I do not think you need this
source/material_model/compositing.cc
Outdated
#include <utility> | ||
#include <limits> | ||
|
||
using namespace dealii; |
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.
do you need this?
source/material_model/compositing.cc
Outdated
|
||
// 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 |
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.
I see why you can not do the parsing here, but can you just move these lines below out of the subsection? It would be easier to understand if there were only one loop over the model names.
source/material_model/compositing.cc
Outdated
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; |
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.
please remove the spaces around the arrows in the lines above
source/material_model/compositing.cc
Outdated
Compositing<dim>:: | ||
is_compressible () const | ||
{ | ||
unsigned int ind = model_property_map.at(Property::compressibility); |
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.
make it const
source/material_model/compositing.cc
Outdated
Compositing<dim>:: | ||
reference_viscosity() const | ||
{ | ||
unsigned int ind = model_property_map.at(Property::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.
same here
tests/simple_composite.prm
Outdated
# Duplicate of the simple incompressible model with using the | ||
# composite model instead | ||
|
||
# This is a relatively realistic compressible model setup. |
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.
Please check the comments at the beginning of the file. Make it consistent.
8d8c791
to
f5d4b3e
Compare
Changes made. |
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.
One more questionable condition, and one more style comment. Otherwise good to go.
source/material_model/compositing.cc
Outdated
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, |
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
?
source/material_model/compositing.cc
Outdated
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 comment
The 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 models
above (probably for speed?), but then use at
here instead of []
further down, probably just copied from the earlier loop? Two comments about that:
- Please move the resize command in front of this loop, where
models
is used, so that related commands are close together. - Use consistently
at
or[]
do not mix between them. In this case[]
is totally safe, becausei
will never exceed the bounds of the vector. In generalat
is significantly slower (see e.g. https://stackoverflow.com/questions/9376049/vectorat-vs-vectoroperator), although of course in this case with just a few entries this does not matter at all.
Thanks! |
Work at generating the model suggested in #1529 (also #691). I would appreciate any suggestions on how to better arrange the internals, and what might be a good test case.