Commit 3e164d33 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

New umfpack parameter; Several bugfixes for multiple meshes.

parent 3ee7ae23
......@@ -20,6 +20,7 @@ AMDIS_LIB = -L$(AMDIS_DIR)/lib -lamdis -lcompositeFEM
PNG_LIB = -lpng
UMFPACK_LIB = -L$(AMDIS_DIR)/lib/AMD/Lib -L$(AMDIS_DIR)/lib/UMFPACK/Lib
#UMFPACK_LIB = -L/u/witkowski/test/AMD/Lib -L/u/witkowski/test/UMFPACK/Lib
ifeq ($(strip $(USE_SERVER)), mars)
UMFPACK_LIB += -lmkl -lumfpack -lamd
else
......
......@@ -83,7 +83,7 @@ namespace AMDiS {
{
FUNCNAME("Assembler::calculateElementMatrix()");
if (remember && ((factor != 1.0) || (operat->uhOld)))
if (remember && (factor != 1.0 || operat->uhOld))
rememberElMat = true;
Element *el = smallElInfo->getElement();
......@@ -103,10 +103,11 @@ namespace AMDiS {
return;
}
}
ElementMatrix& mat = rememberElMat ? elementMatrix : userMat;
if (secondOrderAssembler) {
ERROR_EXIT("Da muss i noch ma testen!\n");
secondOrderAssembler->calculateElementMatrix(smallElInfo, mat);
ElementMatrix m(nRow, nRow);
......@@ -134,17 +135,17 @@ namespace AMDiS {
smallElInfo->getSubElemCoordsMat(m, rowFESpace->getBasisFcts()->getDegree());
ElementMatrix tmpMat(nRow, nRow);
if (smallElInfo == colElInfo)
tmpMat = m * mat;
else
if (smallElInfo == colElInfo)
tmpMat = m * mat;
else
tmpMat = mat * trans(m);
mat = tmpMat;
mat = tmpMat;
}
if (rememberElMat)
userMat += factor * elementMatrix;
if (rememberElMat && &userMat != &elementMatrix)
userMat += factor * elementMatrix;
}
......@@ -178,7 +179,7 @@ namespace AMDiS {
if (operat->uhOld && remember) {
matVecAssemble(elInfo, vec);
if (rememberElVec)
userVec += factor * elementVector;
userVec += factor * elementVector;
return;
}
......@@ -189,9 +190,10 @@ namespace AMDiS {
zeroOrderAssembler->calculateElementVector(elInfo, vec);
if (rememberElVec)
userVec += factor * elementVector;
userVec += factor * elementVector;
}
void Assembler::calculateElementVector(const ElInfo *mainElInfo,
const ElInfo *auxElInfo,
const ElInfo *smallElInfo,
......@@ -207,8 +209,8 @@ namespace AMDiS {
Element *el = mainElInfo->getElement();
if ((el != lastMatEl && el != lastVecEl) || !operat->isOptimized())
initElement(auxElInfo);
initElement(smallElInfo, largeElInfo);
if (el != lastVecEl || !operat->isOptimized()) {
if (rememberElVec)
set_to_zero(elementVector);
......@@ -223,32 +225,30 @@ namespace AMDiS {
ElementVector& vec = rememberElVec ? elementVector : userVec;
if (operat->uhOld && remember) {
if (smallElInfo->getLevel() == largeElInfo->getLevel()) {
if (smallElInfo->getLevel() == largeElInfo->getLevel())
matVecAssemble(auxElInfo, vec);
} else {
matVecAssemble(mainElInfo, auxElInfo, smallElInfo, largeElInfo, vec);
}
else
matVecAssemble(mainElInfo, auxElInfo, smallElInfo, largeElInfo, vec);
if (rememberElVec)
userVec += factor * elementVector;
userVec += factor * elementVector;
return;
}
ERROR_EXIT("Not yet implemented!\n");
// if (firstOrderAssemblerGrdPsi) {
// firstOrderAssemblerGrdPsi->calculateElementVector(elInfo, vec);
// }
// if (zeroOrderAssembler) {
// zeroOrderAssembler->calculateElementVector(elInfo, vec);
// }
// if (rememberElVec) {
// axpy(factor, *elementVector, *userVec);
// }
#if 0
if (firstOrderAssemblerGrdPsi)
firstOrderAssemblerGrdPsi->calculateElementVector(elInfo, vec);
if (zeroOrderAssembler)
zeroOrderAssembler->calculateElementVector(elInfo, vec);
if (rememberElVec)
axpy(factor, *elementVector, *userVec);
#endif
}
void Assembler::matVecAssemble(const ElInfo *elInfo, ElementVector& vec)
{
FUNCNAME("Assembler::matVecAssemble()");
......@@ -258,20 +258,23 @@ namespace AMDiS {
operat->uhOld->getLocalVector(el, uhOldLoc);
if (el != lastMatEl)
if (el != lastMatEl) {
set_to_zero(elementMatrix);
calculateElementMatrix(elInfo, elementMatrix);
}
for (int i = 0; i < nRow; i++) {
double val = 0.0;
for (int j = 0; j < nRow; j++) {
for (int j = 0; j < nRow; j++)
val += elementMatrix[i][j] * uhOldLoc[j];
}
vec[i] += val;
}
delete [] uhOldLoc;
}
void Assembler::matVecAssemble(const ElInfo *mainElInfo, const ElInfo *auxElInfo,
const ElInfo *smallElInfo, const ElInfo *largeElInfo,
ElementVector& vec)
......@@ -289,35 +292,22 @@ namespace AMDiS {
const BasisFunction *basFcts = rowFESpace->getBasisFcts();
int nBasFcts = basFcts->getNumber();
double *uhOldLoc = new double[nBasFcts];
double *uhOldLoc2 = new double[nBasFcts];
operat->uhOld->getLocalVector(auxEl, uhOldLoc);
std::vector<double> uhOldLoc(nBasFcts);
mtl::dense2D<double> m(nRow, nRow);
smallElInfo->getSubElemCoordsMat(m, rowFESpace->getBasisFcts()->getDegree());
for (int i = 0; i < nBasFcts; i++) {
uhOldLoc2[i] = 0.0;
for (int j = 0; j < nBasFcts; j++)
uhOldLoc2[i] += m[j][i] * uhOldLoc[i];
}
operat->uhOld->getLocalVector(auxEl, &(uhOldLoc[0]));
if (mainEl != lastMatEl) {
set_to_zero(elementMatrix);
calculateElementMatrix(mainElInfo, auxElInfo, smallElInfo, largeElInfo,
elementMatrix);
elementMatrix);
}
for (int i = 0; i < nBasFcts; i++) {
double val = 0.0;
for (int j = 0; j < nBasFcts; j++)
val += elementMatrix[i][j] * uhOldLoc2[j];
val += elementMatrix[i][j] * uhOldLoc[j];
vec[i] += val;
}
delete [] uhOldLoc;
delete [] uhOldLoc2;
}
}
......
......@@ -22,8 +22,10 @@ namespace AMDiS {
status = SingleComponentInfo::EQ_SPACES_NO_AUX;
} else {
status = SingleComponentInfo::EQ_SPACES_WITH_AUX;
for (int i = 0; i < static_cast<int>(auxFeSpaces.size()); i++) {
if (auxFeSpaces[i]->getMesh() != rowFeSpace->getMesh()) {
for (std::set<const FiniteElemSpace*>::iterator it = auxFeSpaces.begin();
it != auxFeSpaces.end(); ++it) {
if ((*it)->getMesh() != rowFeSpace->getMesh()) {
status = SingleComponentInfo::EQ_SPACES_WITH_DIF_AUX;
break;
}
......@@ -34,9 +36,10 @@ namespace AMDiS {
status = SingleComponentInfo::DIF_SPACES_NO_AUX;
} else {
status = SingleComponentInfo::DIF_SPACES_WITH_AUX;
for (int i = 0; i < static_cast<int>(auxFeSpaces.size()); i++) {
if (auxFeSpaces[i]->getMesh() != rowFeSpace->getMesh() &&
auxFeSpaces[i]->getMesh() != colFeSpace->getMesh()) {
for (std::set<const FiniteElemSpace*>::iterator it = auxFeSpaces.begin();
it != auxFeSpaces.end(); ++it) {
if ((*it)->getMesh() != rowFeSpace->getMesh() &&
(*it)->getMesh() != colFeSpace->getMesh()) {
status = SingleComponentInfo::DIF_SPACES_WITH_DIF_AUX;
break;
}
......@@ -72,12 +75,12 @@ namespace AMDiS {
for (int i = 0; i < nComponents; i++) {
if (matrixComponents[row][i].getColFeSpace() != rowFeSpace)
return matrixComponents[row][i].getColFeSpace();
if (matrixComponents[row][i].getAuxFeSpace(0) != rowFeSpace)
return matrixComponents[row][i].getAuxFeSpace(0);
if (matrixComponents[row][i].getAuxFeSpace() != rowFeSpace)
return matrixComponents[row][i].getAuxFeSpace();
}
if (vectorComponents[row].getAuxFeSpace(0) != rowFeSpace)
return vectorComponents[row].getAuxFeSpace(0);
if (vectorComponents[row].getAuxFeSpace() != rowFeSpace)
return vectorComponents[row].getAuxFeSpace();
return NULL;
}
......
......@@ -22,7 +22,7 @@
#ifndef AMDIS_COMPONENTTRAVERSEINFO_H
#define AMDIS_COMPONENTTRAVERSEINFO_H
#include <vector>
#include <set>
#include "Global.h"
#include "FiniteElemSpace.h"
......@@ -34,7 +34,6 @@ namespace AMDiS {
SingleComponentInfo()
: rowFeSpace(NULL),
colFeSpace(NULL),
auxFeSpaces(0),
status(0)
{}
......@@ -44,14 +43,14 @@ namespace AMDiS {
colFeSpace = col;
}
void setAuxFeSpaces(std::vector<const FiniteElemSpace*> feSpaces)
void setAuxFeSpaces(std::set<const FiniteElemSpace*> feSpaces)
{
auxFeSpaces = feSpaces;
}
void addAuxFeSpace(const FiniteElemSpace *fe)
{
auxFeSpaces.push_back(fe);
auxFeSpaces.insert(fe);
}
bool hasFeSpace()
......@@ -76,14 +75,16 @@ namespace AMDiS {
return colFeSpace;
}
const FiniteElemSpace *getAuxFeSpace(int i)
const FiniteElemSpace *getAuxFeSpace()
{
return ((i < static_cast<int>(auxFeSpaces.size())) ? auxFeSpaces[i] : NULL);
}
FUNCNAME("SingleComponentInfo::getAuxFeSpace()");
void setAuxFeSpace(const FiniteElemSpace* fe, int pos)
{
auxFeSpaces[pos] = fe;
TEST_EXIT_DBG(auxFeSpaces.size() <= 1)("More than one aux FE space!\n");
if (auxFeSpaces.size() == 1)
return (*(auxFeSpaces.begin()));
return NULL;
}
int getStatus()
......@@ -96,7 +97,7 @@ namespace AMDiS {
FiniteElemSpace *colFeSpace;
std::vector<const FiniteElemSpace*> auxFeSpaces;
std::set<const FiniteElemSpace*> auxFeSpaces;
/// Status of the component, see the possible status flags below.
int status;
......@@ -177,12 +178,12 @@ namespace AMDiS {
const FiniteElemSpace* getAuxFeSpace(int row, int col)
{
return matrixComponents[row][col].getAuxFeSpace(0);
return matrixComponents[row][col].getAuxFeSpace();
}
const FiniteElemSpace* getAuxFeSpace(int row)
{
return vectorComponents[row].getAuxFeSpace(0);
return vectorComponents[row].getAuxFeSpace();
}
/** \brief
......
......@@ -808,9 +808,11 @@ namespace AMDiS {
return;
set_to_zero(this->elementVector);
bool addVector = false;
if (op) {
op->getElementVector(elInfo, this->elementVector);
addVector = true;
} else {
std::vector<Operator*>::iterator it;
std::vector<double*>::iterator factorIt;
......@@ -818,12 +820,15 @@ namespace AMDiS {
for (it = this->operators.begin(), factorIt = this->operatorFactor.begin();
it != this->operators.end();
++it, ++factorIt)
if ((*it)->getNeedDualTraverse() == false)
if ((*it)->getNeedDualTraverse() == false) {
(*it)->getElementVector(elInfo, this->elementVector,
*factorIt ? **factorIt : 1.0);
addVector = true;
}
}
addElementVector(factor, this->elementVector, bound, elInfo);
if (addVector)
addElementVector(factor, this->elementVector, bound, elInfo);
}
template<>
......@@ -839,27 +844,25 @@ namespace AMDiS {
return;
set_to_zero(this->elementVector);
if (op) {
ERROR_EXIT("TODO");
// op->getElementVector(mainElInfo, this->elementVector);
} else {
std::vector<Operator*>::iterator it;
std::vector<double*>::iterator factorIt;
for (it = this->operators.begin(), factorIt = this->operatorFactor.begin();
it != this->operators.end();
++it, ++factorIt) {
if ((*it)->getNeedDualTraverse()) {
(*it)->getElementVector(mainElInfo, auxElInfo,
smallElInfo, largeElInfo,
this->elementVector,
*factorIt ? **factorIt : 1.0);
}
bool addVector = false;
TEST_EXIT(!op)("Not yet implemented!\n");
std::vector<Operator*>::iterator it;
std::vector<double*>::iterator factorIt;
for (it = this->operators.begin(), factorIt = this->operatorFactor.begin();
it != this->operators.end();
++it, ++factorIt)
if ((*it)->getNeedDualTraverse()) {
(*it)->getElementVector(mainElInfo, auxElInfo,
smallElInfo, largeElInfo,
this->elementVector,
*factorIt ? **factorIt : 1.0);
addVector = true;
}
}
addElementVector(factor, this->elementVector, bound, mainElInfo);
if (addVector)
addElementVector(factor, this->elementVector, bound, mainElInfo);
}
......
......@@ -19,28 +19,16 @@ namespace AMDiS {
{0.0, 0.0, 1.0}};
mtl::dense2D<double> ElInfo2d::mat_d1(mat_d1_val);
/*
double ElInfo2d::mat_d1_left_val[3][3] = {{0.0, 1.0, 0.5},
{0.0, 0.0, 0.5},
{1.0, 0.0, 0.0}};
*/
double ElInfo2d::mat_d1_left_val[3][3] = {{0.0, 0.0, 1.0},
{1.0, 0.0, 0.0},
{0.5, 0.5, 0.0}};
{1.0, 0.0, 0.0}};
mtl::dense2D<double> ElInfo2d::mat_d1_left(mat_d1_left_val);
/*
double ElInfo2d::mat_d1_right_val[3][3] = {{0.0, 0.0, 0.5},
{1.0, 0.0, 0.5},
{0.0, 1.0, 0.0}};
*/
double ElInfo2d::mat_d1_right_val[3][3] = {{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0},
{0.5, 0.5, 0.0}};
{0.0, 1.0, 0.0}};
mtl::dense2D<double> ElInfo2d::mat_d1_right(mat_d1_right_val);
......
......@@ -24,6 +24,8 @@ namespace AMDiS {
FUNCNAME("Estimator::estimate()");
bool dualTraverse = false;
/*
for (unsigned int i = 0; i < matrix.size(); i++) {
TEST_EXIT(traverseInfo.getStatus(row, i) != SingleComponentInfo::DIF_SPACES_WITH_DIF_AUX)
("Not yet implemented!\n");
......@@ -51,7 +53,11 @@ namespace AMDiS {
auxFeSpace->getBasisFcts()->getDegree())
("Mh, do you really want to do this? Think about it ...\n");
}
*/
mesh = uh[row == -1 ? 0 : row]->getFESpace()->getMesh();
auxMesh = NULL;
init(ts);
if (!dualTraverse)
......
......@@ -248,9 +248,11 @@ namespace AMDiS {
nCol = colFESpace->getBasisFcts()->getNumber();
}
void Operator::setUhOld(const DOFVectorBase<double> *uhOld_)
void Operator::setUhOld(const DOFVectorBase<double> *vec)
{
uhOld = uhOld_;
uhOld = vec;
auxFeSpaces.insert(vec->getFESpace());
}
......@@ -344,7 +346,7 @@ namespace AMDiS {
{
TEST_EXIT(dv)("No vector!\n");
auxFESpaces.push_back(dv->getFESpace());
auxFeSpaces.insert(dv->getFESpace());
}
MultVecAtQP_ZOT::MultVecAtQP_ZOT(DOFVectorBase<double> *dv1,
......@@ -357,8 +359,8 @@ namespace AMDiS {
TEST_EXIT(dv1)("No first vector!\n");
TEST_EXIT(dv2)("No second vector!\n");
auxFESpaces.push_back(dv1->getFESpace());
auxFESpaces.push_back(dv2->getFESpace());
auxFeSpaces.insert(dv1->getFESpace());
auxFeSpaces.insert(dv2->getFESpace());
}
Vec2AtQP_ZOT::Vec2AtQP_ZOT(DOFVectorBase<double> *dv1,
......@@ -369,8 +371,8 @@ namespace AMDiS {
TEST_EXIT(dv1)("No first vector!\n");
TEST_EXIT(dv2)("No second vector!\n");
auxFESpaces.push_back(dv1->getFESpace());
auxFESpaces.push_back(dv2->getFESpace());
auxFeSpaces.insert(dv1->getFESpace());
auxFeSpaces.insert(dv2->getFESpace());
}
Vec3AtQP_ZOT::Vec3AtQP_ZOT(DOFVectorBase<double> *dv1,
......@@ -383,9 +385,9 @@ namespace AMDiS {
TEST_EXIT(dv2)("No second vector!\n");
TEST_EXIT(dv3)("No thierd vector!\n");
auxFESpaces.push_back(dv1->getFESpace());
auxFESpaces.push_back(dv2->getFESpace());
auxFESpaces.push_back(dv3->getFESpace());
auxFeSpaces.insert(dv1->getFESpace());
auxFeSpaces.insert(dv2->getFESpace());
auxFeSpaces.insert(dv3->getFESpace());
}
FctGradientCoords_ZOT::FctGradientCoords_ZOT(DOFVectorBase<double> *dv,
......@@ -394,7 +396,7 @@ namespace AMDiS {
{
TEST_EXIT(dv)("No vector!\n");
auxFESpaces.push_back(dv->getFESpace());
auxFeSpaces.insert(dv->getFESpace());
}
VecGradCoordsAtQP_ZOT::VecGradCoordsAtQP_ZOT(DOFVectorBase<double> *dv,
......@@ -403,7 +405,7 @@ namespace AMDiS {
{
TEST_EXIT(dv)("No vector!\n");
auxFESpaces.push_back(dv->getFESpace());
auxFeSpaces.insert(dv->getFESpace());
}
VecAndCoordsAtQP_ZOT::VecAndCoordsAtQP_ZOT(DOFVectorBase<double> *dv,
......@@ -412,7 +414,7 @@ namespace AMDiS {
{
TEST_EXIT(dv)("No vector!\n");
auxFESpaces.push_back(dv->getFESpace());
auxFeSpaces.insert(dv->getFESpace());
}
Vec2AndGradAtQP_ZOT::Vec2AndGradAtQP_ZOT(DOFVectorBase<double> *dv1, DOFVectorBase<double> *dv2,
......@@ -422,8 +424,8 @@ namespace AMDiS {
TEST_EXIT(dv1)("No first vector!\n");
TEST_EXIT(dv2)("No second vector!\n");
auxFESpaces.push_back(dv1->getFESpace());
auxFESpaces.push_back(dv2->getFESpace());
auxFeSpaces.insert(dv1->getFESpace());
auxFeSpaces.insert(dv2->getFESpace());
}
FctGradient_ZOT::FctGradient_ZOT(DOFVectorBase<double> *dv,
......@@ -432,7 +434,7 @@ namespace AMDiS {
{
TEST_EXIT(dv)("No vector!\n");
auxFESpaces.push_back(dv->getFESpace());
auxFeSpaces.insert(dv->getFESpace());
}
VecAndGradAtQP_ZOT::VecAndGradAtQP_ZOT(DOFVectorBase<double> *dv,
......@@ -441,7 +443,7 @@ namespace AMDiS {
{
TEST_EXIT(dv)("No vector!\n");
auxFESpaces.push_back(dv->getFESpace());
auxFeSpaces.insert(dv->getFESpace());
}
VecAndGradVecAtQP_ZOT::VecAndGradVecAtQP_ZOT(DOFVectorBase<double> *dv,
......@@ -452,8 +454,8 @@ namespace AMDiS {
TEST_EXIT(dv)("No vector!\n");
TEST_EXIT(dGrd)("No gradient vector!\n");
auxFESpaces.push_back(dv->getFESpace());
auxFESpaces.push_back(dGrd->getFESpace());
auxFeSpaces.insert(dv->getFESpace());
auxFeSpaces.insert(dGrd->getFESpace());
}
VecAndGradVec2AtQP_ZOT::VecAndGradVec2AtQP_ZOT(DOFVectorBase<double> *dv,
......@@ -466,9 +468,9 @@ namespace AMDiS {
TEST_EXIT(dGrd1)("No first gradient vector!\n");
TEST_EXIT(dGrd2)("No second gradient vector!\n");
auxFESpaces.push_back(dv->getFESpace());
auxFESpaces.push_back(dGrd1->getFESpace());
auxFESpaces.push_back(dGrd2->getFESpace());
auxFeSpaces.insert(dv->getFESpace());
auxFeSpaces.insert(dGrd1->getFESpace());
auxFeSpaces.insert(dGrd2->getFESpace());
}
VecOfDOFVecsAtQP_ZOT::VecOfDOFVecsAtQP_ZOT(const std::vector<DOFVectorBase<double>*>& dv,
......@@ -480,7 +482,7 @@ namespace AMDiS {
for (int i = 0; i < static_cast<int>(dv.size()); i++) {
TEST_EXIT(dv[i])("One vector is NULL!\n");
auxFESpaces.push_back(dv[i]->getFESpace());
auxFeSpaces.insert(dv[i]->getFESpace());
}
}
......@@ -493,7 +495,7 @@ namespace AMDiS {
for (int i = 0; i < static_cast<int>(dv.size()); i++) {
TEST_EXIT(dv[i])("One vector is NULL!\n");
auxFESpaces.push_back(dv[i]->getFESpace());
auxFeSpaces.insert(dv[i]->getFESpace());
}
}
......@@ -509,11 +511,11 @@ namespace AMDiS {
vecs[1] = vec1;
vecs[2] = vec2;
auxFESpaces.push_back(vec0->getFESpace());
auxFeSpaces.insert(vec0->getFESpace());
if (vec1)
auxFESpaces.push_back(vec1->getFESpace());
auxFeSpaces.insert(vec1->getFESpace());
if (vec2)
auxFESpaces.push_back(vec2->getFESpace());
auxFeSpaces.insert(vec2->getFESpace());