1#ifndef OPALX_BINNED_FIELD_SOLVER_H
2#define OPALX_BINNED_FIELD_SOLVER_H
41template <
typename T,
unsigned Dim>
43 static_assert(
Dim == 3,
"BinnedFieldSolver currently supports Dim == 3 only.");
93 std::shared_ptr<BCHandler_t> bcHandler,
int tablePrintFrequency,
bool adaptiveBinning);
200 const std::string& binningCmdName,
const std::vector<BinStatsRow>& rows);
297 const size_type nPartGlobal,
const double gammaBin,
333 double bFieldSign = 1.0,
int flipAxis = -1);
ippl::Vector< T, Dim > Vector_t
ippl::Field< double, Dim, ViewArgs... > Field_t
ippl::Field< ippl::Vector< T, Dim >, Dim, ViewArgs... > VField_t
Template PIC bunch: IPPL PicManager, shared field mesh/solver, and multiple particle containers.
Handler for boundary conditions per spatial dimension.
Field solver wrapper that implements the full binned self-field algorithm.
double shiftedGreensPlaneZ_m
bool isShiftedGreensActiveForStep(size_t step) const
Check whether the shifted Green's function correction should run for a given timestep....
GatherAttribute gatherAttribute_m
bool warnedPlaneDumpParallelUnsupported_m
long long binNumber
Merged bin index (or -1 for legacy mode).
double getImageChargePlaneZ() const
void prepareRhoForBin(PartBunch_t &bunch, std::shared_ptr< AdaptBins_t > bins, const bin_index_type binIndex, const size_type nPartGlobal, const double gammaBin, ImageScatterMode mode=ImageScatterMode::PrimaryAndImage)
Build mesh rho for a specific merged bin and apply all corrections.
bool isImageChargeActiveForStep(size_t step) const
Check whether the explicit image-charge pass should run for a given timestep.
typename PartBunch_t::ParticleContainer_t ParticleCtr_t
typename AdaptBins_t::size_type size_type
void computeSelfFields(PartBunch_t &bunch)
Compute space-charge self-fields for the given particle bunch.
void accumulateFieldToTemp(const double gammaBin, const Vector_t< double, Dim > &pmean, std::shared_ptr< VField_t< T, Dim > > EtmpSP, std::shared_ptr< VField_t< T, Dim > > BtmpSP, double bFieldSign=1.0, int flipAxis=-1)
Accumulate Lorentz-transformed electric/magnetic fields into temporaries.
BinKinematics computeGammaBinGlobal(PartBunch_t &bunch, std::shared_ptr< AdaptBins_t > bins, const bin_index_type binIndex, const size_type nPartGlobal) const
Compute per-bin global mean momentum and gamma.
void setGatherAttribute(const GatherAttribute attr)
Set particle gather attribute (extensible; default is ElectricFieldE).
void setImageChargeConfiguration(bool enabled, double zPlane)
Configure optional image-charge scatter pass.
void computeBinnedSelfFields(PartBunch_t &bunch)
Compute self-fields using the binned algorithm.
void setShiftedGreensConfiguration(bool enabled, double zPlane)
Configure the shifted Green's function Dirichlet correction (alternative to image charges)....
void gatherFromTempToParticles(PartBunch_t &bunch, std::shared_ptr< VField_t< T, Dim > > EtmpSP, std::shared_ptr< VField_t< T, Dim > > BtmpSP)
Gather the accumulated lab-frame fields from temporaries back to particles.
static void setVectorField(VField_t< T, Dim > &field, const Vector_t< T, Dim > &value)
Set all vector field entries, including ghosts, without IPPL expression templates.
void dumpDirichletPlaneDiagnosticsIfRequested(PartBunch_t &bunch, const std::string &solveTag)
Dump and report potential values interpolated on the image-charge plane.
double getShiftedGreensPlaneZ() const
void setZerofaceMaxSteps(int maxSteps)
Set the maximum number of timesteps for which image charges are active (0 = unlimited).
typename AdaptBins_t::bin_index_type bin_index_type
std::shared_ptr< VField_t< T, Dim > > flippedZSlabField_m
bool isShiftedGreensEnabled() const
void setZeroFacePlaneDumpFrequency(int frequency)
Configure dump frequency for dirichlet-plane diagnostics (0 disables dumps).
ImageChargeScatterController< T, Dim > imageScatterController_m
typename PartBunch_t::AdaptBins_t AdaptBins_t
int getZerofaceMaxSteps() const
void rebinAndPrepare(PartBunch_t &bunch, std::shared_ptr< AdaptBins_t > bins)
Build and prepare adaptive bins for the current step.
ScatterAttribute scatterAttribute_m
ScatterAttribute
Which particle attribute to scatter from to build the mesh charge density rho.
void setScatterAttribute(const ScatterAttribute attr)
Set particle scatter attribute (extensible; default is ChargeQ).
GatherAttribute
Which particle attribute to gather the accumulated electric field into.
int zeroFacePlaneDumpFrequency_m
void buildFlippedZSlab(const VField_t< T, Dim > &src)
Populate flippedZSlab_m with the z-axis globally-flipped version of src.
void printBinStatsTable(const std::string &binningCmdName, const std::vector< BinStatsRow > &rows)
Print the bin statistics table at level 3.
bool shiftedGreensEnabled_m
typename PartBunch_t::Base::particle_position_type particle_position_type
double gammaBin
Global average gamma for the (merged) bin.
BinnedFieldSolver(std::string solver, Field_t< Dim > *rho, VField_t< T, Dim > *E, Field_t< Dim > *phi, std::shared_ptr< BCHandler_t > bcHandler, int tablePrintFrequency, bool adaptiveBinning)
Construct a binned/legacy-compatible solver.
int getZeroFacePlaneDumpFrequency() const
unsigned long long nParticles
Number of particles in the (merged) bin.
int tablePrintFrequency_m
static void setScalarField(Field_t< Dim > &field, double value)
Set all scalar field entries, including ghosts, without IPPL expression templates.
bool isImageChargeEnabled() const
void computeLegacySelfFields(PartBunch_t &bunch)
Compute self-fields using the legacy monolithic algorithm.
static void scaleAndShiftScalarField(Field_t< Dim > &field, double scale, double shift)
Apply field = field * scale + shift on owned cells without expression templates.
ImageScatterMode
Controls which charges are scattered during rho preparation.
Vector_t< double, Dim > pmean
Row entry for the level-3 bin statistics table.
Orchestrates primary and image-charge scatter deposition.
ParticleContainer< T, Dim > ParticleContainer_t
typename ParticleBinning::AdaptBinsBase< ParticleContainer_t > AdaptBins_t
typename BunchType::bin_index_type bin_index_type
typename BunchType::size_type size_type