I solve a time dependent problem with LU decomposition. My matrix is constant in time, so I want to reuse LU factorization. I also have to apply boundary condition in each time step. My code looks somewhat like this
F2 = some linear form
a = lhs(F2)
L = rhs(F2)
A = assemble(a)
solver = LUSolver(A)
solver.parameters['reuse_factorization'] = True
while t < Tf:
b = assemble(L)
[bc.apply(A,b) for bc in bcs]
solver.solve(up2.vector(), b)
Question:
Is this correct way to do it ?
Doesn't the matrix A get modified when bc is applied, necessitating recomputation of matrix A for next time step ?