Molecular Dynamics Simulation  1.0
InternalToXSDTypeAdapter.cpp
Go to the documentation of this file.
2 
4  auto position = convertToVector(particle.getX());
5  auto velocity = convertToVector(particle.getV());
6  auto force = convertToVector(particle.getF());
7  auto old_force = convertToVector(particle.getOldF());
8  auto mass = particle.getM();
9  auto type = particle.getType();
10  auto epsilon = particle.getEpsilon();
11  auto sigma = particle.getSigma();
12  auto locked = particle.isLocked();
13  auto connected_particles = convertToConnectedParticles(particle.getConnectedParticles());
14 
15  auto particle_type = ParticleType{position, velocity, force, old_force, mass, type, epsilon, sigma, locked, connected_particles};
16 
17  return particle_type;
18 }
19 
20 DoubleVec3Type InternalToXSDTypeAdapter::convertToVector(const std::array<double, 3>& vector) {
21  return DoubleVec3Type{vector[0], vector[1], vector[2]};
22 }
23 
25  const std::vector<std::tuple<long, double, double>>& connected_particles) {
26  ConnectedParticlesType xsd_connected_particles{};
27 
28  for (const auto& entry : connected_particles) {
29  xsd_connected_particles.entries().push_back(convertToConnectedParticleEntry(entry));
30  }
31 
32  return xsd_connected_particles;
33 }
34 
35 ConnectedParticleEntryType InternalToXSDTypeAdapter::convertToConnectedParticleEntry(const std::tuple<long, double, double>& entry) {
36  return ConnectedParticleEntryType{std::get<0>(entry), std::get<1>(entry), std::get<2>(entry)};
37 }
static ConnectedParticlesType convertToConnectedParticles(const std::vector< std::tuple< long, double, double >> &connected_particles)
static DoubleVec3Type convertToVector(const std::array< double, 3 > &vector)
static ConnectedParticleEntryType convertToConnectedParticleEntry(const std::tuple< long, double, double > &entry)
static ParticleType convertToParticle(const Particle &particle)
Class to represent a particle.
Definition: Particle.h:26
double getSigma() const
Gets the Lennard-Jones potential parameter sigma.
Definition: Particle.h:192
const std::array< double, 3 > & getV() const
Gets the velocity of the particle.
Definition: Particle.h:162
bool isLocked() const
Gets whether the particle is locked in space.
Definition: Particle.h:202
int getType() const
Gets the type of the particle.
Definition: Particle.h:182
const std::array< double, 3 > & getX() const
Gets the position of the particle.
Definition: Particle.h:157
double getM() const
Gets the mass of the particle.
Definition: Particle.h:177
double getEpsilon() const
Gets the Lennard-Jones potential parameter epsilon.
Definition: Particle.h:187
const std::array< double, 3 > & getF() const
Gets the total force of the particle.
Definition: Particle.h:167
const std::array< double, 3 > & getOldF() const
Gets the old total force of the particle.
Definition: Particle.h:172
const std::vector< std::tuple< long, double, double > > & getConnectedParticles() const
Gets the list of connected particles.
Definition: Particle.h:207