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

Work on pdd.

parent 22315a82
......@@ -54,7 +54,7 @@ namespace AMDiS {
virtual int adapt() = 0;
/// Returns \ref name
inline const std::string& getName() const
inline std::string getName() const
{
return name;
}
......
......@@ -246,7 +246,7 @@ namespace AMDiS {
return errorCode;
}
void AdaptInstationary::initialize(const std::string& aName)
void AdaptInstationary::initialize(std::string aName)
{
FUNCNAME("AdaptInstationary::initialize()");
......@@ -262,9 +262,8 @@ namespace AMDiS {
GET_PARAMETER(0, aName + "->info", "%d", &info_);
GET_PARAMETER(0, aName + "->break when stable", "%d", &breakWhenStable);
GET_PARAMETER(0, aName + "->queue->runtime", "%d", &queueRuntime_);
GET_PARAMETER(0, aName + "->queue->serialization filename", &queueSerializationFilename_);
return;
GET_PARAMETER(0, aName + "->queue->serialization filename",
&queueSerializationFilename_);
}
void AdaptInstationary::serialize(std::ostream &out)
......
......@@ -90,7 +90,7 @@ namespace AMDiS {
virtual void oneTimestep();
/// Initialisation of this AdaptInstationary object
void initialize(const std::string& aName);
void initialize(std::string aName);
/// Implements the explit time strategy. Used by \ref oneTimestep().
virtual void explicitTimeStrategy();
......
......@@ -7,7 +7,7 @@
namespace AMDiS {
AdaptStationary::AdaptStationary(const std::string &name,
AdaptStationary::AdaptStationary(std::string name,
ProblemIterationInterface *prob,
AdaptInfo *info)
: AdaptBase(name, prob, info)
......
......@@ -46,7 +46,7 @@ namespace AMDiS {
{
public:
/// Creates a AdaptStationary object with given name.
AdaptStationary(const std::string &name,
AdaptStationary(std::string name,
ProblemIterationInterface *prob,
AdaptInfo *info);
......
......@@ -15,7 +15,7 @@ namespace AMDiS {
/* are those corresponding to these barycentric coordinates. */
/****************************************************************************/
BasisFunction::BasisFunction(const std::string& name_, int dim_, int degree_)
BasisFunction::BasisFunction(std::string name_, int dim_, int degree_)
: name(name_),
degree(degree_),
dim(dim_)
......
......@@ -83,7 +83,7 @@ namespace AMDiS {
{
protected:
/// Creates a BasisFunction object of given dim and degree
BasisFunction(const std::string& name, int dim, int degree);
BasisFunction(std::string name, int dim, int degree);
/// destructor
virtual ~BasisFunction();
......@@ -154,7 +154,7 @@ namespace AMDiS {
}
/// Returns \ref name of BasisFunction
inline const std::string& getName() const
inline std::string getName() const
{
return name;
}
......
......@@ -62,142 +62,112 @@ namespace AMDiS {
basisFcts->getBound(elInfo, localBound);
// get dof indices
basisFcts->getLocalIndicesVec(elInfo->getElement(),
feSpace->getAdmin(), &dofVec);
basisFcts->getLocalIndicesVec(elInfo->getElement(), feSpace->getAdmin(), &dofVec);
// apply non dirichlet boundary conditions
for (it = localBCs.begin(); it != localBCs.end(); ++it) {
if ((*it).second) {
if (!(*it).second->isDirichlet()) {
(*it).second->fillBoundaryCondition(vec, elInfo, &dofVec[0], localBound, nBasFcts);
}
}
}
for (it = localBCs.begin(); it != localBCs.end(); ++it)
if ((*it).second && !(*it).second->isDirichlet())
(*it).second->fillBoundaryCondition(vec, elInfo, &dofVec[0],
localBound, nBasFcts);
// apply dirichlet boundary conditions
for (it = localBCs.begin(); it != localBCs.end(); ++it) {
if ((*it).second) {
if ((*it).second->isDirichlet()) {
(*it).second->fillBoundaryCondition(vec, elInfo, &dofVec[0], localBound, nBasFcts);
}
}
}
for (it = localBCs.begin(); it != localBCs.end(); ++it)
if ((*it).second && (*it).second->isDirichlet())
(*it).second->fillBoundaryCondition(vec, elInfo, &dofVec[0],
localBound, nBasFcts);
}
}
void BoundaryManager::fillBoundaryConditions(ElInfo *elInfo,
DOFMatrix *mat)
{
if (localBCs.size() > 0) {
const FiniteElemSpace *feSpace = mat->getRowFESpace();
Vector<DegreeOfFreedom> &dofVec = dofIndices[omp_get_thread_num()];
const BasisFunction *basisFcts = feSpace->getBasisFcts();
int nBasFcts = basisFcts->getNumber();
std::map<BoundaryType, BoundaryCondition*>::iterator it;
// get boundaries of all DOFs
BoundaryType *localBound = localBounds[omp_get_thread_num()];
basisFcts->getBound(elInfo, localBound);
// get dof indices
basisFcts->getLocalIndicesVec(elInfo->getElement(),
feSpace->getAdmin(), &dofVec);
// apply non dirichlet boundary conditions
for (it = localBCs.begin(); it != localBCs.end(); ++it) {
if ((*it).second) {
if (!(*it).second->isDirichlet()) {
(*it).second->fillBoundaryCondition(mat, elInfo, &dofVec[0], localBound, nBasFcts);
}
}
}
// apply dirichlet boundary conditions
for (it = localBCs.begin(); it != localBCs.end(); ++it) {
if ((*it).second) {
if ((*it).second->isDirichlet()) {
(*it).second->fillBoundaryCondition(mat, elInfo, &dofVec[0], localBound, nBasFcts);
}
}
}
}
if (localBCs.size() <= 0)
return;
const FiniteElemSpace *feSpace = mat->getRowFESpace();
Vector<DegreeOfFreedom> &dofVec = dofIndices[omp_get_thread_num()];
const BasisFunction *basisFcts = feSpace->getBasisFcts();
int nBasFcts = basisFcts->getNumber();
std::map<BoundaryType, BoundaryCondition*>::iterator it;
// get boundaries of all DOFs
BoundaryType *localBound = localBounds[omp_get_thread_num()];
basisFcts->getBound(elInfo, localBound);
// get dof indices
basisFcts->getLocalIndicesVec(elInfo->getElement(),
feSpace->getAdmin(), &dofVec);
// apply non dirichlet boundary conditions
for (it = localBCs.begin(); it != localBCs.end(); ++it)
if ((*it).second)
if (!(*it).second->isDirichlet())
(*it).second->fillBoundaryCondition(mat, elInfo, &dofVec[0],
localBound, nBasFcts);
// apply dirichlet boundary conditions
for (it = localBCs.begin(); it != localBCs.end(); ++it)
if ((*it).second)
if ((*it).second->isDirichlet())
(*it).second->fillBoundaryCondition(mat, elInfo, &dofVec[0],
localBound, nBasFcts);
}
void BoundaryManager::initMatrix(DOFMatrix *matrix)
{
std::map<BoundaryType, BoundaryCondition*>::iterator it;
for (it = localBCs.begin(); it != localBCs.end(); ++it) {
if ((*it).second) {
if (!(*it).second->isDirichlet()) {
for (it = localBCs.begin(); it != localBCs.end(); ++it)
if ((*it).second)
if (!(*it).second->isDirichlet())
(*it).second->initMatrix(matrix);
}
}
}
for (it = localBCs.begin(); it != localBCs.end(); ++it) {
if ((*it).second) {
if ((*it).second->isDirichlet()) {
for (it = localBCs.begin(); it != localBCs.end(); ++it)
if ((*it).second)
if ((*it).second->isDirichlet())
(*it).second->initMatrix(matrix);
}
}
}
}
void BoundaryManager::exitMatrix(DOFMatrix *matrix)
{
std::map<BoundaryType, BoundaryCondition*>::iterator it;
for (it = localBCs.begin(); it != localBCs.end(); ++it) {
if ((*it).second) {
if (!(*it).second->isDirichlet()) {
for (it = localBCs.begin(); it != localBCs.end(); ++it)
if ((*it).second)
if (!(*it).second->isDirichlet())
(*it).second->exitMatrix(matrix);
}
}
}
for(it = localBCs.begin(); it != localBCs.end(); ++it) {
if((*it).second) {
if((*it).second->isDirichlet()) {
for (it = localBCs.begin(); it != localBCs.end(); ++it)
if ((*it).second)
if ((*it).second->isDirichlet())
(*it).second->exitMatrix(matrix);
}
}
}
}
void BoundaryManager::initVector(DOFVectorBase<double> *vector)
{
std::map<BoundaryType, BoundaryCondition*>::iterator it;
for(it = localBCs.begin(); it != localBCs.end(); ++it) {
if((*it).second) {
if(!(*it).second->isDirichlet()) {
for (it = localBCs.begin(); it != localBCs.end(); ++it)
if ((*it).second)
if (!(*it).second->isDirichlet())
(*it).second->initVector(vector);
}
}
}
for(it = localBCs.begin(); it != localBCs.end(); ++it) {
if((*it).second) {
if((*it).second->isDirichlet()) {
for (it = localBCs.begin(); it != localBCs.end(); ++it)
if ((*it).second)
if ((*it).second->isDirichlet())
(*it).second->initVector(vector);
}
}
}
}
void BoundaryManager::exitVector(DOFVectorBase<double> *vector)
{
std::map<BoundaryType, BoundaryCondition*>::iterator it;
for (it = localBCs.begin(); it != localBCs.end(); ++it) {
if ((*it).second) {
if (!(*it).second->isDirichlet()) {
for (it = localBCs.begin(); it != localBCs.end(); ++it)
if ((*it).second)
if (!(*it).second->isDirichlet())
(*it).second->exitVector(vector);
}
}
}
for (it = localBCs.begin(); it != localBCs.end(); ++it) {
if ((*it).second) {
if ((*it).second->isDirichlet()) {
for (it = localBCs.begin(); it != localBCs.end(); ++it)
if ((*it).second)
if ((*it).second->isDirichlet())
(*it).second->exitVector(vector);
}
}
}
}
}
......@@ -41,7 +41,7 @@ namespace AMDiS {
{
public:
/// Constructor.
ConditionalMarker(const std::string name,
ConditionalMarker(std::string name,
int row,
Marker *decoratedMarker,
int globalCoarseGridLevel,
......
......@@ -145,7 +145,7 @@ namespace AMDiS {
}
/// Returns \ref name
inline const std::string& getName() const
inline std::string getName() const
{
return name;
}
......@@ -231,7 +231,7 @@ namespace AMDiS {
void setNumberOfPreDOFs(int i, int v);
/// Sets \ref name = n
inline void setName(const std::string& n)
inline void setName(std::string n)
{
name = n;
}
......
......@@ -310,7 +310,7 @@ namespace AMDiS {
}
/// Returns \ref name
inline const std::string& getName() const
inline std::string getName() const
{
return name;
}
......
......@@ -39,6 +39,7 @@
#include "Serializable.h"
#include "DOFMatrix.h"
#include "BasisFunction.h"
#include "FiniteElemSpace.h"
namespace AMDiS {
......@@ -194,7 +195,7 @@ namespace AMDiS {
}
/// Returns \ref name
inline const std::string& getName() const
inline std::string getName() const
{
return name;
}
......@@ -209,6 +210,18 @@ namespace AMDiS {
boundaryManager = bm;
}
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
void setRankDofs(std::map<DegreeOfFreedom, bool>& dofmap)
{
rankDofs = dofmap;
}
inline bool isRankDof(DegreeOfFreedom dof)
{
return rankDofs[dof];
}
#endif
protected:
///
const FiniteElemSpace *feSpace;
......@@ -251,6 +264,10 @@ namespace AMDiS {
/// Dimension of the mesh this DOFVectorBase belongs to
int dim;
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
std::map<DegreeOfFreedom, bool> rankDofs;
#endif
};
/// Specifies which operation should be done after coarsening
......@@ -777,6 +794,16 @@ namespace AMDiS {
return vec->getUsedSize();
}
template<typename T>
inline void checkFeSpace(const FiniteElemSpace* feSpace, const std::vector<T>& vec)
{
TEST_EXIT_DBG(feSpace)("feSpace is NULL\n");
TEST_EXIT_DBG(feSpace->getAdmin())("admin is NULL\n");
TEST_EXIT_DBG(static_cast<int>(vec.size()) >= feSpace->getAdmin()->getUsedSize())
("size = %d too small: admin->sizeUsed = %d\n", vec.size(),
feSpace->getAdmin()->getUsedSize());
}
WorldVector<DOFVector<double>*> *transform(DOFVector<WorldVector<double> > *vec,
WorldVector<DOFVector<double>*> *result);
}
......
......@@ -117,9 +117,9 @@ namespace AMDiS {
{
name = n;
feSpace = f;
if(feSpace && feSpace->getAdmin()) {
if (feSpace && feSpace->getAdmin())
(feSpace->getAdmin())->addDOFIndexed(this);
}
this->boundaryManager = new BoundaryManager(f);
}
......@@ -164,8 +164,12 @@ namespace AMDiS {
if (!(condition && condition->isDirichlet())) {
DegreeOfFreedom irow = indices[i];
(*this)[irow] = (add ? (*this)[irow] : 0.0);
(*this)[irow] += factor * elVec[i];
if (add) {
(*this)[irow] += factor * elVec[i];
} else {
(*this)[irow] = factor * elVec[i];
}
}
}
}
......@@ -175,14 +179,11 @@ namespace AMDiS {
{
FUNCNAME("DOFVector<T>::nrm2()");
TEST_EXIT_DBG(feSpace)("feSpace is NULL\n");
TEST_EXIT_DBG(feSpace->getAdmin())("admin is NULL\n");
TEST_EXIT_DBG(static_cast<int>(vec.size()) >= feSpace->getAdmin()->getUsedSize())
("size = %d too small: admin->sizeUsed = %d\n", vec.size(),
feSpace->getAdmin()->getUsedSize());
checkFeSpace(feSpace, vec);
double nrm = 0.0;
Iterator vecIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(this)), USED_DOFS);
Iterator vecIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(this)),
USED_DOFS);
for (vecIterator.reset(); !vecIterator.end(); ++vecIterator)
nrm += (*vecIterator) * (*vecIterator);
......@@ -194,14 +195,11 @@ namespace AMDiS {
{
FUNCNAME("DOFVector<T>::nrm2()");
TEST_EXIT_DBG(feSpace)("feSpace is NULL\n");
TEST_EXIT_DBG(feSpace->getAdmin())("admin is NULL\n");
TEST_EXIT_DBG(static_cast<int>(vec.size()) >= feSpace->getAdmin()->getUsedSize())
("size = %d too small: admin->sizeUsed = %d\n", vec.size(),
feSpace->getAdmin()->getUsedSize());
checkFeSpace(feSpace, vec);
double nrm = 0.0;
Iterator vecIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(this)), USED_DOFS);
Iterator vecIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(this)),
USED_DOFS);
for (vecIterator.reset(); !vecIterator.end(); ++vecIterator)
nrm += (*vecIterator) * (*vecIterator);
......@@ -213,14 +211,11 @@ namespace AMDiS {
{
FUNCNAME("DOFVector<T>::asum()");
TEST_EXIT_DBG(feSpace)("feSpace is NULL\n");
TEST_EXIT_DBG(feSpace->getAdmin())("admin is NULL\n");
TEST_EXIT_DBG(static_cast<int>(vec.size()) >= feSpace->getAdmin()->getUsedSize())
("size = %d too small: admin->sizeUsed = %d\n", vec.size(),
feSpace->getAdmin()->getUsedSize());
checkFeSpace(feSpace, vec);
double nrm = 0.0;
Iterator vecIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(this)), USED_DOFS);
Iterator vecIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(this)),
USED_DOFS);
for (vecIterator.reset(); !vecIterator.end(); ++vecIterator)
nrm += abs(*vecIterator);
......@@ -232,14 +227,11 @@ namespace AMDiS {
{
FUNCNAME("DOFVector<T>::sum()");
TEST_EXIT_DBG(feSpace)("feSpace is NULL\n");
TEST_EXIT_DBG(feSpace->getAdmin())("admin is NULL\n");
TEST_EXIT_DBG(static_cast<int>(vec.size()) >= feSpace->getAdmin()->getUsedSize())
("size = %d too small: admin->sizeUsed = %d\n", vec.size(),
feSpace->getAdmin()->getUsedSize());
checkFeSpace(feSpace, vec);
double nrm = 0.0;
Iterator vecIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(this)), USED_DOFS);
Iterator vecIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(this)),
USED_DOFS);
for (vecIterator.reset(); !vecIterator.end(); ++vecIterator)
nrm += *vecIterator;
......@@ -251,16 +243,11 @@ namespace AMDiS {
{
FUNCNAME("DOFVector<T>::set()");
TEST_EXIT_DBG(feSpace)("feSpace is NULL\n");
TEST_EXIT_DBG(feSpace->getAdmin())("admin is NULL\n");
TEST_EXIT_DBG(static_cast<int>(vec.size()) >= feSpace->getAdmin()->getUsedSize())
("size = %d too small: admin->sizeUsed = %d\n", vec.size(),
feSpace->getAdmin()->getUsedSize());
checkFeSpace(feSpace, vec);
Iterator vecIterator(dynamic_cast<DOFIndexed<T>*>(this), USED_DOFS);
for (vecIterator.reset(); !vecIterator.end(); ++vecIterator) {
for (vecIterator.reset(); !vecIterator.end(); ++vecIterator)
*vecIterator = alpha ;
}
}
......@@ -268,27 +255,19 @@ namespace AMDiS {
void DOFVector<T>::copy(const DOFVector<T>& x)
{
FUNCNAME("DOFVector<T>::copy()");
TEST_EXIT_DBG(feSpace && x.feSpace)
("feSpace is NULL: %8X, %8X\n", feSpace, x.feSpace);
TEST_EXIT_DBG(feSpace->getAdmin() && (feSpace->getAdmin() == x.feSpace->getAdmin()))
("no admin or different admins: %8X, %8X\n",
feSpace->getAdmin(), x.feSpace->getAdmin());
TEST_EXIT_DBG(static_cast<int>(vec.size()) >= feSpace->getAdmin()->getUsedSize())
("size = %d too small: admin->sizeUsed = %d\n", vec.size(),
feSpace->getAdmin()->getUsedSize());
checkFeSpace(feSpace, vec);
TEST_EXIT_DBG(static_cast<int>(x.vec.size()) >= feSpace->getAdmin()->getUsedSize())
("x.size = %d too small: admin->sizeUsed = %d\n", x.vec.size(),
feSpace->getAdmin()->getUsedSize());
Iterator vecIterator(dynamic_cast<DOFIndexed<T>*>(this), USED_DOFS);
Iterator xIterator(dynamic_cast<DOFVector<T>*>(const_cast<DOFVector<T>*>(&x)), USED_DOFS);
for (vecIterator.reset(), xIterator.reset();
!vecIterator.end();
++vecIterator, ++xIterator) {
Iterator xIterator(dynamic_cast<DOFVector<T>*>(const_cast<DOFVector<T>*>(&x)),
USED_DOFS);
for (vecIterator.reset(), xIterator.reset(); !vecIterator.end();
++vecIterator, ++xIterator)
*vecIterator = *xIterator;
}
}
......@@ -297,17 +276,12 @@ namespace AMDiS {
{
FUNCNAME("DOFVector<T>::min()");
TEST_EXIT_DBG(feSpace && feSpace->getAdmin())
("pointer is NULL: %8X, %8X\n", this, feSpace->getAdmin());
TEST_EXIT_DBG((static_cast<int>(vec.size())) >= feSpace->getAdmin()->getUsedSize())
("size = %d too small: admin->sizeUsed = %d\n", vec.size(),
feSpace->getAdmin()->getUsedSize());
checkFeSpace(feSpace, vec);
T m;
Iterator vecIterator(const_cast<DOFIndexed<T>*>(dynamic_cast<const DOFIndexed<T>*>(this)), USED_DOFS);
for (vecIterator.reset(), m = *vecIterator; !vecIterator.end(); ++vecIterator) {
for (vecIterator.reset(), m = *vecIterator; !vecIterator.end(); ++vecIterator)
m = std::min(m, *vecIterator);
}
return m;
}
......@@ -317,17 +291,12 @@ namespace AMDiS {
{
FUNCNAME("DOFVector<T>::max()");
TEST_EXIT_DBG(feSpace && feSpace->getAdmin())
("pointer is NULL: %8X, %8X\n", this, feSpace->getAdmin());
TEST_EXIT_DBG((static_cast<int>(vec.size())) >= feSpace->getAdmin()->getUsedSize())
("size = %d too small: admin->sizeUsed = %d\n", vec.size(),
feSpace->getAdmin()->getUsedSize());
checkFeSpace(feSpace, vec);
T m;
Iterator vecIterator(const_cast<DOFIndexed<T>*>(dynamic_cast<const DOFIndexed<T>*>(this)), USED_DOFS);
for (vecIterator.reset(), m = *vecIterator; !vecIterator.end(); ++vecIterator) {
for (vecIterator.reset(), m = *vecIterator; !vecIterator.end(); ++vecIterator)
m = std::max(m, *vecIterator);
}
return m;
}
......@@ -342,6 +311,7 @@ namespace AMDiS {
void DOFVector<T>::print() const
{
FUNCNAME("DOFVector<T>::print()");
const DOFAdmin *admin = NULL;
const char *format;
......@@ -503,18 +473,15 @@ namespace AMDiS {