Hello everyone,
I am solving a phase-field model for crack growth problem. For that, I am applying the load in small time-steps, and the problem is quasi-static. Now, I want to define a growing crack region as Dirichlet BC, so that I can implement the region of crack (based on the solution of loading step i
) as Dirichlet BC for solving the loading step i+1
.
I have the simple code as below. In the below code, I want to know how I can extract the region where |p| > 0.95
(p
is obtained in line 43 pnew.assign(p)
) and use that as Dirichlet BC for future loading steps?
from dolfin import *
mesh = RectangleMesh(Point(-0.5,-0.5),Point(0.5,0.5), 20, 20)
W = VectorFunctionSpace(mesh, 'CG', 1)
p, q, dp = Function(W), TestFunction(W), TrialFunction(W)
u, v, du = Function(W), TestFunction(W), TrialFunction(W)
unew, pold, pnew = Function(W), Function(W) , Function(W)
top = CompiledSubDomain("near(x[1], 0.5) && on_boundary")
bot = CompiledSubDomain("near(x[1], -0.5) && on_boundary")
def crack_region(x, on_boundary):
return abs(x[1]) < 10e-03 and x[0] <= 0
bcbot = DirichletBC(W, Constant((0.0, 0)), bot)
bctop = DirichletBC(W, Constant((0.002, 0)), top)
bc_u = [bcbot, bctop]
bc_phi = [DirichletBC(W, Constant((0.0, 1)), crack_region)]
Gc, l, lmbda, mu= 1, 0.01, 100e3, 80e3
def W0(u):
F = Identity(len(u)) + grad(u)
C = F.T*F
Ic, J = tr(C), det(F)
E = (mu/2)*(Ic - 2) - mu*ln(J) + (lmbda/2)*(ln(J))**2
return E
def total_energy(u,d):
E = ((1- conditional(lt(dot(d,d), 0.001),0.0, sqrt(dot(d,d))))**2)*W0(u) +\
Gc* ( dot(d,d)/(2*l) + (l/2)*inner(grad(d), grad(d)) )
return E
E_du = derivative(total_energy(u, pold) * dx , u, v)
E_phi = derivative(total_energy(unew, p) * dx, p, q)
J_phi = derivative(E_phi, p, dp)
J_u = derivative(E_du, u, du)
p_disp = NonlinearVariationalProblem(E_du, u, bc_u, J_u)
p_phi = NonlinearVariationalProblem(E_phi, p, bc_phi ,J_phi)
solver_disp = NonlinearVariationalSolver(p_disp)
solver_phi = NonlinearVariationalSolver(p_phi)
solver_disp.solve()
unew.assign(u)
solver_phi.solve()
pnew.assign(p)
Thank you so much for your time!
Mary