Skip to content

Commit

Permalink
Define "static" concrete action for those with unique name/description (
Browse files Browse the repository at this point in the history
#1416)

* Define static concrete action for compile-time strings
* Improve string formatting
* Delete move and copy constructors because why not
  • Loading branch information
sethrj authored Sep 20, 2024
1 parent c4806e3 commit 1e54371
Show file tree
Hide file tree
Showing 46 changed files with 182 additions and 93 deletions.
6 changes: 3 additions & 3 deletions src/celeritas/em/model/BetheHeitlerModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ BetheHeitlerModel::BetheHeitlerModel(ActionId id,
ParticleParams const& particles,
SPConstImported data,
bool enable_lpm)
: ConcreteAction(id,
"conv-bethe-heitler",
"interact by Bethe-Heitler gamma conversion")
: StaticConcreteAction(id,
"conv-bethe-heitler",
"interact by Bethe-Heitler gamma conversion")
, imported_(data,
particles,
ImportProcessClass::conversion,
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/model/BetheHeitlerModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace celeritas
/*!
* Set up and launch the Bethe-Heitler model interaction.
*/
class BetheHeitlerModel final : public Model, public ConcreteAction
class BetheHeitlerModel final : public Model, public StaticConcreteAction
{
public:
//!@{
Expand Down
3 changes: 2 additions & 1 deletion src/celeritas/em/model/BraggModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ namespace celeritas
* TODO: This model also applies to hadrons.
*/
BraggModel::BraggModel(ActionId id, ParticleParams const& particles)
: ConcreteAction(id, "ioni-bragg", "interact by muon ionization (Bragg)")
: StaticConcreteAction(
id, "ioni-bragg", "interact by muon ionization (Bragg)")
{
CELER_EXPECT(id);

Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/model/BraggModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ParticleParams;
/*!
* Set up and launch the Bragg ionization model interaction.
*/
class BraggModel final : public Model, public ConcreteAction
class BraggModel final : public Model, public StaticConcreteAction
{
public:
// Construct from model ID and other necessary data
Expand Down
8 changes: 4 additions & 4 deletions src/celeritas/em/model/CombinedBremModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ CombinedBremModel::CombinedBremModel(ActionId id,
SPConstImported data,
ReadData sb_table,
bool enable_lpm)
: ConcreteAction(id,
"brems-combined",
"interact by bremsstrahlung (combined SB/relativistic, "
"e+/-)")
: StaticConcreteAction(
id,
"brems-combined",
R"(interact by bremsstrahlung (combined SB/relativistic, e+/-))")
{
CELER_EXPECT(id);
CELER_EXPECT(sb_table);
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/model/CombinedBremModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ParticleParams;
* Set up and launch a combined model of SeltzerBergerModel at the low energy
* and RelativisticBremModel at the high energy for e+/e- Bremsstrahlung.
*/
class CombinedBremModel final : public Model, public ConcreteAction
class CombinedBremModel final : public Model, public StaticConcreteAction
{
public:
//@{
Expand Down
10 changes: 5 additions & 5 deletions src/celeritas/em/model/CoulombScatteringModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ CoulombScatteringModel::CoulombScatteringModel(ActionId id,
ParticleParams const& particles,
MaterialParams const& materials,
SPConstImported data)
: ConcreteAction(
: StaticConcreteAction(
id, "coulomb-wentzel", "interact by Coulomb scattering (Wentzel)")
, imported_(data,
particles,
Expand All @@ -50,10 +50,10 @@ CoulombScatteringModel::CoulombScatteringModel(ActionId id,
data_.ids.electron = particles.find(pdg::electron());
data_.ids.positron = particles.find(pdg::positron());

CELER_VALIDATE(data_.ids,
<< "missing electron and/or positron particles (required "
"for "
<< this->description() << ")");
CELER_VALIDATE(
data_.ids,
<< R"(missing electron and/or positron particles (required for )"
<< this->description() << ")");

// Get high/low energy limits
energy_limit_
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/model/CoulombScatteringModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class IsotopeView;
/*!
* Set up and launch the Wentzel Coulomb scattering model interaction.
*/
class CoulombScatteringModel final : public Model, public ConcreteAction
class CoulombScatteringModel final : public Model, public StaticConcreteAction
{
public:
//!@{
Expand Down
7 changes: 4 additions & 3 deletions src/celeritas/em/model/EPlusGGModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ namespace celeritas
* Construct from model ID and other necessary data.
*/
EPlusGGModel::EPlusGGModel(ActionId id, ParticleParams const& particles)
: ConcreteAction(id,
"annihil-2-gamma",
"interact by positron annihilation yielding two gammas")
: StaticConcreteAction(
id,
"annihil-2-gamma",
R"(interact by positron annihilation yielding two gammas)")
{
CELER_EXPECT(id);
data_.positron = particles.find(pdg::positron());
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/model/EPlusGGModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace celeritas
/*!
* Set up and launch two-gamma positron annihiliation.
*/
class EPlusGGModel final : public Model, public ConcreteAction
class EPlusGGModel final : public Model, public StaticConcreteAction
{
public:
// Construct from model ID and other necessary data
Expand Down
4 changes: 2 additions & 2 deletions src/celeritas/em/model/ICRU73QOModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ namespace celeritas
* TODO: This model also applies to hadrons.
*/
ICRU73QOModel::ICRU73QOModel(ActionId id, ParticleParams const& particles)
: ConcreteAction(
id, "ioni-icru73qo", "interact by muon ionization (ICRU73QO)")
: StaticConcreteAction(
id, "ioni-icru73qo", "interact by muon ionization (ICRU73QO)")
{
CELER_EXPECT(id);

Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/model/ICRU73QOModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ParticleParams;
/*!
* Set up and launch the ICRU73QO ionization model interaction.
*/
class ICRU73QOModel final : public Model, public ConcreteAction
class ICRU73QOModel final : public Model, public StaticConcreteAction
{
public:
// Construct from model ID and other necessary data
Expand Down
10 changes: 5 additions & 5 deletions src/celeritas/em/model/KleinNishinaModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ namespace celeritas
*/
KleinNishinaModel::KleinNishinaModel(ActionId id,
ParticleParams const& particles)
: ConcreteAction(id,
"scat-klein-nishina",
"interact by Compton scattering (simple Klein-Nishina)")
: StaticConcreteAction(
id,
"scat-klein-nishina",
R"(interact by Compton scattering (simple Klein-Nishina))")
{
CELER_EXPECT(id);
data_.ids.electron = particles.find(pdg::electron());
data_.ids.gamma = particles.find(pdg::gamma());

CELER_VALIDATE(data_.ids.electron && data_.ids.gamma,
<< "missing electron, positron and/or gamma particles "
"(required for "
<< R"(missing electron and/or gamma particles (required for )"
<< this->description() << ")");
data_.inv_electron_mass = 1
/ value_as<KleinNishinaData::Mass>(
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/model/KleinNishinaModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace celeritas
/*!
* Set up and launch the Klein-Nishina model interaction.
*/
class KleinNishinaModel final : public Model, public ConcreteAction
class KleinNishinaModel final : public Model, public StaticConcreteAction
{
public:
// Construct from model ID and other necessary data
Expand Down
5 changes: 2 additions & 3 deletions src/celeritas/em/model/LivermorePEModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ LivermorePEModel::LivermorePEModel(ActionId id,
ParticleParams const& particles,
MaterialParams const& materials,
ReadData load_data)
: ConcreteAction(
: StaticConcreteAction(
id, "photoel-livermore", "interact by Livermore photoelectric effect")
{
CELER_EXPECT(id);
Expand All @@ -53,8 +53,7 @@ LivermorePEModel::LivermorePEModel(ActionId id,
host_data.ids.electron = particles.find(pdg::electron());
host_data.ids.gamma = particles.find(pdg::gamma());
CELER_VALIDATE(host_data.ids,
<< "missing electron and/or gamma particles "
"(required for "
<< R"(missing electron and/or gamma particles (required for )"
<< this->description() << ")");

// Save particle properties
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/model/LivermorePEModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ParticleParams;
/*!
* Set up and launch the Livermore photoelectric model interaction.
*/
class LivermorePEModel final : public Model, public ConcreteAction
class LivermorePEModel final : public Model, public StaticConcreteAction
{
public:
//!@{
Expand Down
10 changes: 5 additions & 5 deletions src/celeritas/em/model/MollerBhabhaModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ namespace celeritas
*/
MollerBhabhaModel::MollerBhabhaModel(ActionId id,
ParticleParams const& particles)
: ConcreteAction(
: StaticConcreteAction(
id, "ioni-moller-bhabha", "interact by Moller+Bhabha ionization")
{
CELER_EXPECT(id);
data_.ids.electron = particles.find(pdg::electron());
data_.ids.positron = particles.find(pdg::positron());

CELER_VALIDATE(data_.ids.electron && data_.ids.positron,
<< "missing electron and/or positron particles "
"(required for "
<< this->description() << ")");
CELER_VALIDATE(
data_.ids.electron && data_.ids.positron,
<< R"(missing electron and/or positron particles (required for )"
<< this->description() << ")");

data_.electron_mass = particles.get(data_.ids.electron).mass();

Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/model/MollerBhabhaModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ParticleParams;
/*!
* Set up and launch the Moller-Bhabha model interaction.
*/
class MollerBhabhaModel final : public Model, public ConcreteAction
class MollerBhabhaModel final : public Model, public StaticConcreteAction
{
public:
// Construct from model ID and other necessary data
Expand Down
6 changes: 3 additions & 3 deletions src/celeritas/em/model/MuBetheBlochModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ namespace celeritas
*/
MuBetheBlochModel::MuBetheBlochModel(ActionId id,
ParticleParams const& particles)
: ConcreteAction(id,
"ioni-mu-bethe-bloch",
"interact by muon ionization (Bethe-Bloch)")
: StaticConcreteAction(id,
"ioni-mu-bethe-bloch",
"interact by muon ionization (Bethe-Bloch)")
{
CELER_EXPECT(id);
data_.electron = particles.find(pdg::electron());
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/model/MuBetheBlochModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ParticleParams;
/*!
* Set up and launch the Bethe-Bloch muon ionization model interaction.
*/
class MuBetheBlochModel final : public Model, public ConcreteAction
class MuBetheBlochModel final : public Model, public StaticConcreteAction
{
public:
// Construct from model ID and other necessary data
Expand Down
3 changes: 2 additions & 1 deletion src/celeritas/em/model/MuBremsstrahlungModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ namespace celeritas
MuBremsstrahlungModel::MuBremsstrahlungModel(ActionId id,
ParticleParams const& particles,
SPConstImported data)
: ConcreteAction(id, "brems-muon", "interact by bremsstrahlung (muon)")
: StaticConcreteAction(
id, "brems-muon", "interact by bremsstrahlung (muon)")
, imported_(data,
particles,
ImportProcessClass::mu_brems,
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/model/MuBremsstrahlungModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace celeritas
/*!
* Set up and launch the Muon Bremsstrahlung model interaction.
*/
class MuBremsstrahlungModel final : public Model, public ConcreteAction
class MuBremsstrahlungModel final : public Model, public StaticConcreteAction
{
public:
//!@{
Expand Down
3 changes: 2 additions & 1 deletion src/celeritas/em/model/RayleighModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ RayleighModel::RayleighModel(ActionId id,
ParticleParams const& particles,
MaterialParams const& materials,
SPConstImported data)
: ConcreteAction(id, "scat-rayleigh", "interact by Rayleigh scattering")
: StaticConcreteAction(
id, "scat-rayleigh", "interact by Rayleigh scattering")
, imported_(data,
particles,
ImportProcessClass::rayleigh,
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/model/RayleighModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ParticleParams;
/*!
* Set up and launch Rayleigh scattering.
*/
class RayleighModel final : public Model, public ConcreteAction
class RayleighModel final : public Model, public StaticConcreteAction
{
public:
//@{
Expand Down
5 changes: 3 additions & 2 deletions src/celeritas/em/model/RelativisticBremModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ RelativisticBremModel::RelativisticBremModel(ActionId id,
MaterialParams const& materials,
SPConstImported data,
bool enable_lpm)
: ConcreteAction(id, "brems-rel", "interact by relativistic bremsstrahlung")
: StaticConcreteAction(
id, "brems-rel", "interact by relativistic bremsstrahlung")
, imported_(data,
particles,
ImportProcessClass::e_brems,
Expand All @@ -55,7 +56,7 @@ RelativisticBremModel::RelativisticBremModel(ActionId id,
host_ref.ids.gamma = particles.find(pdg::gamma());

CELER_VALIDATE(host_ref.ids,
<< "missing IDs (required for " << this->description()
<< "missing particles (required for " << this->description()
<< ")");

// Save particle properties
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/model/RelativisticBremModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ParticleParams;
* Set up and launch the relativistic Bremsstrahlung model for high-energy
* electrons and positrons with the Landau-Pomeranchuk-Migdal (LPM) effect
*/
class RelativisticBremModel final : public Model, public ConcreteAction
class RelativisticBremModel final : public Model, public StaticConcreteAction
{
public:
//@{
Expand Down
7 changes: 3 additions & 4 deletions src/celeritas/em/model/SeltzerBergerModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ SeltzerBergerModel::SeltzerBergerModel(ActionId id,
MaterialParams const& materials,
SPConstImported data,
ReadData load_sb_table)
: ConcreteAction(
: StaticConcreteAction(
id, "brems-sb", "interact by Seltzer-Berger bremsstrahlung")
, imported_(data,
particles,
Expand All @@ -64,9 +64,8 @@ SeltzerBergerModel::SeltzerBergerModel(ActionId id,
host_data.ids.positron = particles.find(pdg::positron());
host_data.ids.gamma = particles.find(pdg::gamma());
CELER_VALIDATE(host_data.ids,
<< "missing electron, positron, and/or gamma particles "
"(required for "
<< this->description() << ")");
<< "missing particles (required for " << this->description()
<< ")");

// Save particle properties
host_data.electron_mass = particles.get(host_data.ids.electron).mass();
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/model/SeltzerBergerModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ParticleParams;
* screened nuclei and orbital electrons of neutral atoms with Z = 1–100", At.
* Data Nucl. Data Tables 35, 345–418.
*/
class SeltzerBergerModel final : public Model, public ConcreteAction
class SeltzerBergerModel final : public Model, public StaticConcreteAction
{
public:
//!@{
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/geo/detail/BoundaryAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace detail
* Construct with action ID.
*/
BoundaryAction::BoundaryAction(ActionId aid)
: ConcreteAction(aid, "geo-boundary", "cross a geometry boundary")
: StaticConcreteAction(aid, "geo-boundary", "cross a geometry boundary")
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/geo/detail/BoundaryAction.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace detail
* Move a track across a boundary.
*/
class BoundaryAction final : public CoreStepActionInterface,
public ConcreteAction
public StaticConcreteAction
{
public:
// Construct with ID
Expand Down
8 changes: 4 additions & 4 deletions src/celeritas/global/CoreParams.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ ActionId find_along_step_id(ActionRegistry const& reg)
}

//---------------------------------------------------------------------------//
class PropagationLimitAction final : public ConcreteAction
class PropagationLimitAction final : public StaticConcreteAction
{
public:
//! Construct with ID
explicit PropagationLimitAction(ActionId id)
: ConcreteAction(id,
"geo-propagation-limit",
"pause due to propagation misbehavior")
: StaticConcreteAction(id,
"geo-propagation-limit",
"pause due to propagation misbehavior")
{
}
};
Expand Down
Loading

0 comments on commit 1e54371

Please sign in to comment.