On 10/11/20 6:09 PM, Nikki Holtzer wrote:
I was hoping to take the outer product which is formed in a FullMatrix, called Kronecker_matrix below, multiply it by a coefficient, and add a matrix to it called nonlinear_part_full. This entire operation I have tried to put into a Sparse matrix, called Nonlinear_part, because I need to add this term to linear_part which is Sparse. I have done this simply because it was the only way I could make the addition between linear_part (Sparse) and nonlinear_part_full (FullMatrix) work all while trying to make the code as efficient as possible.

But if the nonlinear part is a dense matrix, you will necessarily add entries into the sparse matrix that are not present in the sparsity pattern. When you build a sparse matrix with a certain sparsity pattern, you are saying "these are the entries that could possibly be nonzero, please allocate memory for them". So when you later add the dense matrix to the sparse one, you're breaking this promise.

I don't quite understand why you copy everything into a sparse matrix in your code. Couldn't you just keep everything in dense matrices and do the linear solve with that?

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/a0cc822e-19a2-9a29-5fd7-5f735e0eeadd%40colostate.edu.

Reply via email to