Commit 56eca17f authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

Revert "34s"

This reverts commit f7eedff6.
parent f7eedff6
Pipeline #9355 failed with stages
in 58 seconds
......@@ -858,38 +858,29 @@ static int contact_solve(ParticleProblem *p, Contact *c, double dt, double tol)
&p->bodies[p->particles[c->o0].body]:
&p->bodies[p->segments[c->o0].b.body];
{
body_advance(body0, dt);
body_advance(body1, dt);
if (c->type == PARTICLE_PARTICLE) {
const Particle *p0 = &p->particles[c->o0];
mu = particle_problem_get_mu(p,p0->material,p1->material);
{
double dbx = body1->position[0]- body0->position[0] + dt*(body1->velocity[0]-body0->velocity[0]);
double dby = body1->position[1]- body0->position[1] + dt*(body1->velocity[1]-body0->velocity[1]);
double theta0 = body0->theta + body0->omega*dt;
double s0 = sin(theta0);
double c0 = cos(theta0);
double rx0 = c0*p0->x[0] - s0*p0->x[1];
double ry0 = s0*p0->x[0] + c0*p0->x[1];
double theta1 = body0->theta + body0->omega*dt;
double s1 = sin(theta1);
double c1 = cos(theta1);
double rx1 = c1*p1->x[0] - s1*p1->x[1];
double ry1 = s1*p1->x[0] + c1*p1->x[1];
nx = dbx + rx1-rx0;
ny = dby + ry1-ry0;
double nnorm = sqrt(nx*nx+ny*ny);//hypot(nx,ny);
double nnorm = 0;
double x0[DIMENSION], x1[DIMENSION];
body_get_point(body0, p0->x, x0);
body_get_point(body1, p1->x, x1);
nx = x1[0]-x0[0];
ny = x1[1]-x0[1];
nnorm = sqrt(nx*nx+ny*ny);//hypot(nx,ny);
nx /= nnorm;
ny /= nnorm;
r0[0] = rx0 + nx*p0->r;
r1[0] = rx1 - nx*p1->r;
r0[1] = ry0 + ny*p0->r;
r1[1] = ry1 - ny*p1->r;
r0[0] = x0[0]-body0->position[0] + nx*p0->r;
r1[0] = x1[0]-body1->position[0] - nx*p1->r;
r0[1] = x0[1]-body0->position[1] + ny*p0->r;
r1[1] = x1[1]-body1->position[1] - ny*p1->r;
D = nnorm - (p0->r + p1->r);
}
}
else if (c->type == PARTICLE_SEGMENT) {
body_advance(body0, dt);
body_advance(body1, dt);
mu = particle_problem_get_mu(p,p->segments[c->o0].b.material,p1->material);
double x1[DIMENSION];
body_get_point(body1, p1->x, x1);
......@@ -897,9 +888,9 @@ static int contact_solve(ParticleProblem *p, Contact *c, double dt, double tol)
D = contact_update_segment_particle(c, p, x1, normal, r0, r1, &contact_avoided);
nx = normal[0];
ny = normal[1];
body_advance(body0, -dt);
body_advance(body1, -dt);
}
body_advance(body0, -dt);
body_advance(body1, -dt);
}
// allow the pre-existing (from previous time steps) interpenetrations
D -= c->D0;
......@@ -980,8 +971,8 @@ static int contact_solve(ParticleProblem *p, Contact *c, double dt, double tol)
body1->velocity[0]-body1->omega*c->r1[1]-body0->velocity[0]+body0->omega*c->r0[1],
body1->velocity[1]+body1->omega*c->r1[0]-body0->velocity[1]-body0->omega*c->r0[0]
};
double dv[2] = {new_dv[0]-old_dv[0], new_dv[1]-old_dv[1]};
return (dv[0]*dv[0]+dv[1]*dv[1])*dt*dt < tol*tol;
double dv = hypot(new_dv[0]-old_dv[0], new_dv[1]-old_dv[1]);
return dv*dt < tol;
}
void swap(int *a, int *b) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment