Skip to content
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

Merged
merged 14 commits into from May 29, 2017
Merged

Conversation

class4kayaker
Copy link
Contributor

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.

@class4kayaker class4kayaker changed the title Compositing Compositing MaterialModel May 12, 2017
@tjhei
Copy link
Member

tjhei commented May 13, 2017

@jdannberg ?
/run-tests

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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks incorrect.

Copy link
Contributor

@jdannberg jdannberg left a 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!

ASPECT_REGISTER_MATERIAL_MODEL(Compositing,
"compositing",
"The ``compositing'' Material model selects material model properties from a "
"given set of other material models."
Copy link
Contributor

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,
Copy link
Contributor

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
*/
Copy link
Contributor

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.

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");
Copy link
Contributor

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?

Copy link
Contributor Author

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.

= Utilities::split_string_list
(prm.get("Models"));
for (std::vector<std::string>::const_iterator p = x_models.begin();
p != x_models.end(); ++p)
Copy link
Contributor

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.

AssertThrow(split_parts[1] != "compositing",
ExcMessage("You may not use ``compositing'' as the base model for "
"a compositing material model."));
unsigned int model_ind;
Copy link
Contributor

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.

typename Interface<dim>::MaterialModelOutputs &out) const
{
typename Interface<dim>::MaterialModelOutputs evaluated(out.viscosities.size(),
this->introspection().n_compositional_fields);
Copy link
Contributor

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?


model_property_map[prop] = model_ind;
}
models.resize(model_names.size());
Copy link
Contributor

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.

@class4kayaker
Copy link
Contributor Author

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.

@gassmoeller
Copy link
Member

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)

Copy link
Member

@gassmoeller gassmoeller left a 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
Copy link
Member

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;
Copy link
Member

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.
Copy link
Member

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?

<http://www.gnu.org/licenses/>.
*/

#include <deal.II/base/std_cxx11/array.h>
Copy link
Member

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

#include <utility>
#include <limits>

using namespace dealii;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need this?


// 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
Copy link
Member

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.

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;
Copy link
Member

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

Compositing<dim>::
is_compressible () const
{
unsigned int ind = model_property_map.at(Property::compressibility);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it const

Compositing<dim>::
reference_viscosity() const
{
unsigned int ind = model_property_map.at(Property::viscosity);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

# Duplicate of the simple incompressible model with using the
# composite model instead

# This is a relatively realistic compressible model setup.
Copy link
Member

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.

@class4kayaker
Copy link
Contributor Author

Changes made.

Copy link
Member

@gassmoeller gassmoeller left a 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.

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,
Copy link
Member

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?

for (unsigned int i=0; i<model_names.size(); ++i)
{
models.at(i).reset(create_material_model<dim>(model_names[i]));
Copy link
Member

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:

  1. Please move the resize command in front of this loop, where models is used, so that related commands are close together.
  2. Use consistently at or [] do not mix between them. In this case [] is totally safe, because i will never exceed the bounds of the vector. In general at 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.

@gassmoeller
Copy link
Member

Thanks!

@gassmoeller gassmoeller merged commit 7840b34 into geodynamics:master May 29, 2017
@gassmoeller gassmoeller mentioned this pull request May 30, 2017
@class4kayaker class4kayaker deleted the compositing branch May 30, 2017 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants