Imposition of BCs after assembly

Hi,

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)
A.assemble()

I wonder if there is a way to just do

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

Thanks.

I would suggest you have a look at:
http://jsdokken.com/FEniCS23-tutorial/src/lifting.html#identity-row-approach
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)

Hello,

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