From 1699238155a3ba1b95fdd2c1b01f6a18effccdd2 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Tue, 24 Jan 2017 16:04:21 +0100 Subject: [PATCH] fileOutput: MacroParticleCounter Add a macro particle counter to the `fieldTmp` per cell particle to grid operations. Assumes all (macro) particles are point like in space and can be used to validate particle memory structures. --- .../ComputeGridValuePerFrame.def | 12 +++ .../derivedAttributes/Counter.hpp | 2 +- .../derivedAttributes/DerivedAttributes.def | 1 + .../derivedAttributes/DerivedAttributes.hpp | 1 + .../derivedAttributes/MacroCounter.def | 75 +++++++++++++++++++ .../derivedAttributes/MacroCounter.hpp | 50 +++++++++++++ .../simulation_defines/param/fileOutput.param | 8 +- 7 files changed, 141 insertions(+), 8 deletions(-) create mode 100644 src/picongpu/include/particles/particleToGrid/derivedAttributes/MacroCounter.def create mode 100644 src/picongpu/include/particles/particleToGrid/derivedAttributes/MacroCounter.hpp diff --git a/src/picongpu/include/particles/particleToGrid/ComputeGridValuePerFrame.def b/src/picongpu/include/particles/particleToGrid/ComputeGridValuePerFrame.def index f3a7c717e4..6e29199a81 100644 --- a/src/picongpu/include/particles/particleToGrid/ComputeGridValuePerFrame.def +++ b/src/picongpu/include/particles/particleToGrid/ComputeGridValuePerFrame.def @@ -131,6 +131,18 @@ struct CreateCounterOperation typedef FieldTmpOperation< ParticleCounter, T_Species > type; }; +/* MacroParticleCounter */ +template +struct CreateMacroCounterOperation +{ + typedef ComputeGridValuePerFrame< + particles::shapes::Counter, + particleToGrid::derivedAttributes::MacroCounter + > MacroParticleCounter; + + typedef FieldTmpOperation< MacroParticleCounter, T_Species > type; +}; + /* EnergyDensity */ template struct CreateEnergyDensityOperation diff --git a/src/picongpu/include/particles/particleToGrid/derivedAttributes/Counter.hpp b/src/picongpu/include/particles/particleToGrid/derivedAttributes/Counter.hpp index ae6a77bf1f..70bff69551 100644 --- a/src/picongpu/include/particles/particleToGrid/derivedAttributes/Counter.hpp +++ b/src/picongpu/include/particles/particleToGrid/derivedAttributes/Counter.hpp @@ -20,7 +20,7 @@ #pragma once -#include "particles/particleToGrid/derivedAttributes/ChargeDensity.def" +#include "particles/particleToGrid/derivedAttributes/Counter.def" #include "simulation_defines.hpp" diff --git a/src/picongpu/include/particles/particleToGrid/derivedAttributes/DerivedAttributes.def b/src/picongpu/include/particles/particleToGrid/derivedAttributes/DerivedAttributes.def index a33adf6a83..c267615332 100644 --- a/src/picongpu/include/particles/particleToGrid/derivedAttributes/DerivedAttributes.def +++ b/src/picongpu/include/particles/particleToGrid/derivedAttributes/DerivedAttributes.def @@ -22,6 +22,7 @@ #include "particles/particleToGrid/derivedAttributes/Density.def" #include "particles/particleToGrid/derivedAttributes/Counter.def" +#include "particles/particleToGrid/derivedAttributes/MacroCounter.def" #include "particles/particleToGrid/derivedAttributes/ChargeDensity.def" #include "particles/particleToGrid/derivedAttributes/MidCurrentDensityComponent.def" #include "particles/particleToGrid/derivedAttributes/EnergyDensity.def" diff --git a/src/picongpu/include/particles/particleToGrid/derivedAttributes/DerivedAttributes.hpp b/src/picongpu/include/particles/particleToGrid/derivedAttributes/DerivedAttributes.hpp index 67307aae11..59e624b4ba 100644 --- a/src/picongpu/include/particles/particleToGrid/derivedAttributes/DerivedAttributes.hpp +++ b/src/picongpu/include/particles/particleToGrid/derivedAttributes/DerivedAttributes.hpp @@ -22,6 +22,7 @@ #include "particles/particleToGrid/derivedAttributes/Density.hpp" #include "particles/particleToGrid/derivedAttributes/Counter.hpp" +#include "particles/particleToGrid/derivedAttributes/MacroCounter.hpp" #include "particles/particleToGrid/derivedAttributes/ChargeDensity.hpp" #include "particles/particleToGrid/derivedAttributes/MidCurrentDensityComponent.hpp" #include "particles/particleToGrid/derivedAttributes/EnergyDensity.hpp" diff --git a/src/picongpu/include/particles/particleToGrid/derivedAttributes/MacroCounter.def b/src/picongpu/include/particles/particleToGrid/derivedAttributes/MacroCounter.def new file mode 100644 index 0000000000..b9998c27cb --- /dev/null +++ b/src/picongpu/include/particles/particleToGrid/derivedAttributes/MacroCounter.def @@ -0,0 +1,75 @@ +/** + * Copyright 2017 Axel Huebl + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#pragma once + +#include "pmacc_types.hpp" +#include + + +namespace picongpu +{ +namespace particleToGrid +{ +namespace derivedAttributes +{ + struct MacroCounter + { + + HDINLINE float1_64 + getUnit() const; + + HINLINE std::vector + getUnitDimension() const + { + /* L, M, T, I, theta, N, J + * + * Counter is unitless + */ + std::vector unitDimension( 7, 0.0 ); + + return unitDimension; + } + + HINLINE std::string + getName() const + { + return "macroParticleCounter"; + } + + /** Calculate a new attribute per particle + * + * Returns a new (on-the-fly calculated) attribute of a particle + * that can then be mapped to the cells the particle contributes to. + * This method is called on a per-thread basis (each thread of a block + * handles a particle of a frame). + * + * \tparam T_Particle particle in the frame + * \param particle particle in the frame + * + * \return new attribute for the particle (type \see T_AttributeType) + */ + template< class T_Particle > + DINLINE float_X + operator()( T_Particle& particle ) const; + }; +} /* namespace derivedAttributes */ +} /* namespace particleToGrid */ +} /* namespace picongpu */ diff --git a/src/picongpu/include/particles/particleToGrid/derivedAttributes/MacroCounter.hpp b/src/picongpu/include/particles/particleToGrid/derivedAttributes/MacroCounter.hpp new file mode 100644 index 0000000000..ed53430aa8 --- /dev/null +++ b/src/picongpu/include/particles/particleToGrid/derivedAttributes/MacroCounter.hpp @@ -0,0 +1,50 @@ +/** + * Copyright 2017 Axel Huebl + * + * This file is part of PIConGPU. + * + * PIConGPU is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIConGPU is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PIConGPU. + * If not, see . + */ + +#pragma once + +#include "particles/particleToGrid/derivedAttributes/MacroCounter.def" + +#include "simulation_defines.hpp" + + +namespace picongpu +{ +namespace particleToGrid +{ +namespace derivedAttributes +{ + + HDINLINE float1_64 + MacroCounter::getUnit() const + { + return 1.0; + } + + template< class T_Particle > + DINLINE float_X + MacroCounter::operator()( T_Particle& particle ) const + { + /* return attribute */ + return 1.0; + } +} /* namespace derivedAttributes */ +} /* namespace particleToGrid */ +} /* namespace picongpu */ diff --git a/src/picongpu/include/simulation_defines/param/fileOutput.param b/src/picongpu/include/simulation_defines/param/fileOutput.param index aef67ceefc..2022bc3051 100644 --- a/src/picongpu/include/simulation_defines/param/fileOutput.param +++ b/src/picongpu/include/simulation_defines/param/fileOutput.param @@ -62,6 +62,7 @@ namespace picongpu * - CreateMidCurrentDensityComponentOperation: * density * charge * velocity_component * - CreateCounterOperation: counts point like particles per cell + * - CreateMacroCounterOperation: counts point like macro particles per cell */ using namespace particleToGrid; @@ -71,12 +72,6 @@ namespace picongpu CreateChargeDensityOperation< bmpl::_1 > >::type; - /* ParticleCounter section */ - using Counter_Seq = bmpl::transform< - VectorAllSpecies, - CreateCounterOperation< bmpl::_1 > - >::type; - /* EnergyDensity section */ using EnergyDensity_Seq = bmpl::transform< VectorAllSpecies, @@ -101,7 +96,6 @@ namespace picongpu */ using FieldTmpSolvers = MakeSeq_t< ChargeDensity_Seq, - Counter_Seq, EnergyDensity_Seq, MomentumComponent_Seq >;