Commit 44b267f7 authored by Matthieu Constant's avatar Matthieu Constant
Browse files

compute old contact force in iterate -- not good for reload

parent ed94aa8e
......@@ -94,6 +94,7 @@ class ParticleProblem :
raise ValueError("Dimension should be 2 or 3.")
self._lib.particleProblemNew.restype = c_void_p
self._p = c_void_p(self._lib.particleProblemNew())
self._fc = None
if self._p == None :
raise NameError("Cannot create particle problem.")
......@@ -165,6 +166,9 @@ class ParticleProblem :
return self._get_idx("TriangleMaterial")
else :
return np.array([],np.int32)
def previousContactForces(self):
return(self._fc)
def set_boundary_velocity(self, tag, v) :
self._lib.particleProblemGetTagId.restype = c_size_t
......@@ -221,8 +225,10 @@ class ParticleProblem :
forces -- list of vectors containing the forces applied on the particles
tol -- optional argument defining the interpenetration tolerance to stop the NLGS iterations of the NSCD
"""
vn = self.velocity().copy()
self._get_matrix("ExternalForces",self._dim)[:] = forces
self._lib.particleProblemIterate(self._p, c_double(np.min(self.r())), c_double(dt), c_double(tol), c_int(-1))
self._fc = (self.velocity()-vn)*self.mass()/dt - forces
def write_vtk(self, odir, i, t) :
"""Write output files for post-visualization."""
......@@ -319,6 +325,7 @@ class ParticleProblem :
v = np.hstack([v,vt])
o = np.vstack([fdata[k+"_idx"] for k in ks])
t = np.repeat([0,1,2,3],[fdata[k].shape[0] for k in ks])
self._fc = np.zeros_like(self.velocity())
self._lib.particleProblemSetContacts(self._p,c_int(t.shape[0]),_np2c(o,np.uint64),_np2c(v),_np2c(t,np.int32))
def add_boundary_disk(self, x0, r, tag, material="default") :
......@@ -345,6 +352,7 @@ class ParticleProblem :
tag -- particle tag
"""
self._lib.particleProblemAddParticle(self._p, self._coord_type(*x), c_double(r), c_double(m), tag.encode())
self._fc = np.zeros_like(self.velocity())
def set_use_queue(self, use_queue=1):
"""Enables the use of the queue if 1 and disables it if 0."""
......
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