Assemble and assemble_system

Hi, all.

I’m getting in-symmetric matrix after assemble and bc.apply. And I found the following comment from earlier documentation. I do not get the idea how can assemble() and bc.apply() does not preserve the symmetry of assembled matrix and still can solve the problem. As I understand, apply boundary condition is by set the boundary dof diag value to 1 and other values in the column and row to 0. However I found it not always true for assemble() and bc.apply(). Could anyone give more insight to this three functions? assemble(), assemble_system(), bc.apply().

Assemble form(s) and apply any given boundary conditions in a symmetric fashion and return tensor(s).
The standard application of boundary conditions does not necessarily preserve the symmetry of the assembled matrix. In order to perserve symmetry in a system of equations with boundary conditions, one may use the alternative assemble_system instead of multiple calls to assemble .

bc.apply() only sets the rows to zero (exept diagonal value), thus symmetry is not preserved. When using assemble_system() the columns are also set to zero, and the vector b is modified accordingly.

1 Like