OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
ImageChargeScatterController< T, Dim > Class Template Reference

Orchestrates primary and image-charge scatter deposition. More...

#include <ImageChargeScatterController.h>

Collaboration diagram for ImageChargeScatterController< T, Dim >:
Collaboration graph

Public Types

using ParticleCtr_t = ParticleContainer< T, Dim >
 
using PositionAttr_t = typename ippl::ParticleBase< ippl::ParticleSpatialLayout< T, Dim >, Kokkos::DefaultExecutionSpace::memory_space >::particle_position_type
 
using RhoField_t = Field_t< Dim >
 
using BinPolicy_t = Kokkos::RangePolicy<>
 
using Hash_t = typename ParticleBinning::AdaptBinsBase< ParticleCtr_t >::hash_type
 

Public Member Functions

 ImageChargeScatterController ()=default
 Construct disabled controller at zPlane=0.
 
 ImageChargeScatterController (bool enabled, double zPlane)
 Construct controller with explicit image-charge settings.
 
void configure (bool enabled, double zPlane)
 Update runtime settings.
 
bool isEnabled () const
 Returns whether image-charge scatter is enabled.
 
double getZPlane () const
 Returns the mirror plane position in z.
 
void scatterPrimaryAndImage (std::shared_ptr< ParticleCtr_t > pc, PositionAttr_t &positions, RhoField_t &rho) const
 Scatter all local particles with optional image pass.
 
void scatterPrimaryAndImage (std::shared_ptr< ParticleCtr_t > pc, PositionAttr_t &positions, RhoField_t &rho, const BinPolicy_t &policy, const Hash_t &hash) const
 Scatter a bin-restricted particle subset with optional image pass.
 
void scatterPrimaryOnly (std::shared_ptr< ParticleCtr_t > pc, PositionAttr_t &positions, RhoField_t &rho) const
 Scatter only the primary (real) charges for all local particles.
 
void scatterPrimaryOnly (std::shared_ptr< ParticleCtr_t > pc, PositionAttr_t &positions, RhoField_t &rho, const BinPolicy_t &policy, const Hash_t &hash) const
 Scatter only the primary (real) charges for a bin-restricted subset.
 
void scatterImageOnly (std::shared_ptr< ParticleCtr_t > pc, PositionAttr_t &positions, RhoField_t &rho) const
 Scatter only the image (mirrored) charges for all local particles.
 
void scatterImageOnly (std::shared_ptr< ParticleCtr_t > pc, PositionAttr_t &positions, RhoField_t &rho, const BinPolicy_t &policy, const Hash_t &hash) const
 Scatter only the image (mirrored) charges for a bin-restricted subset.
 
void scatterScaledDtAll (std::shared_ptr< ParticleCtr_t > pc, PositionAttr_t &positions, RhoField_t &rho) const
 Scatter all local particles using the standard dt*Q workflow.
 
void scatterScaledDtSubset (std::shared_ptr< ParticleCtr_t > pc, PositionAttr_t &positions, RhoField_t &rho, const BinPolicy_t &policy, const Hash_t &hash) const
 Scatter a hashed particle subset using the standard dt*Q workflow.
 
void accumulateScalarHaloHostStaged (RhoField_t &rho) const
 Accumulate scalar field halo contributions through host-staged MPI buffers.
 
void applyMirrorTransformAll (std::shared_ptr< ParticleCtr_t > pc, PositionAttr_t &positions) const
 Apply z-mirror and charge sign flip for all local particles.
 
void restoreMirrorTransformAll (std::shared_ptr< ParticleCtr_t > pc, PositionAttr_t &positions) const
 Restore z-mirror and charge sign flip for all local particles.
 
void applyMirrorTransformSubset (std::shared_ptr< ParticleCtr_t > pc, PositionAttr_t &positions, const BinPolicy_t &policy, const Hash_t &hash) const
 Apply z-mirror and charge sign flip for a hashed particle subset.
 
void restoreMirrorTransformSubset (std::shared_ptr< ParticleCtr_t > pc, PositionAttr_t &positions, const BinPolicy_t &policy, const Hash_t &hash) const
 Restore z-mirror and charge sign flip for a hashed particle subset.
 
void flipChargeSignAll (std::shared_ptr< ParticleCtr_t > pc) const
 Flip charge sign for all local particles.
 
void flipChargeSignSubset (std::shared_ptr< ParticleCtr_t > pc, const BinPolicy_t &policy, const Hash_t &hash) const
 Flip charge sign for a hashed particle subset.
 

Private Attributes

bool enabled_m = false
 
double zPlane_m = 0.0
 

Detailed Description

template<typename T, unsigned Dim>
class ImageChargeScatterController< T, Dim >

Orchestrates primary and image-charge scatter deposition.

The controller performs: 1) primary scatter using the existing dt * Q deposition workflow, and 2) optional image scatter by reflecting particle z positions around an xy plane and flipping the sign of charge Q.

The particle state is restored after the image deposition pass.

Template Parameters
TScalar type (typically double).
DimSpatial dimension (currently constrained to 3).

Definition at line 26 of file ImageChargeScatterController.h.

Member Typedef Documentation

◆ BinPolicy_t

template<typename T , unsigned Dim>
using ImageChargeScatterController< T, Dim >::BinPolicy_t = Kokkos::RangePolicy<>

Definition at line 35 of file ImageChargeScatterController.h.

◆ Hash_t

template<typename T , unsigned Dim>
using ImageChargeScatterController< T, Dim >::Hash_t = typename ParticleBinning::AdaptBinsBase<ParticleCtr_t>::hash_type

Definition at line 36 of file ImageChargeScatterController.h.

◆ ParticleCtr_t

template<typename T , unsigned Dim>
using ImageChargeScatterController< T, Dim >::ParticleCtr_t = ParticleContainer<T, Dim>

Definition at line 30 of file ImageChargeScatterController.h.

◆ PositionAttr_t

template<typename T , unsigned Dim>
using ImageChargeScatterController< T, Dim >::PositionAttr_t = typename ippl::ParticleBase< ippl::ParticleSpatialLayout<T, Dim>, Kokkos::DefaultExecutionSpace::memory_space>::particle_position_type

Definition at line 31 of file ImageChargeScatterController.h.

◆ RhoField_t

template<typename T , unsigned Dim>
using ImageChargeScatterController< T, Dim >::RhoField_t = Field_t<Dim>

Definition at line 34 of file ImageChargeScatterController.h.

Constructor & Destructor Documentation

◆ ImageChargeScatterController() [1/2]

template<typename T , unsigned Dim>
ImageChargeScatterController< T, Dim >::ImageChargeScatterController ( )
default

Construct disabled controller at zPlane=0.

◆ ImageChargeScatterController() [2/2]

template<typename T , unsigned Dim>
ImageChargeScatterController< T, Dim >::ImageChargeScatterController ( bool  enabled,
double  zPlane 
)
inline

Construct controller with explicit image-charge settings.

Parameters
enabledEnable image scatter pass when true.
zPlaneMirror plane location in z (meters).

Definition at line 49 of file ImageChargeScatterController.h.

Member Function Documentation

◆ accumulateScalarHaloHostStaged()

template<typename T , unsigned Dim>
void ImageChargeScatterController< T, Dim >::accumulateScalarHaloHostStaged ( RhoField_t rho) const

Accumulate scalar field halo contributions through host-staged MPI buffers.

This mirrors rho.accumulateHalo() for scalar rho fields, but avoids the device-buffer MPI path used by IPPL HaloCells. It is used by the all-local binned scatter workaround on GH200/Daint.

◆ applyMirrorTransformAll()

template<typename T , unsigned Dim>
void ImageChargeScatterController< T, Dim >::applyMirrorTransformAll ( std::shared_ptr< ParticleCtr_t pc,
PositionAttr_t positions 
) const

