Particle database base class. More...
#include <particledatabase.hpp>
Public Member Functions | |
virtual | ~ParticleDataBase () |
Virtual destructor. More... | |
void | set_thread_count (uint32_t threadcount) |
Set the number of threads used for calculation. More... | |
void | set_accuracy (double epsabs, double epsrel) |
Set the accuracy requirement for calculation. More... | |
void | set_bfield_suppression (const CallbackFunctorD_V *functor) |
Set magnetic field suppression location depedent callback functor. More... | |
void | set_trajectory_handler_callback (const TrajectoryHandlerCallback *thand_cb) |
Set trajectory handler callback. More... | |
void | set_trajectory_end_callback (const TrajectoryEndCallback *tend_cb) |
Set trajectory end callback. More... | |
void | set_polyint (bool polyint) |
Set the interpolation type to polynomial(true) or linear(false). More... | |
bool | get_polyint (void) const |
Get current interpolation type. More... | |
void | set_max_steps (uint32_t maxsteps) |
Set maximum number of steps to iterate. More... | |
void | set_max_time (double maxt) |
Set maximum lifetime of particle in simulation. More... | |
void | set_save_trajectories (uint32_t div) |
Set trajectory saving. More... | |
uint32_t | get_save_trajectories (void) const |
Get trajectory saving. More... | |
void | set_mirror (const bool mirror[6]) |
Set particle mirroring on boundaries. More... | |
void | get_mirror (bool mirror[6]) const |
Get particle mirroring on boundaries. More... | |
int | get_iteration_number (void) const |
Get the number of iteration rounds done. More... | |
double | get_rhosum (void) const |
Return sum of defined beam space charge density. More... | |
void | set_rhosum (double rhosum) |
Set sum of defined beam space charge density. More... | |
const ParticleStatistics & | get_statistics (void) const |
Get particle iterator statistics. More... | |
geom_mode_e | geom_mode () const |
Return geometry mode. More... | |
size_t | size (void) const |
Returns particle count. More... | |
virtual ParticleBase & | particle (uint32_t i)=0 |
Returns a reference to particle i. More... | |
virtual const ParticleBase & | particle (uint32_t i) const =0 |
Returns a const reference to particle i. More... | |
double | traj_length (uint32_t i) const |
Returns the length of trajectory i. More... | |
size_t | traj_size (uint32_t i) const |
Returns number of trajectory points for particle i. More... | |
virtual const ParticlePBase & | trajectory_point (uint32_t i, uint32_t j) const =0 |
Gets the particle i trajectory point j as particle point. More... | |
void | trajectory_point (double &t, Vec3D &loc, Vec3D &vel, uint32_t i, uint32_t j) const |
Gets the particle i trajectory point j into vel, loc and t. More... | |
void | trajectories_at_plane (TrajectoryDiagnosticData &tdata, coordinate_axis_e axis, double val, const std::vector< trajectory_diagnostic_e > &diagnostics) const |
Gets trajectory diagnostic diagnostics at plane axis = val in trajectory diagnostic data object tdata. More... | |
void | build_trajectory_density_field (ScalarField &tdens) const |
Build trajectory density field. More... | |
void | clear (void) |
Clears the particle database of all particles. More... | |
void | clear_trajectories (void) |
Clears the particle trajectory database. More... | |
void | clear_trajectory (size_t a) |
Clears particle a in the particle trajectory database. More... | |
void | reserve (size_t size) |
Reserve memory for size particles. More... | |
void | iterate_trajectories (ScalarField &scharge, const VectorField &efield, const VectorField &bfield, const Geometry &g) |
Iterate particles through the geometry. More... | |
void | step_particles (ScalarField &scharge, const VectorField &efield, const VectorField &bfield, const Geometry &g, double dt) |
Step particles forward by time step dt. More... | |
virtual void | save (const std::string &filename) const =0 |
Saves data to a new file filename. More... | |
virtual void | save (std::ostream &s) const =0 |
Saves data to stream. More... | |
virtual void | debug_print (std::ostream &os) const =0 |
Print debugging information to os. More... | |
Protected Member Functions | |
ParticleDataBase () | |
Constructor. More... | |
ParticleDataBase (const ParticleDataBase &pdb) | |
Copy constructor. More... | |
const ParticleDataBase & | operator= (const ParticleDataBase &pdb) |
Assignment. More... | |
void | set_implementation_pointer (class ParticleDataBaseImp *imp) |
Set particle database implementation pointer. More... | |
Particle database base class.
Particle database base class holds the definitions of particle iteration parameters. Base class also provides a possibility for general pointer to particle database and virtual functions for accessing particles.
|
protected |
Constructor.
|
protected |
Copy constructor.
|
virtual |
Virtual destructor.
void ParticleDataBase::build_trajectory_density_field | ( | ScalarField & | tdens | ) | const |
Build trajectory density field.
The scalar field tdens can differ from geometry.
void ParticleDataBase::clear | ( | void | ) |
Clears the particle database of all particles.
Clears the database of particles. Also clears beam space charge sum.
void ParticleDataBase::clear_trajectories | ( | void | ) |
Clears the particle trajectory database.
The particle definitions are conserved, but existing trajectories are cleared.
void ParticleDataBase::clear_trajectory | ( | size_t | a | ) |
Clears particle a in the particle trajectory database.
The particle definition is conserved, but existing trajectory are cleared.
|
pure virtual |
Print debugging information to os.
Implemented in ParticleDataBase3D, ParticleDataBaseCyl, and ParticleDataBase2D.
geom_mode_e ParticleDataBase::geom_mode | ( | ) | const |
Return geometry mode.
int ParticleDataBase::get_iteration_number | ( | void | ) | const |
Get the number of iteration rounds done.
void ParticleDataBase::get_mirror | ( | bool | mirror[6] | ) | const |
Get particle mirroring on boundaries.
Mirroring is read for (xmin,xmax,ymin,ymax,zmin,zmax) borders. Mirroring is always false for directions that do not exist.
bool ParticleDataBase::get_polyint | ( | void | ) | const |
Get current interpolation type.
True is returned if polynomial interpolation is enabled and false if disabled.
double ParticleDataBase::get_rhosum | ( | void | ) | const |
Return sum of defined beam space charge density.
Returns the summed beam space charge density for all beams defined with "add_beam" functions. Does not work with individually added particle trajectories. rhosum is cleared with particle database clearing function clear().
Can be used to program plasma electron density with EpotProblem::set_pexp_plasma() for example. Please note that it gives to accumulated charge density which might be incorrect for multi-beam extraction simulation defined with several calls to "add_beam" functions.
uint32_t ParticleDataBase::get_save_trajectories | ( | void | ) | const |
Get trajectory saving.
If div is zero, no trajectories are saved. If div is one, every trajectory is saved. If div N>1, every Nth trajectory is saved.
const ParticleStatistics& ParticleDataBase::get_statistics | ( | void | ) | const |
Get particle iterator statistics.
void ParticleDataBase::iterate_trajectories | ( | ScalarField & | scharge, |
const VectorField & | efield, | ||
const VectorField & | bfield, | ||
const Geometry & | g | ||
) |
Iterate particles through the geometry.
The particles defined in particle database pdb are iterated through electric field efield and magnetic field bfield in geometry g. Space charge density field scharge is set from the particle trajectories.
|
protected |
Assignment.
|
pure virtual |
Returns a reference to particle i.
Implemented in ParticleDataBase3D, ParticleDataBaseCyl, and ParticleDataBase2D.
|
pure virtual |
Returns a const reference to particle i.
Implemented in ParticleDataBase3D, ParticleDataBaseCyl, and ParticleDataBase2D.
void ParticleDataBase::reserve | ( | size_t | size | ) |
Reserve memory for size particles.
|
pure virtual |
Saves data to a new file filename.
Implemented in ParticleDataBase3D, ParticleDataBaseCyl, and ParticleDataBase2D.
|
pure virtual |
Saves data to stream.
Implemented in ParticleDataBase3D, ParticleDataBaseCyl, and ParticleDataBase2D.
void ParticleDataBase::set_accuracy | ( | double | epsabs, |
double | epsrel | ||
) |
Set the accuracy requirement for calculation.
Accuracy requirements default to epsabs = 1.0e-6 and epsrel = 1.0e-6.
void ParticleDataBase::set_bfield_suppression | ( | const CallbackFunctorD_V * | functor | ) |
Set magnetic field suppression location depedent callback functor.
Can be used to suppress the magnetic field effect on particles inside the plasma by making an object with a pointer to electric potential. Comparing to local potential value the magnetic field suppression can be localized to a volume with selected potential range.
|
protected |
Set particle database implementation pointer.
Used by child constructors.
void ParticleDataBase::set_max_steps | ( | uint32_t | maxsteps | ) |
Set maximum number of steps to iterate.
One thousand (1000) steps is the default
void ParticleDataBase::set_max_time | ( | double | maxt | ) |
Set maximum lifetime of particle in simulation.
One millisecond (1e-3 sec) is the default
void ParticleDataBase::set_mirror | ( | const bool | mirror[6] | ) |
Set particle mirroring on boundaries.
Mirroring is set for (xmin,xmax,ymin,ymax,zmin,zmax) borders. Mirroring is always false for directions that do not exist.
By default, mirroring is disabled for all boundaries.
void ParticleDataBase::set_polyint | ( | bool | polyint | ) |
Set the interpolation type to polynomial(true) or linear(false).
Polynomial interpolation is the default.
void ParticleDataBase::set_rhosum | ( | double | rhosum | ) |
Set sum of defined beam space charge density.
void ParticleDataBase::set_save_trajectories | ( | uint32_t | div | ) |
Set trajectory saving.
If div is zero, no trajectories are saved. If div is one, every trajectory is saved. If div N>1, every Nth trajectory is saved.
By default, all trajectories are saved.
|
inline |
Set the number of threads used for calculation.
void ParticleDataBase::set_trajectory_end_callback | ( | const TrajectoryEndCallback * | tend_cb | ) |
Set trajectory end callback.
void ParticleDataBase::set_trajectory_handler_callback | ( | const TrajectoryHandlerCallback * | thand_cb | ) |
Set trajectory handler callback.
size_t ParticleDataBase::size | ( | void | ) | const |
Returns particle count.
void ParticleDataBase::step_particles | ( | ScalarField & | scharge, |
const VectorField & | efield, | ||
const VectorField & | bfield, | ||
const Geometry & | g, | ||
double | dt | ||
) |
Step particles forward by time step dt.
The particles defined in particle database pdb are stepped forward one time step in electric field efield and geometry g.
double ParticleDataBase::traj_length | ( | uint32_t | i | ) | const |
Returns the length of trajectory i.
size_t ParticleDataBase::traj_size | ( | uint32_t | i | ) | const |
Returns number of trajectory points for particle i.
void ParticleDataBase::trajectories_at_plane | ( | TrajectoryDiagnosticData & | tdata, |
coordinate_axis_e | axis, | ||
double | val, | ||
const std::vector< trajectory_diagnostic_e > & | diagnostics | ||
) | const |
Gets trajectory diagnostic diagnostics at plane axis = val in trajectory diagnostic data object tdata.
|
pure virtual |
Gets the particle i trajectory point j as particle point.
Implemented in ParticleDataBase3D, ParticleDataBaseCyl, and ParticleDataBase2D.
void ParticleDataBase::trajectory_point | ( | double & | t, |
Vec3D & | loc, | ||
Vec3D & | vel, | ||
uint32_t | i, | ||
uint32_t | j | ||
) | const |
Gets the particle i trajectory point j into vel, loc and t.