Using assemble_system
, one can make sure that a symmetric weak form results in a symmetric matrix after boundary conditions are applied. I already assembled my matrices however; is it possible to apply Dirichlet boundary conditions in FEniCS without losing symmetry, still?
To ask the question somehow differently: my problem can be written as $(A_1 + k(\varepsilon) A_2) x = b(\varepsilon)$, where I solve for varying $k$ and $b$. Hence I don't want to assemble $A_1$ and $A_2$ over and over again. Suppose I do something like:
a1 = ... # weak form
a2 = ...
dummy_rhs = ...
bcs = [dolfin.DirichletBC(...), dolfin.DirichletBC(...)]
A1, dummy = dolfin.assemble_system(a1, dummy_rhs, bcs)
A2, dummy = dolfin.assemble_system(a2, dummy_rhs, bcs)
b = ... # weak form
B = dolfin.assemble(b)
for bc in bcs:
bc.apply(B)
A = A1 + k * A2 # using petsc4py to do this
Am I right to believe that using these A
and B
will give the correct result, as long as the values for the Dirichlet boundary conditions are all zero?
Is there any way to apply boundary conditions conserving symmetry in this case, AFTER an assemble step (i.e. not assemble_system) happened?