" 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."
I will assemble the new rhs as vector with size 20. If the values of the new rhs correspondong to constrained DoFs are irrlevant, I do not have to modify the new rhs as well as the 20x20 system matrix at all. But let me make a short example with the following linear 3x3 linear system A*x = b: A = [K00 K01 0 ; K10 K11 K12; 0 K21 K22;] x=[x0; x1; x2] b=[b1, b2; b3] Say x0=c=const. The linear system looks like this after the assembly routine: A = [K00 0 0 ; 0 K11 K12; 0 K21 K22;] x=[0 ; x1; x2] b=[0 ; b2-c*K10; b3] This system boilds down to a 2x2 system for x1 and x2 with x0=0. This is exactly what I want to compute, but without having -c*K10 substracted. (Because the new rhs comes from a different problem and has nothing to do with the constrainted dofs - I just need the 2x2 portion from the original problem) Currently I only deal with homogeneous constraints (x0=0). In this case constraints.distribute(...) does not change the unconstrained entries of the rhs, right? But I will also have to deal with inhomogeneous constraints, in which case it makes a difference. That said, is there a way to leave the components of the rhs corresponding to unconstrained DoFs unchanged? Best Simon Am Fr., 19. Aug. 2022 um 01:41 Uhr schrieb Wolfgang Bangerth < [email protected]>: > 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: [email protected] > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/dealii/17c15884-e251-1c38-f563-16bec6ad37a7%40colostate.edu > . > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/CAM50jEuP777mMbgKsxwU%3DsJhMzAMYm2vYzUNPY1JzMV69U1FQw%40mail.gmail.com.
