Imposition of BCs after assembly


Is it possible to impose in a fast and efficient way dirichlet BCs? In general one uses

A = dolfinx.fem.petsc.assemble_matrix(a, bcs)

I wonder if there is a way to just do

A = dolfinx.fem.petsc.assemble_matrix(a)
bc.apply(A)  # or something similar


I would suggest you have a look at:
and the lifting section, as it explains what goes on in DOLFINx

Hi @dokken,

Thank you. It boils down to adding this:

for bc in bcs:
    dofs, _ = bc.dof_indices()
    A.zeroRows(dofs, diag=1)


Can we impose BC over form assembly in legacy-dolfin?
assemble(form,bcs=bc), based on bcs being an argument in assemble here. However, getting

TypeError                                 Traceback (most recent call last)
Cell In[256], line 1
----> 1 assemble(form,bcs=bc)

TypeError: assemble() got an unexpected keyword argument 'bcs'

If not, can you suggest a process for imposing bc in form assembly?

I find that, bc.apply(assemble(form)) is working.

You are looking at outdated documentation (v 1.5.0).
The newest documentation can be found at: Bitbucket
You can use bc.apply on an assembled object as you showed in the last post.

1 Like