Hello,
I wrote a code where I solve many times some PDEs using the same bilinear form but the boundary conditions and right-hand side keep changing. So I thought I could speed up the process by assembling once the matrix corresponding to this bilinear form, then save it and reuse it applying each iteration the new boundary conditions.
Let's say I take the following bilinear form for instance:
a = inner(grad(u), grad(v))*dx
then assemble the matrix
M = assemble(a)
Then save the matrix
M_copy = M
Then apply boundary conditions to the copy
bc.apply(M_copy)
but here the problem is that the function "apply" modifies M_copy but also modifies M. Then I tried to do
M_copy = copy.copy(M)
but the problem is the same. Can someone explain me why M is also modified and how to avoid this? And also, if I succeed, can I really speed up the computation by doing so?