Update all code to use real type

This commit is contained in:
Alex Selimov 2025-04-27 14:33:46 -04:00
parent 4269333aa2
commit 62e52940bc
3 changed files with 19 additions and 16 deletions

View file

@ -1,19 +1,20 @@
#ifndef BOX_H #ifndef BOX_H
#define BOX_H #define BOX_H
#include "precision.hpp"
/** /**
* Struct representing the simulation box. * Struct representing the simulation box.
* Currently the simulation box is always assumed to be perfectly rectangular. * Currently the simulation box is always assumed to be perfectly rectangular.
* This code does not support shearing the box. This functionality may be added * This code does not support shearing the box. This functionality may be added
* in later. * in later.
*/ */
template <typename T> struct Box { struct Box {
T xlo; real xlo;
T xhi; real xhi;
T ylo; real ylo;
T yhi; real yhi;
T zlo; real zlo;
T zhi; real zhi;
bool x_is_periodic; bool x_is_periodic;
bool y_is_periodic; bool y_is_periodic;
bool z_is_periodic; bool z_is_periodic;

View file

@ -1,6 +1,7 @@
#ifndef PARTICLE_H #ifndef PARTICLE_H
#define PARTICLE_H #define PARTICLE_H
#include "precision.hpp"
#include "vec3.h" #include "vec3.h"
/** /**
@ -8,11 +9,11 @@
* This class is only used on the host side of the code and is converted * This class is only used on the host side of the code and is converted
* to the device arrays. * to the device arrays.
*/ */
template <typename T = float> struct Particle { struct Particle {
Vec3<T> pos; Vec3<real> pos;
Vec3<T> vel; Vec3<real> vel;
Vec3<T> force; Vec3<real> force;
T mass; real mass;
}; };
#endif #endif

View file

@ -3,15 +3,16 @@
#include "box.hpp" #include "box.hpp"
#include "particle.hpp" #include "particle.hpp"
#include "precision.hpp"
#include <vector> #include <vector>
template <typename T> class Simulation { class Simulation {
// Simulation State variables // Simulation State variables
T timestep; real timestep;
Box<T> box; Box box;
// Host Data // Host Data
std::vector<Particle<T>> particles; std::vector<Particle> particles;
}; };
#endif #endif