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

Work on pdd and general code refactoring.

parent 0fee3b03
...@@ -89,12 +89,8 @@ namespace AMDiS { ...@@ -89,12 +89,8 @@ namespace AMDiS {
Flag CoarseningManager::coarsenMesh(Mesh *aMesh) Flag CoarseningManager::coarsenMesh(Mesh *aMesh)
{ {
int n_elements;
ElInfo *el_info;
mesh = aMesh; mesh = aMesh;
int n_elements = mesh->getNumberOfLeaves();
n_elements = mesh->getNumberOfLeaves();
spreadCoarsenMark(); spreadCoarsenMark();
...@@ -102,14 +98,10 @@ namespace AMDiS { ...@@ -102,14 +98,10 @@ namespace AMDiS {
do { do {
doMore = false; doMore = false;
el_info = stack->traverseFirst(mesh, -1, ElInfo* el_info =
Mesh::CALL_EVERY_EL_POSTORDER | Mesh::FILL_NEIGH); stack->traverseFirst(mesh, -1, Mesh::CALL_EVERY_EL_POSTORDER | Mesh::FILL_NEIGH);
while (el_info) { while (el_info) {
int idx = el_info->getElement()->getIndex();
// if (idx != 2288 && idx != 2283)
coarsenFunction(el_info); coarsenFunction(el_info);
el_info = stack->traverseNext(el_info); el_info = stack->traverseNext(el_info);
} }
} while (doMore); } while (doMore);
......
...@@ -57,10 +57,6 @@ namespace AMDiS { ...@@ -57,10 +57,6 @@ namespace AMDiS {
colIndices.resize(nCol); colIndices.resize(nCol);
applyDBCs.clear(); applyDBCs.clear();
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
applicationOrdering = NULL;
#endif
} }
DOFMatrix::DOFMatrix(const DOFMatrix& rhs) DOFMatrix::DOFMatrix(const DOFMatrix& rhs)
...@@ -213,17 +209,23 @@ namespace AMDiS { ...@@ -213,17 +209,23 @@ namespace AMDiS {
bound ? boundaryManager->getBoundaryCondition(bound[i]) : NULL; bound ? boundaryManager->getBoundaryCondition(bound[i]) : NULL;
if (condition && condition->isDirichlet()) { if (condition && condition->isDirichlet()) {
if (condition->applyBoundaryCondition()) if (condition->applyBoundaryCondition()) {
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
if (isRankDOF[row])
applyDBCs.insert(static_cast<int>(row));
#else
applyDBCs.insert(static_cast<int>(row)); applyDBCs.insert(static_cast<int>(row));
#endif
}
} else } else
for (int j = 0; j < nCol; j++) { // for all columns for (int j = 0; j < nCol; j++) { // for all columns
DegreeOfFreedom col = colIndices[j]; DegreeOfFreedom col = colIndices[j];
double entry = elMat[i][j]; double entry = elMat[i][j];
if (add) if (add)
ins[row][col]+= sign * entry; ins[row][col] += sign * entry;
else else
ins[row][col]= sign * entry; ins[row][col] = sign * entry;
} }
} }
} }
...@@ -249,6 +251,18 @@ namespace AMDiS { ...@@ -249,6 +251,18 @@ namespace AMDiS {
(*it)->getElementMatrix(elInfo, elementMatrix, *factorIt ? **factorIt : 1.0); (*it)->getElementMatrix(elInfo, elementMatrix, *factorIt ? **factorIt : 1.0);
addElementMatrix(factor, elementMatrix, bound, elInfo, NULL); addElementMatrix(factor, elementMatrix, bound, elInfo, NULL);
// if (MPI::COMM_WORLD.Get_rank() == 0 && elInfo->getElement()->getIndex() == 53) {
// std::cout << elementMatrix << std::endl;
// rowFESpace->getBasisFcts()->getLocalIndicesVec(elInfo->getElement(),
// rowFESpace->getAdmin(),
// &rowIndices);
// rowIndices.print();
// print();
// }
} }
void DOFMatrix::assemble(double factor, ElInfo *elInfo, const BoundaryType *bound, void DOFMatrix::assemble(double factor, ElInfo *elInfo, const BoundaryType *bound,
......
...@@ -37,10 +37,6 @@ ...@@ -37,10 +37,6 @@
#include "Boundary.h" #include "Boundary.h"
#include "Serializable.h" #include "Serializable.h"
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
#include "petscao.h"
#endif
namespace AMDiS { namespace AMDiS {
/** \ingroup DOFAdministration /** \ingroup DOFAdministration
...@@ -447,10 +443,9 @@ namespace AMDiS { ...@@ -447,10 +443,9 @@ namespace AMDiS {
int memsize(); int memsize();
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS #ifdef HAVE_PARALLEL_DOMAIN_AMDIS
/// Sets the petsc application ordering object to map dof indices. void setIsRankDOF(std::map<DegreeOfFreedom, bool>& dofmap)
void useApplicationOrdering(AO *ao)
{ {
applicationOrdering = ao; isRankDOF = dofmap;
} }
#endif #endif
...@@ -525,8 +520,7 @@ namespace AMDiS { ...@@ -525,8 +520,7 @@ namespace AMDiS {
std::set<int> applyDBCs; std::set<int> applyDBCs;
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS #ifdef HAVE_PARALLEL_DOMAIN_AMDIS
/// Petsc application ordering to map dof indices. std::map<DegreeOfFreedom, bool> isRankDOF;
AO *applicationOrdering;
#endif #endif
/// Inserter object: implemented as pointer, allocated and deallocated as needed /// Inserter object: implemented as pointer, allocated and deallocated as needed
......
...@@ -82,11 +82,13 @@ namespace AMDiS { ...@@ -82,11 +82,13 @@ namespace AMDiS {
writeElement = writeElem; writeElement = writeElem;
} }
std::string getFilename() { std::string getFilename()
{
return filename; return filename;
} }
void setFilename(std::string n) { void setFilename(std::string n)
{
filename = n; filename = n;
} }
......
...@@ -142,7 +142,8 @@ namespace AMDiS { ...@@ -142,7 +142,8 @@ namespace AMDiS {
void calculateElementMatrix(const ElInfo *elInfo, ElementMatrix& mat); void calculateElementMatrix(const ElInfo *elInfo, ElementMatrix& mat);
/// Implements SubAssembler::calculateElementVector(). /// Implements SubAssembler::calculateElementVector().
void calculateElementVector(const ElInfo*, ElementVector&) { void calculateElementVector(const ElInfo*, ElementVector&)
{
ERROR_EXIT("should not be called\n"); ERROR_EXIT("should not be called\n");
} }
}; };
...@@ -193,7 +194,8 @@ namespace AMDiS { ...@@ -193,7 +194,8 @@ namespace AMDiS {
void calculateElementMatrix(const ElInfo *elInfo, ElementMatrix& mat); void calculateElementMatrix(const ElInfo *elInfo, ElementMatrix& mat);
/// Implements SubAssembler::calculateElementVector(). /// Implements SubAssembler::calculateElementVector().
void calculateElementVector(const ElInfo*, ElementVector&) { void calculateElementVector(const ElInfo*, ElementVector&)
{
ERROR_EXIT("should not be called\n"); ERROR_EXIT("should not be called\n");
} }
......
...@@ -89,29 +89,32 @@ namespace AMDiS { ...@@ -89,29 +89,32 @@ namespace AMDiS {
} }
/// Initialisation for dim. /// Initialisation for dim.
inline void init(int dim) { inline void init(int dim)
{
this->resize(calcSize(dim)); this->resize(calcSize(dim));
} }
/// Initialisation for size /// Initialisation for size
inline void initSize(int size) { inline void initSize(int size)
{
this->resize(size); this->resize(size);
} }
/// Returns the \ref size_ of the FixVec. /// Returns the \ref size_ of the FixVec.
inline int size() const { inline int size() const
{
return this->getSize(); return this->getSize();
} }
protected: protected:
/// Determines needed vector size. /// Determines needed vector size.
static int calcSize(int dim) { static int calcSize(int dim)
if (dim < 0) { {
if (dim < 0)
return Global::getGeo(WORLD); return Global::getGeo(WORLD);
} else { else
return Global::getGeo(d, dim); return Global::getGeo(d, dim);
} }
}
public: public:
friend class GLWindow; friend class GLWindow;
......
...@@ -30,7 +30,8 @@ namespace AMDiS { ...@@ -30,7 +30,8 @@ namespace AMDiS {
class VecConv class VecConv
{ {
public: public:
static FixVec<T,d1>& convertVec(FixVec<T,d2>& rhs, Mesh* mesh) { static FixVec<T,d1>& convertVec(FixVec<T,d2>& rhs, Mesh* mesh)
{
TEST_EXIT(mesh->getGeo(d1)==mesh->getGeo(d2))("Incompatible dimensions.\n"); TEST_EXIT(mesh->getGeo(d1)==mesh->getGeo(d2))("Incompatible dimensions.\n");
return reinterpret_cast<FixVec<T,d1>&>(rhs); return reinterpret_cast<FixVec<T,d1>&>(rhs);
} }
......
...@@ -48,129 +48,150 @@ namespace AMDiS { ...@@ -48,129 +48,150 @@ namespace AMDiS {
inline ~Flag() {} inline ~Flag() {}
/// Compares two Flags /// Compares two Flags
inline bool operator==(const Flag& f) const { inline bool operator==(const Flag& f) const
{
return (flags == f.flags); return (flags == f.flags);
} }
/// Compares two Flags /// Compares two Flags
bool operator!=(const Flag& f) const { bool operator!=(const Flag& f) const
{
return !(f == *this); return !(f == *this);
} }
/// Assignment operator /// Assignment operator
inline Flag& operator=(const Flag& f) { inline Flag& operator=(const Flag& f)
{
if (this != &f) if (this != &f)
flags = f.flags; flags = f.flags;
return *this; return *this;
} }
/// Typecast /// Typecast
inline operator bool() const { inline operator bool() const
{
return isAnySet(); return isAnySet();
} }
/// Set \ref flags /// Set \ref flags
inline void setFlags(const unsigned long f) { inline void setFlags(const unsigned long f)
{
flags = f; flags = f;
} }
/// Set \ref flags /// Set \ref flags
inline void setFlags(const Flag& f) { inline void setFlags(const Flag& f)
{
flags = f.flags; flags = f.flags;
} }
/// Sets \ref flags to \ref flags | f /// Sets \ref flags to \ref flags | f
inline void setFlag(const unsigned long f) { inline void setFlag(const unsigned long f)
{
flags |= f; flags |= f;
} }
/// Sets \ref flags to \ref flags | f.flags /// Sets \ref flags to \ref flags | f.flags
inline void setFlag(const Flag& f) { inline void setFlag(const Flag& f)
{
flags |= f.flags; flags |= f.flags;
} }
/// Sets \ref flags to \ref flags & ~f /// Sets \ref flags to \ref flags & ~f
inline void unsetFlag(const unsigned long f) { inline void unsetFlag(const unsigned long f)
{
flags &= ~f; flags &= ~f;
} }
/// Sets \ref flags to \ref flags & ~f.flags /// Sets \ref flags to \ref flags & ~f.flags
inline void unsetFlag(const Flag& f) { inline void unsetFlag(const Flag& f)
{
flags &= ~f.flags; flags &= ~f.flags;
} }
inline const unsigned long getFlags() const { inline const unsigned long getFlags() const
{
return flags; return flags;
} }
/// Returns \ref flags | f.flags /// Returns \ref flags | f.flags
inline Flag operator+(const Flag& f) const { inline Flag operator+(const Flag& f) const
{
Flag r(flags); Flag r(flags);
r.setFlag(f); r.setFlag(f);
return r; return r;
} }
/// Returns \ref flags & ~f.flags /// Returns \ref flags & ~f.flags
inline Flag operator-(const Flag& f) const { inline Flag operator-(const Flag& f) const
{
Flag r(flags); Flag r(flags);
r.unsetFlag(f); r.unsetFlag(f);
return r; return r;
} }
/// Returns \ref flags | f.flags /// Returns \ref flags | f.flags
inline Flag operator|(const Flag& f) const { inline Flag operator|(const Flag& f) const
{
Flag r(flags); Flag r(flags);
r.setFlag(f); r.setFlag(f);
return r; return r;
} }
/// Returns \ref flags & f.flags /// Returns \ref flags & f.flags
inline Flag operator&(const Flag& f) const { inline Flag operator&(const Flag& f) const
{
Flag r(flags); Flag r(flags);
r.flags &= f.flags; r.flags &= f.flags;
return r; return r;
} }
/// Sets \ref flags to \ref flags &= f.flags /// Sets \ref flags to \ref flags &= f.flags
inline Flag operator&=(const Flag& f) { inline Flag operator&=(const Flag& f)
{
flags &= f.flags; flags &= f.flags;
return *this; return *this;
} }
/// Returns \ref flags ^ f.flags /// Returns \ref flags ^ f.flags
inline Flag operator^(const Flag& f) const { inline Flag operator^(const Flag& f) const
{
Flag r(flags); Flag r(flags);
r.flags ^=f.flags; r.flags ^=f.flags;
return r; return r;
} }
/// Sets \ref flags to \ref flags & f.flags /// Sets \ref flags to \ref flags & f.flags
inline Flag& operator|=(const Flag& f) { inline Flag& operator|=(const Flag& f)
if (this != &f) { {
if (this != &f)
flags |= f.flags; flags |= f.flags;
};
return *this; return *this;
} }
/// Returns ~\ref flags /// Returns ~\ref flags
inline Flag operator~() const { inline Flag operator~() const
{
Flag r; Flag r;
r.flags = ~flags; r.flags = ~flags;
return r; return r;
} }
/// Checks whether all set bits of f.flags are set in \ref flags too. /// Checks whether all set bits of f.flags are set in \ref flags too.
inline bool isSet(const Flag& f) const { inline bool isSet(const Flag& f) const
{
return ((flags&f.flags) == f.flags); return ((flags&f.flags) == f.flags);
} }
/// Returns !\ref isSet(f) /// Returns !\ref isSet(f)
inline bool isUnset(const Flag& f) const { inline bool isUnset(const Flag& f) const
{
return !isSet(f); return !isSet(f);
} }
/// Returns true if \ref flags != 0 /// Returns true if \ref flags != 0
inline bool isAnySet() const { inline bool isAnySet() const
{
return (flags != 0); return (flags != 0);
} }
......
...@@ -25,49 +25,33 @@ ...@@ -25,49 +25,33 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include "FileWriter.h" #include "FileWriter.h"
#include "AMDiS_fwd.h"
namespace AMDiS { namespace AMDiS {
template<typename T> class DOFVector; ///
class FiniteElemSpace;
/** \brief
*
*/
class GNUPlotWriter : public FileWriterInterface class GNUPlotWriter : public FileWriterInterface
{ {
public: public:
/** \brief ///
* Constructor
*/
GNUPlotWriter(std::string filename, GNUPlotWriter(std::string filename,
FiniteElemSpace *feSpace, FiniteElemSpace *feSpace,
std::vector<DOFVector<double>*> &dofVectors); std::vector<DOFVector<double>*> &dofVectors);
/** \brief ///
* Destructor virtual ~GNUPlotWriter() {}
*/
virtual ~GNUPlotWriter() {};
/** \brief ///
* Implementation of FileWriter::writeFiles()
*/
virtual void writeFiles(AdaptInfo *adaptInfo, bool force); virtual void writeFiles(AdaptInfo *adaptInfo, bool force);
protected: protected:
/** \brief /// Contains the mesh
* Contains the mesh
*/
FiniteElemSpace *feSpace_; FiniteElemSpace *feSpace_;
/** \brief /// vector of dof vectors to write
* vector of dof vectors to write
*/
std::vector<DOFVector<double>*> dofVectors_; std::vector<DOFVector<double>*> dofVectors_;
/** \brief /// file name
* file name
*/
std::string filename_;