From 0283fb7b11c89cfcc5c6776f3845cdba326aaef7 Mon Sep 17 00:00:00 2001 From: Nikos Karastathis <n.karastathis@kit.edu> Date: Tue, 21 Dec 2021 12:50:41 +0100 Subject: [PATCH] add test stack files used only in unit tests --- tests/common/SetupStack.hpp | 41 ++++++++++++++++++++++++ tests/common/TestStack.hpp | 64 +++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 tests/common/SetupStack.hpp create mode 100644 tests/common/TestStack.hpp diff --git a/tests/common/SetupStack.hpp b/tests/common/SetupStack.hpp new file mode 100644 index 000000000..67715c8d0 --- /dev/null +++ b/tests/common/SetupStack.hpp @@ -0,0 +1,41 @@ +/* +* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu +* +* This software is distributed under the terms of the GNU General Public +* Licence version 3 (GPL Version 3). See file LICENSE for a full version of +* the license. + */ + +#include <tests/common/TestStack.hpp> + +#include <array> +#include <memory> + +namespace corsika::test { + + // --------------------------------------- + // this is the stack we use in C8 executables: + +#ifdef WITH_HISTORY + +#include <corsika/stack/history/HistoryStackExtension.hpp> +#include <corsika/stack/history/HistorySecondaryProducer.hpp> + + /* + * the version with history + */ + using Stack = detaill::StackWithHistory; + +#else // WITH_HISTORY + + /* + * the version without history + */ + using Stack = detail::StackWithGeometry; + +#endif + + // the correct secondary stack view + using StackView = typename Stack::stack_view_type; + +} // namespace corsika::test \ No newline at end of file diff --git a/tests/common/TestStack.hpp b/tests/common/TestStack.hpp new file mode 100644 index 000000000..6e93f8d77 --- /dev/null +++ b/tests/common/TestStack.hpp @@ -0,0 +1,64 @@ +/* +* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu +* +* This software is distributed under the terms of the GNU General Public +* Licence version 3 (GPL Version 3). See file LICENSE for a full version of +* the license. + */ + +#pragma once + +#include <corsika/framework/stack/CombinedStack.hpp> +#include <corsika/stack/GeometryNodeStackExtension.hpp> +#include <corsika/stack/VectorStack.hpp> +#include <corsika/stack/WeightStackExtension.hpp> +#include <corsika/stack/history/HistorySecondaryProducer.hpp> +#include <corsika/stack/history/HistoryStackExtension.hpp> + +#include <corsika/setup/SetupEnvironment.hpp> + +namespace corsika { + + // maybe use a similar copy of this file with defined templates for tests? + using DummyEnvironmentInterface = IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>; + using DummyEnvironment = Environment<DummyEnvironmentInterface>; + + namespace test::detail { + + // ------------------------------------------ + // add geometry node tracking data to stack: + + // the GeometryNode stack needs to know the type of geometry-nodes from the + // environment: + template <typename TStackIter> + using SetupGeometryDataInterface = + typename node::MakeGeometryDataInterface<TStackIter, DummyEnvironment>::type; + + // combine particle data stack with geometry information for tracking + template <typename TStackIter> + using StackWithGeometryInterface = + CombinedParticleInterface<VectorStack::pi_type, SetupGeometryDataInterface, + TStackIter>; + + using StackWithGeometry = + CombinedStack<typename VectorStack::stack_data_type, + node::GeometryData<DummyEnvironment>, StackWithGeometryInterface, + DefaultSecondaryProducer>; + + // ------------------------------------------ + // Add [optional] history data to stack, too: + + // combine dummy stack with geometry information for tracking + template <typename TStackIter> + using StackWithHistoryInterface = + CombinedParticleInterface<StackWithGeometry::pi_type, + history::HistoryEventDataInterface, TStackIter>; + + using StackWithHistory = + CombinedStack<typename StackWithGeometry::stack_data_type, + history::HistoryEventData, StackWithHistoryInterface, + history::HistorySecondaryProducer>; + + } // namespace test::detail + +} // namespace corsika \ No newline at end of file -- GitLab