Commit 4185a4d7 authored by Nathan Coppin's avatar Nathan Coppin
Browse files

correcting bug on an index

parent a68115e8
Pipeline #6504 passed with stage
in 2 minutes and 47 seconds
......@@ -193,7 +193,7 @@ class ParticleProblem :
return np.array([],np.int32)
def contact_forces(self):
return self._get_matrix("ContactForces",self._dim)
return (self._get_matrix("ContactForces",self._dim))
def set_boundary_velocity(self, tag, v) :
self._lib.particleProblemGetTagId.restype = c_size_t
......@@ -201,7 +201,7 @@ class ParticleProblem :
disks = self._get_matrix("Disk",2*self._dim+(dim if self._friction_enabled else 1))
diskTag = self._get_idx("DiskTag")
disks[diskTag == tag, self._dim:2*self._dim] = v
segments = self._get_matrix("Segment",3*self._dim)
segments = self._get_matrix("Segment",3*self._dim+(self._dim-1 if self._friction_enabled else 1))
segmentTag = self._get_idx("SegmentTag")
segments[segmentTag == tag, 2*self._dim:3*self._dim+((dim-1) if self._friction_enabled else 0)] = v
if self._dim == 3 :
......
......@@ -75,6 +75,7 @@ def predictor_corrector_iterate(fluid, particles, dt, min_nsub=1, contact_tol=1e
fluid.advance_concentration(dt)
# Reset solid velocities
particles.velocity()[:,:] = vp0
fluid.set_particles(particles.mass(), particles.volume(), particles.position(), particles.velocity(), particles.contact_forces())
_advance_particles(particles,(alpha*f0+(1-alpha)*f1),dt,min_nsub,contact_tol,momentum=momentum)
# Give to the fluid the solid information
fluid.set_particles(particles.mass(), particles.volume(), particles.position(), particles.velocity(), particles.contact_forces())
......@@ -100,7 +101,7 @@ def iterate(fluid, particles, dt, min_nsub=1, contact_tol=1e-8, external_particl
if particles is not None and external_particles_forces is not None:
if external_particles_forces.shape!=particles.velocity().shape:
raise ValueError("external_particles_forces must have shape (number of particles,dimension!")
if particles is None and fluid is not None:
if (particles is None or particles.r() is None) and fluid is not None:
fluid.implicit_euler(dt)
# For two fluids flows, advance the concentration field with the fluid velocity.
# The number of sub-time steps for the advection is automatically computed.
......@@ -108,7 +109,7 @@ def iterate(fluid, particles, dt, min_nsub=1, contact_tol=1e-8, external_particl
fluid.advance_concentration(dt)
if particles is not None and fluid is None:
_advance_particles(particles,external_particles_forces,dt,min_nsub,contact_tol,momentum=momentum)
if fluid is not None and particles is not None:
if fluid is not None and particles is not None and particles.r() is not None:
if fixed_grains:
fluid.implicit_euler(dt)
fluid.set_particles(particles.mass(), particles.volume(), particles.position(), particles.velocity(),-fluid.compute_node_force(dt))
......
......@@ -1288,7 +1288,7 @@ int particleProblemIterate(ParticleProblem *p, double alert, double dt, double t
{
for (size_t j = 0; j < vectorSize(p->particles); ++j){
for (size_t i = 0; i < DIMENSION; ++i){
if(!p->ForcedFlag[i]){
if(!p->ForcedFlag[j]){
p->velocity[j * DIMENSION + i] += externalForces[j * DIMENSION + i] * dt / p->particles[j].m;
}
p->contactForces[j*DIMENSION+i] = p->velocity[j*DIMENSION+i];
......@@ -1297,7 +1297,7 @@ int particleProblemIterate(ParticleProblem *p, double alert, double dt, double t
if(!particleProblemSolve(p, alert, dt, tol, maxit) && !force_motion){
for (size_t j = 0; j < vectorSize(p->particles); ++j){
for (size_t i = 0; i < DIMENSION; ++i){
if(!p->ForcedFlag[i]){
if(!p->ForcedFlag[j]){
p->velocity[j * DIMENSION + i] -= externalForces[j * DIMENSION + i] * dt / p->particles[j].m;
}
}
......
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