dev_fab = 4.*(fab-trace(fab)/dim*kronecker(prob.getDomain())) anis = sqrt(.5*inner(dev_fab,dev_fab)) # set anis to -1 if no contact for i in range(numg): if math.isnan(anis.getTupleForDataPoint(i)[0]): anis.setValueOfDataPoint(i,-1) # get local rotation rot = prob.getLocalAvgRotation(); rot = proj(rot) # get local shear strain strain = prob.getCurrentStrain() volume_strain = trace(strain) dev_strain = symmetric(strain) - volume_strain*kronecker(prob.getDomain())/dim shear = sqrt(2*inner(dev_strain,dev_strain)); shear = proj(shear) # export FE scene saveVTK(vtkDir+"/ms"+mshName+"FE_%d.vtu"%t,u=u,sig=sig,shear=shear,e=vR,rot=rot,anis=anis) # export DE scenes prob.VTKExporter(vtkDir=vtkDir+"/ms"+mshName+"DE",t=t) # export local responses at Gauss points saveGauss2D(gaussDir+"/time_"+str(t)+".dat",strain=strain,stress=stress,fab=fab) print "stress ratio at the bottom: %e"%(forceBot[0]/forceBot[1]) # next iteration print "Step NO.%d finished, current kinetic energy: %2.1e"%(t,Ek) t += 1 prob.getCurrentPacking(pos=(),time=t,prefix=packDir) time_elapse = time.time() - time_start fout.write("#Elapsed time in hours: "+str(time_elapse/3600.)+'\n') fout.close() prob.exitSimulation()
disp += du stress=prob.getCurrentStress() dom = prob.getDomain() # domain updated (Lagrangian) proj = Projector(dom) sig = proj(stress) sig_bounda = interpolate(sig,FunctionOnBoundary(dom)) traction = matrix_mult(sig_bounda,dom.getNormal()) tractFoot = traction*footingBase forceFoot = integrate(tractFoot,where=FunctionOnBoundary(dom)) lengthFoot = integrate(footingBase,where=FunctionOnBoundary(dom)) fout.write(str(t*vel)+' '+str(forceFoot[0])+' '+str(forceFoot[1])+' '+str(lengthFoot)+'\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) volume_strain = trace(strain) dev_strain = symmetric(strain) - volume_strain*k/dim shear = sqrt(2*inner(dev_strain,dev_strain)) saveVTK("./result/vtk/footing_%d.vtu"%t,disp=disp,stress=stress,shear=shear,e=vR,rot=rotation) prob.getCurrentPacking(pos=packNo,time=t,prefix='./result/packing/') # output packing time_elapse = time.time() - time_start fout.write("#Elapsed time in hours: "+str(time_elapse/3600.)+'\n') fout.close() prob.exitSimulation()
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) dev_strain = symmetric(strain) - volume_strain * k / dim shear = sqrt(2 * inner(dev_strain, dev_strain)) saveVTK("./result/vtk/biaxialSmooth_%d.vtu" % t, disp=disp, shear=shear, e=vR) prob.getCurrentPacking(pos=(), time=t, prefix="./result/packing/") time_elapse = time.time() - time_start fout.write("#Elapsed time in hours: " + str(time_elapse / 3600.0) + "\n") fout.close() prob.exitSimulation()