tract = traction*wallBF # traction on wall forceWall = integrate(tract,where=FunctionOnBoundary(mydomain)) # force on wall lengthWall = integrate(wallBF,where=FunctionOnBoundary(mydomain)) fout=file('./result/pressure.dat','w') fout.write('0 '+str(forceWall[0])+' '+str(lengthWall)+'\n') while t < 100: prob.initialize(f=Nbc,specified_u_mask=Dbc,specified_u_val=Vbc) t += 1 du=prob.solve(iter_max=100) disp += du stress=prob.getCurrentStress() dom = prob.getDomain() proj = Projector(dom) sig = proj(stress) sig_bounda = interpolate(sig,FunctionOnBoundary(dom)) traction = matrix_mult(sig_bounda,dom.getNormal()) tract = traction*wallBF forceWall = integrate(tract,where=FunctionOnBoundary(dom)) lengthWall = integrate(wallBF,where=FunctionOnBoundary(dom)) fout.write(str(t*vel)+' '+str(forceWall[0])+' '+str(lengthWall)+'\n') vR=prob.getLocalVoidRatio() rotation=prob.getLocalAvgRotation() fabric=prob.getLocalFabric() strain = prob.getCurrentStrain() saveGauss2D(name='./result/gauss/time_'+str(t)+'.dat',strain=strain,stress=stress,fabric=fabric)
# Dirichlet BC values Vbc = whereZero(x[1])*[0,0]+whereZero(x[1]-ly)*[0,vel]+whereZero(x[1])*whereZero(x[0]-.5*lx)*[0,0] # Neumann BC, constant confining pressure Nbc = whereZero(bx[0])*[-confining,0]+whereZero(bx[0]-lx)*[confining,0] time_start = time.time() while t < 100: # apply 100 load steps prob.initialize(f=Nbc, specified_u_mask=Dbc, specified_u_val=Vbc) # initialize BC t += 1 du=prob.solve(iter_max=100) # get solution: nodal displacement disp += du stress=prob.getCurrentStress() dom = prob.getDomain() # domain is updated Lagrangian formulation proj = Projector(dom) sig = proj(stress) sig_bounda = interpolate(sig,FunctionOnBoundary(dom)) traction = matrix_mult(sig_bounda,dom.getNormal()) tractTop = traction*topSurf forceTop = integrate(tractTop,where=FunctionOnBoundary(dom)) lengthTop = integrate(topSurf,where=FunctionOnBoundary(dom)) fout.write(str(t*vel/ly)+' '+str(forceTop[1])+' '+str(lengthTop)+'\n') vR=prob.getLocalVoidRatio() fabric=prob.getLocalFabric() strain = prob.getCurrentStrain() saveGauss2D(name='./result/gauss/time_'+str(t)+'.dat',strain=strain,stress=stress,fabric=fabric) volume_strain = trace(strain)
forceWall = integrate(tract, where=FunctionOnBoundary(mydomain)) # force on wall lengthWall = integrate(wallBF, where=FunctionOnBoundary(mydomain)) fout = file('./result/pressure.dat', 'w') fout.write('0 ' + str(forceWall[0]) + ' ' + str(lengthWall) + '\n') while t < 100: prob.initialize(f=Nbc, specified_u_mask=Dbc, specified_u_val=Vbc) t += 1 du = prob.solve(iter_max=100) disp += du stress = prob.getCurrentStress() dom = prob.getDomain() proj = Projector(dom) sig = proj(stress) sig_bounda = interpolate(sig, FunctionOnBoundary(dom)) traction = matrix_mult(sig_bounda, dom.getNormal()) tract = traction * wallBF forceWall = integrate(tract, where=FunctionOnBoundary(dom)) lengthWall = integrate(wallBF, where=FunctionOnBoundary(dom)) fout.write( str(t * vel) + ' ' + str(forceWall[0]) + ' ' + str(lengthWall) + '\n') vR = prob.getLocalVoidRatio() rotation = prob.getLocalAvgRotation() fabric = prob.getLocalFabric() strain = prob.getCurrentStrain()
# Neumann BC, constant confining pressure Nbc = whereZero(bx[0]) * [-confining, 0 ] + whereZero(bx[0] - lx) * [confining, 0] time_start = time.time() while t < 100: # apply 100 load steps prob.initialize(f=Nbc, specified_u_mask=Dbc, specified_u_val=Vbc) # initialize BC t += 1 du = prob.solve(iter_max=100) # get solution: nodal displacement disp += du stress = prob.getCurrentStress() dom = prob.getDomain() # domain is updated Lagrangian formulation proj = Projector(dom) sig = proj(stress) sig_bounda = interpolate(sig, FunctionOnBoundary(dom)) traction = matrix_mult(sig_bounda, dom.getNormal()) tractTop = traction * topSurf forceTop = integrate(tractTop, where=FunctionOnBoundary(dom)) lengthTop = integrate(topSurf, where=FunctionOnBoundary(dom)) fout.write( str(t * vel / ly) + ' ' + str(forceTop[1]) + ' ' + str(lengthTop) + '\n') vR = prob.getLocalVoidRatio() fabric = prob.getLocalFabric() strain = prob.getCurrentStrain()