From: Timo Heister Date: Wed, 13 Mar 2019 13:10:43 +0000 (-0400) Subject: add Trilinos error checks and fix nonlocal sparsity graph entry X-Git-Tag: v9.1.0-rc1~245^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F7833%2Fhead;p=dealii.git add Trilinos error checks and fix nonlocal sparsity graph entry - Bugfix: Use GID64(0) instead of MyGID(0) which is a bool - add more checks to other function calls - add comments - fix for rectangular patterns --- diff --git a/source/lac/trilinos_sparsity_pattern.cc b/source/lac/trilinos_sparsity_pattern.cc index 33887b18c5..ad5880afd9 100644 --- a/source/lac/trilinos_sparsity_pattern.cc +++ b/source/lac/trilinos_sparsity_pattern.cc @@ -793,17 +793,34 @@ namespace TrilinosWrappers if (nonlocal_graph->IndicesAreGlobal() == false && nonlocal_graph->RowMap().NumMyElements() > 0) { - // insert dummy element + // Insert dummy element at (row, column) that corresponds to row 0 + // in local index counting. TrilinosWrappers::types::int_type row = - nonlocal_graph->RowMap().MyGID(0); - nonlocal_graph->InsertGlobalIndices(row, 1, &row); + TrilinosWrappers::global_index(nonlocal_graph->RowMap(), 0); + TrilinosWrappers::types::int_type column = 0; + + // in case we have a square sparsity pattern, add the entry on the + // diagonal + if (TrilinosWrappers::n_global_elements(*column_space_map) == + TrilinosWrappers::n_global_elements(graph->RangeMap())) + column = row; + // if not, take a column index that we have ourselves since we + // know for sure it is there (and it will not create spurious + // messages to many ranks like putting index 0 on many processors) + else if (column_space_map->NumMyElements() > 0) + column = TrilinosWrappers::global_index(*column_space_map, 0); + ierr = nonlocal_graph->InsertGlobalIndices(row, 1, &column); + AssertThrow(ierr == 0, ExcTrilinosError(ierr)); } Assert(nonlocal_graph->RowMap().NumMyElements() == 0 || nonlocal_graph->IndicesAreGlobal() == true, ExcInternalError()); - nonlocal_graph->FillComplete(*column_space_map, graph->RangeMap()); - nonlocal_graph->OptimizeStorage(); + ierr = + nonlocal_graph->FillComplete(*column_space_map, graph->RangeMap()); + AssertThrow(ierr >= 0, ExcTrilinosError(ierr)); + ierr = nonlocal_graph->OptimizeStorage(); + AssertThrow(ierr >= 0, ExcTrilinosError(ierr)); Epetra_Export exporter(nonlocal_graph->RowMap(), graph->RowMap()); ierr = graph->Export(*nonlocal_graph, exporter, Add); AssertThrow(ierr == 0, ExcTrilinosError(ierr));