ComputationalRadiationPhysics / picongpu

Performance-Portable Particle-in-Cell Simulations for the Exascale Era :sparkles:
https://picongpu.readthedocs.io
Other
708 stars 218 forks source link

refactor `value_identifier` #5130

Closed psychocoderHPC closed 1 month ago

psychocoderHPC commented 2 months ago

This PR provide the possibility that a value_identifier can fully describe the operation performed for the

For PIConGPU the binary manipulator Assign is renamed into Derive and a Copy manipulator is added.

With the new description of value identifier, there is no need to handle special attributes e.g. particleId explicitly in any algorithm where we derive particles.

BREAKING input change. In principle, this is a breaking change because speciesAttributes.param changed BUT typically this file is not part of input sets, therefore users should not be affected.

With the new attributes it is possible to implement a counter to count how often a particle is deep copied during the simulation runtime. This can be useful for code optimizations.

value_identifier_func(
    uint32_t,
    numCopies,
    ([](auto const&, IdGenerator&) constexpr { return 0u; }),
    ([](auto const idName, auto const& srcParticle) constexpr { return srcParticle[idName] + 1u; }),
    (pmacc::particles::identifier::CallInit{}));

template<>
struct Unit<numCopies>
{
    // unitless and not scaled by a factor: by convention 1.0
    static std::vector<double> get()
    {
        std::vector<double> unit(1, 1.0);
        return unit;
    }
};
template<>
struct UnitDimension<numCopies>
{
    static std::vector<float_64> get()
    {
        // numCopies is unitless
        std::vector<float_64> unitDimension(NUnitDimension, 0.0);

        return unitDimension;
    }
};
template<>
struct MacroWeighted<numCopies>
{
    // identical and can not be scaled by weightings
    static bool get()
    {
        return false;
    }
};
template<>
struct WeightingPower<numCopies>
{
    // flag * weighting^0 == flag: same for real and macro particle
    static float_64 get()
    {
        return 0.0;
    }
};