Apply z-mirror and charge sign flip for all local particles.

Parameters
pcShared particle container.
positionsParticle positions attribute.

◆ applyMirrorTransformSubset()

template<typename T , unsigned Dim>
void ImageChargeScatterController< T, Dim >::applyMirrorTransformSubset ( std::shared_ptr< ParticleCtr_t pc,
PositionAttr_t positions,
const BinPolicy_t policy,
const Hash_t hash 
) const

Apply z-mirror and charge sign flip for a hashed particle subset.

Parameters
pcShared particle container.
positionsParticle positions attribute.
policyBin iteration policy.
hashMapping from policy index to particle index.

◆ configure()

template<typename T , unsigned Dim>
void ImageChargeScatterController< T, Dim >::configure ( bool  enabled,
double  zPlane 
)
inline

Update runtime settings.

Parameters
enabledEnable image scatter pass when true.
zPlaneMirror plane location in z (meters).

Definition at line 57 of file ImageChargeScatterController.h.

References ImageChargeScatterController< T, Dim >::enabled_m, and ImageChargeScatterController< T, Dim >::zPlane_m.

◆ flipChargeSignAll()

template<typename T , unsigned Dim>
void ImageChargeScatterController< T, Dim >::flipChargeSignAll ( std::shared_ptr< ParticleCtr_t pc) const

Flip charge sign for all local particles.

In single-value Q mode, only the shared scalar is flipped.

Parameters
pcShared particle container.

◆ flipChargeSignSubset()

template<typename T , unsigned Dim>
void ImageChargeScatterController< T, Dim >::flipChargeSignSubset ( std::shared_ptr< ParticleCtr_t pc,
const BinPolicy_t policy,
const Hash_t hash 
) const

Flip charge sign for a hashed particle subset.

In single-value Q mode, only the shared scalar is flipped.

Parameters
pcShared particle container.
policyBin iteration policy.
hashMapping from policy index to particle index.

◆ getZPlane()

template<typename T , unsigned Dim>
double ImageChargeScatterController< T, Dim >::getZPlane ( ) const
inline

Returns the mirror plane position in z.

Definition at line 65 of file ImageChargeScatterController.h.

References ImageChargeScatterController< T, Dim >::zPlane_m.

◆ isEnabled()

template<typename T , unsigned Dim>
bool ImageChargeScatterController< T, Dim >::isEnabled ( ) const
inline

Returns whether image-charge scatter is enabled.

Definition at line 63 of file ImageChargeScatterController.h.

References ImageChargeScatterController< T, Dim >::enabled_m.

◆ restoreMirrorTransformAll()

template<typename T , unsigned Dim>
void ImageChargeScatterController< T, Dim >::restoreMirrorTransformAll ( std::shared_ptr< ParticleCtr_t pc,
PositionAttr_t positions 
) const

Restore z-mirror and charge sign flip for all local particles.

The operation is its own inverse.

Parameters
pcShared particle container.
positionsParticle positions attribute.

◆ restoreMirrorTransformSubset()

template<typename T , unsigned Dim>
void ImageChargeScatterController< T, Dim >::restoreMirrorTransformSubset ( std::shared_ptr< ParticleCtr_t pc,
PositionAttr_t positions,
const BinPolicy_t policy,
const Hash_t hash 
) const

Restore z-mirror and charge sign flip for a hashed particle subset.

The operation is its own inverse.

Parameters
pcShared particle container.
positionsParticle positions attribute.
policyBin iteration policy.
hashMapping from policy index to particle index.

◆ scatterImageOnly() [1/2]

template<typename T , unsigned Dim>
void ImageChargeScatterController< T, Dim >::scatterImageOnly ( std::shared_ptr< ParticleCtr_t pc,
PositionAttr_t positions,
RhoField_t rho 
) const

Scatter only the image (mirrored) charges for all local particles.

