Electrons are explicitly stored between timesteps
and can be dumped using MPI-IO. Restarts read particles from earlier output.
This commit is contained in:
@@ -18,6 +18,43 @@ Particle::Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
||||
}
|
||||
*/
|
||||
|
||||
// requires the name of a species "spec_name" to be smaller than 16 characters
|
||||
// this is not! checked here and will lead to undefined behaviour if this
|
||||
// requirement is not fulfilled
|
||||
SerializedParticle::SerializedParticle(double time_birth, double weight,
|
||||
blitz::TinyVector<double, 3> cartPos,
|
||||
blitz::TinyVector<double, 3> cartVel,
|
||||
std::string spec_name) :
|
||||
time_birth_(time_birth), weight_(weight),
|
||||
cartesian_position_(cartPos),
|
||||
cartesian_velocity_(cartVel) {
|
||||
std::copy(spec_name.begin(), spec_name.end(), specie_name_.data());
|
||||
specie_name_[spec_name.length()] = '\0';
|
||||
}
|
||||
|
||||
double SerializedParticle::timeBirth() {
|
||||
return time_birth_;
|
||||
}
|
||||
|
||||
double SerializedParticle::weight() {
|
||||
return weight_;
|
||||
}
|
||||
|
||||
blitz::TinyVector<double, 3> SerializedParticle::cartesianPosition() {
|
||||
return cartesian_position_;
|
||||
}
|
||||
|
||||
blitz::TinyVector<double, 3> SerializedParticle::cartesianVelocity() {
|
||||
return cartesian_velocity_;
|
||||
}
|
||||
|
||||
std::string SerializedParticle::specieName() {
|
||||
return std::string (specie_name_.data());
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Particle::Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
||||
const Coordinate& position,
|
||||
const Vector& velocity,
|
||||
@@ -34,6 +71,20 @@ Particle::Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
||||
last_id_++;
|
||||
}
|
||||
|
||||
Particle::Particle(particle::SerializedParticle sparticle, std::map<std::string,
|
||||
std::shared_ptr<species::TrackedSpecie>>& tracked_species) :
|
||||
specie_(tracked_species[sparticle.specieName()]),
|
||||
position_cart_(sparticle.cartesianPosition()),
|
||||
position_cyl_(blitz::TinyVector<double, 3>(0,0,0)),
|
||||
velocity_(sparticle.cartesianVelocity()),
|
||||
id_(this->last_id_),
|
||||
time_alive_s_(sparticle.timeBirth()),
|
||||
interaction_counter_(0),
|
||||
weight_(sparticle.weight()) {
|
||||
last_id_++;
|
||||
position_cyl_ = CylinderCoordinate(position_cart_);
|
||||
}
|
||||
|
||||
long int Particle::last_id_ = 0;
|
||||
|
||||
double Particle::mass_kg() const {
|
||||
@@ -115,12 +166,18 @@ double Particle::weight() const {
|
||||
return weight_;
|
||||
}
|
||||
|
||||
void Particle::deposited() {
|
||||
deposited_ = true;
|
||||
void Particle::deposited(bool truthValue) {
|
||||
deposited_ = truthValue;
|
||||
}
|
||||
|
||||
bool Particle::wasDeposited() {
|
||||
return deposited_;
|
||||
}
|
||||
|
||||
particle::SerializedParticle Particle::serialize() {
|
||||
return particle::SerializedParticle(time_alive_s_, weight_,
|
||||
position_cart_.cartesianEntries(), velocity_.cartesianEntries(),
|
||||
specie_->name());
|
||||
}
|
||||
|
||||
} // namespace particle
|
||||
|
||||
Reference in New Issue
Block a user