Skip to content

Commit cefca9e

Browse files
Merge pull request ComputationalRadiationPhysics#5402 from ikbuibui/fields_fix
Field binning fixes to pass fields and setters to configure binning
2 parents d7929e1 + 7fca3ff commit cefca9e

File tree

14 files changed

+379
-115
lines changed

14 files changed

+379
-115
lines changed

docs/source/usage/plugins/binningPlugin.rst

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ Species can be instances of a species type or a particle species name as a PMACC
191191
auto electronsObj = PMACC_CSTRING("e"){};
192192

193193
Optionally, users can specify a filter to be used with the species. This is a predicate functor, i.e. it is a functor with a signature as described above and which returns a boolean. If the filter returns true it means the particle is included in the binning.
194-
They can then create a FilteredSpecies object which contains the species and the filter.
194+
They can then create a ``FilteredSpecies`` object which contains the species and the filter.
195195

196196
.. literalinclude:: ../../../../share/picongpu/tests/compile2/include/picongpu/param/binningSetup.param
197197
:language: c++
@@ -207,21 +207,37 @@ They can then create a FilteredSpecies object which contains the species and the
207207
Fields
208208
------
209209
PIConGPU fields which should be used in field binning.
210-
Fields can be instances of a field type. For example,
210+
Fields must be instances of the ``FieldInfo`` type.
211+
212+
.. doxygenclass:: picongpu::plugins::binning::FieldInfo
213+
:members:
214+
215+
For example,
211216

212217
.. literalinclude:: ../../../../share/picongpu/tests/compile2/include/picongpu/param/binningSetup.param
213218
:language: c++
214219
:start-after: doc-include-start: fieldTuple
215220
:end-before: doc-include-end: fieldTuple
216221
:dedent:
217222

218-
Fields are passed to addFieldBinner in the form of a tuple. This is just a collection of field objects and is of arbitrary size.
223+
Fields are passed to addFieldBinner in the form of a tuple. This is just a collection of ``FieldInfo`` and is of arbitrary size.
219224
Users can make a fields tuple by using the ``createTuple()`` function and passing in the objects as arguments.
225+
The functors receive the fields in the form of the field data box, which is the field data on the current GPU including the guard cells, in the order they are passed in the tuple.
226+
227+
.. literalinclude:: ../../../../share/picongpu/tests/compile2/include/picongpu/param/binningSetup.param
228+
:language: c++
229+
:start-after: doc-include-start: fieldBox
230+
:end-before: doc-include-end: fieldBox
231+
:dedent:
220232

221233
.. note::
222234

223235
It is possible to have an empty tuple for fields when doing field binning, in which case the functor will be called with no fields. This may be useful if you are passing in extra data and want field traversal over it.
224236

237+
.. note::
238+
239+
It is possible to have field information available while doing particle binning as well. Users can simply pass in ``FieldInfo`` objects in the extra data tuple, and the functor will be called with the field information as well.
240+
225241
Deposited Quantity
226242
------------------
227243
Quantity to be deposited is simply a :ref:`functor description <usage/plugins/binningPlugin:Functor Description>`.

