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

Print ElementId in DataTooBig error #6160

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/ParallelAlgorithms/Events/ErrorIfDataTooBig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "DataStructures/ExtractPoint.hpp"
#include "DataStructures/Tensor/Tensor.hpp"
#include "DataStructures/Tensor/TypeAliases.hpp"
#include "Domain/Tags.hpp"
#include "Options/String.hpp"
#include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
#include "Utilities/ErrorHandling/Error.hpp"
Expand Down Expand Up @@ -119,10 +120,12 @@ class ErrorIfDataTooBig : public Event {
for (const auto& component : tensor) {
for (size_t point = 0; point < component.size(); ++point) {
if (std::abs(component[point]) > threshold_) {
ERROR_NO_TRACE(tag_name << " too big with value "
<< extract_point(tensor, point)
<< " at position "
<< extract_point(coordinates, point));
ERROR_NO_TRACE(
tag_name
<< " too big with value " << extract_point(tensor, point)
<< " at position\n"
<< extract_point(coordinates, point) << "\nwith ElementId: "
<< get<::domain::Tags::Element<Dim>>(box).id());
}
}
}
Expand Down
31 changes: 19 additions & 12 deletions tests/Unit/ParallelAlgorithms/Events/Test_ErrorIfDataTooBig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ void run_event(
ActionTesting::MockRuntimeSystem<Metavariables> runner{{}};
ActionTesting::emplace_component<my_component>(&runner, 0);

auto databox = db::create<
db::AddSimpleTags<domain::Tags::Coordinates<2, Frame::Inertial>,
TestTags::ScalarVar, TestTags::OptionalScalar>>(
std::move(coordinates), std::move(scalar_var),
std::move(optional_scalar));
auto databox = db::create<db::AddSimpleTags<
domain::Tags::Element<2>, domain::Tags::Coordinates<2, Frame::Inertial>,
TestTags::ScalarVar, TestTags::OptionalScalar>>(
Element<2>{ElementId<2>{0}, {}}, std::move(coordinates),
std::move(scalar_var), std::move(optional_scalar));

auto obs_box = make_observation_box<tmpl::filter<
TooBig::compute_tags_for_observation_box, db::is_compute_tag<tmpl::_1>>>(
Expand Down Expand Up @@ -145,8 +145,10 @@ SPECTRE_TEST_CASE("Unit.ParallelAlgorithms.Events.ErrorIfDataTooBig",
" Threshold: 8.5"),
Catch::Matchers::ContainsSubstring("ScalarVar too big") and
Catch::Matchers::ContainsSubstring("value T()=9") and
Catch::Matchers::ContainsSubstring("at position T(0)=3") and
Catch::Matchers::ContainsSubstring("T(1)=3"));
Catch::Matchers::ContainsSubstring("at position") and
Catch::Matchers::ContainsSubstring("T(0)=3") and
Catch::Matchers::ContainsSubstring("T(1)=3") and
Catch::Matchers::ContainsSubstring("with ElementId:"));
CHECK_THROWS_WITH(
run_event(tnsr::I<DataVector, 2>{{{{1.0, 2.0, 3.0}, {1.0, 2.0, 3.0}}}},
Scalar<DataVector>{{{{1.0, 2.0, 3.0}}}},
Expand All @@ -156,8 +158,10 @@ SPECTRE_TEST_CASE("Unit.ParallelAlgorithms.Events.ErrorIfDataTooBig",
" Threshold: 8.5"),
Catch::Matchers::ContainsSubstring("OptionalScalar too big") and
Catch::Matchers::ContainsSubstring("value T()=9") and
Catch::Matchers::ContainsSubstring("at position T(0)=3") and
Catch::Matchers::ContainsSubstring("T(1)=3"));
Catch::Matchers::ContainsSubstring("at position") and
Catch::Matchers::ContainsSubstring("T(0)=3") and
Catch::Matchers::ContainsSubstring("T(1)=3") and
Catch::Matchers::ContainsSubstring("with ElementId:"));
CHECK_THROWS_WITH(
run_event(tnsr::I<DataVector, 2>{{{{1.0, 2.0, 3.0}, {1.0, 2.0, 3.0}}}},
Scalar<DataVector>{{{{1.0, 2.0, -9.0}}}}, std::nullopt,
Expand All @@ -166,8 +170,10 @@ SPECTRE_TEST_CASE("Unit.ParallelAlgorithms.Events.ErrorIfDataTooBig",
" Threshold: 8.5"),
Catch::Matchers::ContainsSubstring("ScalarVar too big") and
Catch::Matchers::ContainsSubstring("value T()=-9") and
Catch::Matchers::ContainsSubstring("at position T(0)=3") and
Catch::Matchers::ContainsSubstring("T(1)=3"));
Catch::Matchers::ContainsSubstring("at position") and
Catch::Matchers::ContainsSubstring("T(0)=3") and
Catch::Matchers::ContainsSubstring("T(1)=3") and
Catch::Matchers::ContainsSubstring("with ElementId:"));
CHECK_THROWS_WITH(
run_event(tnsr::I<DataVector, 2>{{{{1.0, 5.0, 3.0}, {1.0, 2.0, 3.0}}}},
Scalar<DataVector>{{{{1.0, 2.0, 3.0}}}}, std::nullopt,
Expand All @@ -178,6 +184,7 @@ SPECTRE_TEST_CASE("Unit.ParallelAlgorithms.Events.ErrorIfDataTooBig",
Catch::Matchers::ContainsSubstring("value T(0,0)=7") and
Catch::Matchers::ContainsSubstring("T(1,0)=8") and
Catch::Matchers::ContainsSubstring("T(1,1)=9") and
Catch::Matchers::ContainsSubstring("at position T(0)=5") and
Catch::Matchers::ContainsSubstring("at position") and
Catch::Matchers::ContainsSubstring("T(0)=5") and
Catch::Matchers::ContainsSubstring("T(1)=2"));
}
Loading