Skip to content

Commit

Permalink
Moving ParticleID and ReactionID into the id namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
whaeck committed Jun 27, 2024
1 parent 0020c78 commit ba76e6f
Show file tree
Hide file tree
Showing 26 changed files with 122 additions and 118 deletions.
2 changes: 1 addition & 1 deletion python/src/ProjectileTarget.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void wrapProjectileTarget( python::module& module, python::module& ) {

// type aliases
using Component = njoy::dryad::ProjectileTarget;
using ParticleID = njoy::dryad::ParticleID;
using ParticleID = njoy::dryad::id::ParticleID;
using Reaction = njoy::dryad::Reaction;
using ToleranceConvergence = njoy::dryad::ToleranceConvergence;
using InteractionType = njoy::dryad::InteractionType;
Expand Down
2 changes: 1 addition & 1 deletion python/src/Reaction.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void wrapReaction( python::module& module, python::module& ) {

// type aliases
using Component = njoy::dryad::Reaction;
using ReactionID = njoy::dryad::ReactionID;
using ReactionID = njoy::dryad::id::ReactionID;
using ReactionType = njoy::dryad::ReactionType;
using ReactionProduct = njoy::dryad::ReactionProduct;
using TabulatedCrossSection = njoy::dryad::TabulatedCrossSection;
Expand Down
2 changes: 1 addition & 1 deletion python/src/ReactionProduct.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void wrapReactionProduct( python::module& module, python::module& ) {

// type aliases
using Component = njoy::dryad::ReactionProduct;
using ParticleID = njoy::dryad::ParticleID;
using ParticleID = njoy::dryad::id::ParticleID;
using Multiplicity = njoy::dryad::ReactionProduct::Multiplicity;
using ToleranceConvergence = njoy::dryad::ToleranceConvergence;

Expand Down
14 changes: 7 additions & 7 deletions src/dryad/ProjectileTarget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// other includes
#include "dryad/type-aliases.hpp"
#include "dryad/InteractionType.hpp"
#include "dryad/ParticleID.hpp"
#include "dryad/Reaction.hpp"
#include "dryad/id/ParticleID.hpp"
#include "dryad/resonances/ResonanceParameters.hpp"

namespace njoy {
Expand All @@ -21,8 +21,8 @@ namespace dryad {
class ProjectileTarget {

/* fields */
ParticleID projectile_id_;
ParticleID target_id_;
id::ParticleID projectile_id_;
id::ParticleID target_id_;

InteractionType interaction_;

Expand All @@ -41,15 +41,15 @@ namespace dryad {
/**
* @brief Return the projectile identifier
*/
const ParticleID& projectileIdentifier() const noexcept {
const id::ParticleID& projectileIdentifier() const noexcept {

return this->projectile_id_;
}

/**
* @brief Return the target identifier
*/
const ParticleID& targetIdentifier() const noexcept {
const id::ParticleID& targetIdentifier() const noexcept {

return this->target_id_;
}
Expand Down Expand Up @@ -83,7 +83,7 @@ namespace dryad {
*
* @param[in] id the reaction identifier
*/
bool hasReaction( const ReactionID& id ) const {
bool hasReaction( const id::ReactionID& id ) const {

auto iter = std::find_if( this->reactions().begin(),
this->reactions().end(),
Expand All @@ -97,7 +97,7 @@ namespace dryad {
*
* @param[in] id the reaction identifier
*/
const Reaction& reaction( const ReactionID& id ) const {
const Reaction& reaction( const id::ReactionID& id ) const {

auto iter = std::find_if( this->reactions().begin(),
this->reactions().end(),
Expand Down
4 changes: 2 additions & 2 deletions src/dryad/ProjectileTarget/src/ctor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @param linearised a flag indicating whether or not the data is
* linearised
*/
ProjectileTarget( ParticleID&& projectile, ParticleID&& target,
ProjectileTarget( id::ParticleID&& projectile, id::ParticleID&& target,
InteractionType type,
std::optional< resonances::ResonanceParameters > resonances,
std::vector< Reaction >&& reactions,
Expand All @@ -34,7 +34,7 @@ ProjectileTarget& operator=( ProjectileTarget&& ) = default;
* @param target the target identifier
* @param reactions the reaction data
*/
ProjectileTarget( ParticleID projectile, ParticleID target,
ProjectileTarget( id::ParticleID projectile, id::ParticleID target,
InteractionType type,
std::vector< Reaction > reactions ) :
ProjectileTarget( std::move( projectile ),
Expand Down
38 changes: 19 additions & 19 deletions src/dryad/ProjectileTarget/test/ProjectileTarget.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ SCENARIO( "ProjectileTarget" ) {

WHEN( "the data is given explicitly" ) {

ParticleID projectile( "n" );
ParticleID target( "Fe56" );
id::ParticleID projectile( "n" );
id::ParticleID target( "Fe56" );

InteractionType type = InteractionType::Nuclear;

std::vector< Reaction > reactions = {

Reaction( ReactionID( "n,Fe56->n,Fe56" ), ReactionType::Primary,
Reaction( id::ReactionID( "n,Fe56->n,Fe56" ), ReactionType::Primary,
TabulatedCrossSection( { 1e-5, 20. }, { 1000., 10. },
InterpolationType::LogLinear ),
{},
0, 0 ),
Reaction( ReactionID( "n,Fe56->n,Fe56_e1" ), ReactionType::Primary,
Reaction( id::ReactionID( "n,Fe56->n,Fe56_e1" ), ReactionType::Primary,
TabulatedCrossSection( { 1., 20. }, { 0., 100. },
InterpolationType::LinearLinear ),
{},
Expand Down Expand Up @@ -68,8 +68,8 @@ SCENARIO( "ProjectileTarget" ) {
void verifyChunk( const ProjectileTarget& chunk ) {

// identifiers
CHECK( ParticleID( "n" ) == chunk.projectileIdentifier() );
CHECK( ParticleID( "Fe56" ) == chunk.targetIdentifier() );
CHECK( id::ParticleID( "n" ) == chunk.projectileIdentifier() );
CHECK( id::ParticleID( "Fe56" ) == chunk.targetIdentifier() );

// interaction type
CHECK( InteractionType::Nuclear == chunk.interactionType() );
Expand All @@ -78,13 +78,13 @@ void verifyChunk( const ProjectileTarget& chunk ) {
CHECK( std::nullopt == chunk.resonances() );

// reactions are present
CHECK( true == chunk.hasReaction( ReactionID( "n,Fe56->n,Fe56" ) ) );
CHECK( true == chunk.hasReaction( ReactionID( "n,Fe56->n,Fe56_e1" ) ) );
CHECK( false == chunk.hasReaction( ReactionID( "some unknown reaction" ) ) );
CHECK( true == chunk.hasReaction( id::ReactionID( "n,Fe56->n,Fe56" ) ) );
CHECK( true == chunk.hasReaction( id::ReactionID( "n,Fe56->n,Fe56_e1" ) ) );
CHECK( false == chunk.hasReaction( id::ReactionID( "some unknown reaction" ) ) );

// reactions
auto reaction = chunk.reactions()[0];
CHECK( ReactionID( "n,Fe56->n,Fe56" ) == reaction.identifier() );
CHECK( id::ReactionID( "n,Fe56->n,Fe56" ) == reaction.identifier() );
CHECK( ReactionType::Primary == reaction.type() );
CHECK( false == reaction.hasProducts() );
CHECK( false == reaction.isLinearised() );
Expand All @@ -104,7 +104,7 @@ void verifyChunk( const ProjectileTarget& chunk ) {
CHECK( InterpolationType::LogLinear == reaction.crossSection().interpolants()[0] );
CHECK( false == reaction.crossSection().isLinearised() );
reaction = chunk.reactions()[1];
CHECK( ReactionID( "n,Fe56->n,Fe56_e1" ) == reaction.identifier() );
CHECK( id::ReactionID( "n,Fe56->n,Fe56_e1" ) == reaction.identifier() );
CHECK_THAT( 0, WithinRel( reaction.massDifferenceQValue().value() ) );
CHECK_THAT( -1, WithinRel( reaction.reactionQValue().value() ) );
CHECK( false == reaction.hasProducts() );
Expand All @@ -124,8 +124,8 @@ void verifyChunk( const ProjectileTarget& chunk ) {
CHECK( true == reaction.crossSection().isLinearised() );

// reaction
reaction = chunk.reaction( ReactionID( "n,Fe56->n,Fe56" ) );
CHECK( ReactionID( "n,Fe56->n,Fe56" ) == reaction.identifier() );
reaction = chunk.reaction( id::ReactionID( "n,Fe56->n,Fe56" ) );
CHECK( id::ReactionID( "n,Fe56->n,Fe56" ) == reaction.identifier() );
CHECK( ReactionType::Primary == reaction.type() );
CHECK( false == reaction.hasProducts() );
CHECK( false == reaction.isLinearised() );
Expand All @@ -144,8 +144,8 @@ void verifyChunk( const ProjectileTarget& chunk ) {
CHECK( 1 == reaction.crossSection().boundaries()[0] );
CHECK( InterpolationType::LogLinear == reaction.crossSection().interpolants()[0] );
CHECK( false == reaction.crossSection().isLinearised() );
reaction = chunk.reaction( ReactionID( "n,Fe56->n,Fe56_e1" ) );
CHECK( ReactionID( "n,Fe56->n,Fe56_e1" ) == reaction.identifier() );
reaction = chunk.reaction( id::ReactionID( "n,Fe56->n,Fe56_e1" ) );
CHECK( id::ReactionID( "n,Fe56->n,Fe56_e1" ) == reaction.identifier() );
CHECK_THAT( 0, WithinRel( reaction.massDifferenceQValue().value() ) );
CHECK_THAT( -1, WithinRel( reaction.reactionQValue().value() ) );
CHECK( 2 == reaction.crossSection().numberPoints() );
Expand All @@ -169,15 +169,15 @@ void verifyChunk( const ProjectileTarget& chunk ) {
void verifyLinearisedChunk( const ProjectileTarget& chunk ) {

// identifiers
CHECK( ParticleID( "n" ) == chunk.projectileIdentifier() );
CHECK( ParticleID( "Fe56" ) == chunk.targetIdentifier() );
CHECK( id::ParticleID( "n" ) == chunk.projectileIdentifier() );
CHECK( id::ParticleID( "Fe56" ) == chunk.targetIdentifier() );

// resonances are not present
CHECK( std::nullopt == chunk.resonances() );

// reactions
auto reaction = chunk.reactions()[0];
CHECK( ReactionID( "n,Fe56->n,Fe56" ) == reaction.identifier() );
CHECK( id::ReactionID( "n,Fe56->n,Fe56" ) == reaction.identifier() );
CHECK( ReactionType::Primary == reaction.type() );
CHECK_THAT( 0, WithinRel( reaction.massDifferenceQValue().value() ) );
CHECK_THAT( 0, WithinRel( reaction.reactionQValue().value() ) );
Expand All @@ -201,7 +201,7 @@ void verifyLinearisedChunk( const ProjectileTarget& chunk ) {
CHECK( InterpolationType::LinearLinear == reaction.crossSection().interpolants()[0] );
CHECK( true == reaction.crossSection().isLinearised() );
reaction = chunk.reactions()[1];
CHECK( ReactionID( "n,Fe56->n,Fe56_e1" ) == reaction.identifier() );
CHECK( id::ReactionID( "n,Fe56->n,Fe56_e1" ) == reaction.identifier() );
CHECK( ReactionType::Primary == reaction.type() );
CHECK( false == reaction.hasProducts() );
CHECK( true == reaction.isLinearised() );
Expand Down
6 changes: 3 additions & 3 deletions src/dryad/Reaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

// other includes
#include "dryad/type-aliases.hpp"
#include "dryad/ReactionID.hpp"
#include "dryad/id/ReactionID.hpp"
#include "dryad/ReactionType.hpp"
#include "dryad/ReactionProduct.hpp"
#include "dryad/TabulatedCrossSection.hpp"
Expand All @@ -23,7 +23,7 @@ namespace dryad {
class Reaction {

/* fields */
ReactionID id_;
id::ReactionID id_;

ReactionType type_;

Expand All @@ -45,7 +45,7 @@ namespace dryad {
/**
* @brief Return the reaction identifier
*/
const ReactionID& identifier() const noexcept {
const id::ReactionID& identifier() const noexcept {

return this->id_;
}
Expand Down
4 changes: 2 additions & 2 deletions src/dryad/Reaction/src/ctor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @param linearised a flag indicating whether or not the data is
* linearised
*/
Reaction( ReactionID&& id,
Reaction( id::ReactionID&& id,
ReactionType&& type,
TabulatedCrossSection&& xs,
std::vector< ReactionProduct >&& products,
Expand Down Expand Up @@ -41,7 +41,7 @@ Reaction& operator=( Reaction&& ) = default;
* @param mass_q the mass difference Q value
* @param reaction_q the reaction Q value
*/
Reaction( ReactionID id,
Reaction( id::ReactionID id,
ReactionType type,
TabulatedCrossSection xs,
std::vector< ReactionProduct > products = {},
Expand Down
8 changes: 4 additions & 4 deletions src/dryad/Reaction/test/Reaction.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SCENARIO( "Reaction" ) {

WHEN( "the data is given explicitly" ) {

ReactionID id( "n,Fe56->n,Fe56_e1" );
id::ReactionID id( "n,Fe56->n,Fe56_e1" );
ReactionType type = ReactionType::Primary;
TabulatedCrossSection xs( { 1., 2., 2., 3., 4. },
{ 4., 3., 4., 3., 2. },
Expand Down Expand Up @@ -61,7 +61,7 @@ SCENARIO( "Reaction" ) {

WHEN( "the data is given explicitly" ) {

ReactionID id( "n,Fe56->total" );
id::ReactionID id( "n,Fe56->total" );
ReactionType type = ReactionType::Summation;
TabulatedCrossSection xs( { 1., 2., 2., 3., 4. },
{ 4., 3., 4., 3., 2. },
Expand Down Expand Up @@ -97,7 +97,7 @@ SCENARIO( "Reaction" ) {
void verifyChunk( const Reaction& chunk ) {

// reaction identifier
CHECK( ReactionID( "n,Fe56->n,Fe56_e1" ) == chunk.identifier() );
CHECK( id::ReactionID( "n,Fe56->n,Fe56_e1" ) == chunk.identifier() );

// reaction type
CHECK( ReactionType::Primary == chunk.type() );
Expand Down Expand Up @@ -180,7 +180,7 @@ void verifyLinearisedChunk( const Reaction& chunk ) {
void verifySummationChunk( const Reaction& chunk ) {

// reaction identifier
CHECK( ReactionID( "n,Fe56->total" ) == chunk.identifier() );
CHECK( id::ReactionID( "n,Fe56->total" ) == chunk.identifier() );

// reaction type
CHECK( ReactionType::Summation == chunk.type() );
Expand Down
6 changes: 3 additions & 3 deletions src/dryad/ReactionProduct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// other includes
#include "tools/overload.hpp"
#include "dryad/type-aliases.hpp"
#include "dryad/ParticleID.hpp"
#include "dryad/id/ParticleID.hpp"
#include "dryad/TabulatedMultiplicity.hpp"

namespace njoy {
Expand All @@ -27,7 +27,7 @@ namespace dryad {
private:

/* fields */
ParticleID id_;
id::ParticleID id_;

Multiplicity multiplicity_;
bool linearised_;
Expand All @@ -42,7 +42,7 @@ namespace dryad {
/**
* @brief Return the particle identifier for the reaction product
*/
const ParticleID& identifier() const noexcept {
const id::ParticleID& identifier() const noexcept {

return this->id_;
}
Expand Down
4 changes: 2 additions & 2 deletions src/dryad/ReactionProduct/src/ctor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @param linearised a flag indicating whether or not the data is
* linearised
*/
ReactionProduct( ParticleID&& id,
ReactionProduct( id::ParticleID&& id,
Multiplicity&& multiplicity, bool linearised ) :
id_( std::move( id ) ), multiplicity_( std::move( multiplicity ) ),
linearised_( linearised ) {}
Expand All @@ -25,7 +25,7 @@ ReactionProduct& operator=( ReactionProduct&& ) = default;
* @param id the reaction product identifier
* @param multiplicity the reaction product multiplicity
*/
ReactionProduct( ParticleID id,
ReactionProduct( id::ParticleID id,
Multiplicity multiplicity ) :
ReactionProduct( std::move( id ),
std::move( multiplicity ),
Expand Down
10 changes: 5 additions & 5 deletions src/dryad/ReactionProduct/test/ReactionProduct.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SCENARIO( "ReactionProduct" ) {

WHEN( "the data is given explicitly" ) {

ParticleID id( "n" );
id::ParticleID id( "n" );
int multiplicity = 1;

ReactionProduct chunk( std::move( id ), std::move( multiplicity ) );
Expand Down Expand Up @@ -52,7 +52,7 @@ SCENARIO( "ReactionProduct" ) {

WHEN( "the data is given explicitly" ) {

ParticleID id( "n" );
id::ParticleID id( "n" );
TabulatedMultiplicity multiplicity( { 1., 2., 2., 3., 4. },
{ 4., 3., 4., 3., 2. },
{ 1, 4 },
Expand Down Expand Up @@ -87,7 +87,7 @@ SCENARIO( "ReactionProduct" ) {
void verifyChunk( const ReactionProduct& chunk ) {

// ReactionProduct identifier
CHECK( ParticleID( "n" ) == chunk.identifier() );
CHECK( id::ParticleID( "n" ) == chunk.identifier() );

// multiplicity
auto multiplicity = chunk.multiplicity();
Expand All @@ -101,7 +101,7 @@ void verifyChunk( const ReactionProduct& chunk ) {
void verifyTabulatedChunk( const ReactionProduct& chunk ) {

// ReactionProduct identifier
CHECK( ParticleID( "n" ) == chunk.identifier() );
CHECK( id::ParticleID( "n" ) == chunk.identifier() );

// multiplicity
CHECK( true == std::holds_alternative< TabulatedMultiplicity >( chunk.multiplicity() ) );
Expand Down Expand Up @@ -135,7 +135,7 @@ void verifyTabulatedChunk( const ReactionProduct& chunk ) {
void verifyTabulatedLinearisedChunk( const ReactionProduct& chunk ) {

// ReactionProduct identifier
CHECK( ParticleID( "n" ) == chunk.identifier() );
CHECK( id::ParticleID( "n" ) == chunk.identifier() );

// multiplicity
CHECK( true == std::holds_alternative< TabulatedMultiplicity >( chunk.multiplicity() ) );
Expand Down
Loading

0 comments on commit ba76e6f

Please sign in to comment.