From 5a739e2ff896b3d4ec8b5eca54e91afa1d7cad30 Mon Sep 17 00:00:00 2001 From: Guilherme Lima Date: Fri, 10 Jan 2025 09:09:00 -0600 Subject: [PATCH] Update expected safeties in Vecgeom tests and CMake version range (#1552) * Fix expected volumes and safety values in Vecgeom.test.cc * Revert "REVERTME: disable failing vecgeom tests" * Fix build when +vecgeom~geant4 * Fix SolidsGeantTest* * Fix test Geometry:CmseTest* * Fix geometry tests for VecGeom's master branch * Attempt to fix Geometry test, failing at the CI * Temporarily disable Geometry test for Cmse (host fixture): See issue #1570 for more details. --------- Co-authored-by: Seth R Johnson --- src/geocel/GeantGeoUtils.hh | 10 ++++ test/celeritas/geo/Geometry.test.cc | 16 ++++--- test/geocel/CMakeLists.txt | 1 + test/geocel/vg/Vecgeom.test.cc | 73 +++++------------------------ 4 files changed, 32 insertions(+), 68 deletions(-) diff --git a/src/geocel/GeantGeoUtils.hh b/src/geocel/GeantGeoUtils.hh index 5b54262ba9..7f4ed0fd20 100644 --- a/src/geocel/GeantGeoUtils.hh +++ b/src/geocel/GeantGeoUtils.hh @@ -133,6 +133,16 @@ inline std::string make_gdml_name(G4LogicalVolume const&) { CELER_NOT_CONFIGURED("Geant4"); } + +inline std::ostream& operator<<(std::ostream&, PrintableNavHistory const&) +{ + CELER_NOT_CONFIGURED("Geant4"); +} + +inline std::ostream& operator<<(std::ostream&, PrintableLV const&) +{ + CELER_NOT_CONFIGURED("Geant4"); +} #endif //---------------------------------------------------------------------------// diff --git a/test/celeritas/geo/Geometry.test.cc b/test/celeritas/geo/Geometry.test.cc index 9ef9f11bda..0694be8e58 100644 --- a/test/celeritas/geo/Geometry.test.cc +++ b/test/celeritas/geo/Geometry.test.cc @@ -213,10 +213,11 @@ auto CmseTest::reference_volumes() const -> SpanConstStr auto CmseTest::reference_avg_path() const -> SpanConstReal { // clang-format off - static real_type const paths[] = {74.17136, 13.25306, 76.67924, 449.5464, - 0.09551618, 0.3231404, 0.310899, 0.3844357, 0.01179415, 11.09485, - 9.101073, 0.0004083249, 0.3033329, 0.4292332, 228.7892, 0.03947559, - 563.0746, 2858.592}; + static real_type const paths[] = { + 74.681789113, 13.9060168654525, 67.789037081, 460.34598500, + 0.0752032527, 0.3958262271, 0.25837963337, 0.51484801201, 0.01179415, + 10.662958365, 9.3044714865, 0.0004083249, 0.25874352886, 0.4292332, + 225.390314534812, 0.0394755943, 550.75653646, 2824.1066316 }; // clang-format on return make_span(paths); } @@ -312,8 +313,8 @@ TEST_F(ThreeSpheresTest, TEST_IF_CELER_DEVICE(device)) //---------------------------------------------------------------------------// // CMSE //---------------------------------------------------------------------------// - -TEST_F(CmseTest, host) +// TODO: ensure reference values are the same for all CI platforms (see #1570) +TEST_F(CmseTest, DISABLED_host) { auto const& bbox = this->geometry()->bbox(); real_type const geo_eps @@ -324,7 +325,8 @@ TEST_F(CmseTest, host) EXPECT_VEC_SOFT_EQ((Real3{1750 + geo_eps, 1750 + geo_eps, 45000 + geo_eps}), bbox.upper()); - real_type tol = 0.35; + real_type tol = CELERITAS_CORE_GEO == CELERITAS_CORE_GEO_VECGEOM ? 0.005 + : 0.35; this->run_host(512, tol); } diff --git a/test/geocel/CMakeLists.txt b/test/geocel/CMakeLists.txt index 86ff2ddc3b..0f6423f950 100644 --- a/test/geocel/CMakeLists.txt +++ b/test/geocel/CMakeLists.txt @@ -84,6 +84,7 @@ if(CELERITAS_USE_VecGeom) "FourLevelsTest.*" "MultiLevelTest.*" "SolidsTest.*" + "CmseTest.*" ) endif() endif() diff --git a/test/geocel/vg/Vecgeom.test.cc b/test/geocel/vg/Vecgeom.test.cc index 6def01dbca..bad5a26ba7 100644 --- a/test/geocel/vg/Vecgeom.test.cc +++ b/test/geocel/vg/Vecgeom.test.cc @@ -285,19 +285,6 @@ class FourLevelsTest : public VecgeomVgdmlTestBase { return this->load_vgdml("four-levels.gdml"); } - - SpanStringView expected_log_levels() const final - { - if (vecgeom_version >= Version{2}) - { - static std::string_view const levels[] = {"warning"}; - return make_span(levels); - } - else - { - return {}; - } - } }; //---------------------------------------------------------------------------// @@ -746,8 +733,7 @@ class SolidsTest : public VecgeomVgdmlTestBase { if (vecgeom_version >= Version{2}) { - static std::string_view const levels[] - = {"warning", "warning", "warning"}; + static std::string_view const levels[] = {"warning", "warning"}; return make_span(levels); } else if (geant4_version >= Version{11}) @@ -1067,24 +1053,11 @@ class CmseTest : public VecgeomVgdmlTestBase { public: SPConstGeo build_geometry() final { return this->load_vgdml("cmse.gdml"); } - - SpanStringView expected_log_levels() const final - { - if (vecgeom_version >= Version(2)) - { - static std::string_view const levels[] = {"warning"}; - return make_span(levels); - } - else - { - return {}; - } - } }; //---------------------------------------------------------------------------// -TEST_F(CmseTest, DISABLED_trace) +TEST_F(CmseTest, trace) { // clang-format off { @@ -1099,8 +1072,8 @@ TEST_F(CmseTest, DISABLED_trace) 180, 910, 24000, 6000}; EXPECT_VEC_SOFT_EQ(expected_distances, result.distances); static real_type const expected_hw_safety[] = {100, 2.1499999999997, - 0.52499999999986, 13.023518051922, 6.95, 6.95, 13.023518051922, - 0.52499999999986, 2.15, 100, 5, 8, 100, 100, 100}; + 10.302730220675, 13.023518051922, 6.95, 6.95, 13.023518051922, + 10.302730220675, 2.15, 100, 5, 8, 100, 100, 100}; EXPECT_VEC_SOFT_EQ(expected_hw_safety, result.halfway_safeties); } { @@ -1136,8 +1109,8 @@ TEST_F(CmseTest, DISABLED_trace) 535, 920}; EXPECT_VEC_SOFT_EQ(expected_distances, result.distances); static real_type const expected_hw_safety[] = {85, 267.5, 85.85, - 58.4195, 0.078366388350241, 2.343262600759, 0.078366388350241, - 58.4195, 85.85, 267.5, 460}; + 60.4, 0.078366388350241, 2.343262600759, 0.078366388350241, + 60.4, 85.85, 267.5, 460}; EXPECT_VEC_SOFT_EQ(expected_hw_safety, result.halfway_safeties); } { @@ -1149,7 +1122,7 @@ TEST_F(CmseTest, DISABLED_trace) static real_type const expected_distances[] = {12.495, 287.505, 530, 920}; EXPECT_VEC_SOFT_EQ(expected_distances, result.distances); - static real_type const expected_hw_safety[] = {1, 1, 242, 460}; + static real_type const expected_hw_safety[] = {6.2475, 47.95, 242, 460}; EXPECT_VEC_SOFT_EQ(expected_hw_safety, result.halfway_safeties); } // clang-format on @@ -1237,7 +1210,7 @@ TEST_F(FourLevelsGeantTest, tracking) EXPECT_VEC_SOFT_EQ(expected_distances, result.distances); } { - SCOPED_TRACE("From outside edge"); + SCOPED_TRACE("From exactly on outside edge"); auto result = this->track({-24, 10., 10.}, {1, 0, 0}); static char const* const expected_volumes[] = {"[OUTSIDE]", "World", @@ -1276,29 +1249,6 @@ TEST_F(FourLevelsGeantTest, tracking) static real_type const expected_distances[] = {5, 1, 3, 5}; EXPECT_VEC_SOFT_EQ(expected_distances, result.distances); } - { - // Formerly in linear propagator test, used to fail - SCOPED_TRACE("From just outside world"); - auto result = this->track({-24, 10, 10}, {1, 0, 0}); - static char const* const expected_volumes[] = {"[OUTSIDE]", - "World", - "Envelope", - "Shape1", - "Shape2", - "Shape1", - "Envelope", - "World", - "Envelope", - "Shape1", - "Shape2", - "Shape1", - "Envelope", - "World"}; - EXPECT_VEC_EQ(expected_volumes, result.volumes); - static real_type const expected_distances[] - = {1e-13, 7, 1, 1, 10, 1, 1, 6, 1, 1, 10, 1, 1, 7}; - EXPECT_VEC_SOFT_EQ(expected_distances, result.distances); - } } //---------------------------------------------------------------------------// @@ -1499,9 +1449,10 @@ TEST_F(SolidsGeantTest, geant_volumes) { { auto result = this->get_import_geant_volumes(); - static int const expected_volumes[] - = {0, 1, 2, 3, 4, 5, 6, 7, -1, 9, 10, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30}; + static int const expected_volumes[] = { + 0, 1, 2, 3, 4, 5, 6, 7, -1, 9, 10, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, + }; EXPECT_VEC_EQ(expected_volumes, result.volumes); EXPECT_EQ(0, result.missing_names.size()) << repr(result.missing_names); }