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

Merge branch 'fix_periodic' into 'master'

Fix periodic

See merge request !20
parents b60343a1 320a778d
Pipeline #9344 passed with stages
in 3 minutes and 50 seconds
......@@ -39,16 +39,13 @@ os.chdir(dir_path)
outputdir = "outputDepotNP"
if not os.path.isdir(outputdir) :
os.makedirs(outputdir)
subprocess.call(["gmsh", "-2", "meshDepot.geo","-clscale","1"])
#subprocess.call(["gmsh", "-2", "meshDepot.geo","-clscale","1"])
t = 0
ii = 0
#physical parameters
# g = np.array([0.001,-0.001])
# g = np.array([0.1,-0.5]) # gravity
g = np.array([0.,-9.81]) # gravity
rho = 1000 # fluid density
rhop = 1500 # particle density
......@@ -91,16 +88,16 @@ fluid.set_wall_boundary("Top",velocity=[0,0])
# fluid.set_strong_boundary("Bottom",0,0)
# if strong boundary on periodic line, it should be forced on both sides
fluid.set_strong_boundary("Right",2,0)
fluid.set_strong_boundary("Left",2,0)
# fluid.set_strong_boundary("Right",2,0)
# fluid.set_strong_boundary("Left",2,0)
ii = 0
t = 0
#set initial_condition
fluid.set_particles(p.mass(), p.volume(), p.state(),p.contact_forces())
fluid.export_vtk(outputdir,0,0)
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(),p.contact_forces())
fluid.write_vtk(outputdir,0,0)
G = np.zeros((p.n_particles(),2))
G[:,1] = p.mass()[:,0]*g[1]
......@@ -109,23 +106,20 @@ ii = 0
tic = time.time()
while t < tEnd :
#Fluid solver
oldstate = np.copy(p.state())
time_integration.iterate(fluid, p, dt, min_nsub=5, external_particles_forces=G)
state = p.state()
state.x[:,0] = np.fmod(state.x[:,0],L)
ind = np.where(state.x[:,0] <= 0)
state.x[ind,0] += L
p.set_state(state)
p.position()[:,0] = np.fmod(p.position()[:,0],L)
ind = np.where(p.position()[:,0] <= 0)
p.position()[ind,0] += L
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(),p.contact_forces())
fluid.set_particles(p.mass(), p.volume(), oldstate,p.contact_forces(),init=False)
fluid.set_particles(p.mass(), p.volume(), p.state(),p.contact_forces(),init=False)
#Output files writting
t += dt
if ii %outf == 0 :
ioutput = int(ii/outf) + 1
fluid.export_vtk(outputdir, t, ioutput)
fluid.write_vtk(outputdir, ioutput, t)
p.write_vtk(outputdir, ioutput, t)
ii += 1
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.time() - tic))
......
......@@ -96,8 +96,8 @@ ii = 0
t = 0
#set initial_condition
fluid.set_particles(p.mass(), p.volume(), p.state(),p.contact_forces())
fluid.export_vtk(outputdir,0,0)
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(),p.contact_forces())
fluid.write_vtk(outputdir,0,0)
G = p.mass()*g
ii = 0
......@@ -105,22 +105,18 @@ tic = time.time()
while t < tEnd :
# while ii < 10:
#Fluid solver
oldstate = np.copy(p.state())
time_integration.iterate(fluid,p,dt,external_particles_forces=G)
t += dt
state = p.state()
state.x[:,0] = np.fmod(state.x[:,0],L)
ind = np.where(state.x[:,0] <= 0)
state.x[ind,0] += L
p.set_state(state)
fluid.set_particles(p.mass(), p.volume(), oldstate,p.contact_forces(),init=False)
fluid.set_particles(p.mass(), p.volume(), p.state(),p.contact_forces(),init=False)
p.position()[:,0] = np.fmod(p.position()[:,0],L)
ind = p.position()[:,0] <= 0
p.position()[ind,0] += L
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(),p.contact_forces())
#Output files writting
if ii %outf == 0 :
ioutput = int(ii/outf) + 1
fluid.export_vtk(outputdir, t, ioutput)
fluid.write_vtk(outputdir, ioutput, t)
p.write_vtk(outputdir, ioutput, t)
ii += 1
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.time() - tic))
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