how to do symmetric imposition of bcs without reassembling matrix?

Asked by Doug Arnold

Suppose I want to solve the linear system corresponding to a linear
variational problem subject to Dirichlet boundary conditions
many times with different right hand sides (e.g., as part of
a time-stepping loop). I may choose to do this by assembling
the matrix, applying the boundary conditions, and then doing a
Cholesky decomposition or other preprocessing to make the matrix
solves speedy. For each right hand side I then have to apply the
boundary conditions. In FEniCS I can do this with something like

  A = assemble(a) # assemble the matrix
  bc.apply(A) # apply the boundary conditions to the matrix
  <set up Solver for A>
  <loop over right hand sides>
     ...
     b = assemble(L) # assemble rhs
     bc.apply(b) # apply the boundary condition to the rhs
     Solver.solve(u.vector(), b)

But this applies the boundary conditions in the nonsymmetric way,
destroying the symmetry of the matrix A.

I could used

  A, b = assemble_system(a, L)

which preserves the symmetry, but then I have to reassemble the matrix
for each right hand side.

Is there a way to do symmetric imposition of boundary conditions, without
reassembling the matrix? I don't see any reason it is not doable,
but have not found how to specify it to dolfin.

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Doug Arnold
Solved:
Last query:
Last reply:
Revision history for this message
Anders Logg (logg) said :
#1

On Tue, Oct 04, 2011 at 12:15:45AM -0000, Doug Arnold wrote:
> New question #173160 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/173160
>
> Suppose I want to solve the linear system corresponding to a linear
> variational problem subject to Dirichlet boundary conditions
> many times with different right hand sides (e.g., as part of
> a time-stepping loop). I may choose to do this by assembling
> the matrix, applying the boundary conditions, and then doing a
> Cholesky decomposition or other preprocessing to make the matrix
> solves speedy. For each right hand side I then have to apply the
> boundary conditions. In FEniCS I can do this with something like
>
> A = assemble(a) # assemble the matrix
> bc.apply(A) # apply the boundary conditions to the matrix
> <set up Solver for A>
> <loop over right hand sides>
> ...
> b = assemble(L) # assemble rhs
> bc.apply(b) # apply the boundary condition to the rhs
> Solver.solve(u.vector(), b)
>
> But this applies the boundary conditions in the nonsymmetric way,
> destroying the symmetry of the matrix A.
>
> I could used
>
> A, b = assemble_system(a, L)
>
> which preserves the symmetry, but then I have to reassemble the matrix
> for each right hand side.
>
> Is there a way to do symmetric imposition of boundary conditions, without
> reassembling the matrix? I don't see any reason it is not doable,
> but have not found how to specify it to dolfin.

This is not supported at the moment. But it's something I'd like to
add.

--
Anders

Revision history for this message
Doug Arnold (dnarnold) said :
#2

Thanks. I have converted this into a bug report, with a possible syntax for implementing it.

Revision history for this message
Kent-Andre Mardal (kent-and) said :
#3

On 4 October 2011 18:20, Anders Logg
<email address hidden>wrote:

> Question #173160 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/173160
>
> Status: Open => Answered
>
> Anders Logg proposed the following answer:
> On Tue, Oct 04, 2011 at 12:15:45AM -0000, Doug Arnold wrote:
> > New question #173160 on DOLFIN:
> > https://answers.launchpad.net/dolfin/+question/173160
> >
> > Suppose I want to solve the linear system corresponding to a linear
> > variational problem subject to Dirichlet boundary conditions
> > many times with different right hand sides (e.g., as part of
> > a time-stepping loop). I may choose to do this by assembling
> > the matrix, applying the boundary conditions, and then doing a
> > Cholesky decomposition or other preprocessing to make the matrix
> > solves speedy. For each right hand side I then have to apply the
> > boundary conditions. In FEniCS I can do this with something like
> >
> > A = assemble(a) # assemble the matrix
> > bc.apply(A) # apply the boundary conditions to the matrix
> > <set up Solver for A>
> > <loop over right hand sides>
> > ...
> > b = assemble(L) # assemble rhs
> > bc.apply(b) # apply the boundary condition to the rhs
> > Solver.solve(u.vector(), b)
> >
> > But this applies the boundary conditions in the nonsymmetric way,
> > destroying the symmetry of the matrix A.
> >
> > I could used
> >
> > A, b = assemble_system(a, L)
> >
> > which preserves the symmetry, but then I have to reassemble the matrix
> > for each right hand side.
> >
> > Is there a way to do symmetric imposition of boundary conditions, without
> > reassembling the matrix? I don't see any reason it is not doable,
> > but have not found how to specify it to dolfin.
>
> This is not supported at the moment. But it's something I'd like to
> add.
>

Agree. It would require some very sparse matrices having a sparsity pattern
different from
the one obtained from the dof_map, though. In serial it would be simple to
add via
a stl map, but I am not sure what to do in parallel.

Kent

>
> --
> Anders
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>

Revision history for this message
Garth Wells (garth-wells) said :
#4

I would expect that the fastest and simplest way to do this is just how we do it now, but skip the insertion of the cell matrix into a global matrix.

Revision history for this message
Joachim Haga (jobh) said :
#5

I didn't notice this bug report before, but it looks like exactly the
problem that symmetric-assembler addresses.
Den 25. jan. 2013 10:06 skrev "Garth Wells" <
<email address hidden>> følgende:

> Bug #867680 status changed in DOLFIN:
>
> Confirmed => In Progress
>
> https://bugs.launchpad.net/dolfin/+bug/867680
> "need away to do symmetric imposition of bc with multiple rhs without
> reassembling matrix"
>
> This bug is linked to #173160.
> how to do symmetric imposition of bcs without reassembling matrix?
> https://answers.launchpad.net/dolfin/+question/173160
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>