inverse operation to AffineConstraints.condense() (recovering full system matrix)

30 views
Skip to first unread message

Simon

unread,
Oct 28, 2023, 2:46:13 PM10/28/23
to deal.II User Group
Dear all,

the "Constraints on Degrees of Freedom" module introduces several approaches to deal with constraints.
I implemented the "second" approach, that is, distributing the constraints on the fly when assembling the linear system using the constraints.distribute_local_to_global() function.
Since I plan to move from serial to distributed versions of my program in the future,
it makes sense to stick to this approach as mentioned in the module.

After assembling and solving the linear system, I need the uncondensed system matrix and right hand side to perform a sensitivity analysis.
In particular, I need the rows and entries of the system matrix and RHS corresponding to constrained dofs.
However, the constraints.distribute_local_to_global() function sets these entries all to zero (except the diagonal value of the system matrix).
My solution to deal with this is to basically copy my assembly function and,
instead of distributing the constraints with the constraints object --
constraints.distribute_local_to_global() --
I distributed them with the cell iterator --
cell-> distribute_local_to_global(),
which does not care about the constraints.

This solution is of course very inefficient as for efficiency and code re-use.
As I said, it is basically a copy of my assembly function,
although most of the system matrix "is already there".

So is there a more efficient way to recover the full system matrix based on the condensed system matrix?

Thanks for your help!

Best,
Simon


Wolfgang Bangerth

unread,
Oct 28, 2023, 3:15:11 PM10/28/23
to dea...@googlegroups.com
On 10/28/23 12:46, Simon wrote:
>
> After assembling and solving the linear system, I need the uncondensed system
> matrix and right hand side to perform a sensitivity analysis.
> In particular, I need the rows and entries of the system matrix and RHS
> corresponding to constrained dofs.
> However, the constraints.distribute_local_to_global() function sets these
> entries all to zero (except the diagonal value of the system matrix).
> My solution to deal with this is to basically copy my assembly function and,
> instead of distributing the constraints with the constraints object --
> constraints.distribute_local_to_global() --
> I distributed them with the cell iterator --
> cell-> distribute_local_to_global(),
> which does not care about the constraints.
>
> This solution is of course very inefficient as for efficiency and code re-use.
> As I said, it is basically a copy of my assembly function,
> although most of the system matrix "is already there".
>
> So is there a more efficient way to recover the full system matrix based on
> the condensed system matrix?

No. If I tell you that a number x is a sum of two contributions a+b, there is
no way for you to recover a and b from x. You have to store it somewhere.

In your case, though, you don't actually need to compute the contributions
twice -- you can just compute it once and then both save the contributions
locally *and* distribute them to the global matrix. In fact, you only need to
store contributions for constrained degrees of freedom, rather than for all.

Best
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/


Mathieu

unread,
Oct 28, 2023, 3:42:07 PM10/28/23
to dea...@googlegroups.com
This makes sense. 

What do you think is an appropriate data structure for the storage of the entries associated with the constrained dofs? A FullMatrix or a separate AffineConstraints? 

Later, I have to somehow merge this data structure with the condensed system matrix since I have to solve a linear system with it. 

Best,
Simon 

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/ad4901fe-d57c-39b6-50f6-1bea81683fea%40colostate.edu.

Wolfgang Bangerth

unread,
Oct 28, 2023, 7:08:05 PM10/28/23
to dea...@googlegroups.com
On 10/28/23 13:41, Mathieu wrote:
>
> What do you think is an appropriate data structure for the storage of the
> entries associated with the constrained dofs? A FullMatrix or a separate
> AffineConstraints?
>
> Later, I have to somehow merge this data structure with the condensed system
> matrix since I have to solve a linear system with it.

The storing it as a sparse matrix seems reasonable. Its sparsity pattern is a
subset of the sparsity pattern of the system matrix. If you just want to get
things working, then using the same sparsity pattern is going to be a quick
solution though it wastes a substantial amount of memory. If you want to put
some more work in, you can relatively easily determine which rows and columns
need to be stored.
Reply all
Reply to author
Forward
0 new messages