Commit cfbd82f1 authored by Thomas Witkowski's avatar Thomas Witkowski

Work on pdd and general code refactoring.

parent 0fee3b03
......@@ -89,12 +89,8 @@ namespace AMDiS {
Flag CoarseningManager::coarsenMesh(Mesh *aMesh)
{
int n_elements;
ElInfo *el_info;
mesh = aMesh;
n_elements = mesh->getNumberOfLeaves();
int n_elements = mesh->getNumberOfLeaves();
spreadCoarsenMark();
......@@ -102,14 +98,10 @@ namespace AMDiS {
do {
doMore = false;
el_info = stack->traverseFirst(mesh, -1,
Mesh::CALL_EVERY_EL_POSTORDER | Mesh::FILL_NEIGH);
ElInfo* el_info =
stack->traverseFirst(mesh, -1, Mesh::CALL_EVERY_EL_POSTORDER | Mesh::FILL_NEIGH);
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);
}
} while (doMore);
......
......@@ -57,10 +57,6 @@ namespace AMDiS {
colIndices.resize(nCol);
applyDBCs.clear();
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
applicationOrdering = NULL;
#endif
}
DOFMatrix::DOFMatrix(const DOFMatrix& rhs)
......@@ -213,17 +209,23 @@ namespace AMDiS {
bound ? boundaryManager->getBoundaryCondition(bound[i]) : NULL;
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));
#endif
}
} else
for (int j = 0; j < nCol; j++) { // for all columns
DegreeOfFreedom col = colIndices[j];
double entry = elMat[i][j];
if (add)
ins[row][col]+= sign * entry;
ins[row][col] += sign * entry;
else
ins[row][col]= sign * entry;
ins[row][col] = sign * entry;
}
}
}
......@@ -249,6 +251,18 @@ namespace AMDiS {
(*it)->getElementMatrix(elInfo, elementMatrix, *factorIt ? **factorIt : 1.0);
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,
......
......@@ -37,10 +37,6 @@
#include "Boundary.h"
#include "Serializable.h"
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
#include "petscao.h"
#endif
namespace AMDiS {
/** \ingroup DOFAdministration
......@@ -447,10 +443,9 @@ namespace AMDiS {
int memsize();
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
/// Sets the petsc application ordering object to map dof indices.
void useApplicationOrdering(AO *ao)
void setIsRankDOF(std::map<DegreeOfFreedom, bool>& dofmap)
{
applicationOrdering = ao;
isRankDOF = dofmap;
}
#endif
......@@ -525,8 +520,7 @@ namespace AMDiS {
std::set<int> applyDBCs;
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
/// Petsc application ordering to map dof indices.
AO *applicationOrdering;
std::map<DegreeOfFreedom, bool> isRankDOF;
#endif
/// Inserter object: implemented as pointer, allocated and deallocated as needed
......
......@@ -82,11 +82,13 @@ namespace AMDiS {
writeElement = writeElem;
}
std::string getFilename() {
std::string getFilename()
{
return filename;
}
void setFilename(std::string n) {
void setFilename(std::string n)
{
filename = n;
}
......
......@@ -142,7 +142,8 @@ namespace AMDiS {
void calculateElementMatrix(const ElInfo *elInfo, ElementMatrix& mat);
/// Implements SubAssembler::calculateElementVector().
void calculateElementVector(const ElInfo*, ElementVector&) {
void calculateElementVector(const ElInfo*, ElementVector&)
{
ERROR_EXIT("should not be called\n");
}
};
......@@ -193,7 +194,8 @@ namespace AMDiS {
void calculateElementMatrix(const ElInfo *elInfo, ElementMatrix& mat);
/// Implements SubAssembler::calculateElementVector().
void calculateElementVector(const ElInfo*, ElementVector&) {
void calculateElementVector(const ElInfo*, ElementVector&)
{
ERROR_EXIT("should not be called\n");
}
......
......@@ -89,28 +89,31 @@ namespace AMDiS {
}
/// Initialisation for dim.
inline void init(int dim) {
inline void init(int dim)
{
this->resize(calcSize(dim));
}
/// Initialisation for size
inline void initSize(int size) {
inline void initSize(int size)
{
this->resize(size);
}
/// Returns the \ref size_ of the FixVec.
inline int size() const {
inline int size() const
{
return this->getSize();
}
protected:
/// Determines needed vector size.
static int calcSize(int dim) {
if (dim < 0) {
static int calcSize(int dim)
{
if (dim < 0)
return Global::getGeo(WORLD);
} else {
else
return Global::getGeo(d, dim);
}
}
public:
......
......@@ -30,7 +30,8 @@ namespace AMDiS {
class VecConv
{
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");
return reinterpret_cast<FixVec<T,d1>&>(rhs);
}
......
......@@ -48,129 +48,150 @@ namespace AMDiS {
inline ~Flag() {}
/// Compares two Flags
inline bool operator==(const Flag& f) const {
inline bool operator==(const Flag& f) const
{
return (flags == f.flags);
}
/// Compares two Flags
bool operator!=(const Flag& f) const {
bool operator!=(const Flag& f) const
{
return !(f == *this);
}
/// Assignment operator
inline Flag& operator=(const Flag& f) {
inline Flag& operator=(const Flag& f)
{
if (this != &f)
flags = f.flags;
return *this;
}
/// Typecast
inline operator bool() const {
inline operator bool() const
{
return isAnySet();
}
/// Set \ref flags
inline void setFlags(const unsigned long f) {
inline void setFlags(const unsigned long f)
{
flags = f;
}
/// Set \ref flags
inline void setFlags(const Flag& f) {
inline void setFlags(const Flag& f)
{
flags = f.flags;
}
/// Sets \ref flags to \ref flags | f
inline void setFlag(const unsigned long f) {
inline void setFlag(const unsigned long f)
{
flags |= f;
}
/// Sets \ref flags to \ref flags | f.flags
inline void setFlag(const Flag& f) {
inline void setFlag(const Flag& f)
{
flags |= f.flags;
}
/// Sets \ref flags to \ref flags & ~f
inline void unsetFlag(const unsigned long f) {
inline void unsetFlag(const unsigned long f)
{
flags &= ~f;
}
/// Sets \ref flags to \ref flags & ~f.flags
inline void unsetFlag(const Flag& f) {
inline void unsetFlag(const Flag& f)
{
flags &= ~f.flags;
}
inline const unsigned long getFlags() const {
inline const unsigned long getFlags() const
{
return flags;
}
/// Returns \ref flags | f.flags
inline Flag operator+(const Flag& f) const {
inline Flag operator+(const Flag& f) const
{
Flag r(flags);
r.setFlag(f);
return r;
}
/// Returns \ref flags & ~f.flags
inline Flag operator-(const Flag& f) const {
inline Flag operator-(const Flag& f) const
{
Flag r(flags);
r.unsetFlag(f);
return r;
}
/// Returns \ref flags | f.flags
inline Flag operator|(const Flag& f) const {
inline Flag operator|(const Flag& f) const
{
Flag r(flags);
r.setFlag(f);
return r;
}
/// Returns \ref flags & f.flags
inline Flag operator&(const Flag& f) const {
inline Flag operator&(const Flag& f) const
{
Flag r(flags);
r.flags &= f.flags;
return r;
}
/// Sets \ref flags to \ref flags &= f.flags
inline Flag operator&=(const Flag& f) {
inline Flag operator&=(const Flag& f)
{
flags &= f.flags;
return *this;
}
/// Returns \ref flags ^ f.flags
inline Flag operator^(const Flag& f) const {
inline Flag operator^(const Flag& f) const
{
Flag r(flags);
r.flags ^=f.flags;
return r;
}
/// Sets \ref flags to \ref flags & f.flags
inline Flag& operator|=(const Flag& f) {
if (this != &f) {
inline Flag& operator|=(const Flag& f)
{
if (this != &f)
flags |= f.flags;
};
return *this;
}
/// Returns ~\ref flags
inline Flag operator~() const {
inline Flag operator~() const
{
Flag r;
r.flags = ~flags;
return r;
}
/// 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);
}
/// Returns !\ref isSet(f)
inline bool isUnset(const Flag& f) const {
inline bool isUnset(const Flag& f) const
{
return !isSet(f);
}
/// Returns true if \ref flags != 0
inline bool isAnySet() const {
inline bool isAnySet() const
{
return (flags != 0);
}
......
......@@ -25,49 +25,33 @@
#include <vector>
#include <string>
#include "FileWriter.h"
#include "AMDiS_fwd.h"
namespace AMDiS {
template<typename T> class DOFVector;
class FiniteElemSpace;
/** \brief
*
*/
///
class GNUPlotWriter : public FileWriterInterface
{
public:
/** \brief
* Constructor
*/
///
GNUPlotWriter(std::string filename,
FiniteElemSpace *feSpace,
std::vector<DOFVector<double>*> &dofVectors);
/** \brief
* Destructor
*/
virtual ~GNUPlotWriter() {};
///
virtual ~GNUPlotWriter() {}
/** \brief
* Implementation of FileWriter::writeFiles()
*/
///
virtual void writeFiles(AdaptInfo *adaptInfo, bool force);
protected:
/** \brief
* Contains the mesh
*/
/// Contains the mesh
FiniteElemSpace *feSpace_;
/** \brief
* vector of dof vectors to write
*/
/// vector of dof vectors to write
std::vector<DOFVector<double>*> dofVectors_;
/** \brief
* file name
*/
/// file name
std::string filename_;
};
......
......@@ -187,25 +187,43 @@ namespace AMDiS {
int ntime);
/// Sets \ref msgInfo
static void setMsgInfo(int info) { msgInfo = info; }
static void setMsgInfo(int info)
{
msgInfo = info;
}
/// Returns \ref msgInfo
static int getMsgInfo() { return msgInfo; }
static int getMsgInfo()
{
return msgInfo;
}
/// Sets \ref msgWait
static void setMsgWait(bool wait) { msgWait = wait; }
static void setMsgWait(bool wait)
{
msgWait = wait;
}
/// Returns \ref msgWait
static bool getMsgWait() { return msgWait; }
static bool getMsgWait()
{
return msgWait;
}
/// Waits for enter if w is true
static void wait(bool w);
/// Returns \ref out
static std::ostream *getOutStream() { return out; }
static std::ostream *getOutStream()
{
return out;
}
/// Returns \ref error
static std::ostream *getErrorStream() { return error; }
static std::ostream *getErrorStream()
{
return error;
}
protected:
/// Message stram
......@@ -341,14 +359,16 @@ namespace AMDiS {
* returns a pointer to \ref referenceElement [dim]. With this pointer you
* can get information about the element via Element's getGeo method.
*/
static const Element *getReferenceElement(int dim) {
static const Element *getReferenceElement(int dim)
{
FUNCNAME("Global::getReferenceElement()");
TEST_EXIT((dim > 0) && (dim < 4))("invalid dim: %d\n", dim);
return referenceElement[dim];
}
/// returns geometrical information. Currently this is only dimOfWorld.
static inline int getGeo(GeoIndex p) {
static inline int getGeo(GeoIndex p)
{
if (WORLD == p)
return dimOfWorld;
......@@ -360,7 +380,8 @@ namespace AMDiS {
* returns geometrical information about elements of the dimension dim.
* getGeo(VERTEX, 3) returns 4 because a Tetrahedron has 4 vertices.
*/
static inline int getGeo(GeoIndex p, int dim) {
static inline int getGeo(GeoIndex p, int dim)
{
TEST_EXIT_DBG((p >= MINPART) && (p <= MAXPART))
("Calling for invalid geometry value %d\n",p);
TEST_EXIT_DBG((dim >= 0) && (dim < 4))
......
......@@ -23,16 +23,10 @@
#define AMDIS_GRID_WRITER_H
#include "Global.h"
#include "AMDiS_fwd.h"
namespace AMDiS {
template<typename T> class WorldVector;
template<typename T> class DOFVector;
// ============================================================================
// ===== class GridWriter =====================================================
// ============================================================================
/** \ingroup Output
* \brief
* Produces a grid-based output of a dof-vector
......@@ -62,9 +56,7 @@ namespace AMDiS {
int *numPoints,
double *dist,
DOFVector<T> *vec,
char* filename);
private:
char* filename);
};
}
......
......@@ -61,38 +61,27 @@ namespace AMDiS {
*/
static Lagrange* getLagrange(int dim, int degree);
/** \brief
* Implements BasisFunction::interpol
*/
/// Implements BasisFunction::interpol
const double *interpol(const ElInfo *, int, const int *,
AbstractFunction<double, WorldVector<double> >*,
double *);
/** \brief
* Implements BasisFunction::interpol
*/
/// Implements BasisFunction::interpol
const WorldVector<double> *interpol(const ElInfo *, int,
const int *b_no,
AbstractFunction<WorldVector<double>,
WorldVector<double> >*,
WorldVector<double> *);
/** \brief
* Returns the barycentric coordinates of the i-th basis function.
*/
/// Returns the barycentric coordinates of the i-th basis function.
DimVec<double> *getCoords(int i) const;
/** \brief
* Implements BasisFunction::getDOFIndices
*/
/// Implements BasisFunction::getDOFIndices
const DegreeOfFreedom* getDOFIndices(const Element*,
const DOFAdmin&,
DegreeOfFreedom*) const;
/** \brief
* Implements BasisFunction::getBound
*/
/// Implements BasisFunction::getBound
void getBound(const ElInfo*, BoundaryType *) const;
/** \brief
......@@ -158,44 +147,29 @@ namespace AMDiS {
*/
void setBary();
/** \brief
* Recursive calculation of coordinates. Used by \ref setBary
*/
/// Recursive calculation of coordinates. Used by \ref setBary
void createCoords(int* coordInd, int numCoords, int dimIndex, int rest,
DimVec<double>* vec = NULL);
/** \brief
* Used by \ref setBary
*/
/// Used by \ref setBary
int** getIndexPermutations(int numIndices) const;
/** \brief
* Implements BasisFunction::setNDOF
*/
/// Implements BasisFunction::setNDOF
void setNDOF();
/** \brief
* Sets used function pointers
*/
/// Sets used function pointers
void setFunctionPointer();
/** \brief
* Used by \ref getDOFIndices and \ref getVec
*/
/// Used by \ref getDOFIndices and \ref getVec
int* orderOfPositionIndices(const Element* el,
GeoIndex position,
int positionIndex) const;
/** \brief
* Calculates the number of DOFs needed for Lagrange of the given dim and
* degree.
*/
/// Calculates the number of DOFs needed for Lagrange of the given dim and degree.
static int getNumberOfDOFs(int dim, int degree);
private:
/** \brief
* barycentric coordinates of the locations of all basis functions
*/
/// barycentric coordinates of the locations of all basis functions
std::vector<DimVec<double>* > *bary;
/** \name static dim-degree-arrays
......@@ -217,11 +191,8 @@ namespace AMDiS {
protected:
/** \brief
* Pointer to the used refineInter function
*/
void (*refineInter_fct)(DOFIndexed<double> *, RCNeighbourList*, int,
BasisFunction*);