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

Is there a way to disapply/remove BCs?

0 votes

Suppose we have this timoshenko beam
https://bitbucket.org/jackhale/timoshenko/src/30f59208921c339f0d94a1272e5b53f337df2c8f/cantilever.py?at=master

But instead of applying the bcs in the for loop in line 72-76 we do

A_matrix, b_vector = assemble_system(A, L, bcs)

I want the reaction forces on left_boundary. For that I can do

reaction = Function(U)
reaction.vector()[:] = A_matrix * u_h.vector()

But that will give me 0 on the boundary point.
If I reassemble A_matrix without the bcs it gives the correct result as can be seen doing

reaction = Function(U)
reaction.vector()[:] = A_matrix * u_h.vector()
reaction_forces = reaction.split(deepcopy=True)[1]
plot(reaction_forces); interactive()
AA_matrix = assemble(A)
reaction.vector()[:] = AA_matrix * u_h.vector()
reaction_forces = reaction.split(deepcopy=True)[1]
plot(reaction_forces); interactive()

But if the assembly takes a long time I don't want to do it again. Is there a way to operate A_matrix without the bcs or to remove/detach/disapply them?

I've put a working example here http://pastebin.com/b0QenJWd

asked Aug 24, 2015 by yuri_teixeira FEniCS Novice (130 points)

I'm not quite sure what you're trying to accomplish, but you can always create a copy of A_matrix:

A_matrix = assemble(A)
AA_matrix = A_matrix.copy()

I can always copy, but I get it without the BCs only if it was assembled with assemble(a) and if I do it before applying said BCs.
If I use assemble_system() I never get to access the matrix without the BCs applied.

Undoing the addition of boundary conditions is not possible without reassembling the missing stencils. So in FEniCS it probably makes most sense to create a copy where necessary. And yes, if you use utilities like assemble_system you end up with a constrained system. So the solution would be not to do this and set up the system step by step.

Thank you. Should I delete this question since it has no solution? (Meaning, get stuff without BCs after assemble_system). Or you could put your comment in an answer to be accepted.

...