Setting up system matrix fails

25 views
Skip to first unread message

Gabriel Peters

unread,
Jul 9, 2019, 11:01:25 AM7/9/19
to deal.II User Group
Hey everyone,

I am setting up a system matrix in Trilinos::Blocksparsematrix with a DOfHandler, which has 3 velocity components and 1 pressure component (analogously to step-32).
Somehow everything worked fine a long time, but now I get an error I dont understand.

I call:


std::vector<double>                  div_sol_u   (dofs_per_cell);
    std::vector<double>                  sol_p       (dofs_per_cell);
[...]
 for (unsigned int k=0; k<dofs_per_cell; ++k)
                {
                div_sol_u[k]      = fe_values[velocities].divergence(k,q);
                sol_p[k]          = fe_values[pressure].value(k,q);
                 }
 for (unsigned int i=0; i<dofs_per_cell; ++i)
                  for (unsigned int j=0; j<dofs_per_cell; ++j){
                           local_matrix(i,j) += (-1)* sol_p[i]*div_sol_u[j]*fe_values.JxW(q);
[...]
constraints.distribute_local_to_global (local_matrix,
                                                       local_dof_indices,
                                                       system_matrixt);


 (In loval_matrix += ... I left out the other parts of the matrix to keep notation short in this question)
But when I run this  I get the following error                

  void dealii::TrilinosWrappers::SparseMatrix::add(dealii::TrilinosWrappers::SparseMatrix::size_type, dealii::TrilinosWrappers::SparseMatrix::size_type, const size_type*, const TrilinosScalar*, bool, bool)
The violated condition was:
    ierr == 0
Additional information:
    An error with error number 2 occurred while calling a Trilinos function



After some debugging I found out that the term (-1)* sol_p[i]*div_sol_u[j] makes this trouble. Can somebody tell me why?

Best
Gabriel


Wolfgang Bangerth

unread,
Jul 18, 2019, 4:52:46 AM7/18/19
to dea...@googlegroups.com
On 7/9/19 9:01 AM, Gabriel Peters wrote:
>
> After some debugging I found out that the term /(-1)* sol_p[i]*div_sol_u[j]/
> makes this trouble. Can somebody tell me why?

My suspicion would be that you are writing into an element of the matrix for
which you have not allocated space in the sparsity pattern. Could that be the
case?

Best
W.

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

Gabriel Peters

unread,
Jul 18, 2019, 5:41:48 AM7/18/19
to deal.II User Group


Am Donnerstag, 18. Juli 2019 10:52:46 UTC+2 schrieb Wolfgang Bangerth:
On 7/9/19 9:01 AM, Gabriel Peters wrote:
>
> After some debugging I found out that the term /(-1)* sol_p[i]*div_sol_u[j]/
> makes this trouble. Can somebody tell me why?

My suspicion would be that you are writing into an element of the matrix for
which you have not allocated space in the sparsity pattern. Could that be the
case?

Thanks a lot for the hint, now I found an error in my coupling for the make_sparsity_pattern function.
So indeed the space was not allocated.
Thanks a lot

Gabriel

Wolfgang Bangerth

unread,
Jul 18, 2019, 6:06:43 AM7/18/19
to dea...@googlegroups.com
On 7/18/19 3:41 AM, Gabriel Peters wrote:
>
> Thanks a lot for the hint, now I found an error in my coupling for the
> make_sparsity_pattern function.
> So indeed the space was not allocated.

Great, glad to help. It's easier to point people at the likely problem once
you've made every mistake yourself once (or even more often than that)... ;-)

Cheers
Reply all
Reply to author
Forward
0 new messages