Commit 3c9efbeb authored by Thomas Witkowski's avatar Thomas Witkowski

Fixed 0-diagonal problem in parallel computations.

parent 7bf3e8d7
...@@ -44,7 +44,7 @@ available_tags=" CXX F77" ...@@ -44,7 +44,7 @@ available_tags=" CXX F77"
# ### BEGIN LIBTOOL CONFIG # ### BEGIN LIBTOOL CONFIG
# Libtool was configured on host deimos103: # Libtool was configured on host deimos102:
# Shell to use when invoking shell scripts. # Shell to use when invoking shell scripts.
SHELL="/bin/sh" SHELL="/bin/sh"
...@@ -6760,7 +6760,7 @@ build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac` ...@@ -6760,7 +6760,7 @@ build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac`
# End: # End:
# ### BEGIN LIBTOOL TAG CONFIG: CXX # ### BEGIN LIBTOOL TAG CONFIG: CXX
# Libtool was configured on host deimos103: # Libtool was configured on host deimos102:
# Shell to use when invoking shell scripts. # Shell to use when invoking shell scripts.
SHELL="/bin/sh" SHELL="/bin/sh"
...@@ -7065,7 +7065,7 @@ include_expsyms="" ...@@ -7065,7 +7065,7 @@ include_expsyms=""
# ### BEGIN LIBTOOL TAG CONFIG: F77 # ### BEGIN LIBTOOL TAG CONFIG: F77
# Libtool was configured on host deimos103: # Libtool was configured on host deimos102:
# Shell to use when invoking shell scripts. # Shell to use when invoking shell scripts.
SHELL="/bin/sh" SHELL="/bin/sh"
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "DOFVector.h" #include "DOFVector.h"
#include "Debug.h" #include "Debug.h"
#include "SystemVector.h" #include "SystemVector.h"
#include "VtkWriter.h"
#include "petscksp.h" #include "petscksp.h"
namespace AMDiS { namespace AMDiS {
...@@ -94,6 +94,8 @@ namespace AMDiS { ...@@ -94,6 +94,8 @@ namespace AMDiS {
int globalRowDof = meshDistributor->mapLocalToGlobal(*cursor); int globalRowDof = meshDistributor->mapLocalToGlobal(*cursor);
// Test if the current row dof is a periodic dof. // Test if the current row dof is a periodic dof.
bool periodicRow = meshDistributor->isPeriodicDof(globalRowDof); bool periodicRow = meshDistributor->isPeriodicDof(globalRowDof);
// Calculate petsc row index.
int rowIndex = globalRowDof * dispMult + dispAddRow;
// === Traverse all non zero entries of the row and produce vector cols === // === Traverse all non zero entries of the row and produce vector cols ===
...@@ -102,13 +104,14 @@ namespace AMDiS { ...@@ -102,13 +104,14 @@ namespace AMDiS {
for (icursor_type icursor = begin<nz>(cursor), icend = end<nz>(cursor); for (icursor_type icursor = begin<nz>(cursor), icend = end<nz>(cursor);
icursor != icend; ++icursor) { icursor != icend; ++icursor) {
// Global index of the current column index.
int globalColDof = meshDistributor->mapLocalToGlobal(col(*icursor));
// Calculate the exact position of the column index in the petsc matrix.
int colIndex = globalColDof * dispMult + dispAddCol;
// Set only non null values. // Set only non null values.
if (value(*icursor) != 0.0) { if (value(*icursor) != 0.0 || rowIndex == colIndex) {
// Global index of the current column index.
int globalColDof = meshDistributor->mapLocalToGlobal(col(*icursor));
// Calculate the exact position of the column index in the petsc matrix.
int colIndex = globalColDof * dispMult + dispAddCol;
// If the current row is not periodic, but the current dof index is periodic, // If the current row is not periodic, but the current dof index is periodic,
// we have to duplicate the value to the other corresponding periodic columns. // we have to duplicate the value to the other corresponding periodic columns.
...@@ -140,10 +143,7 @@ namespace AMDiS { ...@@ -140,10 +143,7 @@ namespace AMDiS {
// === Up to now we have assembled on row. Now, the row must be send to the === // === Up to now we have assembled on row. Now, the row must be send to the ===
// === corresponding rows to the petsc matrix. === // === corresponding rows to the petsc matrix. ===
// Calculate petsc row index.
int rowIndex = globalRowDof * dispMult + dispAddRow;
if (periodicRow) { if (periodicRow) {
// The row dof is periodic, so send dof to all the corresponding rows. // The row dof is periodic, so send dof to all the corresponding rows.
std::set<int>& perAsc = meshDistributor->getPerDofAssociations(globalRowDof); std::set<int>& perAsc = meshDistributor->getPerDofAssociations(globalRowDof);
...@@ -151,7 +151,7 @@ namespace AMDiS { ...@@ -151,7 +151,7 @@ namespace AMDiS {
double scalFactor = 1.0 / (perAsc.size() + 1.0); double scalFactor = 1.0 / (perAsc.size() + 1.0);
for (unsigned int i = 0; i < values.size(); i++) for (unsigned int i = 0; i < values.size(); i++)
values[i] *= scalFactor; values[i] *= scalFactor;
// Send the main row to the petsc matrix. // Send the main row to the petsc matrix.
MatSetValues(petscMatrix, 1, &rowIndex, cols.size(), MatSetValues(petscMatrix, 1, &rowIndex, cols.size(),
...@@ -174,6 +174,7 @@ namespace AMDiS { ...@@ -174,6 +174,7 @@ namespace AMDiS {
} }
int perRowIndex = (meshDistributor->getPeriodicMapping(*perIt, globalRowDof) * dispMult) + dispAddRow; int perRowIndex = (meshDistributor->getPeriodicMapping(*perIt, globalRowDof) * dispMult) + dispAddRow;
MatSetValues(petscMatrix, 1, &perRowIndex, perCols.size(), MatSetValues(petscMatrix, 1, &perRowIndex, perCols.size(),
&(perCols[0]), &(perValues[0]), ADD_VALUES); &(perCols[0]), &(perValues[0]), ADD_VALUES);
} }
......
...@@ -1815,10 +1815,13 @@ namespace AMDiS { ...@@ -1815,10 +1815,13 @@ namespace AMDiS {
debug::getAllDofs(feSpace, testDofs); debug::getAllDofs(feSpace, testDofs);
for (std::set<const DegreeOfFreedom*>::iterator it = testDofs.begin(); for (std::set<const DegreeOfFreedom*>::iterator it = testDofs.begin();
it != testDofs.end(); ++it) { it != testDofs.end(); ++it) {
// WorldVector<double> coords;
// mesh->getDofIndexCoords(**it, feSpace, coords);
MSG("DOF %d: mapLocalGlobalDofs = %d vertexDof = %d isRankDof = %d\n", **it, MSG("DOF %d: mapLocalGlobalDofs = %d vertexDof = %d isRankDof = %d\n", **it,
mapLocalGlobalDofs[**it], mapLocalGlobalDofs[**it],
vertexDof[*it], vertexDof[*it],
isRankDof[**it]); isRankDof[**it]);
// MSG("coord = %f %f\n", coords[0], coords[1]);
} }
#endif #endif
#endif #endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment