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

Support surface-based VecGeom 2.x navigator #1422

Draft
wants to merge 36 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2cb9b11
Adapt to VG 2.x templated ABBoxManager
mrguilima Sep 16, 2024
ef6eec4
Updates to use the latest BVHSurfNavigator from VecGeom 2.x
mrguilima Sep 20, 2024
6fa1b18
Temporary fix to four-levels.gdml: replace unsupported orb with suppo…
mrguilima Sep 18, 2024
228ed58
Fixes to Vecgeom:FourLevelsTest*
mrguilima Sep 18, 2024
9956e5d
Revert "Fixes to Vecgeom:FourLevelsTest*"
sethrj Sep 23, 2024
5265793
Add orb->sphere translation and disable unimplemented surface solids
sethrj Sep 23, 2024
0c943b7
Add surface geometry to CI
sethrj Sep 24, 2024
f272247
Merge remote-tracking branch 'upstream/develop' into vg-2.x
sethrj Sep 24, 2024
94eba34
REVERTME: delete other CI builds
sethrj Sep 24, 2024
97be3f7
Fix infinite loop in field propagator due to misbehaving boundary
sethrj Sep 25, 2024
162bfa2
Simplify initializer
sethrj Sep 25, 2024
f4ce1c8
Add two-boxes test and re-enable other vecgeom tests
sethrj Sep 25, 2024
6d7acf4
Fix distance-to-boundary by initializing hit surface to -1
sethrj Sep 25, 2024
161823a
Fix SurfNavigator for TwoBoxes*: new field, VecgeomTrackView::hit_surf_
mrguilima Oct 2, 2024
8682d4b
Merge remote-tracking branch 'upstream/develop' into vg-2.x
sethrj Oct 7, 2024
a64570c
Revert orb-to-sphere conversion after vecgeom#1231
sethrj Sep 25, 2024
88e4716
Always save cache if build succeeds
sethrj Oct 8, 2024
a0f38b2
fixup! Always save cache if build succeeds
sethrj Oct 8, 2024
f9d8fb0
New reference values for CmseTest.trace
mrguilima Oct 6, 2024
f29529d
Always reset hit_surf before calling finding next step
mrguilima Oct 10, 2024
69a1de2
No more warnings during loading of four-levels geometry
mrguilima Oct 10, 2024
f75b87b
No more warnings during loading of Cmse.gdml
mrguilima Oct 10, 2024
976089d
Add CELERITAS_VECGEOM_SURFACE macro
sethrj Oct 15, 2024
3b0385b
Make next surface persistent
sethrj Oct 15, 2024
e45bc55
Loosen move-internal requirement for VecGeom
sethrj Oct 15, 2024
137ae12
Remove warning expectation from vecgeom 2
sethrj Oct 15, 2024
4eeed43
Fix build
sethrj Oct 15, 2024
a107ae9
Disabled two tests doing tracking outside of world
mrguilima Oct 15, 2024
b9cbe7f
GL temp: missing code
mrguilima Oct 15, 2024
9426140
Merge branch 'develop' into vg-2.x
mrguilima Oct 23, 2024
a85bc2f
Disable tests related to navigation from the outside
mrguilima Oct 14, 2024
39941c0
Fixes for VecGeom v2.x
mrguilima Oct 29, 2024
970100b
Switch test expected value depending on VecGeom version
mrguilima Nov 4, 2024
7f9b580
More temporary fixes to Vecgeom tests
mrguilima Nov 5, 2024
ce5ec00
Merge branch 'develop' into vg-2.x
mrguilima Nov 5, 2024
b7a5aaa
Merge branch 'develop' into vg-2.x
mrguilima Nov 7, 2024
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
74 changes: 49 additions & 25 deletions .github/workflows/build-spack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,11 @@ jobs:
matrix:
geometry: ["vecgeom"]
special: [null]
geant: ["10.5", "10.6", "10.7", "11.0", "11.1", "11.2"]
geant: ["11.0"]
include:
- geometry: "orange"
special: "minimal"
geant: null
- geometry: "orange"
special: "float"
geant: "11.0"
- geometry: "orange"
special: "asanlite"
geant: null
- geometry: "vecgeom"
special: "clhep"
geant: "11.0"
- geometry: "geant4"
special: null
special: "vgsurf"
geant: "11.0"
- geometry: "orange"
special: "clang-tidy"
geant: "11.2"
env:
CCACHE_DIR: "${{github.workspace}}/.ccache"
CCACHE_MAXSIZE: "100Mi"
Expand All @@ -69,17 +54,19 @@ jobs:
with:
ref: ${{env.SPACK_REF}}
buildcache: true
color: true
color: true
path: spack-src
- name: Initialize spack environment
run: |
# TODO: https://github.com/spack/spack/pull/43136
curl -LfsS https://github.com/spack/spack/pull/43136.patch | git -C spack-src apply -
cp scripts/ci/spack.yaml .
if [ "${{matrix.geometry}}" == "vecgeom" ]; then
if [ "${{matrix.geometry}}" == "vecgeom" ] && [ "${{matrix.special}}" != "vgsurf" ]; then
spack -e . add vecgeom
fi
if [ "${{matrix.special}}" != "minimal" ] && [ "${{matrix.special}}" != "asanlite" ] ; then
if [ "${{matrix.special}}" != "minimal" ] \
&& [ "${{matrix.special}}" != "asanlite" ] \
&& [ "${{matrix.special}}" != "vgsurf" ] ; then
spack -e . add root
fi
if [ "${{matrix.geant}}" != "" ]; then
Expand Down Expand Up @@ -114,8 +101,8 @@ jobs:
echo "${SPACK_VIEW}/bin" >> $GITHUB_PATH
echo "CMAKE_PREFIX_PATH=${SPACK_VIEW}:${CMAKE_PREFIX_PATH}" >> $GITHUB_ENV
spack env activate . --sh > "${SPACK_VIEW}/rc"
- name: Cache ccache
uses: actions/cache@v4
- name: Restore ccache
uses: actions/cache/restore@v4
with:
path: ${{env.CCACHE_DIR}}
key: ccache-${{env.CMAKE_PRESET}}-${{matrix.geant}}-${{github.run_id}}
Expand All @@ -125,6 +112,33 @@ jobs:
- name: Zero ccache stats
run: |
ccache -z
- name: Install VecGeom surface
if: ${{matrix.geometry == 'vecgeom' && matrix.special == 'vgsurf'}}
run: |
. ${SPACK_VIEW}/rc
git clone -b surface_model --depth=368 \
https://gitlab.cern.ch/VecGeom/VecGeom.git vecgeom
cd vecgeom
mkdir build
cd build
export VECGEOM_PREFIX_PATH=$GITHUB_WORKSPACE/vecgeom/install
cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_STANDARD:STRING=17 \
-DVECGEOM_BACKEND:STRING=Scalar -DVECGEOM_VECTOR:STRING=empty \
-DVECGEOM_BUILTIN_VECCORE:BOOL=ON \
-DVECGEOM_NO_SPECIALIZATION:BOOL=ON \
-DVECGEOM_USE_SURF:BOOL=ON -DVECGEOM_USE_NAVTUPLE:BOOL=OFF -DVECGEOM_USE_NAVINDEX:BOOL=ON \
-DBUILD_SHARED_LIBS:BOOL=ON \
-DVECGEOM_GDML:BOOL=ON -DVECGEOM_ENABLE_CUDA:BOOL=OFF -DVECGEOM_GEANT4:BOOL=OFF -DVECGEOM_ROOT:BOOL=OFF \
-DBUILD_TESTING:BOOL=OFF \
-DCMAKE_INSTALL_PREFIX:STRING=$VECGEOM_PREFIX_PATH \
-G Ninja \
..
ninja install
echo "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}:${VECGEOM_PREFIX_PATH}" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${VECGEOM_PREFIX_PATH}/lib" >> $GITHUB_ENV
- name: Configure Celeritas
env:
CLANG_TIDY: "clang-tidy-15"
Expand All @@ -137,8 +151,18 @@ jobs:
continue-on-error: ${{matrix.special == 'clang-tidy'}}
run: |
ninja -v -k0
- name: Save ccache
if: ${{always() && steps.build.outcome == 'success'}}
uses: actions/cache/save@v4
with:
path: ${{env.CCACHE_DIR}}
key: ccache-${{env.CMAKE_PRESET}}-${{matrix.geant}}-${{github.run_id}}
- name: Regenerate ROOT test data
if: ${{matrix.geant == '11.0'}}
if: ${{
matrix.geant == '11.0'
&& matrix.special != 'minimal'
&& matrix.special != 'vgsurf'
}}
working-directory: build
run: |
ninja -v -k0 update-root-test-data
Expand Down Expand Up @@ -178,7 +202,7 @@ jobs:
# TODO: ASAN requires flags downstream
if: >-
${{
(matrix.special != 'asanlite')
matrix.special != 'asanlite'
}}
run: |
. ${SPACK_VIEW}/rc
Expand All @@ -200,7 +224,7 @@ jobs:
./bin/celer-sim --version
- name: Build examples
# TODO: ASAN requires flags downstream
env:
env:
CELER_DISABLE_ACCEL_EXAMPLES: >-
${{
( (matrix.special == 'minimal')
Expand Down
31 changes: 0 additions & 31 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,7 @@ jobs:
with:
name: event-file
path: ${{github.event_path}}
build-fast:
uses: ./.github/workflows/build-fast.yml
build-ultralite:
uses: ./.github/workflows/build-ultralite.yml
doc:
uses: ./.github/workflows/doc.yml
all-prechecks:
needs: [build-fast, build-ultralite, doc]
runs-on: ubuntu-latest
steps:
- name: Success
run: "true"
build-docker:
# Since docker builds aren't cached and are large, don't run on draft
if: ${{github.event.pull_request.draft == false}}
needs: [all-prechecks]
uses: ./.github/workflows/build-docker.yml
build-spack:
needs: [all-prechecks]
uses: ./.github/workflows/build-spack.yml

# Specifying a dependent job allows us to select a single "requires" check in the project GitHub settings
all:
if: ${{always()}}
needs:
- build-docker
- build-spack
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{toJSON(needs)}}

# vim: set nowrap tw=100:
8 changes: 8 additions & 0 deletions scripts/cmake-presets/ci-ubuntu-github.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@
"cacheVariables": {
}
},
{
"name": "reldeb-vecgeom-vgsurf",
"description": "Build with release, assertions, VecGeom",
"inherits": ["reldeb-vecgeom"],
"cacheVariables": {
"CELERITAS_USE_ROOT": {"type": "BOOL", "value": "OFF"}
}
},
{
"name": "ndebug-vecgeom",
"description": "Build release with vecgeom for testing *only* demos",
Expand Down
9 changes: 9 additions & 0 deletions src/celeritas/field/FieldPropagator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ FieldPropagator<DriverT, GTV>::operator()(real_type step) -> result_type
}
auto linear_step
= geo_.find_next_step(chord.length + this->delta_intersection());
CELER_ASSERT(linear_step.distance
<= chord.length + this->delta_intersection());

// Scale the effective substep length to travel by the fraction along
// the chord to the boundary. This value can be slightly larger than 1
Expand Down Expand Up @@ -268,6 +270,13 @@ FieldPropagator<DriverT, GTV>::operator()(real_type step) -> result_type
// The straight-line intercept is too far from substep's end state.
// Decrease the allowed substep (curved path distance) by the
// fraction along the chord, and retry the driver step.
if (CELER_UNLIKELY(update_length > chord.length))
{
// We should be converging to the endpoint, but if the
// navigator is misbehaving then it could get into an infinite
// loop if the update length increases.
--remaining_substeps;
}
remaining = update_length;
}
} while (remaining > this->minimum_substep() && remaining_substeps > 0);
Expand Down
8 changes: 8 additions & 0 deletions src/geocel/g4vg/SolidConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,25 @@ auto SolidConverter::convert_impl(arg_type solid_base) -> result_type
VGSC_TYPE_FUNC(Box , box),
VGSC_TYPE_FUNC(Cons , cons),
VGSC_TYPE_FUNC(CutTubs , cuttubs),
#ifndef VECGEOM_USE_SURF
VGSC_TYPE_FUNC(Ellipsoid , ellipsoid),
VGSC_TYPE_FUNC(EllipticalCone , ellipticalcone),
VGSC_TYPE_FUNC(EllipticalTube , ellipticaltube),
#endif
VGSC_TYPE_FUNC(ExtrudedSolid , extrudedsolid),
#ifndef VECGEOM_USE_SURF
VGSC_TYPE_FUNC(GenericPolycone , genericpolycone),
#endif
VGSC_TYPE_FUNC(GenericTrap , generictrap),
#ifndef VECGEOM_USE_SURF
VGSC_TYPE_FUNC(Hype , hype),
#endif
VGSC_TYPE_FUNC(IntersectionSolid, intersectionsolid),
VGSC_TYPE_FUNC(Orb , orb),
VGSC_TYPE_FUNC(Para , para),
#ifndef VECGEOM_USE_SURF
VGSC_TYPE_FUNC(Paraboloid , paraboloid),
#endif
VGSC_TYPE_FUNC(Polycone , polycone),
VGSC_TYPE_FUNC(Polyhedra , polyhedra),
VGSC_TYPE_FUNC(ReflectedSolid , reflectedsolid),
Expand Down
13 changes: 11 additions & 2 deletions src/geocel/vg/VecgeomParams.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <vector>
#include <VecGeom/base/Config.h>
#include <VecGeom/base/Cuda.h>
#include <VecGeom/base/Version.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've verified that this header (and the VECGEOM_VERSION macro therein) are present in v1.2.4, which is the minimum vecgeom required by Celeritas.

