Skip to content

Commit 8db575e

Browse files
authored
Improve geometry track view testing (#2131)
* Use EXPECT_REF * Add additional checks and remove safety calculation in check * Print full vecgeom version string in unit test * Add bump value to output * Check for throws and add scoped context * fixup! Add additional checks and remove safety calculation in check * Add more ASSERT_NO_THROW * Adjust interfaces * Add UnitLength helper for unit systems * Add name helpers * Add build_checked_track_view * Add additional checks * Add metadata classes to checked track view * Add checked geo track view output * Use G4VG instead of VGDML for everything but a basic check * Add more diagnostic output * Update tolerance to fix float * Add CheckedGeoError and additional error checking * Add data debug data to checked view * Improve checked output * Add more checking * Fix checking and allow zero distance propagation fro this one * Fix missing include * Fix 'statement has no effect' warn-as-error * Allow configurable max_steps per 'track' call
1 parent 5ce7701 commit 8db575e

23 files changed

+1071
-846
lines changed

src/corecel/Assert.hh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,6 @@
8484
<< "failed to open '" << filename
8585
<< "' (should contain relaxation data)");
8686
* \endcode
87-
*
88-
* An always-on debug-type assertion without a detailed message can be
89-
* constructed by omitting the stream (but leaving the comma):
90-
* \code
91-
CELER_VALIDATE(file_stream,);
92-
* \endcode
9387
*/
9488
/*!
9589
* \def CELER_DEBUG_FAIL

src/geocel/GeoParamsInterface.hh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
//---------------------------------------------------------------------------//
77
#pragma once
88

9-
#include <utility>
10-
119
#include "corecel/Macros.hh"
1210
#include "corecel/cont/LabelIdMultiMap.hh" // IWYU pragma: export
1311
#include "corecel/cont/Span.hh" // IWYU pragma: export

src/geocel/GeoTrackInterface.hh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ class GeoTrackInterface
9393
virtual Real3 const& pos() const = 0;
9494
//! Return the direction in the global coordinate system
9595
virtual Real3 const& dir() const = 0;
96-
//!@}
9796

97+
//!@}
9898
//!@{
9999
//! \name Canonical volume state
100100

@@ -124,6 +124,7 @@ class GeoTrackInterface
124124

125125
//!@{
126126
//! \name Surface state
127+
127128
/*!
128129
* Whether the track is exactly on a surface.
129130
*
@@ -142,9 +143,9 @@ class GeoTrackInterface
142143
*/
143144
virtual Real3 normal() const = 0;
144145
//!@}
145-
146146
//!@{
147147
//! \name Straight-line movement and boundary crossing
148+
148149
/*!
149150
* Find the distance to the next boundary (infinite max).
150151
*
@@ -191,9 +192,9 @@ class GeoTrackInterface
191192
*/
192193
virtual void cross_boundary() = 0;
193194
//!@}
194-
195195
//!@{
196196
//! \name Locally bounded movement
197+
197198
/*!
198199
* Find the safety distance at the current position.
199200
*

test/celeritas/field/FieldPropagator.test.cc

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -61,30 +61,11 @@ constexpr bool using_solids_vg = !CELERITAS_VECGEOM_SURFACE
6161

6262
class FieldPropagatorTestBase : public CoreGeoTestBase, public FieldTestBase
6363
{
64-
using CGBase = CoreGeoTestBase;
65-
using FBase = FieldTestBase;
66-
67-
public:
68-
//!@{
69-
//! \name Type aliases
70-
using CGeoTrackView = CheckedGeoTrackView;
71-
//!@}
72-
7364
protected:
74-
//! Get a single-thread host track view
75-
CGeoTrackView make_geo_track_view()
76-
{
77-
CGeoTrackView result{
78-
std::make_unique<WrappedGeoTrack>(CGBase::make_geo_track_view())};
79-
// TODO: VecGeom does not yet support surface normals
80-
result.check_normal(CELERITAS_CORE_GEO != CELERITAS_CORE_GEO_VECGEOM);
81-
return result;
82-
}
83-
8465
//! Get and initialize a single-thread host track view
85-
CGeoTrackView make_geo_track_view(Real3 const& pos, Real3 const& dir)
66+
CheckedGeoTrackView make_geo_track_view(Real3 const& pos, Real3 const& dir)
8667
{
87-
auto result = this->make_geo_track_view();
68+
auto result = this->make_checked_track_view();
8869
result = this->make_initializer(pos, dir);
8970
return result;
9071
}
@@ -326,7 +307,7 @@ TEST_F(TwoBoxesTest, gamma_interior)
326307
}
327308
// Move to boundary
328309
{
329-
auto geo = this->make_geo_track_view();
310+
auto geo = this->make_checked_track_view();
330311
auto propagate
331312
= make_field_propagator(integrate, driver_options, particle, geo);
332313

@@ -340,14 +321,14 @@ TEST_F(TwoBoxesTest, gamma_interior)
340321
}
341322
// Cross boundary
342323
{
343-
auto geo = this->make_geo_track_view();
324+
auto geo = this->make_checked_track_view();
344325
EXPECT_EQ("inner", this->volume_name(geo));
345326
geo.cross_boundary();
346327
EXPECT_EQ("world", this->volume_name(geo));
347328
}
348329
// Move in new region
349330
{
350-
auto geo = this->make_geo_track_view();
331+
auto geo = this->make_checked_track_view();
351332
auto propagate
352333
= make_field_propagator(integrate, driver_options, particle, geo);
353334

@@ -574,15 +555,15 @@ TEST_F(TwoBoxesTest, TEST_IF_CELERITAS_DOUBLE(electron_small_step))
574555
{
575556
SCOPED_TRACE("Cross boundary");
576557

577-
auto geo = this->make_geo_track_view();
558+
auto geo = this->make_checked_track_view();
578559
EXPECT_EQ("inner", this->volume_name(geo));
579560
geo.cross_boundary();
580561
EXPECT_EQ("world", this->volume_name(geo));
581562
}
582563
{
583564
SCOPED_TRACE("Small step from boundary");
584565

585-
auto geo = this->make_geo_track_view();
566+
auto geo = this->make_checked_track_view();
586567
EXPECT_TRUE(geo.is_on_boundary());
587568

588569
// Starting on the boundary, take a step smaller than driver's minimum
@@ -625,7 +606,7 @@ TEST_F(TwoBoxesTest, electron_tangent)
625606
SCOPED_TRACE("Short step tangent to boundary");
626607

627608
constexpr real_type quarter = 0.51 * pi;
628-
auto geo = this->make_geo_track_view();
609+
auto geo = this->make_checked_track_view();
629610
auto propagate = make_mag_field_propagator<DormandPrinceIntegrator>(
630611
field, driver_options, particle, geo);
631612
auto result = propagate(real_type{0.02 * pi});
@@ -654,7 +635,7 @@ TEST_F(TwoBoxesTest, electron_cross)
654635
{
655636
SCOPED_TRACE("Exit (twelfth of a turn)");
656637

657-
auto geo = this->make_geo_track_view();
638+
auto geo = this->make_checked_track_view();
658639
auto propagate = make_mag_field_propagator<DormandPrinceIntegrator>(
659640
field, driver_options, particle, geo);
660641
auto result = propagate(pi);
@@ -668,15 +649,15 @@ TEST_F(TwoBoxesTest, electron_cross)
668649
{
669650
SCOPED_TRACE("Cross boundary");
670651

671-
auto geo = this->make_geo_track_view();
652+
auto geo = this->make_checked_track_view();
672653
EXPECT_EQ("inner", this->volume_name(geo));
673654
geo.cross_boundary();
674655
EXPECT_EQ("world", this->volume_name(geo));
675656
}
676657
{
677658
SCOPED_TRACE("Reenter (1/3 turn)");
678659

679-
auto geo = this->make_geo_track_view();
660+
auto geo = this->make_checked_track_view();
680661
auto propagate = make_mag_field_propagator<DormandPrinceIntegrator>(
681662
field, driver_options, particle, geo);
682663
auto result = propagate(circ);
@@ -690,7 +671,7 @@ TEST_F(TwoBoxesTest, electron_cross)
690671
{
691672
SCOPED_TRACE("Cross boundary");
692673

693-
auto geo = this->make_geo_track_view();
674+
auto geo = this->make_checked_track_view();
694675
geo.cross_boundary();
695676
EXPECT_EQ("inner", this->volume_name(geo));
696677
}
@@ -699,7 +680,7 @@ TEST_F(TwoBoxesTest, electron_cross)
699680

700681
FieldDriverOptions driver_options;
701682
driver_options.max_substeps = 100;
702-
auto geo = this->make_geo_track_view();
683+
auto geo = this->make_checked_track_view();
703684
auto propagate = make_mag_field_propagator<DormandPrinceIntegrator>(
704685
field, driver_options, particle, geo);
705686
auto result = propagate(7. / 12. * circ);
@@ -803,7 +784,7 @@ TEST_F(TwoBoxesTest, electron_corner_hit)
803784
EXPECT_NORMAL_EQUIV((Real3{0, 1, 0}), geo.normal());
804785
}
805786

806-
geo.cross_boundary();
787+
EXPECT_NO_THROW(geo.cross_boundary());
807788
EXPECT_EQ("world", this->volume_name(geo));
808789
}
809790
{
@@ -832,7 +813,7 @@ TEST_F(TwoBoxesTest, electron_corner_hit)
832813
EXPECT_NORMAL_EQUIV((Real3{0, 1, 0}), geo.normal());
833814
}
834815

835-
geo.cross_boundary();
816+
EXPECT_NO_THROW(geo.cross_boundary());
836817
EXPECT_EQ("world", this->volume_name(geo));
837818
}
838819
{
@@ -854,7 +835,7 @@ TEST_F(TwoBoxesTest, electron_corner_hit)
854835
{
855836
EXPECT_VEC_SOFT_EQ((Real3{-1, 0, 0}), geo.normal());
856837
}
857-
geo.cross_boundary();
838+
EXPECT_NO_THROW(geo.cross_boundary());
858839
EXPECT_EQ("world", this->volume_name(geo));
859840
}
860841
}
@@ -873,7 +854,7 @@ TEST_F(TwoBoxesTest, TEST_IF_CELERITAS_DOUBLE(electron_step_endpoint))
873854
static constexpr Real3 first_pos
874855
= {-0.098753281951459, 0.43330671122068, 0};
875856

876-
auto geo = this->make_geo_track_view();
857+
auto geo = this->make_checked_track_view();
877858
auto integrate = make_mag_field_integrator<DiagnosticDPIntegrator>(
878859
field, particle.charge());
879860
auto propagate = [&](real_type start_delta, real_type move_delta) {
@@ -1034,7 +1015,7 @@ TEST_F(TwoBoxesTest,
10341015
Real3 dir{-sintheta, costheta, 0};
10351016
this->make_geo_track_view(pos, dir);
10361017
}
1037-
auto geo = this->make_geo_track_view();
1018+
auto geo = this->make_checked_track_view();
10381019
EXPECT_EQ("inner", this->volume_name(geo));
10391020

10401021
EXPECT_SOFT_EQ(radius,

test/geocel/CMakeLists.txt

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ celeritas_add_test_library(testcel_geocel ${SOURCES})
4949

5050
celeritas_target_link_libraries(testcel_geocel
5151
PUBLIC testcel_harness Celeritas::geocel
52-
PRIVATE Celeritas::ExtGeant4Geo Celeritas::ExtVecGeom
52+
PRIVATE testcel_core Celeritas::ExtGeant4Geo Celeritas::ExtVecGeom
5353
)
5454

5555
#-----------------------------------------------------------------------------#
@@ -78,19 +78,17 @@ if(CELERITAS_USE_VecGeom)
7878
# change the internal numbering. Run all tests separately using a filter,
7979
# first constructing a list of tests that *could* be run.
8080
set(_vgdml_tests
81-
"FourLevelsVgdml"
82-
"MultiLevelVgdml"
83-
"SimpleCmsVgdml"
84-
"SolidsVgdml"
8581
"TwoBoxesVgdml"
8682
)
8783
set(_g4vg_tests
8884
"CmsEeBackDee"
8985
"Cmse"
9086
"FourLevels"
87+
"LarSphere"
9188
"MultiLevel"
9289
"Polyhedra"
9390
"Replica"
91+
"SimpleCms"
9492
"Solids"
9593
"TransformedBox"
9694
"Znenv"
@@ -103,14 +101,7 @@ if(CELERITAS_USE_VecGeom)
103101
# Now build a list of tests that *can't* successfully run
104102
set(_vecgeom_disable)
105103
if(NOT VecGeom_GDML_FOUND)
106-
list(APPEND _vecgeom_disable
107-
".*Vgdml"
108-
)
109-
elseif(CELERITAS_VecGeom_SURFACE)
110-
list(APPEND _vecgeom_disable
111-
MultiLevelVgdml # Scaling used to create mirror symmetry
112-
SolidsVgdml # Missing shapes
113-
)
104+
list(APPEND _vecgeom_disable ${_vgdml_tests})
114105
endif()
115106

116107
if(NOT CELERITAS_USE_Geant4)

0 commit comments

Comments
 (0)