Applies the mirror transform, scatters, and restores. Does nothing if image charges are disabled.

◆ scatterImageOnly() [2/2]

template<typename T , unsigned Dim>
void ImageChargeScatterController< T, Dim >::scatterImageOnly ( std::shared_ptr< ParticleCtr_t pc,
PositionAttr_t positions,
RhoField_t rho,
const BinPolicy_t policy,
const Hash_t hash 
) const

Scatter only the image (mirrored) charges for a bin-restricted subset.

Applies the mirror transform, scatters, and restores. Does nothing if image charges are disabled.

◆ scatterPrimaryAndImage() [1/2]

template<typename T , unsigned Dim>
void ImageChargeScatterController< T, Dim >::scatterPrimaryAndImage ( std::shared_ptr< ParticleCtr_t pc,
PositionAttr_t positions,
RhoField_t rho 
) const

Scatter all local particles with optional image pass.

Primary pass deposits with the nominal charge. If enabled, image pass deposits mirrored particles with flipped charge sign.

Parameters
pcShared particle container.
positionsParticle positions attribute (typically pc->R).
rhoTarget charge-density mesh field.

◆ scatterPrimaryAndImage() [2/2]

template<typename T , unsigned Dim>
void ImageChargeScatterController< T, Dim >::scatterPrimaryAndImage ( std::shared_ptr< ParticleCtr_t pc,
PositionAttr_t positions,
RhoField_t rho,
const BinPolicy_t policy,
const Hash_t hash 
) const

Scatter a bin-restricted particle subset with optional image pass.

Parameters
pcShared particle container.
positionsParticle positions attribute (typically pc->R).
rhoTarget charge-density mesh field.
policyBin iteration policy (index-space for hash access).
hashMapping from policy index to particle index.

◆ scatterPrimaryOnly() [1/2]

template<typename T , unsigned Dim>
void ImageChargeScatterController< T, Dim >::scatterPrimaryOnly ( std::shared_ptr< ParticleCtr_t pc,
PositionAttr_t positions,
RhoField_t rho 
) const

Scatter only the primary (real) charges for all local particles.

◆ scatterPrimaryOnly() [2/2]

template<typename T , unsigned Dim>
void ImageChargeScatterController< T, Dim >::scatterPrimaryOnly ( std::shared_ptr< ParticleCtr_t pc,
PositionAttr_t positions,
RhoField_t rho,
const BinPolicy_t policy,
const Hash_t hash 
) const

Scatter only the primary (real) charges for a bin-restricted subset.

◆ scatterScaledDtAll()

template<typename T , unsigned Dim>
void ImageChargeScatterController< T, Dim >::scatterScaledDtAll ( std::shared_ptr< ParticleCtr_t pc,
PositionAttr_t positions,
RhoField_t rho 
) const

Scatter all local particles using the standard dt*Q workflow.

This helper applies scaleDtByCharge(), scatters dt, and restores dt.

Parameters
pcShared particle container.
positionsParticle positions attribute.
rhoTarget charge-density field.

◆ scatterScaledDtSubset()

template<typename T , unsigned Dim>
void ImageChargeScatterController< T, Dim >::scatterScaledDtSubset ( std::shared_ptr< ParticleCtr_t pc,
PositionAttr_t positions,
RhoField_t rho,
const BinPolicy_t policy,
const Hash_t hash 
) const

Scatter a hashed particle subset using the standard dt*Q workflow.

Parameters
pcShared particle container.
positionsParticle positions attribute.
rhoTarget charge-density field.
policyBin iteration policy.
hashMapping from policy index to particle index.

Member Data Documentation

◆ enabled_m

template<typename T , unsigned Dim>
bool ImageChargeScatterController< T, Dim >::enabled_m = false
private

◆ zPlane_m

template<typename T , unsigned Dim>
double ImageChargeScatterController< T, Dim >::zPlane_m = 0.0
private

The documentation for this class was generated from the following file: