Applying dirichlet boundary conditions with apply()

Asked by Claas Abert

I have a working python code which uses
A, b = assemble_system(a, L, bc)
to assemble the system.

Since I want to solve a time dependent problem, where only L and thus b changes with time, I'd like to assemble the system matrix once at the beginnng of the calculation.

A = assemble(a)
bc.apply(A)

This however yields a different result than the assemble_system call.
What is difference between these two methods?

Thanks in advance, Claas

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Claas Abert
Solved:
Last query:
Last reply:
Revision history for this message
Johan Hake (johan-hake) said :
#1

On 08/09/2012 11:45 AM, Claas Abert wrote:
> New question #205377 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/205377
>
> I have a working python code which uses
> A, b = assemble_system(a, L, bc)
> to assemble the system.
>
> Since I want to solve a time dependent problem, where only L and thus b changes with time, I'd like to assemble the system matrix once at the beginnng of the calculation.
>
> A = assemble(a)
> bc.apply(A)
>
> This however yields a different result than the assemble_system call.
> What is difference between these two methods?

assemble_system generates a symetric system by applying the dirichlet bc
simultaneously to A and b. If you are using the development version of
DOLFIN you should have a look at:

  symetric_assemble

http://fenicsproject.org/documentation/dolfin/dev/cpp/programmers-reference/fem/SymmetricAssembler.html#SymmetricAssembler

Johan

> Thanks in advance, Claas
>

Revision history for this message
Claas Abert (cabert) said :
#2

Hi Johan,

thanks for the quick reply. I think I was not completely clear. I also apply the boundary condition to the vector b:

A = assemble(a)
b = assemble(L)
bc.apply(A)
bc.apply(b)

or alternatively

bc.apply(A, b)

shouldn't this be equivalent to
A, b = assemble_system(a, L, bc)
or am I missing something?

Revision history for this message
Johan Hake (johan-hake) said :
#3

On 08/09/2012 01:21 PM, Claas Abert wrote:
> Question #205377 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/205377
>
> Status: Answered => Open
>
> Claas Abert is still having a problem:
> Hi Johan,
>
> thanks for the quick reply. I think I was not completely clear. I also
> apply the boundary condition to the vector b:
>
> A = assemble(a)
> b = assemble(L)
> bc.apply(A)
> bc.apply(b)
>
> or alternatively
>
> bc.apply(A, b)
>
> shouldn't this be equivalent to
> A, b = assemble_system(a, L, bc)

No, as the latter returns a symmetric matrix and A after applying the BC
is not.

Johan

> or am I missing something?
>

Revision history for this message
Claas Abert (cabert) said :
#4

OK, I think I got it now :) Thank you very much, Johan.