On 8/18/22 10:38, Simon wrote:
Say, I have in total 20 dofs and the dof with global dof index Zero is constrained.
As a consequence, the first component of the rhs b is set to Zero as well as
the first row and column of the system matrix A (except the diagonal value).
In a postprecessing step, I have to solve another linear system, however, with the system matrix being only the 19x19 matrix associated with the 19 unconstrained dofs; I do not need the rhs anymore.

Is there a way to get this portion of the system matrix based on the existing system matrix (sparsity pattern)?

Both the sparsity pattern and the sparse matrix have iterators that allow you to iterate over all entries of a matrix. You can do that and just filter out those rows and columns you're not interested in, and then copy the rest into output objects with translated indices.

But the easier approach may be to use the same 20x20 matrix and just copy the new rhs you want to solve with into a vector with size 20, leaving the entries of the rhs vector that correspond to constrained DoFs zero (or, in fact, whatever you want -- the value there doesn't matter). By zeroing out rows and columns, you are in essence solving a linear system with only the 19x19 matrix. You then copy the 19 DoFs you care about out of the solution vector into an output vector.

Best
 W.


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

--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/17c15884-e251-1c38-f563-16bec6ad37a7%40colostate.edu.

Reply via email to