Commit 988bfc8d authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

* Ein paar kleine Aenderungen, was denn sonst

parent 561814e2
...@@ -340,6 +340,11 @@ namespace AMDiS { ...@@ -340,6 +340,11 @@ namespace AMDiS {
{ {
} }
int DOFAdmin::calcMemoryUsage()
{
return sizeof(DOFAdmin);
}
void DOFAdmin::serialize(std::ostream &out) void DOFAdmin::serialize(std::ostream &out)
{ {
// write name // write name
......
...@@ -284,6 +284,8 @@ namespace AMDiS { ...@@ -284,6 +284,8 @@ namespace AMDiS {
mesh = m; mesh = m;
} }
int calcMemoryUsage();
/** \} */ /** \} */
protected: protected:
......
...@@ -545,6 +545,8 @@ namespace AMDiS { ...@@ -545,6 +545,8 @@ namespace AMDiS {
int result = 0; int result = 0;
result += sizeof(Element); result += sizeof(Element);
result += mesh->getNumberOfNodes() * sizeof(DegreeOfFreedom*);
if (child[0]) { if (child[0]) {
result += child[0]->calcMemoryUsage() + child[1]->calcMemoryUsage(); result += child[0]->calcMemoryUsage() + child[1]->calcMemoryUsage();
} }
......
...@@ -97,10 +97,20 @@ namespace AMDiS { ...@@ -97,10 +97,20 @@ namespace AMDiS {
} }
} }
int FiniteElemSpace::calcMemoryUsage()
{
int result = sizeof(FiniteElemSpace);
result += mesh->calcMemoryUsage();
return result;
}
void FiniteElemSpace::clear() void FiniteElemSpace::clear()
{ {
for (int i = 0; i < feSpaces.size(); i++) { for (int i = 0; i < static_cast<int>(feSpaces.size()); i++) {
DELETE feSpaces[i]; if (feSpaces[i]) {
DELETE feSpaces[i];
feSpaces[i] = NULL;
}
} }
} }
} }
...@@ -106,6 +106,8 @@ namespace AMDiS { ...@@ -106,6 +106,8 @@ namespace AMDiS {
return mesh; return mesh;
} }
int calcMemoryUsage();
static void clear(); static void clear();
protected: protected:
...@@ -116,7 +118,7 @@ namespace AMDiS { ...@@ -116,7 +118,7 @@ namespace AMDiS {
FiniteElemSpace(DOFAdmin* admin_, FiniteElemSpace(DOFAdmin* admin_,
const BasisFunction* basisFcts, const BasisFunction* basisFcts,
Mesh* mesh, Mesh* mesh,
const std::string& name_ = ""); const std::string& name = "");
protected: protected:
/** \brief /** \brief
......
...@@ -75,7 +75,10 @@ namespace AMDiS { ...@@ -75,7 +75,10 @@ namespace AMDiS {
{ {
std::list<Lagrange*>::iterator it; std::list<Lagrange*>::iterator it;
for (it = allBasFcts.begin(); it != allBasFcts.end(); it++) { for (it = allBasFcts.begin(); it != allBasFcts.end(); it++) {
DELETE *it; if (*it) {
DELETE *it;
*it = NULL;
}
} }
} }
......
...@@ -1058,6 +1058,12 @@ namespace AMDiS { ...@@ -1058,6 +1058,12 @@ namespace AMDiS {
{ {
int result = sizeof(Mesh); int result = sizeof(Mesh);
result += nDOFEl;
for (int i = 0; i < static_cast<int>(admin.size()); i++) {
result += admin[i]->calcMemoryUsage();
result += admin[i]->getUsedSize() * sizeof(DegreeOfFreedom);
}
for (int i = 0; i < static_cast<int>(macroElements.size()); i++) { for (int i = 0; i < static_cast<int>(macroElements.size()); i++) {
result += macroElements[i]->calcMemoryUsage(); result += macroElements[i]->calcMemoryUsage();
} }
......
...@@ -53,26 +53,12 @@ namespace AMDiS { ...@@ -53,26 +53,12 @@ namespace AMDiS {
void push(T *solution, void push(T *solution,
double timestamp); double timestamp);
/** \brief
*
*/
void push(T *solution,
typename SolutionHelper<T>::type feSpace,
double timestamp);
/** \brief /** \brief
* *
*/ */
bool pop(T **solution, bool pop(T **solution,
double *timestep); double *timestep);
/** \brief
*
*/
bool pop(T **solution,
typename SolutionHelper<T>::type feSpace,
double *timestep);
/** \brief /** \brief
* Deletes all pointers and empties all internal vectors. * Deletes all pointers and empties all internal vectors.
*/ */
...@@ -88,18 +74,36 @@ namespace AMDiS { ...@@ -88,18 +74,36 @@ namespace AMDiS {
return feSpaces[i]; return feSpaces[i];
} }
/** \brief
*
*/
bool isPoped() { bool isPoped() {
return poped; return poped;
} }
/** \brief
*
*/
void addContainer(std::string name); void addContainer(std::string name);
/** \brief
*
*/
void push(std::string name, WorldVector<double> value); void push(std::string name, WorldVector<double> value);
/** \brief
*
*/
void pop(std::string name, WorldVector<double> &value); void pop(std::string name, WorldVector<double> &value);
/** \brief
*
*/
void reset(std::string name); void reset(std::string name);
/** \brief
*
*/
void clear(std::string name); void clear(std::string name);
protected: protected:
...@@ -120,10 +124,16 @@ namespace AMDiS { ...@@ -120,10 +124,16 @@ namespace AMDiS {
feSpaces.clear(); feSpaces.clear();
} }
/** \brief
*
*/
int addMemoryUsage(FiniteElemSpace* feSpace) { int addMemoryUsage(FiniteElemSpace* feSpace) {
memoryUsage += feSpace->getMesh()->calcMemoryUsage(); memoryUsage += feSpace->getMesh()->calcMemoryUsage();
} }
/** \brief
*
*/
int addMemoryUsage(std::vector<FiniteElemSpace*> feSpaces) { int addMemoryUsage(std::vector<FiniteElemSpace*> feSpaces) {
// Is used to determine equal meshes for different components. // Is used to determine equal meshes for different components.
std::vector<Mesh*> meshes; std::vector<Mesh*> meshes;
...@@ -190,8 +200,14 @@ namespace AMDiS { ...@@ -190,8 +200,14 @@ namespace AMDiS {
*/ */
int memoryUsage; int memoryUsage;
/** \brief
*
*/
std::map<std::string, std::vector<WorldVector<double > > > containers; std::map<std::string, std::vector<WorldVector<double > > > containers;
/** \brief
*
*/
std::map<std::string, int> containersPos; std::map<std::string, int> containersPos;
}; };
......
...@@ -7,7 +7,8 @@ namespace AMDiS { ...@@ -7,7 +7,8 @@ namespace AMDiS {
writeDirectory(""), writeDirectory(""),
fixedFESpace(false), fixedFESpace(false),
lastPos(-1), lastPos(-1),
poped(false) poped(false),
memoryUsage(0)
{ {
solutions.empty(); solutions.empty();
feSpaces.empty(); feSpaces.empty();
...@@ -43,34 +44,37 @@ namespace AMDiS { ...@@ -43,34 +44,37 @@ namespace AMDiS {
void SolutionDataStorage<T>::push(T *solution, void SolutionDataStorage<T>::push(T *solution,
double timestamp) double timestamp)
{ {
FUNCNAME("SolutionDataStorage<T>::push()");
if (fixedFESpace) {
ERROR_EXIT("Not yet\n");
}
std::vector<FiniteElemSpace*> feSpace(solution->getFESpaces().size());
for (int i = 0; i < feSpace.size(); i++) {
feSpace[i] = NEW FiniteElemSpace();
*(feSpace[i]) = *(solution->getFESpace(i));
memoryUsage += feSpace[i]->calcMemoryUsage();
}
feSpaces.push_back(feSpace);
SystemVector *vec = NEW SystemVector("tmp", feSpace, solution->getFESpaces().size());
vec->createNewDOFVectors("tmp");
vec->setCoarsenOperation(COARSE_INTERPOL);
vec->interpol(solution, 1.0);
memoryUsage += vec->calcMemoryUsage();
// If pop was the last operation, cleanup and reset the data storage. // If pop was the last operation, cleanup and reset the data storage.
if (poped) { if (poped) {
clear(); clear();
poped = false; poped = false;
} }
solutions.push_back(solution); solutions.push_back(vec);
timestamps.push_back(timestamp); timestamps.push_back(timestamp);
lastPos++; lastPos++;
// memoryUsage += solution->calcMemoryUsage();
}
template<typename T>
void SolutionDataStorage<T>::push(T *solution,
typename SolutionHelper<T>::type feSpace,
double timestamp)
{
FUNCNAME("SolutionDataStorage<T>::push()");
push(solution, timestamp);
// Store fe space only, if we do not have a fixed fe space.
TEST_EXIT(!fixedFESpace)("push wit fe space not possible!\n");
if (!fixedFESpace) {
feSpaces.push_back(feSpace);
}
} }
template<typename T> template<typename T>
...@@ -90,25 +94,6 @@ namespace AMDiS { ...@@ -90,25 +94,6 @@ namespace AMDiS {
return true; return true;
} }
template<typename T>
bool SolutionDataStorage<T>::pop(T **solution,
typename SolutionHelper<T>::type feSpace,
double *timestep)
{
if (!pop(solution, timestep))
return false;
if (!fixedFESpace) {
feSpace = feSpaces[lastPos + 1]; // + 1, because lastPos was decremented in pop call above
} else {
feSpace = feSpaces[0];
}
return true;
}
template<typename T> template<typename T>
void SolutionDataStorage<T>::clear() void SolutionDataStorage<T>::clear()
{ {
...@@ -127,6 +112,7 @@ namespace AMDiS { ...@@ -127,6 +112,7 @@ namespace AMDiS {
timestamps.clear(); timestamps.clear();
lastPos = -1; lastPos = -1;
memoryUsage = 0;
} }
template<typename T> template<typename T>
......
...@@ -341,6 +341,8 @@ namespace AMDiS { ...@@ -341,6 +341,8 @@ namespace AMDiS {
result += vectors[i]->calcMemoryUsage(); result += vectors[i]->calcMemoryUsage();
} }
result += sizeof(SystemVector);
return result; return result;
} }
......
Supports Markdown
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