include/picongpu/plugins/binning/BinningCreator.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ namespace picongpu
110110
* This can be used to further configure the binning setup if needed.
111111
*/
112112
template<typename T_AccumulateOp = alpaka::AtomicAdd, typename T_Extras = std::tuple<>>
113-
auto addFieldBinner(
113+
auto& addFieldBinner(
114114
std::string const& binnerOutputName,
115115
auto const& axisTupleObject,
116116
auto const& fieldsTupleObject,

include/picongpu/plugins/binning/BinningData.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,51 +117,51 @@ namespace picongpu
117117
/** @brief Time average the accumulated data when doing the dump. Defaults to true. */
118118
Child& setTimeAveraging(bool timeAv)
119119
{
120-
this->timeAveraging = timeAv;
120+
timeAveraging = timeAv;
121121
return interpretAsChild();
122122
}
123123

124124
/** @brief The periodicity of the output. Defaults to 1 */
125125
Child& setNotifyPeriod(std::string notify)
126126
{
127-
this->notifyPeriod = std::move(notify);
127+
notifyPeriod = std::move(notify);
128128
return interpretAsChild();
129129
}
130130

131131
/** @brief The number of notify steps to accumulate over. Dump at the end. Defaults to 1. */
132132
Child& setDumpPeriod(uint32_t dumpXNotifys)
133133
{
134-
this->dumpPeriod = dumpXNotifys;
134+
dumpPeriod = dumpXNotifys;
135135
return interpretAsChild();
136136
}
137137

138-
/** @brief The periodicity of the output. Defaults to 1 */
138+
/** @brief Set the file extension for the openPMD output */
139139
Child& setOpenPMDExtension(std::string extension)
140140
{
141-
this->openPMDExtension = std::move(extension);
141+
openPMDExtension = std::move(extension);
142142
return interpretAsChild();
143143
}
144144

145-
/** @brief The periodicity of the output. Defaults to 1 */
145+
/** @brief Set the infix for file names in openPMD output */
146146
Child& setOpenPMDInfix(std::string infix)
147147
{
148-
this->openPMDInfix = std::move(infix);
148+
openPMDInfix = std::move(infix);
149149
return interpretAsChild();
150150
}
151151

152-
/** @brief The periodicity of the output. Defaults to 1 */
152+
/** @brief Call a functor to add custom data to openPMD output */
153153
Child& setOpenPMDWriteFunctor(
154154
std::function<void(::openPMD::Series& series, ::openPMD::Iteration& iteration, ::openPMD::Mesh& mesh)>
155-
writeOpenPMDFunctor)
155+
functor)
156156
{
157-
this->writeOpenPMDFunctor = std::move(writeOpenPMDFunctor);
157+
writeOpenPMDFunctor = std::move(functor);
158158
return interpretAsChild();
159159
}
160160

161-
/** @brief The periodicity of the output. Defaults to 1 */
161+
/** @brief Set miscellaneous configuration options for openPMD output */
162162
Child& setOpenPMDJsonCfg(std::string cfg)
163163
{
164-
this->openPMDJsonCfg = std::move(cfg);
164+
openPMDJsonCfg = std::move(cfg);
165165
return interpretAsChild();
166166
}
167167

@@ -170,7 +170,7 @@ namespace picongpu
170170
*/
171171
Child& setHostSideHook(std::function<void()> hookFunc)
172172
{
173-
this->hostHook = std::move(hookFunc);
173+
hostHook = std::move(hookFunc);
174174
return interpretAsChild();
175175
}
176176
};

