OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
PartBunch.h
Go to the documentation of this file.
1
7#ifndef PARTBUNCH_H
8#define PARTBUNCH_H
9
10#include <memory>
11#include <vector>
12
14#include "Algorithms/Matrix.h"
15#include "Algorithms/PartData.h"
17#include "BCHandler.hpp"
18#include "Manager/BaseManager.h"
19#include "Manager/PicManager.h"
26#include "Physics/Physics.h"
27#include "Random/Distribution.h"
28#include "Random/InverseTransformSampling.h"
29#include "Random/NormalDistribution.h"
30#include "Random/Randn.h"
33
34class DataSink;
36class Beam;
37
38extern Inform* gmsg;
39
40using view_type = typename ippl::detail::ViewType<ippl::Vector<double, 3>, 1>::view_type;
41
48template <typename T, unsigned Dim>
50
51template <typename T, unsigned Dim>
53 : public ippl::PicManager<
54 T, Dim, ParticleContainer<T, Dim>, FieldContainer<T, Dim>, LoadBalancer<T, Dim>> {
55public:
60 using Base = ippl::ParticleBase<
61 ippl::ParticleSpatialLayout<T, Dim>, Kokkos::DefaultExecutionSpace::memory_space>;
62
67
69
70public:
71 // --- Shared state (all containers / mesh) ---
72
73 double dt_m;
74 int it_m;
76 std::string solver_m;
78 int nrZBase_m = 0;
85
86 double lbt_m;
88 ippl::NDIndex<Dim> domain_m;
89 std::array<bool, Dim> decomp_m;
90
91private:
92 std::vector<bool> pcActive_m;
93 std::vector<bool> pcAtZStop_m;
94 std::vector<std::string> particleNames_m;
95
96 std::vector<double> qi_m;
97 std::vector<double> mi_m;
98
99 const PartData* reference_m = nullptr;
100
101 std::shared_ptr<BunchStateHandler>
103
104 std::shared_ptr<BCHandler_t> bcHandler_m;
105 std::shared_ptr<AdaptBins_t> bins_m;
108
109 double t_m;
110
112 std::shared_ptr<VField_t<T, Dim>> Etmp_m;
114 std::shared_ptr<VField_t<T, Dim>> Btmp_m;
115
117
118 std::unique_ptr<size_t[]>
120
122
123public:
136 PartBunch(
137 std::vector<double> qi, std::vector<double> mi, const std::vector<Beam*>& beams,
138 std::vector<size_t> totalParticlesPerBeam, double lbt, std::string integration_method,
139 FieldSolverCmd* OPALFieldSolver, DataSink* dataSink);
140
149 void bunchUpdate();
150
167
179 void applyGridUpdate(const Vector_t<double, Dim>& lower, const Vector_t<double, Dim>& upper);
180
191 void reinitializeGridZ(int nrZ);
192
199 void setImageChargeConfiguration(bool enabled, double zPlane);
200
210 void setShiftedGreensConfiguration(bool enabled, double zPlane);
211
217 void setZeroFacePlaneDumpFrequency(int frequency);
218
221 void setZerofaceMaxSteps(int maxSteps);
222
227 size_t total = 0;
228 for (const auto& pc : this->getParticleContainers()) {
229 if (pc) {
230 total += pc->getTotalNum();
231 }
232 }
233 return total;
234 }
235
237 void setSolver();
238
240 void setBins();
241
243 void pre_run() override;
244
249 void performBunchSanityChecks() const;
250
252 void resetPcActive();
253
256 bool isPcActive(size_t i) const { return i < pcActive_m.size() && pcActive_m[i]; }
257
259 void setPcActive(size_t i) {
260 if (i < pcActive_m.size()) {
261 pcActive_m[i] = true;
262 }
263 }
264
267 bool pcAtZStop(size_t i) const { return i < pcAtZStop_m.size() && pcAtZStop_m[i]; }
268
270 void setPcAtZStop(size_t i);
271
274
276 bool anyPcActive() const {
277 for (bool a : pcActive_m) {
278 if (a) {
279 return true;
280 }
281 }
282 return false;
283 }
284
286 void advance() override {
287 throw OpalException(
288 "PartBunch::advance",
289 "Not used: just exists because ippl::PicManager wants it that way.");
290 }
291
293 void par2grid() override {
294 throw OpalException(
295 "PartBunch::par2grid",
296 "Not used: just exists because ippl::PicManager wants it that way.");
297 }
298
300 void grid2par() override {
301 throw OpalException(
302 "PartBunch::grid2par",
303 "Not used: just exists because ippl::PicManager wants it that way.");
304 }
305
307 std::shared_ptr<VField_t<T, Dim>> getTempEField() { return this->Etmp_m; }
308
310 void setTempEField(std::shared_ptr<VField_t<T, Dim>> Etmp) { this->Etmp_m = Etmp; }
311
313 std::shared_ptr<VField_t<T, Dim>> getTempBField() { return this->Btmp_m; }
314
316 void setTempBField(std::shared_ptr<VField_t<T, Dim>> Btmp) { this->Btmp_m = Btmp; }
317
319 std::shared_ptr<AdaptBins_t> getBins() { return bins_m; }
320
322 std::shared_ptr<AdaptBins_t> getBins() const { return bins_m; }
323
325 void setBins(std::shared_ptr<AdaptBins_t> bins) { bins_m = bins; }
326
328 void setBCHandler(std::shared_ptr<BCHandler_t> bcHandler) { bcHandler_m = bcHandler; }
329
331 std::shared_ptr<BCHandler_t> getBCHandler() const { return bcHandler_m; }
332
333 DataSink* getDataSink() const { return dataSink_m; }
334
335 std::shared_ptr<BunchStateHandler> getBunchStateHandler() { return bunchState_m; }
336 std::shared_ptr<const BunchStateHandler> getBunchStateHandler() const { return bunchState_m; }
337
338 void updateMoments() { this->pcontainer_m->updateMoments(); }
339
344 void calcBeamParameters();
345
351 void setCharge() {
352 const auto& containers = this->getParticleContainers();
353 if (containers.size() != qi_m.size()) {
354 throw OpalException(
355 "PartBunch::setCharge",
356 "Number of particle containers and qi values do not match.");
357 }
358 for (size_t i = 0; i < containers.size(); ++i) {
359 containers[i]->setQ(qi_m[i]);
360 }
361 }
362
368 void setMass() {
369 const auto& containers = this->getParticleContainers();
370 if (containers.size() != mi_m.size()) {
371 throw OpalException(
372 "PartBunch::setMass",
373 "Number of particle containers and mi values do not match.");
374 }
375 for (size_t i = 0; i < containers.size(); ++i) {
376 containers[i]->setM(mi_m[i]);
377 }
378 }
379
387 double getCharge(size_t containerIndex = 0) const {
388 const auto& containers = this->getParticleContainers();
389 if (containers.size() != qi_m.size()) {
390 throw OpalException(
391 "PartBunch::getCharge",
392 "Number of particle containers and qi values do not match.");
393 }
394 if (containerIndex >= containers.size()) {
395 throw OpalException("PartBunch::getCharge", "Container index out of range.");
396 }
397 return qi_m[containerIndex] * containers[containerIndex]->getTotalNum();
398 }
399
406 double getChargePerParticle(size_t containerIndex = 0) const {
407 if (containerIndex >= qi_m.size()) {
408 throw OpalException("PartBunch::getChargePerParticle", "Container index out of range.");
409 }
410 return qi_m[containerIndex];
411 }
412
419 double getMassPerParticle(size_t containerIndex = 0) const {
420 if (containerIndex >= mi_m.size()) {
421 throw OpalException("PartBunch::getMassPerParticle", "Container index out of range.");
422 }
423 return mi_m[containerIndex];
424 }
425
431 double getQ(size_t containerIndex = 0) const { return this->getCharge(containerIndex); }
432
440 double getM(size_t containerIndex = 0) const {
441 const auto& containers = this->getParticleContainers();
442 if (containers.size() != mi_m.size()) {
443 throw OpalException(
444 "PartBunch::getM", "Number of particle containers and mi values do not match.");
445 }
446 if (containerIndex >= containers.size()) {
447 throw OpalException("PartBunch::getM", "Container index out of range.");
448 }
449 return mi_m[containerIndex] * containers[containerIndex]->getTotalNum();
450 }
451
457 double getTotalCharge() const {
458 const auto& containers = this->getParticleContainers();
459 if (containers.size() != qi_m.size()) {
460 throw OpalException(
461 "PartBunch::getTotalCharge",
462 "Number of particle containers and qi values do not match.");
463 }
464 double charge = 0.0;
465 for (size_t i = 0; i < containers.size(); ++i) {
466 charge += qi_m[i] * containers[i]->getTotalNum();
467 }
468 return charge;
469 }
470
476 double getTotalMass() const {
477 const auto& containers = this->getParticleContainers();
478 if (containers.size() != mi_m.size()) {
479 throw OpalException(
480 "PartBunch::getTotalMass",
481 "Number of particle containers and mi values do not match.");
482 }
483 double mass = 0.0;
484 for (size_t i = 0; i < containers.size(); ++i) {
485 mass += mi_m[i] * containers[i]->getTotalNum();
486 }
487 return mass;
488 }
489
490 double getdE() {
491 return this->pcontainer_m->getStdKineticEnergy(); // Unit: MeV
492 }
493
494 const PartData* getReference() const { return reference_m; }
495
497 void setReference(const PartData* ref) {
498 reference_m = ref;
499 if (reference_m && this->pcontainer_m) {
500 // Ensure mean/std kinetic energy in DistributionMoments are computed using reference
501 // mass. PartData mass is stored in eV; DistributionMoments expects GeV for its energy
502 // computation.
503 this->pcontainer_m->setEnergyReferenceMass(reference_m->getM() * Units::eV2GeV, true);
504 }
505 }
506
508
509 size_t getLoadBalance(int p) { return globalPartPerNode_m[p]; }
510
513 *gmsg << "not implemented:: file: " << __FILE__ << " line: " << __LINE__
514 << " function: " << __func__ << endl;
515 return 0;
516 }
517
520 unsigned int /*nBins*/, std::vector<double>& /*lineDensity*/,
521 std::pair<double, double>& /*meshInfo*/) {
522 *gmsg << "not implemented:: file: " << __FILE__ << " line: " << __LINE__
523 << " function: " << __func__ << endl;
524 }
525
528 *gmsg << "not implemented:: file: " << __FILE__ << " line: " << __LINE__
529 << " function: " << __func__ << endl;
530 return Vector_t<double, Dim>(0);
531 }
532
540 void computeSelfFields();
541
546 void dumpBinConfig(bool preMerge);
547
551 Inform& print(Inform& os);
552
554 bool hasFieldSolver() const { return this->fsolver_m != nullptr; }
555
561
563 const BinnedFieldSolver_t* getFieldSolver() const;
564
566 std::string getFieldSolverType();
567
569 bool hasBinning() const { return this->bins_m != nullptr; }
570
574 int getCurrentNBins() const {
575 if (!hasBinning()) {
576 return 1;
577 }
578
579 int ret_bins = static_cast<int>(bins_m->getCurrentBinCount());
580 // If the number of bins is the same as the maximum number of bins, we haven't merged bins
581 // yet (likely because the simulation is too empty)
582 if (ret_bins == this->getBins()->getMaxBinCount()) {
583 Inform m("PartBunch::getCurrentNBins");
584 m << level4
585 << "WARNING: Number of bins is the same as the maximum number of bins, we haven't "
586 "merged bins yet (likely because the simulation is too empty). Returning 1. If "
587 "that is not the case, check e.g. binning parameters."
588 << endl;
589 return 1;
590 } else {
591 return ret_bins;
592 }
593 }
594
596 double calcMeanPhi() {
597 *gmsg << "not implemented:: file: " << __FILE__ << " line: " << __LINE__
598 << " function: " << __func__ << endl;
599 return 0.0;
600 }
601
603 std::string getParticleName(size_t i) const {
604 if (i >= particleNames_m.size()) {
605 return "";
606 }
607 return particleNames_m[i];
608 }
609
612 throw OpalException(
613 "PartBunch::R",
614 "Not implemented: shouldn't be called, since this is not the correct way to access "
615 "particle positions.");
616 return Vector_t<double, Dim>(0.0);
617 }
618
621 throw OpalException(
622 "PartBunch::P",
623 "Not implemented: shouldn't be called, since this is not the correct way to access "
624 "particle momenta.");
625 return Vector_t<double, Dim>(0.0);
626 }
627
634 rmin = rmin_m;
635 rmax = rmax_m;
636 }
637
639 void setdT(double dt) { dt_m = dt; }
640
642 double getdT() const { return dt_m; }
643
645 void setT(double t) { t_m = t; }
646
648 void incrementT() { t_m += dt_m; }
649
651 double getT() const { return t_m; }
652
658
661 *gmsg << "not implemented:: file: " << __FILE__ << " line: " << __LINE__
662 << " function: " << __func__ << endl;
663 return Vector_t<double, Dim>(0.0);
664 }
665
668
670 void setGlobalTrackStep(long long n) { globalTrackStep_m = n; }
671
673 long long getGlobalTrackStep() const { return globalTrackStep_m; }
674
677
679 void do_binaryRepart();
680
682 double get_rmsDensity() const { return rmsDensity_m; }
683};
684
685extern template class PartBunch<double, 3>;
686
687#endif // PARTBUNCH_H
Defines a structure to hold particles in energy bins and their associated data.
ippl::Vector< T, Dim > Vector_t
typename ippl::detail::ViewType< ippl::Vector< double, Dim >, 1 >::view_type view_type
ippl::Field< ippl::Vector< T, Dim >, Dim, ViewArgs... > VField_t
Definition PBunchDefs.h:31
typename ippl::detail::ViewType< ippl::Vector< double, 3 >, 1 >::view_type view_type
Definition PartBunch.h:40
Inform * gmsg
Definition changes.cpp:7
Handler for boundary conditions per spatial dimension.
Definition BCHandler.hpp:29
Definition Beam.h:32
Field solver wrapper that implements the full binned self-field algorithm.
Vector_t< double, Dim > R(size_t)
Do not use; throws (access positions via ParticleContainer::R).
Definition PartBunch.h:611
void computeBoundsForFieldSolve(Vector_t< double, Dim > &lower, Vector_t< double, Dim > &upper)
Computes the spatial bounds for the field solver based on the current particle distribution.
std::vector< bool > pcAtZStop_m
Per-container: frozen at current z-stop until next segment.
Definition PartBunch.h:93
Vector_t< double, Dim > rmax_m
Current bunch spatial maximum (from primary container stats).
Definition PartBunch.h:83
typename ParticleBinning::CoordinateSelector< ParticleContainer_t > CoordinateSelector_t
Definition PartBunch.h:63
BinnedFieldSolver< T, Dim > BinnedFieldSolver_t
Definition PartBunch.h:58
void par2grid() override
PicManager hook; throws (scatter handled elsewhere).
Definition PartBunch.h:293
void gatherLoadBalanceStatistics()
void setdT(double dt)
Set the global time step.
Definition PartBunch.h:639
void updateMoments()
Definition PartBunch.h:338
void performBunchSanityChecks() const
Validate BC handler, solver wiring, field pointers, and layout extents.
std::string getParticleName(size_t i) const
Particle species name for container i (from BEAM PARTICLE input).
Definition PartBunch.h:603
double getdE()
Definition PartBunch.h:490
std::shared_ptr< VField_t< T, Dim > > getTempEField()
Scratch E field used by the binned solver path.
Definition PartBunch.h:307
void computeSelfFields()
Compute the bunch self-fields (binned when available).
std::vector< std::string > particleNames_m
Per-container beam particle names.
Definition PartBunch.h:94
void incTrackSteps()
Increment globalTrackStep_m by one.
Definition PartBunch.h:676
double getMassPerParticle(size_t containerIndex=0) const
Get the mass per particle for a given particle container.
Definition PartBunch.h:419
void advance() override
PicManager hook; throws (tracking does not use this path).
Definition PartBunch.h:286
std::shared_ptr< VField_t< T, Dim > > Btmp_m
Definition PartBunch.h:114
double getdT() const
Get the global time step.
Definition PartBunch.h:642
void pre_run() override
Warm-up: zero rho and run the field solver once (skip full dumps).
void calcLineDensity(unsigned int, std::vector< double > &, std::pair< double, double > &)
Stub; logs only.
Definition PartBunch.h:519
void setT(double t)
Set the current simulation time.
Definition PartBunch.h:645
std::shared_ptr< AdaptBins_t > getBins() const
Const access to adaptive binning state.
Definition PartBunch.h:322
bool isFirstRepartition_m
True until the first ORB-style repartition completes.
Definition PartBunch.h:87
void setMass()
Set the per-particle mass for each particle container.
Definition PartBunch.h:368
Vector_t< int, Dim > nr_m
Mesh cell count per dimension.
Definition PartBunch.h:77
DataSink * dataSink_m
Borrowed diagnostics and dump output sink.
Definition PartBunch.h:107
std::array< bool, Dim > decomp_m
Domain decomposition flags (per axis).
Definition PartBunch.h:89
Vector_t< double, Dim > rmin_m
Definition PartBunch.h:80
double getTotalCharge() const
Get the total charge across all particle containers.
Definition PartBunch.h:457
void dumpBinConfig(bool preMerge)
Write bin edges/counts to the data sink when configured.
bool pcAtZStop(size_t i) const
Definition PartBunch.h:267
std::shared_ptr< AdaptBins_t > getBins()
Non-const access to adaptive binning state.
Definition PartBunch.h:319
FieldSolverCmd * OPALFieldSolver_m
Borrowed parsed FIELD_SOLVER command.
Definition PartBunch.h:106
std::shared_ptr< const BunchStateHandler > getBunchStateHandler() const
Definition PartBunch.h:336
double calcMeanPhi()
Compatibility stub; logs and returns 0.
Definition PartBunch.h:596
void reinitializeGridZ(int nrZ)
Reinitialize the z dimension of the field grid to nrZ cells.
Vector_t< double, Dim > origin_m
Mesh origin (lab coordinates).
Definition PartBunch.h:79
void calcBeamParameters()
Update moments and set rmin_m / rmax_m from the primary (first) container.
int nrZBase_m
Base z grid count before any image-charge doubling; used to reset nr_m.
Definition PartBunch.h:78
bool hasFieldSolver() const
Definition PartBunch.h:554
typename ParticleBinning::AdaptBinsBase< ParticleContainer_t > AdaptBins_t
Definition PartBunch.h:65
long long globalTrackStep_m
Global integration step counter.
Definition PartBunch.h:116
void do_binaryRepart()
ORB/binary repartition when the load balancer requests it (primary container).
double getT() const
Get the current simulation time.
Definition PartBunch.h:651
double getQ(size_t containerIndex=0) const
Alias for getCharge(containerIndex).
Definition PartBunch.h:431
std::string integration_method_m
Integrator name (e.g. leapfrog).
Definition PartBunch.h:75
double getM(size_t containerIndex=0) const
Get the total mass for a given particle container.
Definition PartBunch.h:440
std::shared_ptr< AdaptBins_t > bins_m
Adaptive velocity/gamma binning (optional).
Definition PartBunch.h:105
Vector_t< double, Dim > hr_m
Mesh spacing (m).
Definition PartBunch.h:84
typename ParticleBinning::GammaSelector< ParticleContainer_t > GammaSelector_t
Definition PartBunch.h:64
std::string solver_m
Field solver type string from input.
Definition PartBunch.h:76
size_t calcNumPartsOutside(Vector_t< double, Dim >)
Stub; logs and returns 0.
Definition PartBunch.h:512
double getCharge(size_t containerIndex=0) const
Get the total charge for a given particle container.
Definition PartBunch.h:387
void setReference(const PartData *ref)
Set inside TrackRun::execute.
Definition PartBunch.h:497
void setBCHandler(std::shared_ptr< BCHandler_t > bcHandler)
Definition PartBunch.h:328
Vector_t< double, Dim > get_origin() const
Cached minimum extent (rmin_m); prefer per-container min/max for multi-beam detail.
Definition PartBunch.h:655
int getCurrentNBins() const
Effective bin count for diagnostics (1 if binning inactive or still at max bins).
Definition PartBunch.h:574
bool hasBinning() const
Definition PartBunch.h:569
void incrementT()
Advance time by one global time step.
Definition PartBunch.h:648
std::vector< bool > pcActive_m
Per-container: participate in this track segment.
Definition PartBunch.h:92
std::shared_ptr< BCHandler_t > bcHandler_m
Field boundary conditions.
Definition PartBunch.h:104
Vector_t< double, Dim > P(size_t)
Do not use; throws (access momenta via ParticleContainer::P).
Definition PartBunch.h:620
std::shared_ptr< VField_t< T, Dim > > Etmp_m
Definition PartBunch.h:112
double lbt_m
Load-balancer timescale parameter.
Definition PartBunch.h:86
void setSolver()
Build field solver and load balancer from OPALFieldSolver_m.
double dt_m
Global time step (s).
Definition PartBunch.h:73
double t_m
Current simulation time (s).
Definition PartBunch.h:109
void setCharge()
Set the per-particle charge for each particle container.
Definition PartBunch.h:351
void grid2par() override
PicManager hook; throws (gather handled elsewhere).
Definition PartBunch.h:300
void setPcAtZStop(size_t i)
Deactivate container i until the next step-size segment (z-stop reached).
Vector_t< double, Dim > get_maxExtent() const
Cached maximum extent (rmax_m).
Definition PartBunch.h:657
ippl::NDIndex< Dim > domain_m
Global mesh index extent per dimension.
Definition PartBunch.h:88
void setImageChargeConfiguration(bool enabled, double zPlane)
Set the image-charge configuration for the field solver.
std::shared_ptr< BunchStateHandler > bunchState_m
Bunch state: unitless flag, repartition flag, etc.
Definition PartBunch.h:102
const PartData * reference_m
Reference particle data (set by TrackRun::execute).
Definition PartBunch.h:99
void setTempEField(std::shared_ptr< VField_t< T, Dim > > Etmp)
Definition PartBunch.h:310
Vector_t< double, Dim > getEExtrema()
Stub; logs and returns zero vector.
Definition PartBunch.h:527
double rmsDensity_m
Legacy RMS density placeholder (may still appear in stats).
Definition PartBunch.h:121
std::shared_ptr< VField_t< T, Dim > > getTempBField()
Scratch B field used by the binned solver path.
Definition PartBunch.h:313
void setTempBField(std::shared_ptr< VField_t< T, Dim > > Btmp)
Definition PartBunch.h:316
void setShiftedGreensConfiguration(bool enabled, double zPlane)
Set the shifted Green's function Dirichlet-correction configuration.
std::shared_ptr< BunchStateHandler > getBunchStateHandler()
Definition PartBunch.h:335
const PartData * getReference() const
Definition PartBunch.h:494
typename ParticleContainer_t::bin_index_type binIndex_t
Definition PartBunch.h:66
void setZerofaceMaxSteps(int maxSteps)
Set the maximum number of timesteps for which image charges are active (0 = unlimited).
ippl::ParticleBase< ippl::ParticleSpatialLayout< T, Dim >, Kokkos::DefaultExecutionSpace::memory_space > Base
Definition PartBunch.h:61
double get_rmsDensity() const
Legacy RMS density field (may be unused).
Definition PartBunch.h:682
void setGlobalTrackStep(long long n)
Definition PartBunch.h:670
void bunchUpdate()
Refresh mesh from particle extents, update layouts, and recompute moments.
double getTotalMass() const
Get the total mass across all particle containers.
Definition PartBunch.h:476
size_t getTotalNumAllContainers() const
Sum of getTotalNum() over all particle containers.
Definition PartBunch.h:226
bool anyPcActive() const
Definition PartBunch.h:276
std::string getFieldSolverType()
Backend type string (e.g. FFT, OPEN, CG, NONE).
void refreshPcActiveAfterEmit()
After emission: reactivate non-empty containers not marked at z-stop.
long long getGlobalTrackStep() const
Current global tracking step.
Definition PartBunch.h:673
DataSink * getDataSink() const
Definition PartBunch.h:333
Vector_t< double, Dim > get_halo() const
Stub; logs and returns zero vector.
Definition PartBunch.h:660
std::shared_ptr< BCHandler_t > getBCHandler() const
Current boundary-condition handler.
Definition PartBunch.h:331
Inform & print(Inform &os)
Human-readable dump of each container to os.
BinnedFieldSolver_t * getFieldSolver()
Non-const pointer to the concrete BinnedFieldSolver.
void applyGridUpdate(const Vector_t< double, Dim > &lower, const Vector_t< double, Dim > &upper)
Updates the mesh/grid and internal data structures to match the given spatial bounds.
void setBins()
Create adaptive bins from the binning command (VELOCITYZ / GAMMAZ).
bool isPcActive(size_t i) const
Definition PartBunch.h:256
void setBins(std::shared_ptr< AdaptBins_t > bins)
Definition PartBunch.h:325
size_t getLoadBalance(int p)
Definition PartBunch.h:509
void get_bounds(Vector_t< double, Dim > &rmin, Vector_t< double, Dim > &rmax)
Copy cached bunch extent (rmin_m, rmax_m) from calcBeamParameters.
Definition PartBunch.h:633
std::vector< double > qi_m
Charge per macroparticle [C], one entry per container.
Definition PartBunch.h:96
double getChargePerParticle(size_t containerIndex=0) const
Get the charge per particle for a given particle container.
Definition PartBunch.h:406
Vector_t< double, Dim > get_hr() const
Get mesh spacing.
Definition PartBunch.h:667
void setZeroFacePlaneDumpFrequency(int frequency)
Configure diagnostic dump frequency for the ZEROFACE plane potential.
void resetPcActive()
At segment start: active if container is non-empty; inactive if empty.
std::unique_ptr< size_t[]> globalPartPerNode_m
Per-rank particle counts for load-balance stats.
Definition PartBunch.h:119
void setPcActive(size_t i)
Force container i active (e.g. for containers with pending emission).
Definition PartBunch.h:259
std::vector< double > mi_m
Mass per macroparticle [GeV], one entry per container.
Definition PartBunch.h:97
int it_m
Iteration counter (legacy / diagnostics).
Definition PartBunch.h:74
Particle reference data.
Definition PartData.h:37
KOKKOS_INLINE_FUNCTION double getM() const
The constant mass per particle.
Definition PartData.h:109
Container for all per-particle (and per-simulation) fields tracked during OPALX tracking.
short int bin_index_type
Defines which type to use as a particle bin.
constexpr double eV2GeV
Definition Units.h:71
Example struct used to access the binning variable for each particle.
Selects the gamma factor for binning.