From 920201e5fdee60cbae56db904d18347b9aada527 Mon Sep 17 00:00:00 2001 From: Rene Gassmoeller Date: Mon, 7 Oct 2024 11:20:30 +0200 Subject: [PATCH] Improve error message --- include/aspect/simulator.h | 7 +++++++ source/simulator/helper_functions.cc | 13 +++++++++++++ source/simulator/initial_conditions.cc | 6 +++--- .../screen-output | 8 ++++---- .../screen-output | 4 ++-- 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/include/aspect/simulator.h b/include/aspect/simulator.h index cd097b848c1..96a62f53d44 100644 --- a/include/aspect/simulator.h +++ b/include/aspect/simulator.h @@ -388,6 +388,13 @@ namespace aspect * field. See Introspection::polynomial_degree for more information. */ unsigned int polynomial_degree(const Introspection &introspection) const; + + /** + * Return a string that describes the field type and the compositional + * variable number and name, if applicable. + */ + std::string + name(const Introspection &introspection) const; }; private: diff --git a/source/simulator/helper_functions.cc b/source/simulator/helper_functions.cc index 22ef169e64c..581a7a628bd 100644 --- a/source/simulator/helper_functions.cc +++ b/source/simulator/helper_functions.cc @@ -205,6 +205,19 @@ namespace aspect } + + template + std::string + Simulator::AdvectionField::name(const Introspection &introspection) const + { + if (this->is_temperature()) + return "temperature"; + else + return "composition " + std::to_string(compositional_variable) + " (" + introspection.name_for_compositional_index(compositional_variable) + ")"; + } + + + template void Simulator::write_plugin_graph (std::ostream &out) const { diff --git a/source/simulator/initial_conditions.cc b/source/simulator/initial_conditions.cc index 5d63861e1eb..8122598208c 100644 --- a/source/simulator/initial_conditions.cc +++ b/source/simulator/initial_conditions.cc @@ -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; @@ -344,8 +344,8 @@ namespace aspect for (unsigned int advection_field=0; advection_field 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) diff --git a/tests/particle_multiple_worlds_interpolation_fail_2/screen-output b/tests/particle_multiple_worlds_interpolation_fail_2/screen-output index ab9fca9bb2f..765324782ee 100644 --- a/tests/particle_multiple_worlds_interpolation_fail_2/screen-output +++ b/tests/particle_multiple_worlds_interpolation_fail_2/screen-output @@ -12,8 +12,8 @@ An error occurred in file 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)