#include <VecGeom/management/ABBoxManager.h>
#include <VecGeom/management/BVHManager.h>
#include <VecGeom/management/GeoManager.h>
Expand Down Expand Up @@ -410,7 +411,11 @@ void VecgeomParams::build_volume_tracking()

{
ScopedTimeAndRedirect time_and_output_("vecgeom::ABBoxManager");
#if VECGEOM_VERSION < 0x020000
vecgeom::ABBoxManager::Instance().InitABBoxesForCompleteGeometry();
#else
vecgeom::ABBoxManager<real_type>::Instance().InitABBoxesForCompleteGeometry();
#endif
}

// Init the bounding volume hierarchy structure
Expand Down Expand Up @@ -570,9 +575,13 @@ void VecgeomParams::build_metadata()
VPlacedVolume const* pv = GeoManager::Instance().GetWorld();

// Calculate bounding box
#if VECGEOM_VERSION < 0x020000
auto bbox_mgr = ABBoxManager::Instance();
#else
auto bbox_mgr = ABBoxManager<real_type>::Instance();
#endif
Vector3D<real_type> lower, upper;
ABBoxManager::Instance().ComputeABBox(pv, &lower, &upper);

bbox_mgr.ComputeABBox(pv, &lower, &upper);
return BBox{detail::to_array(lower), detail::to_array(upper)};
}();
}
Expand Down
Loading
Loading