Commit 71cdde71 authored by Nathan Coppin's avatar Nathan Coppin
Browse files

adding ignoring a given material

parent d605d6d6
......@@ -158,7 +158,6 @@ class ParticleProblem :
self._lib.particle_problem_get_delassus(self._p,_np2c(delassus))
return delassus
def body_velocity(self):
return self._get_array("body", self._bodytype)["velocity"]
......@@ -612,8 +611,10 @@ class ParticleProblem :
invertI = 0 if forced else 1/I
invertM = 0 if forced else 1/np.sum(masses)
idd = self.add_body(x, invertM, invertI)
if not isinstance(material,(list, np.ndarray)):
material = [material for i in range(positions.shape[0])]
for i in range(positions.shape[0]):
self.add_particle_to_body(positions[i,:]-x,radii[i],idd, material)
self.add_particle_to_body(positions[i,:]-x,radii[i],idd, material[i])
def add_particle_to_body(self, x, r, body, material="default"):
"""Adds a particle in the particle problem.
......@@ -624,6 +625,8 @@ class ParticleProblem :
material -- Particle material
"""
imat = self.get_material_id(material)
if material.lower() == "ignore":
imat = -1
self._lib.particle_problem_add_particle(self._p, self._coord_type(*x), c_double(r), c_size_t(body), c_int(imat))
def add_particle(self, x, r, m, tag="default",forced=False, inverse_inertia=None):
......
......@@ -805,7 +805,8 @@ static void particle_problem_gen_contacts(ParticleProblem *p, const double alert
}
#endif
for (size_t i = 0; i < vectorSize(p->particles); ++i) {
contact_tree_add_particle(tree, i, old_contacts, &iold);
if(p->particles[i].material >= 0)
contact_tree_add_particle(tree, i, old_contacts, &iold);
}
for (size_t i = 0; i < vectorSize(p->segments); ++i) {
contact_tree_gen_boundary_contact(tree, PARTICLE_SEGMENT, i, old_contacts, &iold);
......@@ -1268,7 +1269,7 @@ int particle_problem_iterate(ParticleProblem *p, double alert, double dt, double
}
for (size_t j = 0; j < vectorSize(p->particles); ++j){
Body *body = &p->bodies[p->particles[j].body];
#if DIMENSION==2
#if DIMENSION==2
double r[DIMENSION];
body_get_point(body,p->particles[j].x,r);
body->omega += ((r[0]-body->position[0])*externalForces[j*DIMENSION+1] - (r[1]-body->position[1])*externalForces[j*DIMENSION])*dt*body->invertI;
......
Markdown is supported
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