Commit 490f2c2c authored by Nathan Coppin's avatar Nathan Coppin
Browse files

adapting testcases

parent d4527ca1
Pipeline #8255 passed with stages
in 2 minutes and 59 seconds
......@@ -54,11 +54,13 @@ filename = outputdir + "/Drag.csv"
#Injected particles
p = scontact.ParticleProblem(2,True,True)
p.read_vtk("depot/output",10)
p.remove_particles_flag((p.position()[:,1]-p.r()[:,0]>0.5)*(p.position()[:,1]+p.r()[:,0] <0.53))
state = p.state()
p.remove_particles_flag((state.x[:,1]-p.r()[:,0]>0.5)*(state.x[:,1]+p.r()[:,0] <0.53))
#Flow particles
p2 = scontact.ParticleProblem(2,True,True)
p2.read_vtk("depot/output",10)
p2.remove_particles_flag(p2.position()[:,1]+p2.r()[:,0] <0.5)
state2 = p2.state()
p2.remove_particles_flag(state2.x()[:,1]+p2.r()[:,0] <0.5)
p2.clear_boundaries()
p2.load_msh_boundaries("mesh.msh", ["Inner","Left","Right"],material = "Steel")
p2.set_friction_coefficient(0.3,"Sand","Sand")
......@@ -74,20 +76,20 @@ fluid.set_wall_boundary("Left", velocity = [0,0])
fluid.set_wall_boundary("Right", velocity = [0,0])
fluid.set_open_boundary("Bottom", velocity = [0,vit])
fluid.set_open_boundary("Top",pressure = 0)
fluid.set_particles(p2.mass(), p2.volume(), p2.position(), p2.velocity(), p2.contact_forces(),init=True)
fluid.set_particles(p2.mass(), p2.volume(), state2, p2.contact_forces(),init=True)
fluid.export_vtk(outputdir, 0.,0)
#
# COMPUTATION LOOP
#
def accumulate(F):
F+=np.sum(p2.get_boundary_forces("Inner"),axis=0)
F+=np.sum(p2.get_boundary_impulses("Inner"),axis=0)
while t < tEnd :
p2.forced_flag()[(p2.position()[:,1] + p2.r()[:,0] <= -0.5)] = 1
p2.velocity()[p2.forced_flag()==1,:] = [0, vit]
p2.omega()[p2.forced_flag()==1] = 0
if max(p2.position()[:,1]+p2.r()[:,0]) < 0.5 and t < 25 :
p2.add_particles(p.position(),p.r(),p.mass(),v=p.velocity()[:,:] + [0,vit],tag="Sand",forced=p.forced_flag(),contact_forces=p.contact_forces())
p2.remove_particles_flag( (p2.position()[:,1] + p2.r()[:,0] >-0.55))
p2.forced_flag()[(state2.x[:,1] + p2.r()[:,0] <= -0.5)] = 1
state2.v[p2.forced_flag()==1,:] = [0, vit]
state2.omega[p2.forced_flag()==1] = 0
if max(state2.x[:,1]+p2.r()[:,0]) < 0.5 and t < 25 :
p2.add_particles(state.x,p.r(),p.mass(),v=state.v,tag="Sand",forced=p.forced_flag(),contact_forces=p.contact_forces())
p2.remove_particles_flag( (state2.x[:,1] + p2.r()[:,0] >-0.55))
F = np.zeros(2)
time_integration.particle_changed(fluid,p2)
time_integration.iterate(fluid,p2,dt,1,contact_tol=5e-7,external_particles_forces=g*p2.mass(),after_sub_iter=lambda subdt : accumulate(F))
......
......@@ -60,12 +60,14 @@ filename = outputdir + "/Drag.csv"
#Injected particles
p = scontact.ParticleProblem(3,True,True)
p.read_vtk("depot/"+ str(numDep),2)
p.remove_particles_flag((p.position()[:,1]-p.r()[:,0]>0.5)*(p.position()[:,1]+p.r()[:,0] <0.52))
p.velocity()[:,1] = vit
state = p.state()
p.remove_particles_flag((state.x[:,1]-p.r()[:,0]>0.5)*(state.x[:,1]+p.r()[:,0] <0.52))
state.v[:,1] = vit
#Flow particles
p2 = scontact.ParticleProblem(3,True,True)
p.read_vtk("depot/"+ str(numDep),2)
p2.remove_particles_flag(p2.position()[:,1]+p2.r()[:,0] <0.5)
state2 = p2.state()
p2.remove_particles_flag(state2.x[:,1]+p2.r()[:,0] <0.5)
p2.clear_boundaries()
p2.load_msh_boundaries("mesh.msh", ["Inner","Left", "Right","Front","Rear"],material = "Steel")
p2.set_friction_coefficient(mupart,"Sand","Sand")
......@@ -89,20 +91,20 @@ p2.write_vtk(outputdir, 0, 0)
# COMPUTATION LOOP
#
def accumulate(F):
F+=np.sum(p2.get_boundary_forces("Inner"),axis=0)
F+=np.sum(p2.get_boundary_impulses("Inner"),axis=0)
while t < tEnd :
p2.forced_flag()[(p2.position()[:,1] + p2.r()[:,0] <= -0.5)] = 1
p2.velocity()[p2.forced_flag()==1,:] = [0, vit, 0]
p2.omega()[p2.forced_flag()==1,:] = [0,0,0]
if max(p2.position()[:,1]+p2.r()[:,0]) < 0.5 and t < 21 :
p2.add_particles(p.position(),p.r(),p.mass(),v=p.velocity(),tag="Sand",forced=p.forced_flag(),contact_forces=p.contact_forces())
p2.remove_particles_flag( (p2.position()[:,1] + p2.r()[:,0] >-0.52))
p2.forced_flag()[(state2.x[:,1] + p2.r()[:,0] <= -0.5)] = 1
state2.v[p2.forced_flag()==1,:] = [0, vit, 0]
state2.omega[p2.forced_flag()==1,:] = [0,0,0]
if max(state2.x[:,1]+p2.r()[:,0]) < 0.5 and t < 21 :
p2.add_particles(state.x,p.r(),p.mass(),v=state.v,tag="Sand",forced=p.forced_flag(),contact_forces=p.contact_forces())
p2.remove_particles_flag( (state2.x[:,1] + p2.r()[:,0] >-0.52))
F = np.zeros(3)
#time_integration.particle_changed(fluid,p2)
time_integration.iterate(None,p2,dt,1,contact_tol=1e-6,external_particles_forces=g*p2.mass(),after_sub_iter=lambda subdt : accumulate(F))
with open(filename,"a") as file1:
F /= dt
F += fluid.boundary_force()[0,:]
#F += fluid.boundary_force()[0,:]
file1.write( str(F[0])+";"+str(F[1])+";"+str(F[2])+";"+str(t)+"\n")
t += dt
# Output files writing
......
......@@ -74,11 +74,13 @@ p = scontact.ParticleProblem(2,friction_enabled = True,rotation_enabled=True)
p2 = scontact.ParticleProblem(2,friction_enabled = True,rotation_enabled=True)
p.read_vtk(outputdir, 0)
p2.read_vtk(outputdir, 0)
p2.remove_particles_flag((p2.position()[:,1] + p2.r()[:,0] <1.15))
p2.remove_particles_flag((p2.position()[:,1] + p2.r()[:,0] >1.1))
p2.remove_particles_flag((p2.position()[:,0] + p2.r()[:,0] <0.15))
p2.remove_particles_flag((p2.position()[:,0] + p2.r()[:,0] >-0.15))
p2.position()[:,1] -= 0.6
state = p.state()
state2 = p2.state()
p2.remove_particles_flag((state2.x[:,1] + p2.r()[:,0] <1.15))
p2.remove_particles_flag((state2.x[:,1] + p2.r()[:,0] >1.1))
p2.remove_particles_flag((state2.x[:,0] + p2.r()[:,0] <0.15))
p2.remove_particles_flag((state2.x[:,0] + p2.r()[:,0] >-0.15))
state2.x[:,1] -= 0.6
p.clear_boundaries()
p.load_msh_boundaries("mesh.msh", ["Inner"], material = "Steel")
p.load_msh_boundaries("mesh.msh", ["Right","Left","RightUp","RightDown","LeftUp","LeftDown"], material = "Plexi")
......@@ -100,13 +102,13 @@ while t < tEnd :
p.load_msh_boundaries("mesh.msh", ["Inner"],material="Steel")
p.load_msh_boundaries("mesh.msh", ["Right","Left","RightUp","RightDown","LeftUp","LeftDown"],material="Plexi")
#Adding new particles
if (max(p.position()[:,1])+max(p.r()) <0.5) and t > 3 and t < 25:
p.add_particles(p2.position(),p2.r(),p2.mass(),v=p2.velocity(),tag="Sand",forced=p2.forced_flag(),contact_forces=p2.contact_forces())
if (max(state.x[:,1])+max(p.r()) <0.5) and t > 3 and t < 25:
p.add_particles(state2.x,p2.r(),p2.mass(),v=state2.v,tag="Sand",forced=p2.forced_flag(),contact_forces=p2.contact_forces())
#Solving the contacts
F = np.zeros(2)
time_integration.iterate(None,p,dt,min_nsub=1,contact_tol=1e-7,external_particles_forces=g*p.mass(),after_sub_iter= lambda subdt : accumulate(F))
#Removing particles outside the hopper
p.remove_particles_flag( (p.position()[:,1] >-0.6))
p.remove_particles_flag( (state.x[:,1] >-0.6))
#Computing mean velocity and writing to file
with open(filename,"a") as file1:
file1.write(str(F[0])+";"+str(F[1])+";"
......
......@@ -82,11 +82,13 @@ else :
p2 = scontact.ParticleProblem(3,friction_enabled = True,rotation_enabled=True)
p.read_vtk(outputdir, 0)
p2.read_vtk(outputdir, 0)
p2.remove_particles_flag((p2.position()[:,1] + p2.r()[:,0] <1.25))
p2.remove_particles_flag((p2.position()[:,1] + p2.r()[:,0] >1.1))
p2.remove_particles_flag((p2.position()[:,0] + p2.r()[:,0] <0.18))
p2.remove_particles_flag((p2.position()[:,0] + p2.r()[:,0] >-0.18))
p2.position()[:,1] -= 0.5
state = p.state()
state2 = p2.state()
p2.remove_particles_flag((state2.x[:,1] + p2.r()[:,0] <1.25))
p2.remove_particles_flag((state2.x[:,1] + p2.r()[:,0] >1.1))
p2.remove_particles_flag((state2.x[:,0] + p2.r()[:,0] <0.18))
p2.remove_particles_flag((state2.x[:,0] + p2.r()[:,0] >-0.18))
state2.x[:,1] -= 0.5
p.clear_boundaries()
p.load_msh_boundaries("mesh" + ".msh", ["Inner","Right","Left","Front","Rear","LockDown"], material = "Steel")
......@@ -96,20 +98,20 @@ p.write_vtk(outputdir, 0, 0)
#
opened = 0
def accumulate(F):
F+=np.sum(p.get_boundary_forces("Inner"),axis=0)
F+=np.sum(p.get_boundary_impulses("Inner"),axis=0)
while t < tEnd :
if t>=10 and opened == 0:
opened = 1
p.clear_boundaries()
p.load_msh_boundaries("mesh" + ".msh", ["Inner","Right","Left","Front","Rear"],material="Steel")
#Adding new particles
if (max(p.position()[:,1])+max(p.r()) <0.6) and t > 10 and t < 25:
p.add_particles(p2.position(),p2.r(),p2.mass(),v=p2.velocity(),tag="Sand",forced=p2.forced_flag(),contact_forces=p2.contact_forces())
if (max(state.x[:,1])+max(p.r()) <0.6) and t > 10 and t < 25:
p.add_particles(state2.x,p2.r(),p2.mass(),v=state2.v,tag="Sand",forced=p2.forced_flag(),contact_forces=p2.contact_forces())
#Solving the contacts
F = np.zeros(3)
time_integration.iterate(None,p,dt,min_nsub=1,contact_tol=1e-6,external_particles_forces=g*p.mass(),after_sub_iter= lambda subdt : accumulate(F))
#Removing particles outside the hopper
p.remove_particles_flag( (p.position()[:,1] >-0.6))
p.remove_particles_flag( (state.x[:,1] >-0.6))
#Computing mean velocity and writing to file
with open(filename,"a") as file1:
file1.write(str(F[0])+";"+str(F[1])+";"+str(F[2])+";"
......
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