Commit 9ce18f57 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

* More bugfixes for SolutionDataStorage support

parent 9544d86b
...@@ -82,7 +82,7 @@ namespace AMDiS { ...@@ -82,7 +82,7 @@ namespace AMDiS {
/** \brief /** \brief
* constructor * constructor
*/ */
DOFAdmin(Mesh* m,std::string aName); DOFAdmin(Mesh* m, std::string aName);
/** \brief /** \brief
* copy constructor * copy constructor
...@@ -92,7 +92,7 @@ namespace AMDiS { ...@@ -92,7 +92,7 @@ namespace AMDiS {
/** \brief /** \brief
* destructor * destructor
*/ */
virtual ~DOFAdmin(); ~DOFAdmin();
/** \brief /** \brief
* Enlarges the number of DOFs that can be managed at least to minsize by * Enlarges the number of DOFs that can be managed at least to minsize by
...@@ -115,7 +115,7 @@ namespace AMDiS { ...@@ -115,7 +115,7 @@ namespace AMDiS {
*/ */
inline bool operator!=(const DOFAdmin& ad) const { inline bool operator!=(const DOFAdmin& ad) const {
return !(ad==*this); return !(ad==*this);
}; }
/** \brief /** \brief
* Adds a DOFIndexedBase object to the DOFAdmin. This object will be * Adds a DOFIndexedBase object to the DOFAdmin. This object will be
......
...@@ -82,6 +82,8 @@ namespace AMDiS { ...@@ -82,6 +82,8 @@ namespace AMDiS {
if (this->boundaryManager) { if (this->boundaryManager) {
DELETE this->boundaryManager; DELETE this->boundaryManager;
} }
vec.clear();
} }
template<typename T> template<typename T>
......
...@@ -53,17 +53,58 @@ namespace AMDiS { ...@@ -53,17 +53,58 @@ namespace AMDiS {
// call destructor through Mesh::freeElement !!! // call destructor through Mesh::freeElement !!!
Element::~Element() Element::~Element()
{ {
if (child[0]) if (child[0]) {
DELETE child[0]; DELETE child[0];
if (child[1]) }
if (child[1]) {
DELETE child[1]; DELETE child[1];
}
if (newCoord) { if (newCoord) {
DELETE newCoord; DELETE newCoord;
} }
} }
void Element::deleteElementDOFs()
{
int dim = mesh->getDim();
int j = 0;
for (int pos = 0; pos <= dim; pos++) {
GeoIndex position = INDEX_OF_DIM(pos, dim);
int ndof = 0;
for (int i = 0; i < mesh->getNumberOfDOFAdmin(); i++) {
ndof += mesh->getDOFAdmin(i).getNumberOfDOFs(position);
}
if (ndof > 0) {
for (int i = 0; i < mesh->getGeo(position); i++) {
if (dof[j] != NULL) {
if (Mesh::serializedDOFs.count(dof[j][0]) == 0) {
// std::cout << "FREE INNER: " << ndof << std::endl;
FREE_MEMORY(dof[j], DegreeOfFreedom, ndof);
Mesh::serializedDOFs[dof[j][0]] = NULL;
}
}
j++;
}
}
}
// std::cout << "FREE OUTER: " << mesh->getNumberOfNodes() << std::endl;
FREE_MEMORY(dof, DegreeOfFreedom*, mesh->getNumberOfNodes());
if (child[0]) {
child[0]->deleteElementDOFs();
}
if (child[1]) {
child[1]->deleteElementDOFs();
}
}
Element* Element::cloneWithDOFs() Element* Element::cloneWithDOFs()
{ {
Element *el; Element *el;
......
...@@ -84,7 +84,7 @@ namespace AMDiS { ...@@ -84,7 +84,7 @@ namespace AMDiS {
/** \brief /** \brief
* private standard constructor because an Element must know his Mesh * private standard constructor because an Element must know his Mesh
*/ */
Element() {}; Element() {}
public: public:
/** \brief /** \brief
* constructs an Element which belongs to Mesh * constructs an Element which belongs to Mesh
...@@ -101,6 +101,8 @@ namespace AMDiS { ...@@ -101,6 +101,8 @@ namespace AMDiS {
*/ */
virtual ~Element(); virtual ~Element();
void deleteElementDOFs();
/** \brief /** \brief
* Clone this Element and return a reference to it. Because also the DOFs * Clone this Element and return a reference to it. Because also the DOFs
* are cloned, \ref Mesh::serializedDOfs must be used. * are cloned, \ref Mesh::serializedDOfs must be used.
......
...@@ -92,6 +92,7 @@ namespace AMDiS { ...@@ -92,6 +92,7 @@ namespace AMDiS {
elementDataPrototype(NULL), elementDataPrototype(NULL),
elementIndex(-1), elementIndex(-1),
initialized(false), initialized(false),
macroFileInfo(NULL),
final_lambda(dimension, DEFAULT_VALUE, 0.0) final_lambda(dimension, DEFAULT_VALUE, 0.0)
{ {
...@@ -118,7 +119,22 @@ namespace AMDiS { ...@@ -118,7 +119,22 @@ namespace AMDiS {
} }
Mesh::~Mesh() Mesh::~Mesh()
{} {
serializedDOFs.empty();
for (std::deque<MacroElement*>::const_iterator it = macroElements.begin();
it != macroElements.end();
++it) {
(*it)->getElement()->deleteElementDOFs();
DELETE *it;
}
serializedDOFs.empty();
if (macroFileInfo) {
DELETE macroFileInfo;
}
}
Mesh& Mesh::operator=(const Mesh& m) Mesh& Mesh::operator=(const Mesh& m)
{ {
...@@ -540,10 +556,10 @@ namespace AMDiS { ...@@ -540,10 +556,10 @@ namespace AMDiS {
bool Mesh::findElInfoAtPoint(const WorldVector<double>& xy, bool Mesh::findElInfoAtPoint(const WorldVector<double>& xy,
ElInfo *el_info, ElInfo *el_info,
DimVec<double>& bary, DimVec<double>& bary,
const MacroElement *start_mel, const MacroElement *start_mel,
const WorldVector<double> *xy0, const WorldVector<double> *xy0,
double *sp) double *sp)
{ {
static const MacroElement *mel = NULL; static const MacroElement *mel = NULL;
DimVec<double> lambda(dim, NO_INIT); DimVec<double> lambda(dim, NO_INIT);
...@@ -637,8 +653,9 @@ namespace AMDiS { ...@@ -637,8 +653,9 @@ namespace AMDiS {
MSG("outside finest level on el %d: s=%.3e\n", el->getIndex(), s); MSG("outside finest level on el %d: s=%.3e\n", el->getIndex(), s);
return(false); /* ??? */ return(false); /* ??? */
} else {
return(false);
} }
else return(false);
} }
} }
......
...@@ -52,9 +52,11 @@ namespace AMDiS { ...@@ -52,9 +52,11 @@ namespace AMDiS {
/** \brief /** \brief
* Returns the type name for this serializable object. * Returns the type name for this serializable object.
*/ */
virtual std::string getTypeName() const { return ""; }; virtual std::string getTypeName() const {
return "";
}
virtual ~Serializable() {}; virtual ~Serializable() {}
}; };
} }
......
...@@ -66,10 +66,6 @@ namespace AMDiS { ...@@ -66,10 +66,6 @@ namespace AMDiS {
typename SolutionHelper<T>::type feSpace, typename SolutionHelper<T>::type feSpace,
double *timestep); double *timestep);
T* getSolution() {
return solutions[0];
}
/** \brief /** \brief
* Deletes all pointers and empties all internal vectors. * Deletes all pointers and empties all internal vectors.
*/ */
...@@ -87,19 +83,20 @@ namespace AMDiS { ...@@ -87,19 +83,20 @@ namespace AMDiS {
protected: protected:
/** \brief /** \brief
* Auxiliary function for deleting either a single fe space, or a * Deletes the fe space and all it content, i.e., also the dof admin,
* vector of fe spaces. * mesh, etc.
*/ */
void deleteFeSpace(FiniteElemSpace* feSpace) { void deleteFeSpace(FiniteElemSpace* feSpace);
DELETE feSpace;
}
/** \brief
* Deletes a list of fe spaces.
*/
void deleteFeSpace(std::vector<FiniteElemSpace*> feSpaces) { void deleteFeSpace(std::vector<FiniteElemSpace*> feSpaces) {
for (int i = 0; i < static_cast<int>(feSpaces.size()); i++) { for (int i = 0; i < static_cast<int>(feSpaces.size()); i++) {
DELETE feSpaces[i]; deleteFeSpace(feSpaces[i]);
} }
feSpaces.empty(); feSpaces.clear();
} }
int addMemoryUsage(FiniteElemSpace* feSpace) { int addMemoryUsage(FiniteElemSpace* feSpace) {
......
...@@ -23,7 +23,6 @@ namespace AMDiS { ...@@ -23,7 +23,6 @@ namespace AMDiS {
template<typename T> template<typename T>
SolutionDataStorage<T>::~SolutionDataStorage() SolutionDataStorage<T>::~SolutionDataStorage()
{ {
clear();
} }
template<typename T> template<typename T>
...@@ -53,7 +52,7 @@ namespace AMDiS { ...@@ -53,7 +52,7 @@ namespace AMDiS {
timestamps.push_back(timestamp); timestamps.push_back(timestamp);
lastPos++; lastPos++;
memoryUsage += solution->calcMemoryUsage(); // memoryUsage += solution->calcMemoryUsage();
} }
template<typename T> template<typename T>
...@@ -112,25 +111,36 @@ namespace AMDiS { ...@@ -112,25 +111,36 @@ namespace AMDiS {
template<typename T> template<typename T>
void SolutionDataStorage<T>::clear() void SolutionDataStorage<T>::clear()
{ {
for (int i = 0; i < static_cast<int>(solutions.size()); i++) { for (int i = 1; i < static_cast<int>(solutions.size()); i++) {
DELETE solutions[i]; DELETE solutions[i];
} }
std::cout << "MARK 1" << std::endl;
if (!fixedFESpace) { if (!fixedFESpace) {
for (int i = 0; i < static_cast<int>(feSpaces.size()); i++) { for (int i = 0; i < static_cast<int>(feSpaces.size()); i++) {
deleteFeSpace(feSpaces[i]); deleteFeSpace(feSpaces[i]);
} }
} }
std::cout << "MARK 2" << std::endl;
solutions.clear(); solutions.clear();
feSpaces.clear(); feSpaces.clear();
timestamps.clear(); timestamps.clear();
lastPos = -1; lastPos = -1;
}
template<typename T>
void SolutionDataStorage<T>::deleteFeSpace(FiniteElemSpace *feSpace)
{
if (feSpace) {
if (feSpace->getMesh()) {
DELETE feSpace->getMesh();
}
if (feSpace->getAdmin()) {
DELETE feSpace->getAdmin();
}
DELETE feSpace;
}
} }
} }
...@@ -140,8 +140,12 @@ namespace AMDiS { ...@@ -140,8 +140,12 @@ namespace AMDiS {
} }
} }
virtual ~SystemVector() ~SystemVector()
{} {
for (int i = 0; i < vectors.getSize(); i++) {
DELETE vectors[i];
}
}
void createNewDOFVectors(std::string name) void createNewDOFVectors(std::string name)
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment