if MM < 1e-4: MM = 0. pseudodynamic = False elif nit <= 6: MM /= 2. else: TMP = md.interpolation("max(psi0_max,psi0)", mimd1, -1) md.set_variable("psi0_max", TMP) break out = (mfu, md.variable("u"), "Displacements", mfphi, md.variable("phi"), "phi") for i, j in [[1, 1], [2, 2], [1, 2]]: sigma = gf.asm_generic(mim, 1, "{sigma}({i},{j})*Test_t".format(sigma=_sigma_, i=i, j=j), -1, md, "t", True, mfout, np.zeros(mfout.nbdof()))\ [md.nbdof():] sigma = np.transpose(gf.linsolve_mumps(mass_mat, sigma)) out += (mfout, sigma, "Cauchy Stress {i}{j}".format(i=i, j=j)) mfout.export_to_vtk("%s/demo_phase_field_%i.vtk" % (resultspath, step), *out) DIRMULT = -md.variable(dirmultname) DIRMULT = np.reshape(DIRMULT, [1, DIRMULT.size]) dfT = gf.asm_boundary_source(T_BOUNDARY, mim, mfu, md.mesh_fem_of_variable(dirmultname), DIRMULT) f.write(("step=%i eps=%e fR=(%e,%e)\n") % (step, eps, dfT[0::N].sum(), dfT[1::N].sum())) f.flush()
output = (mfu, md.variable('u'), 'Displacements', mfp, md.variable('p'), 'Pressure', mfksi, md.variable('ksi'), 'dksi', mf_dirichlet_mult, -md.variable(dirichlet_multname), "Reaction stresses", mfout, VM, 'Von Mises Stress', mfu, RHS[IU[0]:IU[0] + IU[1]], 'residual u', mfp, RHS[IP[0]:IP[0] + IP[1]], 'residual p', mfksi, RHS[IKSI[0]:IKSI[0] + IKSI[1]], 'residual ksi') md.finite_strain_elastoplasticity_next_iter\ (mim, "Simo_Miehe", "displacement_and_plastic_multiplier_and_pressure", "u", "ksi", "p", "gamma0", "invCp0", _K_, _mu_, "hardening_law") GAMMA = gf.asm_generic(mim, 1, "gamma*Test_t", -1, "gamma", False, mimd1, md.variable("gamma0"), "t", True, mfout, np.zeros(mfout.nbdof())) GAMMA = np.transpose(gf.linsolve_mumps(mass_mat, GAMMA)) output += (mfout, GAMMA, "plastic strain") mf1.export_to_vtk( '%s/finite_strain_plasticity_%i.vtk' % (resultspath, step), 'ascii', *output) DIRMULT = -md.variable(dirichlet_multname) DIRMULT = np.reshape(DIRMULT, [1, DIRMULT.size]) if symmetric and not rigid_grip: dfR = gf.asm_boundary_source(R_BOUNDARY, mim, mf1, mf_dirichlet_mult, DIRMULT) f.write(('step=%i fR=(%f,0) sR=(%f,0)\n') % (step, dfR.sum(), dfR.sum() / H)) else: dfR = gf.asm_boundary_source(R_BOUNDARY, mim, mfN,
md.add_initialized_data("f", [0,0]) md.add_initialized_data("dt", [dt]) md.add_initialized_data("nu", [nu]) md.add_Dirichlet_condition_with_multipliers(mim, "p", mfp, IN_RG, "p_in") md.add_nonlinear_term\ (mim, "1/dt*(v-v0).Test_v + (Grad_v0*v0).Test_v + nu*Grad_v:Grad_Test_v - f.Test_v") md.add_nonlinear_term\ (mim, "Grad_p.Grad_Test_p + 1/dt*Trace(Grad_v)*Test_p") mmat_v = gf.asm_mass_matrix(mim, mfv) #mmat_v = gf.asm_generic(mim, 2, "Test2_v.Test_v", -1, "v", 1, mfv, np.zeros(mfv.nbdof())) IV = md.interval_of_variable("v") t = 0 step = 0 while t < T+1e-8: print("Solving step at t=%f" % t) md.set_variable\ ("p_in", mfp_.eval(p_in_str.format(t), globals(), locals()).flatten("F")) md.set_variable("v0", md.variable("v")) md.solve("noisy", "lsolver", "mumps", "max_res", 1e-8) vv = (gf.asm_generic(mim, 1, "(v-dt*Grad_p).Test_v", -1, md))[IV[0]:IV[0]+IV[1]] md.set_variable("v", gf.linsolve_mumps(mmat_v, vv)) mfv.export_to_vtk("results_%i.vtk" % step, mfv, md.variable("v"), "Velocity", mfp, md.variable("p"), "Pressure") t += dt step += 1