diff --git a/classes/sph0/louis/src_cpp/FixedParticle.h b/classes/sph0/louis/src_cpp/FixedParticle.h index 2ce559dc..6ab0e2f1 100644 --- a/classes/sph0/louis/src_cpp/FixedParticle.h +++ b/classes/sph0/louis/src_cpp/FixedParticle.h @@ -8,7 +8,7 @@ class FixedParticle : public Particle { public: - FixedParticle(Model &m); + explicit FixedParticle(Model &m); virtual void update_vars() override; }; diff --git a/classes/sph0/louis/src_cpp/MobileParticle.h b/classes/sph0/louis/src_cpp/MobileParticle.h index 6e4b801c..41a9a696 100644 --- a/classes/sph0/louis/src_cpp/MobileParticle.h +++ b/classes/sph0/louis/src_cpp/MobileParticle.h @@ -11,7 +11,7 @@ class MobileParticle : public FixedParticle { public: - MobileParticle(Model &m); + explicit MobileParticle(Model &m); virtual void update_vars() override; diff --git a/classes/sph0/louis/src_cpp/Model.cpp b/classes/sph0/louis/src_cpp/Model.cpp index 9adf27ef..dfb94b3e 100644 --- a/classes/sph0/louis/src_cpp/Model.cpp +++ b/classes/sph0/louis/src_cpp/Model.cpp @@ -18,6 +18,19 @@ Model::Model() this->timeStep = 1.0e-15; this->currentTime = 0.0; this->RKstep = 0; + + // init other variables + this->numFP = 0; + this->numMP = 0; + this->h_0 = 0.0; + this->dom_dim = 0.0; + this->alpha = 0.0; + this->beta = 0.0; + this->kappa = 0.0; + this->kernelCorrection = 0.0; + this->maxTime = 0.0; + this->saveInt = 0.0; + this->numPart = 0; } Model::~Model() @@ -264,7 +277,7 @@ Model::update_dt() double dTf = std::numeric_limits::max(); for (int i = this->numFP + 1; i < this->numPart; i++) { - Particle *p = this->particles[i]; + Particle const *p = this->particles[i]; double dt = sqrt(p->h / 9.81); if (dt < dTf) dTf = dt; diff --git a/classes/sph0/louis/src_cpp/Particle.cpp b/classes/sph0/louis/src_cpp/Particle.cpp index 9658f165..cfbf6ab2 100644 --- a/classes/sph0/louis/src_cpp/Particle.cpp +++ b/classes/sph0/louis/src_cpp/Particle.cpp @@ -47,7 +47,7 @@ void Particle::getNeighbours() { int RKstep = this->model.RKstep; - Eigen::Vector3d &xyz = this->coord[RKstep]; // position of the particle + Eigen::Vector3d const &xyz = this->coord[RKstep]; // position of the particle if (RKstep == 0) { @@ -115,7 +115,7 @@ Particle::getNeighbours() for (size_t j = 0; j < cells->size(); j++) { Particle *p = (*cells)[j]; - Eigen::Vector3d &neighXYZ = p->coord[RKstep]; + Eigen::Vector3d const &neighXYZ = p->coord[RKstep]; double r = (xyz - neighXYZ).norm(); if (r <= this->model.kappa * this->h) { @@ -149,7 +149,7 @@ Particle::getNeighbours() for (size_t i = 0; i < this->neighbours.size(); i++) { Neighbour *neigh = &this->neighbours[i]; - Eigen::Vector3d &neighXYZ = neigh->p->coord[RKstep]; + Eigen::Vector3d const &neighXYZ = neigh->p->coord[RKstep]; neigh->r = (xyz - neighXYZ).norm(); } } @@ -167,7 +167,7 @@ Particle::gradW() if (this->neighbours.size() > 150) throw std::runtime_error("number of neighbours greater than expected (max 150 for vec_gradW): " + std::to_string(this->neighbours.size())); - double h = this->h; + // double h = this->h; int RKstep = this->model.RKstep; for (size_t i = 0; i < this->neighbours.size(); i++) @@ -198,8 +198,8 @@ Particle::kernel_corr() for (size_t i = 0; i < this->neighbours.size(); i++) { Particle *neigh = this->neighbours[i].p; - Eigen::Vector3d &pb = neigh->coord[RKstep]; - Eigen::Vector3d &pa = this->coord[RKstep]; + Eigen::Vector3d const &pb = neigh->coord[RKstep]; + Eigen::Vector3d const &pa = this->coord[RKstep]; double factor = neigh->m / neigh->rho[RKstep]; M += factor * (pb - pa) * this->vec_gradW[i].transpose(); diff --git a/classes/sph0/louis/src_cpp/QtVTKHook.h b/classes/sph0/louis/src_cpp/QtVTKHook.h index 0c0e568a..a030dc8c 100644 --- a/classes/sph0/louis/src_cpp/QtVTKHook.h +++ b/classes/sph0/louis/src_cpp/QtVTKHook.h @@ -26,7 +26,8 @@ class DisplayWindow : public QWidget public: DisplayWindow(Model &model, QWidget *parent = nullptr); ~DisplayWindow(); -void updateParticlePositions(); + + void updateParticlePositions(); private: void setupGUI(); diff --git a/classes/sph0/louis/src_cpp/Sorter.cpp b/classes/sph0/louis/src_cpp/Sorter.cpp index 25aba841..b24b8435 100644 --- a/classes/sph0/louis/src_cpp/Sorter.cpp +++ b/classes/sph0/louis/src_cpp/Sorter.cpp @@ -8,6 +8,8 @@ Sorter::Sorter(Model &m) : model(m) { + this->dx = 0.0; + this->nx = 0; } /// Put every particle in their corresponding cell. @@ -23,9 +25,9 @@ Sorter::execute() for(auto &cell : this->cells) cell.clear(); - for(auto &p : this->model.particles) + for(auto const &p : this->model.particles) { - Eigen::Vector3d &pos = p->coord[this->model.RKstep]; + Eigen::Vector3d const &pos = p->coord[this->model.RKstep]; int ix = (int)((pos(0) - fmod(pos(0), this->dx)) / this->dx) + 1; int iy = (int)((pos(1) - fmod(pos(1), this->dx)) / this->dx) + 1; diff --git a/classes/sph0/louis/src_cpp/Sorter.h b/classes/sph0/louis/src_cpp/Sorter.h index a843bbcc..81660afe 100644 --- a/classes/sph0/louis/src_cpp/Sorter.h +++ b/classes/sph0/louis/src_cpp/Sorter.h @@ -19,7 +19,7 @@ class Sorter std::vector> cells; public: - Sorter(Model &m); + explicit Sorter(Model &m); void execute();