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 {
/** \brief
* constructor
*/
DOFAdmin(Mesh* m,std::string aName);
DOFAdmin(Mesh* m, std::string aName);
/** \brief
* copy constructor
......@@ -92,7 +92,7 @@ namespace AMDiS {
/** \brief
* destructor
*/
virtual ~DOFAdmin();
~DOFAdmin();
/** \brief
* Enlarges the number of DOFs that can be managed at least to minsize by
......@@ -115,7 +115,7 @@ namespace AMDiS {
*/
inline bool operator!=(const DOFAdmin& ad) const {
return !(ad==*this);
};
}
/** \brief
* Adds a DOFIndexedBase object to the DOFAdmin. This object will be
......
......@@ -82,6 +82,8 @@ namespace AMDiS {
if (this->boundaryManager) {
DELETE this->boundaryManager;
}
vec.clear();
}
template<typename T>
......
......@@ -54,16 +54,57 @@ namespace AMDiS {
// call destructor through Mesh::freeElement !!!
Element::~Element()
{
if (child[0])
if (child[0]) {
DELETE child[0];
if (child[1])
}
if (child[1]) {
DELETE child[1];
}
if (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 *el;
......
......@@ -84,7 +84,7 @@ namespace AMDiS {
/** \brief
* private standard constructor because an Element must know his Mesh
*/
Element() {};
Element() {}
public:
/** \brief
* constructs an Element which belongs to Mesh
......@@ -101,6 +101,8 @@ namespace AMDiS {
*/
virtual ~Element();
void deleteElementDOFs();
/** \brief
* Clone this Element and return a reference to it. Because also the DOFs
* are cloned, \ref Mesh::serializedDOfs must be used.
......
......@@ -92,6 +92,7 @@ namespace AMDiS {
elementDataPrototype(NULL),
elementIndex(-1),
initialized(false),
macroFileInfo(NULL),
final_lambda(dimension, DEFAULT_VALUE, 0.0)
{
......@@ -118,7 +119,22 @@ namespace AMDiS {
}
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)
{
......@@ -637,8 +653,9 @@ namespace AMDiS {
MSG("outside finest level on el %d: s=%.3e\n", el->getIndex(), s);
return(false); /* ??? */
} else {
return(false);
}
else return(false);
}
}
......
......@@ -52,9 +52,11 @@ namespace AMDiS {
/** \brief
* 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 {
typename SolutionHelper<T>::type feSpace,
double *timestep);
T* getSolution() {
return solutions[0];
}
/** \brief
* Deletes all pointers and empties all internal vectors.
*/
......@@ -87,19 +83,20 @@ namespace AMDiS {
protected:
/** \brief
* Auxiliary function for deleting either a single fe space, or a
* vector of fe spaces.
* Deletes the fe space and all it content, i.e., also the dof admin,
* mesh, etc.
*/
void deleteFeSpace(FiniteElemSpace* feSpace) {
DELETE feSpace;
}
void deleteFeSpace(FiniteElemSpace* feSpace);
/** \brief
* Deletes a list of fe spaces.
*/
void deleteFeSpace(std::vector<FiniteElemSpace*> feSpaces) {
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) {
......
......@@ -23,7 +23,6 @@ namespace AMDiS {
template<typename T>
SolutionDataStorage<T>::~SolutionDataStorage()
{
clear();
}
template<typename T>
......@@ -53,7 +52,7 @@ namespace AMDiS {
timestamps.push_back(timestamp);
lastPos++;
memoryUsage += solution->calcMemoryUsage();
// memoryUsage += solution->calcMemoryUsage();
}
template<typename T>
......@@ -112,20 +111,16 @@ namespace AMDiS {
template<typename T>
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];
}
std::cout << "MARK 1" << std::endl;
if (!fixedFESpace) {
for (int i = 0; i < static_cast<int>(feSpaces.size()); i++) {
deleteFeSpace(feSpaces[i]);
}
}
std::cout << "MARK 2" << std::endl;
solutions.clear();
feSpaces.clear();
timestamps.clear();
......@@ -133,4 +128,19 @@ namespace AMDiS {
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 {
}
}
virtual ~SystemVector()
{}
~SystemVector()
{
for (int i = 0; i < vectors.getSize(); i++) {
DELETE vectors[i];
}
}
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