Particles.h File Reference
#include <cereal/cereal.hpp>
#include <ParticleHandler.h>
#include <Particles/BaseParticle.h>

Go to the source code of this file.

Functions

template<class Archive >
void load (Archive &ar, ParticleHandler &handl)
 
template<class Archive >
void save (Archive &ar, const ParticleHandler &handl)
 
template<class Archive >
void load (Archive &ar, BaseParticle &p)
 
template<class Archive >
void save (Archive &ar, const BaseParticle &p)
 

Function Documentation

◆ load() [1/2]

template<class Archive >
void load ( Archive &  ar,
BaseParticle p 
)
64  {
65  Vec3D position;
66  Vec3D velocity;
67  Mdouble radius;
68 
69  ar( CEREAL_NVP(position),
70  CEREAL_NVP(velocity),
71  CEREAL_NVP(radius));
72 
73  p.setPosition(position);
74  p.setRadius(radius);
75  p.setVelocity(velocity);
76 }
double Mdouble
Definition: GeneralDefine.h:34
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
Definition: BaseInteractable.cc:350
virtual void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
Definition: BaseInteractable.h:239
virtual void setRadius(Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species)
Definition: BaseParticle.cc:553
Definition: Vector.h:51

References BaseInteractable::setPosition(), BaseParticle::setRadius(), and BaseInteractable::setVelocity().

◆ load() [2/2]

template<class Archive >
void load ( Archive &  ar,
ParticleHandler handl 
)
42  {
43  cereal::size_type size;
44  ar ( cereal::make_size_tag(size) );
45 
47 
48  for (int i = 0; i < size; i++) {
49  ar(p);
50  logger(INFO, "Particle: \n\tPOS: % \n\tVEL: % \n\tRAD: %", p.getPosition(), p.getVelocity(), p.getRadius());
51  handl.copyAndAddObject(p);
52  }
53 }
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
std::enable_if<!std::is_pointer< U >::value, U * >::type copyAndAddObject(const U &object)
Creates a copy of a Object and adds it to the BaseHandler.
Definition: BaseHandler.h:379
virtual const Vec3D & getVelocity() const
Returns the velocity of this interactable.
Definition: BaseInteractable.cc:329
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:348
A spherical particle is the most simple particle used in MercuryDPM.
Definition: SphericalParticle.h:37
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51

References BaseHandler< T >::copyAndAddObject(), BaseInteractable::getPosition(), BaseParticle::getRadius(), BaseInteractable::getVelocity(), constants::i, INFO, and logger.

Referenced by main().

◆ save() [1/2]

template<class Archive >
void save ( Archive &  ar,
const BaseParticle p 
)
79  {
80  ar( cereal::make_nvp("position", p.getPosition()),
81  cereal::make_nvp("velocity", p.getVelocity()),
82  cereal::make_nvp("radius", p.getRadius()));
83 }

References BaseInteractable::getPosition(), BaseParticle::getRadius(), and BaseInteractable::getVelocity().

◆ save() [2/2]

template<class Archive >
void save ( Archive &  ar,
const ParticleHandler handl 
)
56  {
57  ar ( cereal::make_size_tag( handl.getNumberOfObjects() ));
58  for (const auto& p : handl) {
59  ar ( p );
60  }
61 }
unsigned int getNumberOfObjects() const override
Returns the number of objects in the container. In parallel code this practice is forbidden to avoid ...
Definition: ParticleHandler.cc:1325

References ParticleHandler::getNumberOfObjects().