114 lines
2.9 KiB
C++
Executable File
114 lines
2.9 KiB
C++
Executable File
#ifndef PARTICLE_H
|
|
#define PARTICLE_H
|
|
|
|
#include "blitz/array.h"
|
|
#include "simulation/coordinates.h"
|
|
#include "simulation/species.h"
|
|
|
|
#include <map>
|
|
|
|
class MpiParticleReader;
|
|
|
|
namespace particle {
|
|
|
|
class SerializedParticle {
|
|
public:
|
|
SerializedParticle(double time_birth, double weight,
|
|
blitz::TinyVector<double, 3> cart_pos,
|
|
blitz::TinyVector<double, 3> cart_vel,
|
|
std::string spec_name);
|
|
SerializedParticle() {};
|
|
|
|
double timeBirth();
|
|
double weight();
|
|
blitz::TinyVector<double, 3> cartesianPosition();
|
|
blitz::TinyVector<double, 3> cartesianVelocity();
|
|
std::string specieName();
|
|
|
|
private:
|
|
double time_birth_;
|
|
blitz::TinyVector<double, 3> cartesian_position_;
|
|
blitz::TinyVector<double, 3> cartesian_velocity_;
|
|
// has to be null terminated
|
|
std::array<char, 16> specie_name_;
|
|
double weight_;
|
|
};
|
|
|
|
class Particle {
|
|
public:
|
|
// Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
|
// Coordinate* position,
|
|
// Vector* velocity);
|
|
Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
|
const Coordinate& position,
|
|
const Vector& velocity,
|
|
const double time_birth,
|
|
const double weight);
|
|
|
|
Particle(particle::SerializedParticle sparticle, std::map<std::string,
|
|
std::shared_ptr<species::TrackedSpecie>>& tracked_species);
|
|
|
|
void position(const Coordinate& new_position);
|
|
CartesianCoordinate cartesianPosition() const;
|
|
CylinderCoordinate cylinderPosition() const;
|
|
|
|
void velocity(const CartesianVector& new_velocity);
|
|
CartesianVector velocity() const;
|
|
|
|
void move(const Coordinate& distance);
|
|
|
|
double kineticEnergy_eV() const;
|
|
double absoluteVelocity() const;
|
|
double absoluteVelocitySquared() const;
|
|
|
|
double mass_kg() const;
|
|
double charge_C() const;
|
|
|
|
species::TrackedSpecie* specie() const;
|
|
|
|
static void lastId(long int id);
|
|
static long int lastId(); // only local on this cpu
|
|
|
|
void increaseInteractionCounter();
|
|
long int interactionCounter() const;
|
|
|
|
void increaseTimeAlive(double time_s);
|
|
double timeAlive() const;
|
|
|
|
long int ID() const;
|
|
|
|
double weight() const;
|
|
|
|
void indexNextInteration(const int index) { index_next_interaction_ = index; };
|
|
int indexNextInteraction() { return index_next_interaction_; };
|
|
|
|
void deposited(bool truthValue=true);
|
|
bool wasDeposited();
|
|
|
|
particle::SerializedParticle serialize();
|
|
|
|
private:
|
|
double weight_;
|
|
bool deposited_ = false;
|
|
|
|
CartesianVector velocity_;
|
|
CartesianCoordinate position_cart_;
|
|
CylinderCoordinate position_cyl_;
|
|
|
|
double time_alive_s_;
|
|
// double time_in_bin_s_;
|
|
long int interaction_counter_;
|
|
|
|
// index of the interaction with the sortest distance (-1 if that's none of them)
|
|
int index_next_interaction_ = -1;
|
|
|
|
std::shared_ptr<species::TrackedSpecie> specie_;
|
|
long int id_;
|
|
|
|
static long int last_id_; // only local on this cpu
|
|
};
|
|
|
|
}; // namespace particle
|
|
|
|
#endif /* PARTICLE_H */
|