Skip to content

Commit

Permalink
Check that material model supports elasticity
Browse files Browse the repository at this point in the history
  • Loading branch information
anne-glerum committed Jul 8, 2023
1 parent ddfd6af commit 23ea3e0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
3 changes: 0 additions & 3 deletions source/material_model/viscoelastic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ namespace aspect
void
Viscoelastic<dim>::parse_parameters (ParameterHandler &prm)
{
AssertThrow(this->get_parameters().enable_elasticity == true,
ExcMessage ("Material model Viscoelastic only works if 'Enable elasticity' is set to true"));

prm.enter_subsection("Material model");
{
prm.enter_subsection("Viscoelastic");
Expand Down
20 changes: 19 additions & 1 deletion source/simulator/core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,25 @@ namespace aspect
material_model->parse_parameters (prm);
material_model->initialize ();

heating_model_manager.initialize_simulator (*this);
// Make sure that the material model supports elasticity when it is requested,
// by checking that the material model creates the necessary material model
// outputs.
if (parameters.enable_elasticity)
{
// Set up outputs for one point
MaterialModel::MaterialModelOutputs<dim> out(1,
introspection.n_compositional_fields);

material_model->create_additional_named_outputs(out);

MaterialModel::ElasticAdditionalOutputs<dim> *elastic_outputs = out.template get_additional_output<MaterialModel::ElasticAdditionalOutputs<dim>>();

// Throw if the elastic_outputs do not exist
AssertThrow(elastic_outputs != nullptr,
ExcMessage("Elasticity is enabled, but not supported by the material model."));
}

heating_model_manager.initialize_simulator(*this);
heating_model_manager.parse_parameters (prm);

if (SimulatorAccess<dim> *sim = dynamic_cast<SimulatorAccess<dim>*>(gravity_model.get()))
Expand Down

0 comments on commit 23ea3e0

Please sign in to comment.