@@ -202,18 +202,24 @@ inline void AsyncAdePTTransport::Initialize(G4HepEmConfig *hepEmConfig)
202202}
203203
204204inline void AsyncAdePTTransport::CompleteInitialization(adeptint::VolAuxData *auxData,
205- const adeptint::WDTHostRaw &wdtRaw ,
205+ const adeptint::WDTHostPacked &wdtPacked ,
206206 const std::vector<float> &uniformFieldValues)
207207{
208+ // This is the second half of the split initialization. A non-zero volume count was already
209+ // required in Initialize() before geometry upload, and it remains a hard precondition here
210+ // before uploading any geometry-derived metadata to the device.
211+ const auto numVolumes = vecgeom::GeoManager::Instance().GetRegisteredVolumesCount();
212+ if (numVolumes == 0)
213+ throw std::runtime_error("AsyncAdePTTransport::CompleteInitialization: Number of geometry volumes is zero.");
214+
208215 // Initialize volume auxiliary data on device
209216 auto &volAuxArray = adeptint::VolAuxArray::GetInstance();
210- volAuxArray.fNumVolumes = vecgeom::GeoManager::Instance().GetRegisteredVolumesCount() ;
217+ volAuxArray.fNumVolumes = numVolumes ;
211218 volAuxArray.fAuxData = auxData;
212219 AsyncAdePT::InitVolAuxArray(volAuxArray);
213220
214- // Pack host-side WDT
215- adeptint::WDTHostPacked wdtPacked = adeptint::PackWDT(wdtRaw);
216- fHasWDTRegions = !wdtPacked.regions.empty(); // set the flag whether WDT regions are enabled
221+ // The Geant4 side has already packed the host-side WDT metadata before handing it to transport.
222+ fHasWDTRegions = !wdtPacked.regions.empty(); // set the flag whether WDT regions are enabled
217223
218224 // Upload WDT to device
219225 adeptint::WDTDeviceBuffers wdtDev;
0 commit comments