Commit ad3473ed authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

remove state in all .py files

parent 8668533f
Pipeline #8535 failed with stages
in 1 minute and 33 seconds
......@@ -82,7 +82,7 @@ fluid.set_wall_boundary("Left")
fluid.set_wall_boundary("Top",pressure=0)
fluid.set_wall_boundary("Right")
# Set locations of the grains in the mesh and compute the porosity in each computation cell.
fluid.set_particles(p.mass(), p.volume(), p.state(),p.contact_forces(),init=True)
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(),p.contact_forces(),init=True)
# Write output files for post-visualization.
fluid.export_vtk(outputdir,0,0)
......
......@@ -113,7 +113,7 @@ fluid.set_strong_boundary("Top",1,0)
fluid.set_strong_boundary("Left",0,0)
fluid.set_strong_boundary("Right",0,0)
# Set locations of the grains in the mesh and compute the porosity in each computation cell.
fluid.set_particles(p.mass(), p.volume(), p.state(), p.contact_forces(), init=True)
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(), p.contact_forces(), init=True)
# Pressure initialization
fluid.solution()[:,2] = (H-fluid.coordinates()[:,1])*(-g[1])*rhof
# Write output files for post-visualization.
......
......@@ -130,7 +130,7 @@ fluid.set_wall_boundary("Left")
fluid.set_wall_boundary("Top",pressure=0)
fluid.set_wall_boundary("Right")
# Set location of the particles in the mesh and compute the porosity in each computation cell
fluid.set_particles(p.mass(), p.volume(), p.state(), p.contact_forces(), init=True)
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(), p.contact_forces(), init=True)
#Access to fluid fields and node coordiantes
s = fluid.solution()
x = fluid.coordinates()
......
......@@ -83,7 +83,7 @@ fluid.set_wall_boundary("Left")
fluid.set_wall_boundary("Top",pressure=0)
fluid.set_wall_boundary("Right")
# Set location of the particles in the mesh and compute the porosity in each computation cell
fluid.set_particles(p.mass(), p.volume(), p.state(),p.contact_forces(),init=True)
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(),p.contact_forces(),init=True)
# Access to fluid fields and node coordiantes
s = fluid.solution()
x = fluid.coordinates()
......
......@@ -117,7 +117,7 @@ fluid.set_wall_boundary("Outer",velocity=[0,0],pressure=0)
fluid.set_strong_boundary("Inner",0,lambda x : (x[:,1]/rout)*0.1)
fluid.set_strong_boundary("Inner",1,lambda x : (-x[:,0]/rout)*0.1)
# Set location of the grains in the mesh and compute the porosity in each computation cell
fluid.set_particles(p.mass(), p.volume(), p.state(), p.contact_forces(), init=True)
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(), p.contact_forces(), init=True)
fluid.export_vtk(outputdir,0,0)
tic = time.time()
#
......
......@@ -109,7 +109,7 @@ fluid.set_wall_boundary("Bottom")
fluid.set_wall_boundary("Lateral")
fluid.set_wall_boundary("Top",pressure=0)
# Set location of the particles in the mesh and compute the porosity in each computation cell
fluid.set_particles(p.mass(), p.volume(), p.state(), p.contact_forces(),init=True)
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(), p.contact_forces(),init=True)
fluid.export_vtk(outputdir,0,0)
p.write_vtk(outputdir, 0, 0)
......
......@@ -104,7 +104,7 @@ fluid.set_wall_boundary("Bottom")
fluid.set_wall_boundary("X")
fluid.set_wall_boundary("Z")
#Set location of the particles in the mesh and compute the porosity in each computation cell
fluid.set_particles(p.mass(), p.volume(), p.state(),p.contact_forces(),init=True)
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(), p.contact_forces(),init=True)
tic = time.time()
fluid.export_vtk(outputdir,0,0)
......
......@@ -80,7 +80,7 @@ ii = 0
mv.velocity = -1/tEnd
p.setBoundaryVelocity("Pile", [0, mv.velocity])
fluid.set_particles(p.mass(), p.volume(), p.state())
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
p.write_vtk(outputdir, ii, t)
p.write_boundary_vtk(outputdir, ii, t)
fluid.write_solution(outputdir, ii, t, "vtk")
......@@ -91,7 +91,7 @@ while t < tEnd :
forces = fluid.solve()
p.iterate(dt, forces)
fluid.set_mesh_position(fluid.mesh_position() + mv.call(fluid.mesh_position()) * dt)
fluid.set_particles(p.mass(), p.volume(), p.state())
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
mv.position += dt * mv.velocity
t += dt
ii += 1
......
......@@ -83,7 +83,7 @@ mv.position = 0.5
t = 0
ii = 0
fluid.set_particles(p.mass(), p.volume(), p.state())
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
p.write(outputdir, ii, t)
fluid.write_solution(outputdir, ii, t)
fluid.write_position(outputdir, ii, t)
......@@ -96,7 +96,7 @@ while t < tEnd :
forces = fluid.solve()
p.iterate(dt, forces)
fluid.set_mesh_position(fluid.mesh_position() + mv.cb(fluid.mesh_position()) * dt)
fluid.set_particles(p.mass(), p.volume(), p.state())
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
mv.position += dt * mv.velocity
t += dt
ii += 1
......
......@@ -54,12 +54,11 @@ filename = outputdir + "/Drag.csv"
#Injected particles
p = scontact.ParticleProblem(2,True,True)
p.read_vtk("depot/outputNotOk",10)
p.remove_particles_flag((p.state().x[:,1]-p.r()[:,0]>0.5)*(p.state().x[:,1]+p.r()[:,0] <0.61))
p.remove_particles_flag((p.position()[:,1]-p.r()[:,0]>0.5)*(p.position()[:,1]+p.r()[:,0] <0.61))
#Flow particles
p2 = scontact.ParticleProblem(2,True,True)
p2.read_vtk("depot/outputNotOk",10)
state2 = p2.state()
p2.remove_particles_flag(state2.x[:,1]+p2.r()[:,0] <0.5)
p2.remove_particles_flag(p2.position()[:,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")
......@@ -75,7 +74,7 @@ p2.write_vtk(outputdir, 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(), state2, p2.contact_forces(),init=True)
#fluid.set_particles(p2.mass(), p2.volume(), p2.position(), p2.velocity(), p2.contact_forces(),init=True)
#fluid.export_vtk(outputdir, 0.,0)
#
# COMPUTATION LOOP
......@@ -83,17 +82,15 @@ p2.write_vtk(outputdir, 0, 0)
def accumulate(F,nsub):
F+=np.sum(p2.get_boundary_forces("Inner"),axis=0)/nsub
while t < tEnd :
state2 = p2.state()
p2.forced_flag()[(state2.x[:,1] + p2.r()[:,0] <= -0.5)] = 1
p2.forced_flag()[(p2.position()[:,1] + p2.r()[:,0] <= -0.5)] = 1
if t > 2:
state2.v[p2.forced_flag()==1,:] = [0, vit]
p2.velocity()[p2.forced_flag()==1,:] = [0, vit]
else :
state2.v[p2.forced_flag()==1,:] = [0, 0]
state2.omega[p2.forced_flag()==0] = 1
p2.set_state(state2)
if max(p2.state().x[:,1]+p2.r()[:,0]) < 0.5 and t < 9 :
p2.add_particles(p.state().x,p.r(),p.mass(),v=p.state().v,tag="Sand",forced=p.forced_flag(),contact_forces=p.contact_forces())
p2.remove_particles_flag( (p2.state().x[:,1] + p2.r()[:,0] >-0.55))
p2.velocity()[p2.forced_flag()==1,:] = [0, 0]
p2.omega()[p2.forced_flag()==0] = 1
if max(p2.position()[:,1]+p2.r()[:,0]) < 0.5 and t < 9 :
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.55))
F = np.zeros(2)
#time_integration.particle_changed(fluid,p2)
time_integration.iterate(None,p2,dt,1,contact_tol=5e-7,external_particles_forces=g*p2.mass(),after_sub_iter=lambda nsub : accumulate(F,nsub))
......
......@@ -60,14 +60,12 @@ filename = outputdir + "/Drag.csv"
#Injected particles
p = scontact.ParticleProblem(3,True,True)
p.read_vtk("depot/"+ str(numDep),2)
p.remove_particles_flag((p.state().x[:,1]-p.r()[:,0]>0.5)*(p.state().x[:,1]+p.r()[:,0] <0.52))
state = p.state()
state.v[:,1] = vit
p.set_state(state)
p.remove_particles_flag((p.position()[:,1]-p.r()[:,0]>0.5)*(p.position()[:,1]+p.r()[:,0] <0.52))
p.velocity()[:,1] = vit
#Flow particles
p2 = scontact.ParticleProblem(3,True,True)
p.read_vtk("depot/"+ str(numDep),2)
p2.remove_particles_flag(p2.state().x[:,1]+p2.r()[:,0] <0.5)
p2.remove_particles_flag(p2.position()[:,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")
......@@ -93,14 +91,12 @@ p2.write_vtk(outputdir, 0, 0)
def accumulate(F,nsub):
F+=np.sum(p2.get_boundary_forces("Inner"),axis=0)/nsub
while t < tEnd :
state2 = p2.state()
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]
p2.set_state(state2)
if max(p2.state().x[:,1]+p2.r()[:,0]) < 0.5 and t < 21 :
p2.add_particles(p.state().x,p.r(),p.mass(),v=p.state().v,tag="Sand",forced=p.forced_flag(),contact_forces=p.contact_forces())
p2.remove_particles_flag( (p2.state().x[:,1] + p2.r()[:,0] >-0.52))
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))
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 nsub : accumulate(F,nsub))
......
......@@ -123,7 +123,7 @@ fluid.set_wall_boundary("Top", pressure=0)
fluid.set_wall_boundary("Bottom")
fluid.set_wall_boundary("Lateral")
# Set location of the particles in the mesh and compute the porosity in each computation cell
fluid.set_particles(p.mass(), p.volume(), p.state(),p.contact_forces(),init=True)
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(),p.contact_forces(),init=True)
fluid.solution()[:,2] = (H-(fluid.coordinates()[:,1]+0.25))*(-g[1])*rho
t = 0
......
......@@ -123,7 +123,7 @@ fluid.set_wall_boundary("Top", pressure=0)
fluid.set_wall_boundary("Bottom")
fluid.set_wall_boundary("Lateral")
# Set location of the particles in the mesh and compute the porosity in each computation cell
fluid.set_particles(p.mass(), p.volume(), p.state(),p.contact_forces(),init=True)
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(),p.contact_forces(),init=True)
fluid.solution()[:,2] = (H-(fluid.coordinates()[:,1]+0.25))*(-g[1])*rho
t = 0
......
......@@ -116,7 +116,7 @@ fluid.set_wall_boundary("Top", pressure=0)
fluid.set_wall_boundary("Bottom")
fluid.set_wall_boundary("Lateral")
# Set location of the particles in the mesh and compute the porosity in each computation cell
fluid.set_particles(p.mass(), p.volume(), p.state(),p.contact_forces(),init=True)
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(),p.contact_forces(),init=True)
t = 0
fluid.solution()[:,2] = (fluid.coordinates()[:,1]-0.6)*rho*g[1]
......
......@@ -82,7 +82,7 @@ fluid.set_wall_boundary("Bottom")
fluid.set_wall_boundary("Lateral")
fluid.import_vtk(outputrel+"/fluid_%05d.vtu"%iReload)
fluid.set_particles(p.mass(), p.volume(), p.state(),reload=1)
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(),reload=1)
ii = (iReload-1)*outf+1
t=ii*dt
......@@ -111,7 +111,7 @@ while t < tEnd :
p.iterate(dt/nsub, forces)
t += dt
fluid.set_particles(p.mass(), p.volume(), p.state())
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
# Output files writting
if ii %outf == 0 :
......@@ -119,4 +119,4 @@ while t < tEnd :
p.write_vtk(outputdir, ioutput, t)
fluid.export_vtk(outputdir, t, ioutput)
ii += 1
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.time() - tic))
\ No newline at end of file
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.time() - tic))
......@@ -129,7 +129,7 @@ H = 0.5
fluid.solution()[:,3] = (H-(fluid.coordinates()[:,1]+0.25))*(-g[1])*rho
# Set location of the particles in the mesh and compute the porosity in each computation cell
fluid.set_particles(p.mass(), p.volume(), p.state(), p.contact_forces(),init=True)
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(), p.contact_forces(),init=True)
t = 0
fluid.export_vtk(outputdir,0,0)
......@@ -157,4 +157,4 @@ while t < tEnd :
p.write_vtk(outputdir, ioutput, t)
fluid.export_vtk(outputdir, t, ioutput)
ii += 1
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.time() - tic))
\ No newline at end of file
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.time() - tic))
......@@ -139,7 +139,7 @@ H = 0.5
fluid.solution()[:,3] = (H-(fluid.coordinates()[:,1]+0.25))*(-g[1])*rho
# Set location of the particles in the mesh and compute the porosity in each computation cell
fluid.set_particles(p.mass(), p.volume(), p.state(), p.contact_forces(),init=True)
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(), p.contact_forces(),init=True)
t = 0
fluid.export_vtk(outputdir,0,0)
......@@ -168,4 +168,4 @@ while t < tEnd :
p.write_vtk(outputdir, ioutput, t)
fluid.export_vtk(outputdir, t, ioutput)
ii += 1
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.time() - tic))
\ No newline at end of file
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.time() - tic))
......@@ -128,7 +128,7 @@ H = 0.5
fluid.solution()[:,3] = (H-(fluid.coordinates()[:,1]+0.25))*(-g[1])*rho
# Set location of the particles in the mesh and compute the porosity in each computation cell
fluid.set_particles(p.mass(), p.volume(), p.state(),p.contact_forces(),init=True)
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(),p.contact_forces(),init=True)
t = 0
tic = time.time()
......
......@@ -114,7 +114,7 @@ fluid.set_wall_boundary("X")
fluid.set_wall_boundary("Z")
fluid.solution()[:,3] = (fluid.coordinates()[:,1]-0.6)*rho*g[1]
# Set location of the particles in the mesh and compute the porosity in each computation cell
fluid.set_particles(p.mass(), p.volume(), p.state(), p.contact_forces(), init=True)
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(), p.contact_forces(), init=True)
t = 0
fluid.export_vtk(outputdir,0,0)
......
......@@ -93,11 +93,11 @@ fluid.set_wall_boundary("Lateral")
fluid.set_wall_boundary("Funnel")
fluid.set_open_boundary("Hole", pressure=0)
fluid.set_particles(p.mass(), p.volume(), p.state())
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
fluid.export_vtk(outputdir,0,0)
tic = time.time()
fluid.set_particles(p.mass(), p.volume(), p.state())
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
while t < tEnd :
fluid.implicit_euler(dt)
forces = fluid.compute_node_force(dt)
......@@ -107,7 +107,7 @@ while t < tEnd :
print("NSUB", nsub,"VMAX",vmax, "VMAX * dt", vmax * dt, "r", min(p.r()))
for i in range(nsub) :
p.iterate(dt/nsub, forces,1e-6)
fluid.set_particles(p.mass(), p.volume(), p.state())
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
t += dt
if ii %outf == 0 :
ioutput = int(ii/outf) + 1
......
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