I recently referred to weakly coupled implementations of thermoelastic problems on Linear thermoelasticity (weak coupling) — Numerical tours of continuum mechanics using FEniCS master documentation (comet-fenics.readthedocs.io). The temperature field calculations are working fine,but Elastic problem calculation broke down. Ask for the possible reasons.
(Error: error code 10
[0] KSPSolve() at /home/conda/feedstock_root/build_artifacts/petsc_1661243737224/work/src/ksp/ksp/interface/itfunc.c:1078
[0] KSPSolve_Private() at /home/conda/feedstock_root/build_artifacts/petsc_1661243737224/work/src/ksp/ksp/interface/itfunc.c:843
[0] KSPSetUp() at /home/conda/feedstock_root/build_artifacts/petsc_1661243737224/work/src/ksp/ksp/interface/itfunc.c:407
[0] PCSetUp() at /home/conda/feedstock_root/build_artifacts/petsc_1661243737224/work/src/ksp/pc/interface/precon.c:990
[0] PCSetUp_LU() at /home/conda/feedstock_root/build_artifacts/petsc_1661243737224/work/src/ksp/pc/impls/factor/lu/lu.c:93
[0] MatLUFactorSymbolic() at /home/conda/feedstock_root/build_artifacts/petsc_1661243737224/work/src/mat/interface/matrix.c:2966
[0] MatLUFactorSymbolic_SeqAIJ() at /home/conda/feedstock_root/build_artifacts/petsc_1661243737224/work/src/mat/impls/aij/seq/aijfact.c:361
[0] PetscFreeSpaceGet() at /home/conda/feedstock_root/build_artifacts/petsc_1661243737224/work/src/mat/utils/freespace.c:10
[0] PetscMallocA() at /home/conda/feedstock_root/build_artifacts/petsc_1661243737224/work/src/sys/memory/mal.c:401
[0] PetscMallocAlign() at /home/conda/feedstock_root/build_artifacts/petsc_1661243737224/work/src/sys/memory/mal.c:49
[0] PetscFreeSpaceGet
)
Specifically as follows,The grid used is a hexahedral grid:
Surface,yp = 1, 4
top = 3
bottom = 2
mesh,subdomains,boundaries = read_mesh(root='./Mesh')
T0 = 293.0
E = 209e3
nu = 0.3
lmbda = E*nu/((1+nu)*(1-2*nu))
mu = E/2/(1+nu)
rho = 8030.0e-12
alpha = 1.84e-5
kappa = alpha*(2*mu + 3*lmbda)
cp = 502.48e3
k = 16.27e-3
Vte = dolfinx.fem.FunctionSpace(mesh, ("CG", 1))
Vue = dolfinx.fem.VectorFunctionSpace(mesh, ("CG", 2))
V_von_mises = dolfinx.fem.FunctionSpace(mesh, ("CG", 1))
dx = ufl.Measure("dx")(subdomain_data=subdomains)
ds = ufl.Measure("ds")(subdomain_data=boundaries)
dt = dolfinx.fem.Constant(mesh,c=0.)
theta_trial = ufl.TrialFunction(Vte)
theta_test = ufl.TestFunction(Vte)
thetaold = dolfinx.fem.Function(Vte)
thetaold.x.array[:] = T0
thetaold.name = "Tempreture"
thetanew = dolfinx.fem.Function(Vte)
h_robin = dolfinx.fem.Function(Vte)
t_wall = dolfinx.fem.Function(Vte)
mecha_trial = ufl.TrialFunction(Vue)
mecha_test = ufl.TestFunction(Vue)
mechaold = dolfinx.fem.Function(Vue)
mechaold.x.array[:] = T0
mechaold.name = "displacement"
mechanew = dolfinx.fem.Function(Vue)
stresses = dolfinx.fem.Function(V_von_mises)
stresses.name = "VonmiseS"
therm_forml = ufl.inner(cp*rho*theta_trial / dt,theta_test)*dx + k*ufl.dot(ufl.grad(theta_trial), ufl.grad(theta_test))*dx
therm_formr = ufl.inner(cp*rho*(thetaold) / dt,theta_test)*dx - ufl.inner(h_robin*(t_wall-thetaold),theta_test)*ds(Surface)
a_cpp_therm = dolfinx.fem.form(therm_forml)
f_cpp_therm = dolfinx.fem.form(therm_formr)
pCoord = ufl.SpatialCoordinate(mesh)
sigma_inner = 2.0*mu*ufl.sym(ufl.grad(mecha_trial))+lmbda*ufl.nabla_div(mecha_trial)*ufl.Identity(len(mecha_trial)) # ufl.sym(ufl.grad(mecha_trial)) Equivalent to 0.5*(ufl.nabla_grad(u) + ufl.nabla_grad(u).T)
therm_sigma = kappa*(thetanew-thetaold)*ufl.Identity(len(mecha_trial))
mecha_forml = ufl.inner(sigma_inner, ufl.sym(ufl.grad(mecha_test)))*dx
mecha_formr = ufl.inner(therm_sigma, ufl.grad(mecha_test))*dx + (ufl.inner((pCoord[0]), mecha_test[0])+ufl.inner(pCoord[2], mecha_test[2]))*dx
facets_FixSurface = boundaries.indices[boundaries.values == bottom]
bdofs_FixSurface = dolfinx.fem.locate_dofs_topological(Vue, mesh.topology.dim - 1, facets_FixSurface)
bc = dolfinx.fem.dirichletbc(np.zeros(3, dtype=petsc4py.PETSc.ScalarType), bdofs_FixSurface, Vue)
....
for (i, dti) in enumerate(np.diff(t)):
print("Increment " + str(i+1))
dt.value = dti
h_robin.x.array[bdofsx_Surface] =[....]
t_wall.x.array[bdofsx_Surface] = [....]
A_therm = dolfinx.fem.petsc.assemble_matrix(a_cpp_therm)
A_therm.assemble()
F_therm = dolfinx.fem.petsc.assemble_vector(f_cpp_therm)
F_therm.ghostUpdate(addv=petsc4py.PETSc.InsertMode.ADD, mode=petsc4py.PETSc.ScatterMode.REVERSE)
solve(A=A_therm,F=F_therm,X=thetanew,mesh=mesh)
A_mecha = dolfinx.fem.petsc.assemble_matrix(a_cpp_mecha, bcs=[bc])
A_mecha.assemble()
F_mecha = dolfinx.fem.petsc.assemble_vector(f_cpp_mecha)
dolfinx.fem.petsc.apply_lifting(F_mecha, [a_cpp_mecha], [bcs])
F_mecha.ghostUpdate(addv=petsc4py.PETSc.InsertMode.ADD, mode=petsc4py.PETSc.ScatterMode.REVERSE)
dolfinx.fem.petsc.set_bc(F_mecha, bcs)
solve(A=A_mecha,F=F_mecha,X=mechanew,mesh=mesh)
def solve(A,F,X,mesh):
ksp = petsc4py.PETSc.KSP()
ksp.create(mesh.comm)
ksp.setOperators(A)
ksp.setType("preonly")
ksp.getPC().setType("lu")
ksp.getPC().setFactorSolverType("mumps")
ksp.setFromOptions()
ksp.solve(F, X.vector)
X.x.scatter_forward()