diff --git a/corsika/detail/framework/process/BoundaryCrossingProcess.hpp b/corsika/detail/framework/process/BoundaryCrossingProcess.hpp index 1e9f7b869ce063971e1df8f13ae74b35a57a26d8..1efd36454579d35b31d9f97421c42ca42a31674c 100644 --- a/corsika/detail/framework/process/BoundaryCrossingProcess.hpp +++ b/corsika/detail/framework/process/BoundaryCrossingProcess.hpp @@ -40,10 +40,10 @@ namespace corsika { static decltype(testSignature(&T::doBoundaryCrossing)) test(std::nullptr_t); public: - /** - @name traits results - @{ - */ + /** + @name traits results + @{ + */ using type = decltype(test<std::decay_t<TProcess>>(nullptr)); static const bool value = type::value; //! @} @@ -51,7 +51,7 @@ namespace corsika { //! @file BoundaryCrossingProcess.hpp //! value traits type - + template <class TProcess, typename TReturn, typename TParticle> bool constexpr has_method_doBoundaryCrossing_v = has_method_doBoundaryCrossing<TProcess, TReturn, TParticle>::value; diff --git a/corsika/detail/framework/process/ContinuousProcess.hpp b/corsika/detail/framework/process/ContinuousProcess.hpp index 6827ac3c9818d24b5842c0ac0886799824614b21..451f45a68be3c592e3ac4d68e58f78cab7f682d3 100644 --- a/corsika/detail/framework/process/ContinuousProcess.hpp +++ b/corsika/detail/framework/process/ContinuousProcess.hpp @@ -36,10 +36,10 @@ namespace corsika { static decltype(testSignature(&T::doContinuous)) test(std::nullptr_t); public: - /** - @name traits results - @{ - */ + /** + @name traits results + @{ + */ using type = decltype(test<std::decay_t<TProcess>>(nullptr)); static const bool value = type::value; //! @} @@ -51,7 +51,6 @@ namespace corsika { bool constexpr has_method_doContinuous_v = has_method_doContinuous<TProcess, TReturn, TArg1, TArg2>::value; - /** traits test for ContinuousProcess::getMaxStepLength method */ @@ -77,10 +76,10 @@ namespace corsika { static decltype(testSignature(&T::getMaxStepLength)) test(std::nullptr_t); public: - /** - @name traits results - @{ - */ + /** + @name traits results + @{ + */ using type = decltype(test<std::decay_t<TProcess>>(nullptr)); static const bool value = type::value; //! @} diff --git a/corsika/detail/framework/process/DecayProcess.hpp b/corsika/detail/framework/process/DecayProcess.hpp index 35bf56e771c9d2df49bf20e70dbf1f8f7677f89b..b5664418a4d6db1692be00294c82d7e224782dbc 100644 --- a/corsika/detail/framework/process/DecayProcess.hpp +++ b/corsika/detail/framework/process/DecayProcess.hpp @@ -38,10 +38,10 @@ namespace corsika { static decltype(testSignature(&T::doDecay)) test(std::nullptr_t); public: - /** - @name traits results - @{ - */ + /** + @name traits results + @{ + */ using type = decltype(test<process_type>(nullptr)); static const bool value = type::value; //! @} @@ -67,7 +67,7 @@ namespace corsika { template <class T> static std::false_type test(...); - //! signature of templated method + //! signature of templated method template <class T> static decltype(testSignature(&T::template getLifetime<TArgs...>)) test( std::nullptr_t); @@ -77,10 +77,10 @@ namespace corsika { static decltype(testSignature(&T::getLifetime)) test(std::nullptr_t); public: - /** - @name traits results - @{ - */ + /** + @name traits results + @{ + */ using type = decltype(test<std::decay_t<TProcess>>(nullptr)); static const bool value = type::value; //! @} diff --git a/corsika/detail/framework/process/InteractionProcess.hpp b/corsika/detail/framework/process/InteractionProcess.hpp index 1de29c1f8a90a8174402e541e37cc5f32e7924cf..8fb157a688c8c4828ea5c0b3eff410af9ad9aa76 100644 --- a/corsika/detail/framework/process/InteractionProcess.hpp +++ b/corsika/detail/framework/process/InteractionProcess.hpp @@ -36,10 +36,10 @@ namespace corsika { static decltype(testSignature(&T::doInteraction)) test(std::nullptr_t); public: - /** - @name traits results - @{ - */ + /** + @name traits results + @{ + */ using type = decltype(test<std::decay_t<TProcess>>(nullptr)); static const bool value = type::value; //! @} @@ -51,7 +51,6 @@ namespace corsika { bool constexpr has_method_doInteract_v = has_method_doInteract<TProcess, TReturn, TArgs...>::value; - /** traits test for InteractionProcess::getInteractionLength method */ @@ -77,10 +76,10 @@ namespace corsika { static decltype(testSignature(&T::getInteractionLength)) test(std::nullptr_t); public: - /** - @name traits results - @{ - */ + /** + @name traits results + @{ + */ using type = decltype(test<std::decay_t<TProcess>>(nullptr)); static const bool value = type::value; //! @} @@ -88,9 +87,9 @@ namespace corsika { //! @file BoundaryCrossingProcess.hpp //! value traits type - + template <class TProcess, typename TReturn, typename... TArgs> bool constexpr has_method_getInteractionLength_v = has_method_getInteractionLength<TProcess, TReturn, TArgs...>::value; - + } // namespace corsika diff --git a/corsika/detail/framework/process/SecondariesProcess.hpp b/corsika/detail/framework/process/SecondariesProcess.hpp index 4a1d42e619310b5f3317e425f498ebabb8363709..0310bf3dfa2b73826c10c2ad25bf4eb2d4ab5a21 100644 --- a/corsika/detail/framework/process/SecondariesProcess.hpp +++ b/corsika/detail/framework/process/SecondariesProcess.hpp @@ -36,10 +36,10 @@ namespace corsika { static decltype(testSignature(&T::doSecondaries)) test(std::nullptr_t); public: - /** - @name traits results - @{ - */ + /** + @name traits results + @{ + */ using type = decltype(test<std::decay_t<TProcess>>(nullptr)); static const bool value = type::value; //! @} diff --git a/corsika/detail/framework/process/StackProcess.hpp b/corsika/detail/framework/process/StackProcess.hpp index 4222c4f9667483c42dab1f74d66f1fcb9ca70cee..68f350adf1bd1db6cc2be74b329e6a4824b2df07 100644 --- a/corsika/detail/framework/process/StackProcess.hpp +++ b/corsika/detail/framework/process/StackProcess.hpp @@ -39,10 +39,10 @@ namespace corsika { static decltype(testSignature(&T::doStack)) test(std::nullptr_t); public: - /** - @name traits results - @{ - */ + /** + @name traits results + @{ + */ using type = decltype(test<std::decay_t<TProcess>>(nullptr)); static const bool value = type::value; //! @} diff --git a/tests/framework/testProcessSequence.cpp b/tests/framework/testProcessSequence.cpp index 58be1f358f59b7da6a66a7d2694edb6eb2855032..85c0506450d83f53deac927389c59f29e9908d60 100644 --- a/tests/framework/testProcessSequence.cpp +++ b/tests/framework/testProcessSequence.cpp @@ -21,7 +21,6 @@ #include <boost/type_index.hpp> - /* Unit test for testing all Process types and their arrangement in containers ProcessSequence and SwitchProcessSequence @@ -34,7 +33,8 @@ static int const nData = 10; // DummyNode is only needed for BoundaryCrossingProcess struct DummyNode { - DummyNode(int v) : data_(v) {} + DummyNode(int v) + : data_(v) {} int data_ = 0; }; @@ -59,7 +59,6 @@ struct DummyView { DummyData& parent() { return p_; } }; - int globalCount = 0; // simple counter int checkDecay = 0; // use this as a bit field @@ -334,20 +333,21 @@ private: class Boundary1 : public BoundaryCrossingProcess<Boundary1> { public: - Boundary1(double const v=1.0) : v_(v) {} - + Boundary1(double const v = 1.0) + : v_(v) {} + template <typename Particle> ProcessReturn doBoundaryCrossing(Particle& p, typename Particle::node_type const& from, typename Particle::node_type const& to) { - for (int i = 0; i < nData; ++i) { p.data_[i] += v_*(from.data_ - to.data_); } + for (int i = 0; i < nData; ++i) { p.data_[i] += v_ * (from.data_ - to.data_); } return ProcessReturn::Ok; } + private: double v_ = 0.0; }; - TEST_CASE("ProcessSequence General", "ProcessSequence") { logging::set_level(logging::level::info); @@ -537,9 +537,11 @@ TEST_CASE("ProcessSequence General", "ProcessSequence") { DummyData particle; DummyNode node_from(5); DummyNode node_to(4); - + int const nLoop = 20; - for (int i = 0; i < nLoop; ++i) { sequence1.doBoundaryCrossing(particle, node_from, node_to); } + for (int i = 0; i < nLoop; ++i) { + sequence1.doBoundaryCrossing(particle, node_from, node_to); + } for (int i = 0; i < nData; i++) { CORSIKA_LOG_DEBUG("data_[{}]={}", i, particle.data_[i]); @@ -550,7 +552,6 @@ TEST_CASE("ProcessSequence General", "ProcessSequence") { CHECK(contains_stack_process_v<decltype(sequence1)> == false); CHECK(count_processes<decltype(sequence1)>::count == 1); } - } TEST_CASE("SwitchProcessSequence", "ProcessSequence") { @@ -581,15 +582,17 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") { auto sequence3 = make_sequence(cp1, Process3(0), SwitchProcessSequence(sequence1, sequence2, select1)); - auto sequence4 = make_sequence(cp1, Boundary1(2.0), Process3(0), - SwitchProcessSequence(sequence1, Boundary1(-1.0), select1)); + auto sequence4 = + make_sequence(cp1, Boundary1(2.0), Process3(0), + SwitchProcessSequence(sequence1, Boundary1(-1.0), select1)); SECTION("Check construction") { - auto sequence_alt = - make_sequence(cp1, Process3(0), - make_select(make_sequence(Process1(0), cp2, Decay1(0), Boundary1(1.0)), - make_sequence(cp3, Process2(0), Boundary1(-1.0), Decay2(0)), select1)); + auto sequence_alt = make_sequence( + cp1, Process3(0), + make_select(make_sequence(Process1(0), cp2, Decay1(0), Boundary1(1.0)), + make_sequence(cp3, Process2(0), Boundary1(-1.0), Decay2(0)), + select1)); auto switch_seq = SwitchProcessSequence(sequence1, sequence2, select1); CHECK(is_process_sequence_v<decltype(switch_seq)>); @@ -699,10 +702,10 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") { sequence4.selectDecay(view, time_select); sequence4.doSecondaries(view); CHECK(checkInteract == 0); - CHECK(checkDecay == 0); + CHECK(checkDecay == 0); CHECK(checkCont == 0); CHECK(checkSec == 0); - + // check that large "select" value will correctly ignore the call lambda_select = 1e5 * square(1_cm) / 1_g; time_select = 1e5 / second; @@ -815,14 +818,13 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") { sequence4.doBoundaryCrossing(particle, node_from, node_to); CHECK(particle.data_[0] == 97); // 100 - 2*1 - 1*1 - + particle.data_[0] = -100; // data positive, selects particular branch on SwitchProcessSequence sequence4.doBoundaryCrossing(particle, node_from, node_to); CHECK(particle.data_[0] == -101); // -100 - 2*1 + 1*1 } - } TEST_CASE("ProcessSequence Indexing", "ProcessSequence") {