include/picongpu/plugins/binning/BinningFunctors.hpp

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,22 @@ namespace picongpu
105105
auto const& worker,
106106
T_HistBox binningBox,
107107
auto particlesBox,
108-
pmacc::DataSpace<simDim> const& localOffset,
109-
pmacc::DataSpace<simDim> const& globalOffset,
108+
DomainInfo<BinningType::Particle> domainInfo,
110109
auto const& axisTuple,
111110
T_DepositionFunctor const& quantityFunctor,
112111
DataSpace<T_nAxes> const& extents,
113112
auto const& userFunctorData,
114113
auto const& filter,
115-
uint32_t const currentStep,
116114
T_Mapping const& mapper) const
117115
{
118116
DataSpace<simDim> const superCellIdx(mapper.getSuperCellIndex(worker.blockDomIdxND()));
117+
auto const guardingSuperCells = mapper.getGuardingSuperCells();
119118
// supercell index relative to the border origin
120-
auto const physicalSuperCellIdx = superCellIdx - mapper.getGuardingSuperCells();
119+
auto const physicalSuperCellIdx = superCellIdx - guardingSuperCells;
121120
/**
122121
* Init the Domain info, here because of the possibility of a moving window
123122
*/
124-
auto const domainInfo
125-
= DomainInfo<BinningType::Particle>{currentStep, globalOffset, localOffset, physicalSuperCellIdx};
123+
domainInfo.fillDeviceData(physicalSuperCellIdx);
126124

127125
auto const functorParticle = FunctorParticle<T_AtomicOp>{};
128126

@@ -194,25 +192,23 @@ namespace picongpu
194192
T_Worker const& worker,
195193
T_HistBox binningBox,
196194
TParticlesBox particlesBox,
197-
pmacc::DataSpace<simDim> const& localOffset,
198-
pmacc::DataSpace<simDim> const& globalOffset,
195+
DomainInfo<BinningType::Particle> domainInfo,
199196
T_AxisTuple const& axisTuple,
200197
T_DepositionFunctor const& quantityFunctor,
201198
DataSpace<T_nAxes> const& extents,
202199
auto const& userFunctorData,
203200
auto const& filter,
204-
uint32_t const currentStep,
205201
pmacc::DataSpace<simDim> const& beginCellIdxLocal,
206202
pmacc::DataSpace<simDim> const& endCellIdxLocal,
207203
T_Mapping const& mapper) const
208204
{
209205
/* multi-dimensional offset vector from local domain origin on GPU in units of super cells */
210206
pmacc::DataSpace<simDim> const superCellIdx(mapper.getSuperCellIndex(worker.blockDomIdxND()));
207+
auto const guardingSuperCells = mapper.getGuardingSuperCells();
211208
// supercell index relative to the border origin
212-
auto const physicalSuperCellIdx = superCellIdx - mapper.getGuardingSuperCells();
209+
auto const physicalSuperCellIdx = superCellIdx - guardingSuperCells;
213210

214-
auto const domainInfo
215-
= DomainInfo<BinningType::Particle>{currentStep, globalOffset, localOffset, physicalSuperCellIdx};
211+
domainInfo.fillDeviceData(physicalSuperCellIdx);
216212
auto const functorParticle = FunctorParticle<T_AtomicOp>{};
217213

218214
auto forEachParticle
@@ -317,21 +313,20 @@ namespace picongpu
317313
DINLINE void operator()(
318314
auto const& worker,
319315
T_HistBox binningBox,
320-
pmacc::DataSpace<simDim> const& localOffset,
321-
pmacc::DataSpace<simDim> const& globalOffset,
316+
DomainInfo<BinningType::Field> domainInfo,
322317
auto const& axisTuple,
323318
auto const& userFunctorData,
324319
T_DepositionFunctor const& quantityFunctor,
325320
DataSpace<T_nAxes> const& extents,
326-
uint32_t const currentStep,
327321
T_Mapping const& mapper) const
328322
{
329323
using SuperCellSize = typename T_Mapping::SuperCellSize;
330324
constexpr uint32_t cellsPerSupercell = pmacc::math::CT::volume<SuperCellSize>::type::value;
331325

332326
DataSpace<simDim> const superCellIdx(mapper.getSuperCellIndex(worker.blockDomIdxND()));
327+
auto const guardingSuperCells = mapper.getGuardingSuperCells();
333328
// supercell index relative to the border origin
334-
auto const physicalSuperCellIdx = superCellIdx - mapper.getGuardingSuperCells();
329+
auto const physicalSuperCellIdx = superCellIdx - guardingSuperCells;
335330

336331
using SuperCellSize = typename T_Mapping::SuperCellSize;
337332

@@ -348,12 +343,7 @@ namespace picongpu
348343
/**
349344
* Init the Domain info, here because of the possibility of a moving window
350345
*/
351-
auto const domainInfo = DomainInfo<BinningType::Field>{
352-
currentStep,
353-
globalOffset,
354-
localOffset,
355-
physicalSuperCellIdx,
356-
localCellIndex};
346+
domainInfo.fillDeviceData(physicalSuperCellIdx, localCellIndex);
357347

358348
functorCell(
359349
worker,

0 commit comments

Comments
 (0)