stress = prob.getCurrentStress() proj = Projector(mydomain) sig = proj(stress) sig_bounda = interpolate(sig,FunctionOnBoundary(mydomain)) traction = matrix_mult(sig_bounda,mydomain.getNormal()) 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')
lengthTop = integrate(topSurf,where=FunctionOnBoundary(mydomain)) # length of top surface fout=file('./result/biaxial_surf.dat','w') fout.write('0 '+str(forceTop[1])+' '+str(lengthTop)+'\n') # Dirichlet BC positions, smooth at bottom and top, fixed at the center of bottom Dbc = whereZero(x[1])*[0,1]+whereZero(x[1]-ly)*[0,1]+whereZero(x[1])*whereZero(x[0]-.5*lx)*[1,1] # 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')
proj = Projector(mydomain) sig = proj(stress) sig_bounda = interpolate(sig, FunctionOnBoundary(mydomain)) traction = matrix_mult(sig_bounda, mydomain.getNormal()) 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')
Dbc = whereZero(x[1]) * [0, 1] + whereZero(x[1] - ly) * [0, 1] + whereZero( x[1]) * whereZero(x[0] - .5 * lx) * [1, 1] # 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) +