The issue that I have when all matrices are FullMatrix matrices is I can't
seem to get the .add function to result in anything other than error. If I
keep ONLY both nonlinear_part and linear_part as FullMatrix
I receive:
error: no matching function for call to
‘dealii::FullMatrix<double>::add(double, const
dealii::SparseMatrix<double>&)’
linear_part.add((1. - theta) * kappa, S_c);
Which leads me to believe that I cannot add a SparseMatrix (S_c) to a
FullMatrix (linear_part). I tried to back track and change S_c to be a
FullMatrix instead of a SparseMatrix
For instance:
FullMatrix<double> mass_matrix_unconstrainted;
mass_matrix_unconstrained = 0;
FullMatrix<double> cell_mass_matrix(dofs_per_cell, dofs_per_cell);
cell_mass_matrix = 0;
Then I fill cell_mass_matrix.
mass_matrix_unconstrained.add(local_dof_indices, cell_mass_matrix);
error: no matching function for call to
‘dealii::FullMatrix<double>::add(std::vector<unsigned int>&,
dealii::FullMatrix<double>&)’
mass_matrix_unconstrained.add(local_dof_indices, cell_mass_matrix);
Alternatively if I try:
mass_matrix_unconstrained = mass_matrix_unconstrained +
local_dof_indices*cell_mass_matrix;
I receive.
error: no match for ‘operator*’ (operand types are ‘std::vector<unsigned
int>’ and ‘dealii::FullMatrix<double>’)
mass_matrix_unconstrained = mass_matrix_unconstrained +
local_dof_indices * cell_mass_matrix;
I thought maybe this is a type error, i.e. I can't multiply a vector of int
by a matrix of double but I can't seem to be able to convert the vector
without error either.
Thank you,
Nikki
On Monday, October 12, 2020 at 7:27:35 PM UTC-4 Wolfgang Bangerth wrote:
> 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/a9ee9a8a-6cab-47b0-9ef1-49a133a6828dn%40googlegroups.com.