IAP GITLAB

Skip to content
Snippets Groups Projects
Commit ac5a7044 authored by Maximilian Reininghaus's avatar Maximilian Reininghaus :vulcan:
Browse files

adapt NullModel to current ContinuousProcess interface

parent eddce42b
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@
#define _include_corsika_continuousprocess_h_
#include <corsika/process/ProcessReturn.h> // for convenience
#include <corsika/units/PhysicalUnits.h>
//#include <corsika/setup/SetupTrajectory.h>
namespace corsika::process {
......@@ -33,8 +34,12 @@ namespace corsika::process {
// here starts the interface part
// -> enforce derived to implement DoContinuous...
template <typename P, typename T, typename S>
inline EProcessReturn DoContinuous(P&, T&, S&) const;
template <typename Particle, typename Track, typename Stack>
EProcessReturn DoContinuous(Particle&, Track&, Stack&) const;
// -> enforce derived to implement MaxStepLength...
template <typename Particle, typename Track>
corsika::units::si::LengthType MaxStepLength(Particle& p, Track& track) const;
};
} // namespace corsika::process
......
......@@ -29,14 +29,13 @@ namespace corsika::process {
template <typename derived>
struct DecayProcess {
derived& GetRef() { return static_cast<derived&>(*this); }
const derived& GetRef() const { return static_cast<const derived&>(*this); }
/// here starts the interface-definition part
// -> enforce derived to implement DoDecay...
template <typename Particle, typename Stack>
inline EProcessReturn DoDecay(Particle&, Stack&) const;
EProcessReturn DoDecay(Particle&, Stack&) const;
template <typename Particle>
corsika::units::si::TimeType GetLifetime(Particle& p) const;
......
......@@ -176,8 +176,9 @@ namespace corsika::process {
template <typename Particle, typename Track>
corsika::units::si::LengthType MaxStepLength(Particle& p, Track& track) const {
corsika::units::si::LengthType max_length =
corsika::units::si::LengthType max_length = // if no other process in the sequence implements it
std::numeric_limits<double>::infinity() * corsika::units::si::meter;
if constexpr (std::is_base_of<ContinuousProcess<T1>, T1>::value ||
is_process_sequence<T1>::value) {
corsika::units::si::LengthType const len = A.MaxStepLength(p, track);
......
/**
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
......@@ -11,37 +10,4 @@
#include <corsika/process/null_model/NullModel.h>
#include <corsika/logging/Logger.h>
#include <corsika/setup/SetupTrajectory.h>
#include <iostream>
#include <limits>
using namespace std;
using namespace corsika;
using namespace corsika::units::si;
using namespace corsika::process::null_model;
template <typename Stack>
NullModel<Stack>::NullModel() {}
template <typename Stack>
NullModel<Stack>::~NullModel() {}
template <typename Stack>
process::EProcessReturn NullModel<Stack>::DoContinuous(Particle&, setup::Trajectory&,
Stack&) const {
return EProcessReturn::eOk;
}
template <typename Stack>
double NullModel<Stack>::MaxStepLength(Particle&, setup::Trajectory&) const {
return std::numeric_limits<double>::infinity();
}
template <typename Stack>
void NullModel<Stack>::Init() {}
#include <corsika/setup/SetupStack.h>
template class process::null_model::NullModel<setup::Stack>;
void corsika::process::null_model::NullModel::Init() {}
/**
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
......@@ -15,26 +14,29 @@
#include <corsika/process/ContinuousProcess.h>
#include <corsika/setup/SetupTrajectory.h>
namespace corsika::process {
namespace null_model {
namespace corsika::process::null_model {
template <typename Stack>
class NullModel {
class NullModel : public corsika::process::ContinuousProcess<NullModel> {
corsika::units::si::LengthType fMaxStepLength{
corsika::units::si::meter * std::numeric_limits<double>::infinity()};
typedef typename Stack::ParticleType Particle;
public:
NullModel(corsika::units::si::LengthType maxStepLength)
: fMaxStepLength(maxStepLength) {}
public:
NullModel();
~NullModel();
void Init();
void Init();
EProcessReturn DoContinuous(Particle&, corsika::setup::Trajectory&, Stack& s) const;
double MaxStepLength(Particle&, corsika::setup::Trajectory&) const;
};
template <typename Particle, typename Track, typename Stack>
process::EProcessReturn DoContinuous(Particle&, Track&, Stack&) const {
return EProcessReturn::eOk;
}
} // namespace null_model
template <typename Particle, typename Track>
corsika::units::si::LengthType MaxStepLength(Particle&, Track&) const {
return fMaxStepLength;
}
};
} // namespace corsika::process
} // namespace corsika::process::null_model
#endif
......@@ -43,11 +43,13 @@ TEST_CASE("NullModel", "[processes]") {
SECTION("interface") {
NullModel<setup::Stack> model;
NullModel model(10_m);
model.Init();
[[maybe_unused]] const process::EProcessReturn ret =
model.DoContinuous(particle, track, stack);
[[maybe_unused]] const double length = model.MaxStepLength(particle, track);
LengthType const length = model.MaxStepLength(particle, track);
CHECK((length / 10_m) == Approx(1));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment