symmetric_assemble

Asked by Claas Abert on 2013-04-18

I just updated to the new dev version of FEniCS and realized that symmetric_assemble does no longer exist in the Python interface. Is there a new syntax to achieve the same thing as

A, An = symmetric_assemble(a, bc)

b = assemble(L)
bc.apply(b)
b = b - An*b

I'm doing a time integration where only b (and not A) changes in time so I don't want to assemble the whole thing in every timestep.

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:
2013-04-18
Last query:
2013-04-18
Last reply:
2013-04-18
Johan Hake (johan-hake) said : #1

SystemAssembler should do this for you.

A, b = assemble_system(a, L, bcs)
assembler = SystemAssembler(a, L, bcs)

for t in time:
   assembler.assemble(b)

Code is not tested...

Johan

On 04/18/2013 11:46 AM, Claas Abert wrote:
> New question #226971 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/226971
>
> I just updated to the new dev version of FEniCS and realized that symmetric_assemble does no longer exist in the Python interface. Is there a new syntax to achieve the same thing as
>
> A, An = symmetric_assemble(a, bc)
>
> b = assemble(L)
> bc.apply(b)
> b = b - An*b
>
> I'm doing a time integration where only b (and not A) changes in time so I don't want to assemble the whole thing in every timestep.
>
> Thanks in advance, Claas
>

Jan Blechta (blechta) said : #2

On Thu, 18 Apr 2013 10:11:41 -0000
Johan Hake <email address hidden> wrote:
> Question #226971 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/226971
>
> Status: Open => Answered
>
> Johan Hake proposed the following answer:
> SystemAssembler should do this for you.
>
> A, b = assemble_system(a, L, bcs)
> assembler = SystemAssembler(a, L, bcs)
>
> for t in time:
> assembler.assemble(b)
>
> Code is not tested...

Little enhanced:
________________________________________
mesh = UnitSquareMesh(2, 2)
V = FunctionSpace(mesh, 'CG', 1)
u = TrialFunction(V)
v = TestFunction(V)
c = Constant(1.0)
a = u*v*dx
L = c*v*dx

assembler = SystemAssembler(a, L)
A, b = Matrix(), Vector()
assembler.assemble(A, b)

# you may appreciate this
assembler.reset_sparsity = False

for i in range(4):
  # Here's inportant that L is mutable so you avoid
  # creating new instance of SystemAssembler
  c.assign(i)

  assembler.assemble(b)

  # See it it works
  print b.array()
_________________________________________

BTW why is dev documentation at fenicsproject.org outdated? At least
regarding assemblers? Is this issue?

Jan

>
> Johan
>
> On 04/18/2013 11:46 AM, Claas Abert wrote:
> > New question #226971 on DOLFIN:
> > https://answers.launchpad.net/dolfin/+question/226971
> >
> > I just updated to the new dev version of FEniCS and realized that
> > symmetric_assemble does no longer exist in the Python interface. Is
> > there a new syntax to achieve the same thing as
> >
> > A, An = symmetric_assemble(a, bc)
> >
> > b = assemble(L)
> > bc.apply(b)
> > b = b - An*b
> >
> > I'm doing a time integration where only b (and not A) changes in
> > time so I don't want to assemble the whole thing in every timestep.
> >
> > Thanks in advance, Claas
> >
>

Claas Abert (cabert) said : #3

Thank you Johan and Jan, this is what I was looking for.

Claas