This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Dirichlet boundary conditions using cbc.block

+1 vote

Hello !

Here is my problem. I need to use the cbc.block package for my python code (I need block-structure matrix), but I don't know how to apply my boundary condition (Dirichlet boundary conditions, basically non-slip conditions). Let me explain:

I downloaded the last version of cbc.block from: https://bitbucket.org/fenics-apps/cbc.bloI ck/overview. I first tried to run some demo, mixedpoisson.py and biot.py for example. However, I have a problem with the block_symmetric_assemble and block_assemble functions. Here is the error I obtain :

Traceback (most recent call last):
File "mixedpoisson.py", line 97, in
[a21, 0 ]], bcs=bcs)
File "/usr/local/lib/python2.7/dist-packages/block/block_assemble.py", line 35, in block_symmetric_assemble
symm[i,j], asymm[i,j] = _symmetric_assemble(forms[i,j], row_bcs=bcs[i], col_bcs=bcs[j])
File "/usr/local/lib/python2.7/dist-packages/block/block_assemble.py", line 79, in _symmetric_assemble
from dolfin import symmetric_assemble
ImportError: cannot import name symmetric_assemble

I suspect an incompatibility between the versions of FEniCS/cbc.block (I have dolfin-1.2.0). I understood that "symmetric_assemble" does no longer exist in the Python interface, sp obviously it won't work.

Consequently, I downloaded a previous version of cbc.block (1.0.1), where I can use bc = block_bc([...]) (with inside my boundary conditions defined with DirichletBC) and bc.apply(A, b) to apply my boundary conditions (block_bc is not available in the last version of cbc.block). I previously assemble my blocks and build my block matrix with: A = block_mat([...]) and the RHS: b = block_vec([...]).

Obviously, it's not the best way to do it (some of the demo for example still don't work), but I don't know how to apply boundary conditions with the newest version of cbc.block.

On top of that, I have an other error which I don't know how to solve:

Calculated signs of diagonal blocks:[1, None, 1]
Traceback (most recent call last):
File "block_stokes_1.py", line 93, in
bc.apply(A, b, save_A=True)
File "/usr/local/lib/python2.7/dist-packages/block/block_bc.py", line 41, in apply
self.apply_matvec(A, b, symmetric)
File "/usr/local/lib/python2.7/dist-packages/block/block_bc.py", line 87, in apply_matvec
bc.zero_columns(A[j,i], b[j])
TypeError: in method 'DirichletBC_zero_columns', argument 2 of type 'dolfin::GenericMatrix &'

I had an idea from https://lists.launchpad.net/cbc.block/msg00018.html, but even with that, it still doesn't work.So now, I'm lost ! Anyone can help me with that ?

Thanks in advance for your time (sorry for the huge question...),

Coraline

PS: I install FEniCS via dorsal, so I have dolfin-1.2.0

Python 2.7.3

asked Aug 9, 2013 by Coraline FEniCS Novice (160 points)

1 Answer

+2 votes
 
Best answer

Regarding your first issue:

from dolfin import symmetric_assemble
ImportError: cannot import name symmetric_assemble

As error message says, DOLFIN 1.2.0 does not have function symmetric_assemble. Try DOLFIN 1.1.0 or report an CBC.block issue and wait for a fix.

answered Aug 9, 2013 by Jan Blechta FEniCS Expert (51,420 points)
selected Aug 10, 2013 by logg

Thanks ! I reported the issue.

...