Skip to content

Commit

Permalink
Improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
gassmoeller committed Oct 7, 2024
1 parent 61f4214 commit 920201e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
7 changes: 7 additions & 0 deletions include/aspect/simulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,13 @@ namespace aspect
* field. See Introspection::polynomial_degree for more information.
*/
unsigned int polynomial_degree(const Introspection<dim> &introspection) const;

/**
* Return a string that describes the field type and the compositional
* variable number and name, if applicable.
*/
std::string
name(const Introspection<dim> &introspection) const;
};

private:
Expand Down
13 changes: 13 additions & 0 deletions source/simulator/helper_functions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,19 @@ namespace aspect
}



template <int dim>
std::string
Simulator<dim>::AdvectionField::name(const Introspection<dim> &introspection) const
{
if (this->is_temperature())
return "temperature";
else
return "composition " + std::to_string(compositional_variable) + " (" + introspection.name_for_compositional_index(compositional_variable) + ")";
}



template <int dim>
void Simulator<dim>::write_plugin_graph (std::ostream &out) const
{
Expand Down
6 changes: 3 additions & 3 deletions source/simulator/initial_conditions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ namespace aspect
if (particle_property_manager.get_data_info().fieldname_exists(particle_property_and_component.first))
{
Assert (advection_field_has_been_found[advection_field] == false,
ExcMessage("The same advection field is mapped to particle properties in different particle worlds. This is not supported."));
ExcMessage("The field " + advection_fields[advection_field].name(introspection) + " is mapped to particle properties in more than one particle world. This is not supported."));

const unsigned int particle_property_index = particle_property_manager.get_data_info().get_position_by_field_name(particle_property_and_component.first)
+ particle_property_and_component.second;
Expand Down Expand Up @@ -344,8 +344,8 @@ namespace aspect

for (unsigned int advection_field=0; advection_field<advection_fields.size(); ++advection_field)
Assert (advection_field_has_been_found[advection_field] == true,
ExcMessage("An compositional field is marked as advected by particles, but no particle property exists that is mapped to this compositional field. "
"Make sure that the particle property exists and is mapped to the compositional field in the parameter file."));
ExcMessage("The field " + advection_fields[advection_field].name(introspection) + " is marked as advected by particles, but no particle property exists that is mapped to this field. "
"Make sure that the particle property exists and is mapped to the correct field in the parameter file."));

LinearAlgebra::BlockVector particle_solution;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ An error occurred in file <initial_conditions.cc> in function
The violated condition was:
advection_field_has_been_found[advection_field] == true
Additional information:
An compositional field is marked as advected by particles, but no
particle property exists that is mapped to this compositional field.
Make sure that the particle property exists and is mapped to the
compositional field in the parameter file.
The field composition 1 (function) is marked as advected by particles,
but no particle property exists that is mapped to this field. Make
sure that the particle property exists and is mapped to the correct
field in the parameter file.

Stacktrace:
(rest of the output replaced by default.sh script)
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ An error occurred in file <initial_conditions.cc> in function
The violated condition was:
advection_field_has_been_found[advection_field] == false
Additional information:
The same advection field is mapped to particle properties in different
particle worlds. This is not supported.
The field composition 0 (anomaly) is mapped to particle properties in
more than one particle world. This is not supported.

Stacktrace:
(rest of the output replaced by default.sh script)

0 comments on commit 920201e

Please sign in to comment.