From 2ffb4759c780a09471cb4fa94e92b388eeeb3534 Mon Sep 17 00:00:00 2001 From: Thomas Witkowski <thomas.witkowski@gmx.de> Date: Thu, 15 Jul 2010 14:06:16 +0000 Subject: [PATCH] Improved memory allocation for petsc matrix in the case of zero diagonal elements. --- AMDiS/src/parallel/GlobalMatrixSolver.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/AMDiS/src/parallel/GlobalMatrixSolver.cc b/AMDiS/src/parallel/GlobalMatrixSolver.cc index 22823ca9..66336ba9 100644 --- a/AMDiS/src/parallel/GlobalMatrixSolver.cc +++ b/AMDiS/src/parallel/GlobalMatrixSolver.cc @@ -4,7 +4,7 @@ #include "DOFVector.h" #include "Debug.h" #include "SystemVector.h" -#include "VtkWriter.h" + #include "petscksp.h" namespace AMDiS { @@ -283,10 +283,10 @@ namespace AMDiS { // Traverse all non zero entries in this row. for (icursor_type icursor = begin<nz>(cursor), icend = end<nz>(cursor); icursor != icend; ++icursor) { - if (value(*icursor) != 0.0) { - int petscColIdx = - meshDistributor->mapLocalToGlobal(col(*icursor)) * nComponents + j; + int petscColIdx = + meshDistributor->mapLocalToGlobal(col(*icursor)) * nComponents + j; + if (value(*icursor) != 0.0 || petscRowIdx == petscColIdx) { // The row DOF is a rank DOF, if also the column is a rank DOF, // increment the d_nnz values for this row, otherwise the o_nnz value. if (petscColIdx >= meshDistributor->getRstart() * nComponents && @@ -445,6 +445,9 @@ namespace AMDiS { MatAssemblyBegin(petscMatrix, MAT_FINAL_ASSEMBLY); MatAssemblyEnd(petscMatrix, MAT_FINAL_ASSEMBLY); +#if (DEBUG != 0) + INFO(info, 8)("Fill petsc matrix 3 needed %.5f seconds\n", TIME_USED(first, clock())); +#endif // === Transfer values from DOF vector to the PETSc vector. === -- GitLab