Linear solver change

Hello everybody!
Now I have a code for a heat solver. However, I don’t want to use LU method as my linear solver, since my coefficient matrix is time-dependent. I want to use a more efficient way to solve the linear problem, such as Guass elimination. So I hope that someone can tell me how to do it!
Here is my code:
A = assemble_matrix(a)
A.assemble()
b = create_vector(L)
uh = fem.Function(V)
solver = PETSc.KSP().create(domain.comm)
solver.setOperators(A)
solver.setType(PETSc.KSP.Type.PREONLY) solver.getPC().setType(PETSc.PC.Type.LU)
with b.localForm() as loc_b:
loc_b.set(0)
assemble_vector(b, L)
solver.solve(b, uh.vector)
uh.x.scatter_forward()

Any professor of numerical analysis would tell you that this makes no sense. Double check the difference between LU and Gauss elimination.

In any case, the main point to change in your snippet is

solver.setType(PETSc.KSP.Type.PREONLY)
solver.getPC().setType(PETSc.PC.Type.LU)

If you want to use another solver, you’ll need to use another option within those available in PETSc.KSP.Type. Which solver to choose is very often a research question (hence, you are better off asking to your advisor or a senior colleague), and highly dependent on the specific problem.