I am new to FEniCSx and Phase Field Method for Fracture Mechanics.
I am trying to rewrite an open-source dolfin code to dolfinx version, and meet this problem:
The code I am working with is PHASE FIELD FRACTURE IMPLEMENTATION IN FENICS from Codes | Emilio Martínez Pañeda.
unew, uold = Function(W), Function(W)
pnew, pold, Hold = Function(V), Function(V), Function(V)
E_du = ((1.0-pold)**2)*inner(grad(v),sigma(u))*dx
E_phi = (Gc*l*inner(grad(p),grad(q))+((Gc/l)+2.0*H(uold,unew,Hold))\
*inner(p,q)-2.0*H(uold,unew,Hold)*q)*dx
p_disp = LinearVariationalProblem(lhs(E_du), rhs(E_du), unew, bc_u)
p_phi = LinearVariationalProblem(lhs(E_phi), rhs(E_phi), pnew, bc_phi)
solver_disp = LinearVariationalSolver(p_disp)
solver_phi = LinearVariationalSolver(p_phi)
I tried to find the current version of LinearVariationalProblem
and LinearVariationalSolver
, but it seems they no longer exist. Currently, dolfinx has dolfinx.fem.petsc.LinearProblem
dolfinx.fem.petsc — DOLFINx 0.9.0 documentation
So I tried to use:
# Set up the linear problems
p_disp = LinearProblem(
a=lhs(E_du),
L=rhs(E_du),
bcs=bc_u,
u=unew
)
p_phi = LinearProblem(
a=lhs(E_phi),
L=rhs(E_phi),
bcs=bc_phi,
u=pnew
)
# Solve the linear problems
p_disp.solve()
p_phi.solve()
But this is not working since LinearProblem
does not take bc_u as input. But after I delete the input of u
, it still gives error:
AttributeError: 'NoneType' object has no attribute 'function_spaces'
My question is:
- Is there a well-developed open-source Phase Field Code for Dolfinx that beginner can easily get start with?
- For the above code, is there a solution for transferring previous
LinearVariationalProblem
method to current Dolfinx version?
Very Thanks!