Commit 1f3eed71 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

* Bugfixing around SolutionDataStorage

parent 535ca95d
...@@ -53,13 +53,14 @@ namespace AMDiS { ...@@ -53,13 +53,14 @@ namespace AMDiS {
usedCount = src.usedCount; usedCount = src.usedCount;
holeCount = src.holeCount; holeCount = src.holeCount;
sizeUsed = src.sizeUsed; sizeUsed = src.sizeUsed;
for (int i = 0; i < mesh->getDim(); i++) { for (int i = 0; i <= mesh->getDim(); i++) {
nrDOF[i] = src.nrDOF[i]; nrDOF[i] = src.nrDOF[i];
nr0DOF[i] = src.nr0DOF[i]; nr0DOF[i] = src.nr0DOF[i];
} }
dofIndexedList = src.dofIndexedList; dofIndexedList = src.dofIndexedList;
dofContainerList = src.dofContainerList; dofContainerList = src.dofContainerList;
} }
return *this; return *this;
} }
/****************************************************************************/ /****************************************************************************/
......
...@@ -76,32 +76,33 @@ namespace AMDiS { ...@@ -76,32 +76,33 @@ namespace AMDiS {
elementVector(NULL), elementVector(NULL),
boundaryManager(NULL), boundaryManager(NULL),
nBasFcts(0) nBasFcts(0)
{}; {}
DOFVectorBase(const FiniteElemSpace *f, std::string n); DOFVectorBase(const FiniteElemSpace *f, std::string n);
virtual ~DOFVectorBase(); virtual ~DOFVectorBase();
virtual const T *getLocalVector(const Element *el, T* localVec) const; virtual const T *getLocalVector(const Element *el,
T* localVec) const;
const T *getVecAtQPs(const ElInfo *elInfo, const T *getVecAtQPs(const ElInfo *elInfo,
const Quadrature *quad, const Quadrature *quad,
const FastQuadrature *quadFast, const FastQuadrature *quadFast,
T *vecAtQPs) const; T *vecAtQPs) const;
const WorldVector<T> *getGrdAtQPs(const ElInfo *elInfo, const WorldVector<T> *getGrdAtQPs(const ElInfo *elInfo,
const Quadrature *quad, const Quadrature *quad,
const FastQuadrature *quadFast, const FastQuadrature *quadFast,
WorldVector<T> *grdAtQPs) const; WorldVector<T> *grdAtQPs) const;
const WorldMatrix<T> *getD2AtQPs(const ElInfo *elInfo, const WorldMatrix<T> *getD2AtQPs(const ElInfo *elInfo,
const Quadrature *quad, const Quadrature *quad,
const FastQuadrature *quadFast, const FastQuadrature *quadFast,
WorldMatrix<T> *d2AtQPs) const; WorldMatrix<T> *d2AtQPs) const;
virtual const FiniteElemSpace* getFESpace() const { inline const FiniteElemSpace* getFESpace() const {
return feSpace; return feSpace;
}; }
ElementVector *assemble(T factor, ElInfo *elInfo, ElementVector *assemble(T factor, ElInfo *elInfo,
const BoundaryType *bound, const BoundaryType *bound,
...@@ -119,32 +120,32 @@ namespace AMDiS { ...@@ -119,32 +120,32 @@ namespace AMDiS {
operators.push_back(op); operators.push_back(op);
operatorFactor.push_back(factor); operatorFactor.push_back(factor);
operatorEstFactor.push_back(estFactor); operatorEstFactor.push_back(estFactor);
}; }
inline std::vector<double*>::iterator getOperatorFactorBegin() { inline std::vector<double*>::iterator getOperatorFactorBegin() {
return operatorFactor.begin(); return operatorFactor.begin();
}; }
inline std::vector<double*>::iterator getOperatorFactorEnd() { inline std::vector<double*>::iterator getOperatorFactorEnd() {
return operatorFactor.end(); return operatorFactor.end();
}; }
inline std::vector<double*>::iterator getOperatorEstFactorBegin() { inline std::vector<double*>::iterator getOperatorEstFactorBegin() {
return operatorEstFactor.begin(); return operatorEstFactor.begin();
}; }
inline std::vector<double*>::iterator getOperatorEstFactorEnd() { inline std::vector<double*>::iterator getOperatorEstFactorEnd() {
return operatorEstFactor.end(); return operatorEstFactor.end();
}; }
inline std::vector<Operator*>::iterator getOperatorsBegin() { inline std::vector<Operator*>::iterator getOperatorsBegin() {
return operators.begin(); return operators.begin();
}; }
inline std::vector<Operator*>::iterator getOperatorsEnd() { inline std::vector<Operator*>::iterator getOperatorsEnd() {
return operators.end(); return operators.end();
}; }
Flag getAssembleFlag(); Flag getAssembleFlag();
...@@ -158,30 +159,30 @@ namespace AMDiS { ...@@ -158,30 +159,30 @@ namespace AMDiS {
inline std::vector<Operator*>& getOperators() { inline std::vector<Operator*>& getOperators() {
return operators; return operators;
}; }
inline std::vector<double*>& getOperatorFactor() { inline std::vector<double*>& getOperatorFactor() {
return operatorFactor; return operatorFactor;
}; }
inline std::vector<double*>& getOperatorEstFactor() { inline std::vector<double*>& getOperatorEstFactor() {
return operatorEstFactor; return operatorEstFactor;
}; }
/** \brief /** \brief
* Returns \ref name * Returns \ref name
*/ */
inline const std::string& getName() const { inline const std::string& getName() const {
return name; return name;
}; }
inline BoundaryManager* getBoundaryManager() const { inline BoundaryManager* getBoundaryManager() const {
return boundaryManager; return boundaryManager;
}; }
inline void setBoundaryManager(BoundaryManager *bm) { inline void setBoundaryManager(BoundaryManager *bm) {
boundaryManager = bm; boundaryManager = bm;
}; }
protected: protected:
/** \brief /** \brief
...@@ -285,26 +286,28 @@ namespace AMDiS { ...@@ -285,26 +286,28 @@ namespace AMDiS {
public: public:
Iterator(DOFIndexed<T> *c, DOFIteratorType type) Iterator(DOFIndexed<T> *c, DOFIteratorType type)
: DOFIterator<T>(c, type) : DOFIterator<T>(c, type)
{}; {}
Iterator(DOFAdmin *admin, DOFIndexed<T> *c, DOFIteratorType type) Iterator(DOFAdmin *admin, DOFIndexed<T> *c, DOFIteratorType type)
: DOFIterator<T>(admin, c, type) : DOFIterator<T>(admin, c, type)
{}; {}
}; };
class Creator : public CreatorInterface<DOFVector<T> > { class Creator : public CreatorInterface<DOFVector<T> > {
public: public:
MEMORY_MANAGED(Creator); MEMORY_MANAGED(Creator);
Creator(FiniteElemSpace *feSpace_) : feSpace(feSpace_) {}; Creator(FiniteElemSpace *feSpace_)
: feSpace(feSpace_)
{}
DOFVector<T> *create() { DOFVector<T> *create() {
return NEW DOFVector<T>(feSpace, ""); return NEW DOFVector<T>(feSpace, "");
}; }
void free(DOFVector<T> *vec) { void free(DOFVector<T> *vec) {
DELETE vec; DELETE vec;
}; }
private: private:
FiniteElemSpace *feSpace; FiniteElemSpace *feSpace;
...@@ -351,14 +354,14 @@ namespace AMDiS { ...@@ -351,14 +354,14 @@ namespace AMDiS {
*/ */
typename std::vector<T>::iterator begin() { typename std::vector<T>::iterator begin() {
return vec.begin(); return vec.begin();
}; }
/** \brief /** \brief
* Returns iterator to the end of \ref vec * Returns iterator to the end of \ref vec
*/ */
typename std::vector<T>::iterator end() { typename std::vector<T>::iterator end() {
return vec.end(); return vec.end();
}; }
/** \brief /** \brief
* Used by DOFAdmin to compress this DOFVector. Implementation of * Used by DOFAdmin to compress this DOFVector. Implementation of
...@@ -469,7 +472,7 @@ namespace AMDiS { ...@@ -469,7 +472,7 @@ namespace AMDiS {
*/ */
inline double L2Norm(Quadrature* q = NULL) const { inline double L2Norm(Quadrature* q = NULL) const {
return sqrt(L2NormSquare()); return sqrt(L2NormSquare());
}; }
/** \brief /** \brief
* Calculates square of L2 norm of this DOFVector * Calculates square of L2 norm of this DOFVector
...@@ -481,7 +484,7 @@ namespace AMDiS { ...@@ -481,7 +484,7 @@ namespace AMDiS {
*/ */
inline double H1Norm(Quadrature* q = NULL) const { inline double H1Norm(Quadrature* q = NULL) const {
return sqrt(H1NormSquare()); return sqrt(H1NormSquare());
}; };
/** \brief /** \brief
* Calculates square of H1 norm of this DOFVector * Calculates square of H1 norm of this DOFVector
...@@ -575,6 +578,9 @@ namespace AMDiS { ...@@ -575,6 +578,9 @@ namespace AMDiS {
*/ */
void print() const; void print() const;
/** \brief
*
*/
int calcMemoryUsage() const; int calcMemoryUsage() const;
/** \brief /** \brief
...@@ -692,11 +698,11 @@ namespace AMDiS { ...@@ -692,11 +698,11 @@ namespace AMDiS {
inline double min(const DOFVector<double>& v) { inline double min(const DOFVector<double>& v) {
return v.min(); return v.min();
}; }
inline double max(const DOFVector<double>& v) { inline double max(const DOFVector<double>& v) {
return v.max(); return v.max();
}; }
// =========================================================================== // ===========================================================================
// ===== class DOFVectorDOF ================================================== // ===== class DOFVectorDOF ==================================================
...@@ -720,14 +726,14 @@ namespace AMDiS { ...@@ -720,14 +726,14 @@ namespace AMDiS {
: DOFVector<DegreeOfFreedom>(feSpace_, name_) : DOFVector<DegreeOfFreedom>(feSpace_, name_)
{ {
feSpace->getAdmin()->addDOFContainer(this); feSpace->getAdmin()->addDOFContainer(this);
}; }
/** \brief /** \brief
* Deregisters itself at DOFAdmin. * Deregisters itself at DOFAdmin.
*/ */
~DOFVectorDOF() { ~DOFVectorDOF() {
feSpace->getAdmin()->removeDOFContainer(this); feSpace->getAdmin()->removeDOFContainer(this);
}; }
/** \brief /** \brief
* Implements DOFContainer::operator[]() by calling * Implements DOFContainer::operator[]() by calling
...@@ -735,14 +741,14 @@ namespace AMDiS { ...@@ -735,14 +741,14 @@ namespace AMDiS {
*/ */
DegreeOfFreedom& operator[](DegreeOfFreedom i) { DegreeOfFreedom& operator[](DegreeOfFreedom i) {
return DOFVector<DegreeOfFreedom>::operator[](i); return DOFVector<DegreeOfFreedom>::operator[](i);
}; }
/** \brief /** \brief
* Implements DOFIndexedBase::getSize() * Implements DOFIndexedBase::getSize()
*/ */
int getSize() const { int getSize() const {
return DOFVector<DegreeOfFreedom>::getSize(); return DOFVector<DegreeOfFreedom>::getSize();
}; }
/** \brief /** \brief
* Implements DOFIndexedBase::resize() * Implements DOFIndexedBase::resize()
...@@ -765,22 +771,22 @@ namespace AMDiS { ...@@ -765,22 +771,22 @@ namespace AMDiS {
template<typename T> template<typename T>
double norm(DOFVector<T> *vec) { double norm(DOFVector<T> *vec) {
return vec->nrm2(); return vec->nrm2();
}; }
template<typename T> template<typename T>
double L2Norm(DOFVector<T> *vec) { double L2Norm(DOFVector<T> *vec) {
return vec->L2Norm(); return vec->L2Norm();
}; }
template<typename T> template<typename T>
double H1Norm(DOFVector<T> *vec) { double H1Norm(DOFVector<T> *vec) {
return vec->H1Norm(); return vec->H1Norm();
}; }
template<typename T> template<typename T>
void print(DOFVector<T> *vec) { void print(DOFVector<T> *vec) {
vec->print(); vec->print();
}; }
// point wise multiplication // point wise multiplication
template<typename T> template<typename T>
...@@ -834,7 +840,9 @@ namespace AMDiS { ...@@ -834,7 +840,9 @@ namespace AMDiS {
void xpay(double a,const DOFVector<T>& x,DOFVector<T>& y); void xpay(double a,const DOFVector<T>& x,DOFVector<T>& y);
template<typename T> template<typename T>
inline void scal(T a, DOFVector<T>& y) {y*=a;}; inline void scal(T a, DOFVector<T>& y) {
y *= a;
}
template<typename T> template<typename T>
inline const DOFVector<T>& mult(double scal, inline const DOFVector<T>& mult(double scal,
...@@ -861,21 +869,19 @@ namespace AMDiS { ...@@ -861,21 +869,19 @@ namespace AMDiS {
template<typename T> template<typename T>
inline void set(DOFVector<T>& vec, T d) inline void set(DOFVector<T>& vec, T d) {
{
vec.set(d); vec.set(d);
}; }
template<typename T> template<typename T>
inline void setValue(DOFVector<T>& vec, T d) inline void setValue(DOFVector<T>& vec, T d) {
{
vec.set(d); vec.set(d);
}; }
template<typename T> template<typename T>
inline int size(DOFVector<T> *vec) { inline int size(DOFVector<T> *vec) {
return vec->getUsedSize(); return vec->getUsedSize();
}; }
WorldVector<DOFVector<double>*> *transform(DOFVector<WorldVector<double> > *vec, WorldVector<DOFVector<double>*> *transform(DOFVector<WorldVector<double> > *vec,
WorldVector<DOFVector<double>*> *result); WorldVector<DOFVector<double>*> *result);
......
...@@ -23,7 +23,6 @@ namespace AMDiS { ...@@ -23,7 +23,6 @@ namespace AMDiS {
// === get admin === // === get admin ===
localAdmin_ = const_cast<DOFAdmin*>(feSpace->getAdmin()); localAdmin_ = const_cast<DOFAdmin*>(feSpace->getAdmin());
// === create vertex info vector === // === create vertex info vector ===
vertexInfos_ = NEW DOFVector< std::list<VertexInfo> >(feSpace, "vertex infos"); vertexInfos_ = NEW DOFVector< std::list<VertexInfo> >(feSpace, "vertex infos");
interpPointInd_ = NEW DOFVector<int>(feSpace, "interpolation point indices"); interpPointInd_ = NEW DOFVector<int>(feSpace, "interpolation point indices");
...@@ -100,8 +99,9 @@ namespace AMDiS { ...@@ -100,8 +99,9 @@ namespace AMDiS {
// Traverse elements to create element information // Traverse elements to create element information
elInfo = stack.traverseFirst(mesh_, level_, flag); elInfo = stack.traverseFirst(mesh_, level_, flag);
while (elInfo) { while (elInfo) {
if (!writeElem_ || writeElem_(elInfo)) if (!writeElem_ || writeElem_(elInfo)) {
addElementData(elInfo); addElementData(elInfo);
}
elInfo = stack.traverseNext(elInfo); elInfo = stack.traverseNext(elInfo);
} }
...@@ -124,7 +124,7 @@ namespace AMDiS { ...@@ -124,7 +124,7 @@ namespace AMDiS {
basisFcts_ = const_cast<BasisFunction*>(feSpace_->getBasisFcts()); basisFcts_ = const_cast<BasisFunction*>(feSpace_->getBasisFcts());
nBasisFcts_ = basisFcts_->getNumber(); nBasisFcts_ = basisFcts_->getNumber();
localDOFs_ = GET_MEMORY(DegreeOfFreedom, nBasisFcts_); localDOFs_ = GET_MEMORY(DegreeOfFreedom, nBasisFcts_);
TraverseStack stack; TraverseStack stack;
// Traverse elements to add value information and to mark // Traverse elements to add value information and to mark
...@@ -133,8 +133,9 @@ namespace AMDiS { ...@@ -133,8 +133,9 @@ namespace AMDiS {
level_, level_,
traverseFlag_ | Mesh::FILL_COORDS); traverseFlag_ | Mesh::FILL_COORDS);
while (elInfo) { while (elInfo) {
if (!writeElem_ || writeElem_(elInfo)) if (!writeElem_ || writeElem_(elInfo)) {
addValueData(elInfo); addValueData(elInfo);
}
elInfo = stack.traverseNext(elInfo); elInfo = stack.traverseNext(elInfo);
} }
...@@ -158,7 +159,7 @@ namespace AMDiS { ...@@ -158,7 +159,7 @@ namespace AMDiS {
elInfo = stack.traverseNext(elInfo); elInfo = stack.traverseNext(elInfo);
} }
} }
FREE_MEMORY(localDOFs_, DegreeOfFreedom, nBasisFcts_); FREE_MEMORY(localDOFs_, DegreeOfFreedom, nBasisFcts_);
valueDataCollected_ = true; valueDataCollected_ = true;
...@@ -231,12 +232,10 @@ namespace AMDiS { ...@@ -231,12 +232,10 @@ namespace AMDiS {
} else { } else {
elementInfo.elementRegion = -1; elementInfo.elementRegion = -1;
} }
// read surface regions to element info // read surface regions to element info
ed = elInfo->getElement()->getElementData(SURFACE_REGION); ed = elInfo->getElement()->getElementData(SURFACE_REGION);
elementInfo.surfaceRegions.set(-1); elementInfo.surfaceRegions.set(-1);
while (ed) { while (ed) {
SurfaceRegion_ED *sr = dynamic_cast<SurfaceRegion_ED*>(ed); SurfaceRegion_ED *sr = dynamic_cast<SurfaceRegion_ED*>(ed);
elementInfo.surfaceRegions[sr->getSide()] = sr->getRegion(); elementInfo.surfaceRegions[sr->getSide()] = sr->getRegion();
...@@ -250,7 +249,7 @@ namespace AMDiS { ...@@ -250,7 +249,7 @@ namespace AMDiS {
// get dof index of this vertex // get dof index of this vertex
vertexDOF = dof[i][nPreDofs_]; vertexDOF = dof[i][nPreDofs_];
// search for coords at this dof // search for coords at this dof
std::list<VertexInfo>::iterator it = std::list<VertexInfo>::iterator it =
find((*vertexInfos_)[vertexDOF].begin(), find((*vertexInfos_)[vertexDOF].begin(),
...@@ -280,6 +279,7 @@ namespace AMDiS { ...@@ -280,6 +279,7 @@ namespace AMDiS {
outputIndices_[elInfo->getNeighbour(i)->getIndex()] : outputIndices_[elInfo->getNeighbour(i)->getIndex()] :
-1; -1;
} }
if (dim_ == 3) { if (dim_ == 3) {
elementInfo.type = (dynamic_cast<ElInfo3d*>(elInfo)->getType()); elementInfo.type = (dynamic_cast<ElInfo3d*>(elInfo)->getType());
...@@ -294,12 +294,11 @@ namespace AMDiS { ...@@ -294,12 +294,11 @@ namespace AMDiS {
int DataCollector::addValueData(ElInfo *elInfo) int DataCollector::addValueData(ElInfo *elInfo)
{ {
FUNCNAME("DataCollector::addValueData()"); FUNCNAME("DataCollector::addValueData()");
basisFcts_->getLocalIndices(elInfo->getElement(), localAdmin_, localDOFs_); basisFcts_->getLocalIndices(elInfo->getElement(), localAdmin_, localDOFs_);
// WorldVector<double> vertexCoords;
// First, traverse all DOFs at the vertices of the element, determine // First, traverse all DOFs at the vertices of the element, determine
// their coordinates and add them to the corresponding entry in dofCoords_. // their coordinates and add them to the corresponding entry in dofCoords_.
for (int i = 0; i < mesh_->getGeo(VERTEX); i++) { for (int i = 0; i < mesh_->getGeo(VERTEX); i++) {
DegreeOfFreedom dofi = localDOFs_[i]; DegreeOfFreedom dofi = localDOFs_[i];
...@@ -307,7 +306,7 @@ namespace AMDiS { ...@@ -307,7 +306,7 @@ namespace AMDiS {
// get coords of this vertex // get coords of this vertex
*vertexCoords = elInfo->getCoord(i);