Commit d8a17f14 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Fixed Lumped preconditioner issue.

parent 82a26536
...@@ -23,9 +23,9 @@ namespace AMDiS { ...@@ -23,9 +23,9 @@ namespace AMDiS {
{ {
FUNCNAME("DofToMatIndex::getReverse()"); FUNCNAME("DofToMatIndex::getReverse()");
for (map<int, map<DegreeOfFreedom, int> >::iterator it0 = data.begin(); for (map<int, boost::container::flat_map<DegreeOfFreedom, int> >::iterator it0 = data.begin();
it0 != data.end(); ++it0) it0 != data.end(); ++it0)
for (map<DegreeOfFreedom, int>::iterator it1 = it0->second.begin(); for (boost::container::flat_map<DegreeOfFreedom, int>::iterator it1 = it0->second.begin();
it1 != it0->second.end(); ++it1) it1 != it0->second.end(); ++it1)
if (it1->second == rowIndex) { if (it1->second == rowIndex) {
component = it0->first; component = it0->first;
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include <set> #include <set>
#include <petsc.h> #include <petsc.h>
#include <petscis.h> #include <petscis.h>
#include <boost/container/flat_map.hpp>
#include <boost/container/flat_set.hpp>
#include "AMDiS_fwd.h" #include "AMDiS_fwd.h"
#include "parallel/DofComm.h" #include "parallel/DofComm.h"
...@@ -92,7 +94,8 @@ namespace AMDiS { ...@@ -92,7 +94,8 @@ namespace AMDiS {
private: private:
/// The mapping data. For each system component there is a specific map that /// The mapping data. For each system component there is a specific map that
/// maps global DOF indices to global matrix indices. /// maps global DOF indices to global matrix indices.
map<int, map<DegreeOfFreedom, int> > data; // map<int, map<DegreeOfFreedom, int> > data;
map<int, boost::container::flat_map<DegreeOfFreedom, int> > data;
}; };
...@@ -273,7 +276,7 @@ namespace AMDiS { ...@@ -273,7 +276,7 @@ namespace AMDiS {
DofMap dofMap; DofMap dofMap;
/// Set of all DOFs that are in mapping but are not owned by the rank. /// Set of all DOFs that are in mapping but are not owned by the rank.
std::set<DegreeOfFreedom> nonRankDofs; boost::container::flat_set<DegreeOfFreedom> nonRankDofs;
/// If true, a global index mapping will be computed for all DOFs. /// If true, a global index mapping will be computed for all DOFs.
bool needGlobalMapping; bool needGlobalMapping;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <vector> #include <vector>
#include <set> #include <set>
#include <map> #include <map>
#include <boost/container/flat_map.hpp>
#include "BoundaryObject.h" #include "BoundaryObject.h"
#include "Global.h" #include "Global.h"
#include "parallel/InteriorBoundary.h" #include "parallel/InteriorBoundary.h"
...@@ -72,7 +73,8 @@ namespace AMDiS { ...@@ -72,7 +73,8 @@ namespace AMDiS {
int local, global; int local, global;
}; };
typedef std::map<DegreeOfFreedom, MultiIndex> DofMap; // typedef std::map<DegreeOfFreedom, MultiIndex> DofMap;
typedef boost::container::flat_map<DegreeOfFreedom, MultiIndex> DofMap;
typedef vector<MeshStructure> MeshCodeVec; typedef vector<MeshStructure> MeshCodeVec;
......
...@@ -1395,7 +1395,7 @@ namespace AMDiS { ...@@ -1395,7 +1395,7 @@ namespace AMDiS {
{ {
FUNCNAME("PetscSolverFeti::createPreconditionerMatrix()"); FUNCNAME("PetscSolverFeti::createPreconditionerMatrix()");
if (fetiPreconditioner != FETI_NONE) if (fetiPreconditioner == FETI_NONE)
return; return;
double wtime = MPI::Wtime(); double wtime = MPI::Wtime();
...@@ -1460,6 +1460,9 @@ namespace AMDiS { ...@@ -1460,6 +1460,9 @@ namespace AMDiS {
const FiniteElemSpace *rowFeSpace = feSpaces[rowComponent]; const FiniteElemSpace *rowFeSpace = feSpaces[rowComponent];
const FiniteElemSpace *colFeSpace = feSpaces[colComponent]; const FiniteElemSpace *colFeSpace = feSpaces[colComponent];
if (enableStokesMode && (rowFeSpace == fullInterface || colFeSpace == fullInterface))
continue;
traits::col<Matrix>::type col(dofMat->getBaseMatrix()); traits::col<Matrix>::type col(dofMat->getBaseMatrix());
traits::const_value<Matrix>::type value(dofMat->getBaseMatrix()); traits::const_value<Matrix>::type value(dofMat->getBaseMatrix());
...@@ -1469,51 +1472,49 @@ namespace AMDiS { ...@@ -1469,51 +1472,49 @@ namespace AMDiS {
if (isPrimal(rowFeSpace, *cursor)) if (isPrimal(rowFeSpace, *cursor))
continue; continue;
colsLocal.clear();
colsLocalOther.clear();
valuesLocal.clear();
valuesLocalOther.clear();
// Traverse all columns.
for (icursor_type icursor = begin<nz>(cursor), icend = end<nz>(cursor);
icursor != icend; ++icursor) {
if (isPrimal(colFeSpace, col(*icursor)))
continue;
if (!isDual(rowFeSpace, *cursor)) {
if (!isDual(colFeSpace, col(*icursor))) {
int colIndex =
interiorDofMap.getLocalMatIndex(colComponent, col(*icursor));
colsLocal.push_back(colIndex);
valuesLocal.push_back(value(*icursor));
} else {
int colIndex =
dualDofMap.getLocalMatIndex(colComponent, col(*icursor));
colsLocalOther.push_back(colIndex);
valuesLocalOther.push_back(value(*icursor));
}
} else {
if (!isDual(colFeSpace, col(*icursor))) {
int colIndex =
interiorDofMap.getLocalMatIndex(colComponent, col(*icursor));
colsLocalOther.push_back(colIndex);
valuesLocalOther.push_back(value(*icursor));
} else {
int colIndex =
dualDofMap.getLocalMatIndex(colComponent, col(*icursor));
colsLocal.push_back(colIndex);
valuesLocal.push_back(value(*icursor));
}
}
} // for each nnz in row
// === Set matrix values for preconditioner ===
switch (fetiPreconditioner) { switch (fetiPreconditioner) {
case FETI_DIRICHLET: case FETI_DIRICHLET:
colsLocal.clear();
colsLocalOther.clear();
valuesLocal.clear();
valuesLocalOther.clear();
// Traverse all columns.
for (icursor_type icursor = begin<nz>(cursor), icend = end<nz>(cursor);
icursor != icend; ++icursor) {
if (isPrimal(colFeSpace, col(*icursor)))
continue;
if (!isDual(rowFeSpace, *cursor)) {
if (!isDual(colFeSpace, col(*icursor))) {
int colIndex =
interiorDofMap.getLocalMatIndex(colComponent, col(*icursor));
colsLocal.push_back(colIndex);
valuesLocal.push_back(value(*icursor));
} else {
int colIndex =
dualDofMap.getLocalMatIndex(colComponent, col(*icursor));
colsLocalOther.push_back(colIndex);
valuesLocalOther.push_back(value(*icursor));
}
} else {
if (!isDual(colFeSpace, col(*icursor))) {
int colIndex =
interiorDofMap.getLocalMatIndex(colComponent, col(*icursor));
colsLocalOther.push_back(colIndex);
valuesLocalOther.push_back(value(*icursor));
} else {
int colIndex =
dualDofMap.getLocalMatIndex(colComponent, col(*icursor));
colsLocal.push_back(colIndex);
valuesLocal.push_back(value(*icursor));
}
}
} // for each nnz in row
if (!isDual(rowFeSpace, *cursor)) { if (!isDual(rowFeSpace, *cursor)) {
int rowIndex = int rowIndex =
interiorDofMap.getLocalMatIndex(rowComponent, *cursor); interiorDofMap.getLocalMatIndex(rowComponent, *cursor);
...@@ -1532,18 +1533,38 @@ namespace AMDiS { ...@@ -1532,18 +1533,38 @@ namespace AMDiS {
MatSetValues(mat_duals_interior, 1, &rowIndex, colsLocalOther.size(), MatSetValues(mat_duals_interior, 1, &rowIndex, colsLocalOther.size(),
&(colsLocalOther[0]), &(valuesLocalOther[0]), INSERT_VALUES); &(colsLocalOther[0]), &(valuesLocalOther[0]), INSERT_VALUES);
} }
break; break;
case FETI_LUMPED: case FETI_LUMPED:
if (isDual(rowFeSpace, *cursor)) { if (!isDual(rowFeSpace, *cursor))
int rowIndex = dualDofMap.getLocalMatIndex(rowComponent, *cursor); continue;
MatSetValues(mat_duals_duals, 1, &rowIndex, colsLocal.size(),
&(colsLocal[0]), &(valuesLocal[0]), INSERT_VALUES); colsLocal.clear();
} valuesLocal.clear();
// Traverse all columns.
for (icursor_type icursor = begin<nz>(cursor), icend = end<nz>(cursor);
icursor != icend; ++icursor) {
if (!isDual(colFeSpace, col(*icursor)))
continue;
int colIndex =
dualDofMap.getLocalMatIndex(colComponent, col(*icursor));
colsLocal.push_back(colIndex);
valuesLocal.push_back(value(*icursor));
}
int rowIndex = dualDofMap.getLocalMatIndex(rowComponent, *cursor);
MatSetValues(mat_duals_duals, 1, &rowIndex, colsLocal.size(),
&(colsLocal[0]), &(valuesLocal[0]), INSERT_VALUES);
break; break;
default: default:
break; break;
} }
} }
} }
} }
......
Supports Markdown
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