Skip to content
Snippets Groups Projects
Commit eba84165 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Clean-up drift task and make it more const-correct

parent 28c96a8f
No related branches found
No related tags found
2 merge requests!136Master,!79First version of the multiple time-stepping
...@@ -756,9 +756,9 @@ void runner_doghost(struct runner *r, struct cell *c) { ...@@ -756,9 +756,9 @@ void runner_doghost(struct runner *r, struct cell *c) {
*/ */
void runner_dodrift(struct runner *r, struct cell *c, int timer) { void runner_dodrift(struct runner *r, struct cell *c, int timer) {
int k, nr_parts = c->count; const int nr_parts = c->count;
float ih, rho, u, w, h = 5.; const float dt = r->e->time - r->e->timeOld;
float dt = r->e->time - r->e->timeOld; float u, w, rho;
struct part *restrict p, *restrict parts = c->parts; struct part *restrict p, *restrict parts = c->parts;
struct xpart *restrict xp, *restrict xparts = c->xparts; struct xpart *restrict xp, *restrict xparts = c->xparts;
...@@ -768,17 +768,15 @@ void runner_dodrift(struct runner *r, struct cell *c, int timer) { ...@@ -768,17 +768,15 @@ void runner_dodrift(struct runner *r, struct cell *c, int timer) {
if (!c->split) { if (!c->split) {
/* Loop over all the particles in the cell */ /* Loop over all the particles in the cell */
for (k = 0; k < nr_parts; k++) { for (int k = 0; k < nr_parts; k++) {
/* Get a handle on the part. */ /* Get a handle on the part. */
p = &parts[k]; p = &parts[k];
xp = &xparts[k]; xp = &xparts[k];
/* Get local copies of particle data. */ /* Get local copies of particle data. */
h = p->h; const float h = p->h;
ih = 1.0f / h; const float ih = 1.0f / h;
;
/* Drift... */ /* Drift... */
p->x[0] += xp->v_full[0] * dt; p->x[0] += xp->v_full[0] * dt;
...@@ -793,7 +791,7 @@ void runner_dodrift(struct runner *r, struct cell *c, int timer) { ...@@ -793,7 +791,7 @@ void runner_dodrift(struct runner *r, struct cell *c, int timer) {
/* Predict internal energy */ /* Predict internal energy */
w = p->force.u_dt / p->u * dt; w = p->force.u_dt / p->u * dt;
if (fabsf(w) < 0.01f) if (fabsf(w) < 0.01f)
u = p->u *= u = p->u *=
1.0f + 1.0f +
w * (1.0f + w * (0.5f + w * (1.0f / 6.0f + w * (1.0f + w * (0.5f + w * (1.0f / 6.0f +
1.0f / 24.0f * w))); /* 1st order 1.0f / 24.0f * w))); /* 1st order
...@@ -805,11 +803,11 @@ void runner_dodrift(struct runner *r, struct cell *c, int timer) { ...@@ -805,11 +803,11 @@ void runner_dodrift(struct runner *r, struct cell *c, int timer) {
/* Predict smoothing length */ /* Predict smoothing length */
w = p->force.h_dt * ih * dt; w = p->force.h_dt * ih * dt;
if (fabsf(w) < 0.01f) if (fabsf(w) < 0.01f)
h = p->h *= p->h *=
1.0f + 1.0f +
w * (1.0f + w * (0.5f + w * (1.0f / 6.0f + 1.0f / 24.0f * w))); w * (1.0f + w * (0.5f + w * (1.0f / 6.0f + 1.0f / 24.0f * w)));
else else
h = p->h *= expf(w); p->h *= expf(w);
/* Predict density */ /* Predict density */
w = -3.0f * p->force.h_dt * ih * dt; w = -3.0f * p->force.h_dt * ih * dt;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment