Commit a84364dc by Matthieu Constant

### updatetestcases

parent a1e0eaec
 ... ... @@ -371,6 +371,7 @@ HXTStatus hxtLinearSystemPETScMapFromVec(HXTLinearSystemPETSc *system, Vec vec, int nf = system->nFields; for (int i=0; i< system->nNodes; ++i) { uint32_t n= system->nodeMap[i]; if(n==-1) continue; for (int j = 0; j < nf; ++j) v[i*nf+j] = vv[n*nf+j]; } ... ...
 ... ... @@ -10,7 +10,7 @@ #define n_fields (DIMENSION+1) #define newton_max_it 10 #define newton_atol 2.5e-6 #define newton_atol 5e-7 #define newton_rtol 1e-5 #if DIMENSION==2 ... ... @@ -449,7 +449,12 @@ static void fluid_problem_compute_porosity(FluidProblem *problem) problem->porosity[el[j]] += sf[j]*volume[i]; } for (int i = 0; i < mesh->n_nodes; ++i){ problem->porosity[i] = (1-problem->porosity[i]/problem->node_volume[i]); if(problem->node_volume[i]==0.){ problem->porosity[i] = 1.; } else{ problem->porosity[i] = (1-problem->porosity[i]/problem->node_volume[i] /4.); } } } ... ...
 #!/usr/bin/env python use_lmgc = 0 use_lmgc = 1 from marblesbag import fluid as fluid ... ... @@ -38,17 +38,17 @@ def genInitialPosition(filename, r, rout, rhop) : x = x[keep] y = y[keep] for i in range(x.shape[0]) : p.add_particle((x[i], y[i]), r, r**2 * np.pi * rhop); # x = np.arange(rout, -rout, 2 * -r/3) # y = np.arange(-rout/2.+r, -5*rout/12., 2 * r/3) # x, y = np.meshgrid(x, y) # R2 = x**2 + y**2 # keep = R2 < (rout - r/3)**2 # x = x[keep] # y = y[keep] # for i in range(x.shape[0]) : # p.add_particle((x[i], y[i]), r/3, r**2 /9 * np.pi * rhop); p.write(filename) p.add_particle((x[i], y[i]), r/2., r**2/4. * np.pi * rhop); x = np.arange(rout, -rout, 2 * -r/3) y = np.arange(-rout/2.+r, -5*rout/12., 2 * r/3) x, y = np.meshgrid(x, y) R2 = x**2 + y**2 keep = R2 < (rout - r/3)**2 x = x[keep] y = y[keep] for i in range(x.shape[0]) : p.add_particle((x[i], y[i]), r/3, r**2 /9 * np.pi * rhop); p.write_vtk(filename,0,0) t = 0 ... ... @@ -63,7 +63,7 @@ tEnd = 100 #numerical parameters h = 0.002 # approx r*100 but should match the mesh size dt = 5e-4#h/V*0.1 dt = 5e-3#h/V*0.1 epsilon = 1e-4 # ?? not sure ??import pyfefp ... ... @@ -74,7 +74,7 @@ compacity3d = 0.18 N = int((rout**2 - rin**2) * compacity3d * 3./2 / r**2) shutil.copy("mesh.msh", outputdir +"/mesh.msh") genInitialPosition(outputdir + "/part-00000", r, rout, rhop) genInitialPosition(outputdir, r, rout, rhop) if use_lmgc : ... ... @@ -82,9 +82,10 @@ if use_lmgc : lmgc2Interface.scontactToLmgc90(outputdir+"/part-00000", friction) p = lmgc2Interface.LmgcInterface() else : p = scontact2.ParticleProblem(outputdir+"/part-00000") p = scontact2.ParticleProblem() p.read_vtk(outputdir,0) outf = 10 outf = 5 strong_boundaries = [("Outer",0,lambda x : -4*x[:, 1]),("Outer",1,lambda x : 4*x[:, 0]),("Inner",0,0.),("Inner",1,0.),("PtFix",2,0.)] #g is define in fluid_problem fluid = fluid.fluid_problem("mesh.msh",g,nu*rho,rho,epsilon,strong_boundaries) ... ...
 ... ... @@ -26,7 +26,7 @@ def genInitialPosition(filename, r, rout, rin, rhop) : y = y[keep] for i in range(x.shape[0]) : p.add_particle((x[i], y[i]), r, r**2 * np.pi * rhop); p.write(filename) p.write_vtk(filename,0,0) t = 0 ... ... @@ -41,7 +41,7 @@ tEnd = 50 #numerical parameters h = 0.002 # approx r*100 but should match the mesh size dt = 1e-3#h/V*0.1 dt = 1e-2#h/V*0.1 epsilon = 1e-5 # ?? not sure ??import pyfefp rout = 0.0254 ... ... @@ -51,12 +51,12 @@ compacity3d = 0.18 N = int((rout**2 - rin**2) * compacity3d * 3./2 / r**2) p = scontact2.ParticleProblem() shutil.copy("mesh.msh", outputdir +"/mesh.msh") p.write(outputdir+"/part-00000") genInitialPosition(outputdir + "/part-00000", r, rout, rin, rhop) p = scontact2.ParticleProblem(outputdir+"/part-00000") genInitialPosition(outputdir, r, rout, rin, rhop) p = scontact2.ParticleProblem() p.read_vtk(outputdir,0) outf = 50 outf = 5 strong_boundaries = [("Outer",0,lambda x : -x[:, 1]),("Outer",1,lambda x : x[:, 0]),("Inner",0,0.),("Inner",1,0.),("PtFix",2,0.)] #g is define in fluid_problem fluid = fluid.fluid_problem("mesh.msh",g,nu*rho,rho,epsilon,strong_boundaries) ... ... @@ -65,21 +65,21 @@ fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity()) fluid.export(outputdir,0,0) tic = time.clock() while t < tEnd : fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity()) while t < tEnd : fluid.implicit_euler(dt) forces = fluid.compute_node_force(dt) vn = p.velocity() + forces * dt / p.mass() vmax = np.max(np.hypot(vn[:, 0], vn[:, 1])) nsub = max(1, int(np.ceil((vmax * dt * 4)/min(p.r())))) print("NSUB", nsub,"VMAX",vmax, "VMAX * dt", vmax * dt, "r", min(p.r())) for i in range(nsub) : p.iterate(dt/nsub, forces) p.iterate(dt/nsub, forces,1e-6) fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity()) fluid.implicit_euler(dt) t += dt if ii %outf == 0 : ioutput = int(ii/outf) + 1 p.write_vtk(outputdir, ioutput, t) p.write(outputdir+"/part-%05d" % ioutput) fluid.export(outputdir, t, ioutput) fluid.export_vtk(outputdir, t, ioutput) ii += 1 print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.clock() - tic))
 ... ... @@ -17,12 +17,12 @@ def genInitialPosition(filename, r, ly, rhop) : x = x.flat y = y.flat for i in range(len(x)) : rhop = random.choice([1100,1100,1100]) rhop = random.choice([1100,1200,1300]) p.add_particle((x[i], y[i]), r/2, r**2/4 * np.pi * rhop); p.write(filename) p.write_vtk(filename,0,0) outputdir = "outputdep" outputdir = "output" if not os.path.isdir(outputdir) : os.makedirs(outputdir) ... ... @@ -45,35 +45,25 @@ tEnd = 100 #numerical parameters lcmin = 0.001 # approx r*100 but should match the mesh size dt = 1e-4 dt = 1e-2 alpha = 2.5e-5 epsilon = alpha*lcmin**2 /nu print('epsilon',epsilon) shutil.copy("mesh.msh", outputdir +"/mesh.msh") #scontact2Interface.MeshLoader(p, "funnel.msh", ("Funnel", "Top", "Bottom", "Lateral")) p.write(outputdir+"/part-00000") genInitialPosition(outputdir + "/part-00000", r, ly, rhop) genInitialPosition(outputdir, r, ly, rhop) p = scontact2.ParticleProblem(outputdir+"/part-00000") p = scontact2.ParticleProblem() p.read_vtk(outputdir,0) print("r = %g, m = %g\n" % (p.r()[0], p.mass()[0])) print("RHOP = %g" % rhop) outf = 200 outf = 20 outf1 = 100000 ii = 0 def outerBndV(x) : bndLoop = 12000 if ii%bndLoop<11000 and ii%bndLoop>9500: print(min(((ii-9500)%bndLoop)*5e-5,.05)) return min(((ii-9500)%bndLoop)*5e-5,.05) else: print(.05/((ii-11000)%bndLoop + 1)) return .05/((ii-11000)%bndLoop + 1) strong_boundaries = [("Top",2,0.),("TopOut",1,0),("Top",1,0),("BottomOut",1,0),("Bottom",1,0),("Lateral",0,0.),("Lateral",1,0.)] fluid = fluid.fluid_problem("mesh.msh",g,nu*rho,rho,epsilon,strong_boundaries) ... ... @@ -83,17 +73,17 @@ fluid.export(outputdir,0,0) tic = time.clock() forces = g*p.mass() fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity()) while t < tEnd : fluid.implicit_euler(dt) forces = fluid.compute_node_force(dt) vn = p.velocity() + forces * dt / p.mass() vmax = np.max(np.hypot(vn[:, 0], vn[:, 1])) nsub = max(1, int(np.ceil((vmax * dt * 4)/min(p.r())))) print("NSUB", nsub,"VMAX",vmax, "VMAX * dt", vmax * dt, "r", min(p.r())) for i in range(nsub) : p.iterate(dt/nsub, forces) p.iterate(dt/nsub, forces,1e-6) fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity()) fluid.implicit_euler(dt) t += dt if ii %outf == 0 : ioutput = int(ii/outf) + 1 ... ...