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

Removed some static variables.

parent 1b0e1b16
...@@ -34,8 +34,6 @@ namespace AMDiS { ...@@ -34,8 +34,6 @@ namespace AMDiS {
using namespace mtl; using namespace mtl;
DOFMatrix *DOFMatrix::traversePtr = NULL;
DOFMatrix::DOFMatrix() DOFMatrix::DOFMatrix()
: rowFeSpace(NULL), : rowFeSpace(NULL),
colFeSpace(NULL), colFeSpace(NULL),
......
...@@ -424,9 +424,6 @@ namespace AMDiS { ...@@ -424,9 +424,6 @@ namespace AMDiS {
/// default compressed2D<double> /// default compressed2D<double>
base_matrix_type matrix; base_matrix_type matrix;
/// Used while mesh traversal
static DOFMatrix *traversePtr;
/// Pointers to all operators of the equation systems. Are used in the /// Pointers to all operators of the equation systems. Are used in the
/// assembling process. /// assembling process.
vector<Operator*> operators; vector<Operator*> operators;
......
...@@ -68,7 +68,8 @@ namespace AMDiS { ...@@ -68,7 +68,8 @@ namespace AMDiS {
template<> template<>
const double& DOFVector<double>::evalAtPoint(WorldVector<double> &p, ElInfo *oldElInfo, double* values) const double DOFVector<double>::evalAtPoint(WorldVector<double> &p,
ElInfo *oldElInfo) const
{ {
FUNCNAME("DOFVector<double>::evalAtCoords()"); FUNCNAME("DOFVector<double>::evalAtCoords()");
...@@ -82,7 +83,7 @@ namespace AMDiS { ...@@ -82,7 +83,7 @@ namespace AMDiS {
DimVec<double> lambda(dim, NO_INIT); DimVec<double> lambda(dim, NO_INIT);
ElInfo *elInfo = mesh->createNewElInfo(); ElInfo *elInfo = mesh->createNewElInfo();
static double value = 0.0; double value = 0.0;
bool inside = false; bool inside = false;
if (oldElInfo && oldElInfo->getMacroElement()) { if (oldElInfo && oldElInfo->getMacroElement()) {
...@@ -107,14 +108,13 @@ namespace AMDiS { ...@@ -107,14 +108,13 @@ namespace AMDiS {
if (oldElInfo == NULL) if (oldElInfo == NULL)
delete elInfo; delete elInfo;
if (values != NULL)
*values = value;
return value; return value;
}; }
template<> template<>
const WorldVector<double>& DOFVector<WorldVector<double> >::evalAtPoint(WorldVector<double> &p, ElInfo *oldElInfo, WorldVector<double>* values) const WorldVector<double> DOFVector<WorldVector<double> >::evalAtPoint(WorldVector<double> &p,
ElInfo *oldElInfo) const
{ {
FUNCNAME("DOFVector<double>::evalAtCoords()"); FUNCNAME("DOFVector<double>::evalAtCoords()");
...@@ -129,9 +129,7 @@ namespace AMDiS { ...@@ -129,9 +129,7 @@ namespace AMDiS {
ElInfo *elInfo = mesh->createNewElInfo(); ElInfo *elInfo = mesh->createNewElInfo();
static WorldVector<double> Values(DEFAULT_VALUE, 0.0); WorldVector<double> value(DEFAULT_VALUE, 0.0);
WorldVector<double> *val = (NULL != values) ? values : &Values;
bool inside = false; bool inside = false;
if (oldElInfo && oldElInfo->getMacroElement()) { if (oldElInfo && oldElInfo->getMacroElement()) {
...@@ -148,7 +146,7 @@ namespace AMDiS { ...@@ -148,7 +146,7 @@ namespace AMDiS {
mtl::dense_vector<WorldVector<double> > uh(nBasFcts); mtl::dense_vector<WorldVector<double> > uh(nBasFcts);
for (int i = 0; i < nBasFcts; i++) for (int i = 0; i < nBasFcts; i++)
uh[i] = operator[](localIndices[i]); uh[i] = operator[](localIndices[i]);
*val = basFcts->evalUh(lambda, uh); value = basFcts->evalUh(lambda, uh);
} else } else
throw(std::runtime_error("Can not eval DOFVector at point p, because point is outside geometry.")); throw(std::runtime_error("Can not eval DOFVector at point p, because point is outside geometry."));
...@@ -156,8 +154,8 @@ namespace AMDiS { ...@@ -156,8 +154,8 @@ namespace AMDiS {
if (oldElInfo == NULL) if (oldElInfo == NULL)
delete elInfo; delete elInfo;
return ((*val)); return value;
}; }
template<> template<>
......
...@@ -613,13 +613,11 @@ namespace AMDiS { ...@@ -613,13 +613,11 @@ namespace AMDiS {
/// Eval DOFVector at given point p. If oldElInfo != NULL the search for /// Eval DOFVector at given point p. If oldElInfo != NULL the search for
/// the element, where p is inside, starts from oldElInfo. implemented for: /// the element, where p is inside, starts from oldElInfo. implemented for:
/// double, WorldVector< double > /// double, WorldVector< double >
inline const T& evalAtPoint(WorldVector<double> &p, T evalAtPoint(WorldVector<double> &p,
ElInfo *oldElInfo = NULL, ElInfo *oldElInfo = NULL) const
T* value = NULL) const
{ {
FUNCNAME("DOFVector::evalAtPoint())"); FUNCNAME("DOFVector::evalAtPoint())");
TEST_EXIT(false)("Please implement your evaluation\n"); TEST_EXIT(false)("Please implement your evaluation\n");
return *value;
} }
/// Determine the DegreeOfFreedom that has coords with minimal euclidean /// Determine the DegreeOfFreedom that has coords with minimal euclidean
...@@ -674,12 +672,12 @@ namespace AMDiS { ...@@ -674,12 +672,12 @@ namespace AMDiS {
BoundaryType boundaryType, Quadrature* q) const; BoundaryType boundaryType, Quadrature* q) const;
template<> template<>
const double& DOFVector<double>::evalAtPoint( double DOFVector<double>::evalAtPoint(WorldVector<double> &p,
WorldVector<double> &p, ElInfo *oldElInfo, double* value) const; ElInfo *oldElInfo) const;
template<> template<>
const WorldVector<double>& DOFVector<WorldVector<double> >::evalAtPoint( WorldVector<double> DOFVector<WorldVector<double> >::evalAtPoint(WorldVector<double> &p,
WorldVector<double> &p, ElInfo *oldElInfo, WorldVector<double>* value) const; ElInfo *oldElInfo) const;
template<> template<>
void DOFVector<double>::refineInterpol(RCNeighbourList&, int); void DOFVector<double>::refineInterpol(RCNeighbourList&, int);
......
...@@ -1599,9 +1599,9 @@ namespace AMDiS { ...@@ -1599,9 +1599,9 @@ namespace AMDiS {
elObjDb.create(partitionMap, levelData); elObjDb.create(partitionMap, levelData);
elObjDb.updateRankData(); elObjDb.updateRankData();
unsigned long memsize = elObjDb.calculateMemoryUsage(); // unsigned long memsize = elObjDb.calculateMemoryUsage();
MSG("Memory usage of element object database = %5.f KByte\n", // MSG("Memory usage of element object database = %5.f KByte\n",
static_cast<double>(memsize / 1024)); // static_cast<double>(memsize / 1024));
intBoundary.create(levelData, 0, elObjDb); intBoundary.create(levelData, 0, elObjDb);
ParallelDebug::printBoundaryInfo(intBoundary); ParallelDebug::printBoundaryInfo(intBoundary);
......
...@@ -680,7 +680,7 @@ namespace AMDiS { ...@@ -680,7 +680,7 @@ namespace AMDiS {
VecAssemblyBegin(tmpVec); VecAssemblyBegin(tmpVec);
VecAssemblyEnd(tmpVec); VecAssemblyEnd(tmpVec);
subdomain->solve(tmpVec, tmpVec); subdomain->solve(tmpVec, tmpVec);
PetscScalar *tmpValues; PetscScalar *tmpValues;
...@@ -1018,9 +1018,8 @@ namespace AMDiS { ...@@ -1018,9 +1018,8 @@ namespace AMDiS {
MatMult(subdomain->getMatInterior(), ktest0, ktest1); MatMult(subdomain->getMatInterior(), ktest0, ktest1);
PetscScalar *valarray; PetscScalar *valarray;
VecGetArray(ktest1, &valarray);
Vec ktest2, ktest3; Vec ktest2, ktest3;
VecGetArray(ktest1, &valarray);
VecCreateMPIWithArray(PETSC_COMM_WORLD, 1, VecCreateMPIWithArray(PETSC_COMM_WORLD, 1,
localDofMap.getRankDofs(), nGlobalOverallInterior, localDofMap.getRankDofs(), nGlobalOverallInterior,
valarray, &ktest2); valarray, &ktest2);
...@@ -1046,14 +1045,26 @@ namespace AMDiS { ...@@ -1046,14 +1045,26 @@ namespace AMDiS {
KSPSetNullSpace(ksp_feti, matNullSpace); KSPSetNullSpace(ksp_feti, matNullSpace);
MatNullSpaceDestroy(&matNullSpace); MatNullSpaceDestroy(&matNullSpace);
#if (DEBUG != 0) //#if (DEBUG != 0)
Vec vecSol; Vec vecSol;
VecDuplicate(nullSpaceBasis, &vecSol); VecDuplicate(nullSpaceBasis, &vecSol);
MatMult(mat_feti, nullSpaceBasis, vecSol); MatMult(mat_feti, nullSpaceBasis, vecSol);
PetscReal norm;
Vec vecSol0, vecSol1;
VecNestGetSubVec(vecSol, 0, &vecSol0);
VecNestGetSubVec(vecSol, 1, &vecSol1);
PetscReal norm, norm0, norm1;
VecNorm(vecSol, NORM_2, &norm); VecNorm(vecSol, NORM_2, &norm);
MSG("NORM: %e\n", norm); VecNorm(vecSol0, NORM_2, &norm0);
#endif VecNorm(vecSol1, NORM_2, &norm1);
MSG("NORM: %e (%e %e)\n", norm, norm0, norm1);
VecDestroy(&vecSol);
//#endif
// AMDiS::finalize();
// exit(0);
VecDestroy(&ktest0); VecDestroy(&ktest0);
VecDestroy(&ktest1); VecDestroy(&ktest1);
...@@ -1692,6 +1703,8 @@ namespace AMDiS { ...@@ -1692,6 +1703,8 @@ namespace AMDiS {
{ {
FUNCNAME("PetscSolverFeti::solveReducedFetiMatrix()"); FUNCNAME("PetscSolverFeti::solveReducedFetiMatrix()");
debugNullSpace(vec);
// === Some temporary vectors. === // === Some temporary vectors. ===
Vec tmp_b0, tmp_b1; Vec tmp_b0, tmp_b1;
...@@ -2017,4 +2030,96 @@ namespace AMDiS { ...@@ -2017,4 +2030,96 @@ namespace AMDiS {
&(nestMat[0]), &mat); &(nestMat[0]), &mat);
} }
} }
void PetscSolverFeti::debugNullSpace(SystemVector &vec)
{
FUNCNAME("PetscSolverFeti::debugNullSpace()");
TEST_EXIT(stokesMode)("This function works only for the stokes mode!\n");
Mat fetiMat;
createNestedFetiMat(fetiMat);
Vec vecArray[4];
Vec ktest0, ktest1, ktest2;
localDofMap.createLocalVec(ktest0);
localDofMap.createLocalVec(ktest1);
localDofMap.createVec(ktest2, nGlobalOverallInterior);
DofMap& m = localDofMap[pressureFeSpace].getMap();
for (DofMap::iterator it = m.begin(); it != m.end(); ++it) {
if (meshDistributor->getDofMap()[pressureFeSpace].isRankDof(it->first)) {
int index = localDofMap.getLocalMatIndex(pressureComponent, it->first);
VecSetValue(ktest0, index, 1.0, INSERT_VALUES);
}
}
VecAssemblyBegin(ktest0);
VecAssemblyEnd(ktest0);
MatMult(subdomain->getMatInterior(), ktest0, ktest1);
PetscScalar *valarray;
VecGetArray(ktest0, &valarray);
VecCreateMPIWithArray(PETSC_COMM_WORLD, 1,
localDofMap.getRankDofs(), nGlobalOverallInterior,
valarray, &vecArray[0]);
Vec ktest3;
VecGetArray(ktest1, &valarray);
VecCreateMPIWithArray(PETSC_COMM_WORLD, 1,
localDofMap.getRankDofs(), nGlobalOverallInterior,
valarray, &ktest3);
primalDofMap.createVec(vecArray[1]);
VecSet(vecArray[1], 0.0);
interfaceDofMap.createVec(vecArray[2]);
VecSet(vecArray[2], 1.0);
lagrangeMap.createVec(vecArray[3]);
MatMult(subdomain->getMatInteriorCoarse(1), vecArray[2], ktest2);
VecAXPY(ktest2, 1.0, ktest3);
MatMult(mat_lagrange_scaled, ktest2, vecArray[3]);
VecScale(vecArray[3], -1.0);
Vec nullSpaceBasis;
VecCreateNest(mpiCommGlobal, 4, PETSC_NULL, vecArray, &nullSpaceBasis);
Vec vecSol;
VecDuplicate(nullSpaceBasis, &vecSol);
MatMult(fetiMat, nullSpaceBasis, vecSol);
PetscReal norm;
VecNorm(vecSol, NORM_2, &norm);
MSG("Null space norm: %e\n", norm);
Vec vec0;
Vec vec1;
Vec vec2;
Vec vec3;
VecNestGetSubVec(vecSol, 0, &vec0);
VecNestGetSubVec(vecSol, 1, &vec1);
VecNestGetSubVec(vecSol, 2, &vec2);
VecNestGetSubVec(vecSol, 3, &vec3);
PetscReal norm0, norm1, norm2, norm3;
VecNorm(vec0, NORM_2, &norm0);
VecNorm(vec1, NORM_2, &norm1);
VecNorm(vec2, NORM_2, &norm2);
VecNorm(vec3, NORM_2, &norm3);
MSG("Splitted null space norm: %e %e %e %e\n", norm0, norm1, norm2, norm3);
recoverSolution(vec0, vec1, vec);
recoverInterfaceSolution(vec2, vec);
VtkWriter::writeFile(&vec, "nullspace.vtu");
MatDestroy(&fetiMat);
VecDestroy(&nullSpaceBasis);
VecDestroy(&vecSol);
}
} }
...@@ -221,6 +221,9 @@ namespace AMDiS { ...@@ -221,6 +221,9 @@ namespace AMDiS {
/// For debugging only! /// For debugging only!
void createNestedFetiMat(Mat &mat); void createNestedFetiMat(Mat &mat);
/// For debugging only!
void debugNullSpace(SystemVector &vec);
protected: protected:
/// Mapping from primal DOF indices to a global index of primals. /// Mapping from primal DOF indices to a global index of primals.
ParallelDofMapping primalDofMap; ParallelDofMapping primalDofMap;
......
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