Skip to content
Snippets Groups Projects
Commit d990457c authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

collect the right quantities at the right times.

Former-commit-id: 982f19233d8ae55e6ae0a454e564059ea96c1fba
parent a887426d
No related branches found
No related tags found
No related merge requests found
......@@ -860,15 +860,9 @@ void runner_dokick ( struct runner *r , struct cell *c , int timer ) {
v[2] = v_old[2] + hdt * a[2];
u = u_old + hdt * u_dt;
/* Collect momentum */
mom[0] += m * v[0];
mom[1] += m * v[1];
mom[2] += m * v[2];
/* Collect angular momentum */
ang[0] += m * ( x[1]*v[2] - x[2]*v[1] );
ang[1] += m * ( x[2]*v[0] - x[0]*v[2] );
ang[2] += m * ( x[0]*v[1] - x[1]*v[0] );
/* Collect total energy. */
ekin += 0.5 * m * ( v[0]*v[0] + v[1]*v[1] + v[2]*v[2] );
epot += m * u;
/* Step and store the velocity and internal energy. */
xp->v_old[0] = ( v_old[0] += dt * a[0] );
......@@ -885,6 +879,16 @@ void runner_dokick ( struct runner *r , struct cell *c , int timer ) {
(x[2] - x_old[2])*(x[2] - x_old[2]) );
dx_max = fmaxf( dx_max , dx );
/* Collect momentum */
mom[0] += m * v[0];
mom[1] += m * v[1];
mom[2] += m * v[2];
/* Collect angular momentum */
ang[0] += m * ( x[1]*v[2] - x[2]*v[1] );
ang[1] += m * ( x[2]*v[0] - x[0]*v[2] );
ang[2] += m * ( x[0]*v[1] - x[1]*v[0] );
/* Update positions and energies at the half-step. */
p->v[0] = v[0] + dt * a[0];
p->v[1] = v[1] + dt * a[1];
......@@ -901,10 +905,6 @@ void runner_dokick ( struct runner *r , struct cell *c , int timer ) {
p->h = h * expf( w );
h_max = fmaxf( h_max , h );
/* Collect total energy. */
ekin += 0.5 * m * ( v[0]*v[0] + v[1]*v[1] + v[2]*v[2] );
epot += m * u;
/* Init fields for density calculation. */
p->density.wcount = 0.0f;
p->density.wcount_dh = 0.0f;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment