Celeritas  0.5.0-86+4a8eea4
Public Member Functions | List of all members
celeritas::LocalTransporter Class Reference

Manage offloading of tracks to Celeritas. More...

#include <LocalTransporter.hh>

Public Types

Type aliases
using MapStrReal = std::unordered_map< std::string, real_type >
 

Public Member Functions

 LocalTransporter (SetupOptions const &options, SharedParams &params)
 Construct with shared (MT) params. More...
 
void Initialize (SetupOptions const &options, SharedParams &params)
 Helper for making initialization more obvious from user code. More...
 
void SetEventId (int id)
 
void InitializeEvent (int)
 Set the event ID and reseed the Celeritas RNG at the start of an event.
 
void Push (G4Track const &)
 Convert a Geant4 track to a Celeritas primary and add to buffer. More...
 
void Flush ()
 Transport the buffered tracks and all secondaries produced. More...
 
void Finalize ()
 Clear local data. More...
 
MapStrReal GetActionTime () const
 Get the accumulated action times.
 
size_type GetBufferSize () const
 
 operator bool () const
 Whether the class instance is initialized.
 

Detailed Description

Manage offloading of tracks to Celeritas.

This class must be constructed locally on each worker thread/task/stream, usually as a shared pointer that's accessible to:

Warning
Due to Geant4 thread-local allocators, this class must be finalized or destroyed on the same CPU thread in which is created and used!
Todo:
Rename LocalOffload or something?

Constructor & Destructor Documentation

◆ LocalTransporter()

celeritas::LocalTransporter::LocalTransporter ( SetupOptions const &  options,
SharedParams params 
)

Construct with shared (MT) params.

Todo:
Add support for Geant4 navigation wrapper, which requires calling state.ref().geometry.reset() on the local transporter thread due to thread-allocated navigator data.

Member Function Documentation

◆ Finalize()

void celeritas::LocalTransporter::Finalize ( )

Clear local data.

This may need to be executed on the same thread it was created in order to safely deallocate some Geant4 objects under the hood...

◆ Flush()

void celeritas::LocalTransporter::Flush ( )

Transport the buffered tracks and all secondaries produced.

Abort cleanly for interrupt and user-defined (i.e., job manager) signals.

Todo:
The signal handler is not thread safe. We may need to set an atomic/volatile bit so all local transporters abort.

◆ Initialize()

void celeritas::LocalTransporter::Initialize ( SetupOptions const &  options,
SharedParams params 
)
inline

Helper for making initialization more obvious from user code.

This gives it some symmetry with Finalize, which is provided as an exception-friendly destructor.

◆ Push()

void celeritas::LocalTransporter::Push ( G4Track const &  g4track)

Convert a Geant4 track to a Celeritas primary and add to buffer.

Todo:
Non-unit weights: see issue #1268
Todo:
Eliminate event ID from primary.
Todo:
Maybe only run one iteration? But then make sure that Flush still transports active tracks to completion.

The documentation for this class was generated from the following files: