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 {
{
}
int DOFAdmin::calcMemoryUsage()
{
return sizeof(DOFAdmin);
}
void DOFAdmin::serialize(std::ostream &out)
{
// write name
......
......@@ -284,6 +284,8 @@ namespace AMDiS {
mesh = m;
}
int calcMemoryUsage();
/** \} */
protected:
......
......@@ -545,6 +545,8 @@ namespace AMDiS {
int result = 0;
result += sizeof(Element);
result += mesh->getNumberOfNodes() * sizeof(DegreeOfFreedom*);
if (child[0]) {
result += child[0]->calcMemoryUsage() + child[1]->calcMemoryUsage();
}
......
......@@ -97,10 +97,20 @@ namespace AMDiS {
}
}
int FiniteElemSpace::calcMemoryUsage()
{
int result = sizeof(FiniteElemSpace);
result += mesh->calcMemoryUsage();
return result;
}
void FiniteElemSpace::clear()
{
for (int i = 0; i < feSpaces.size(); i++) {
DELETE feSpaces[i];
for (int i = 0; i < static_cast<int>(feSpaces.size()); i++) {
if (feSpaces[i]) {
DELETE feSpaces[i];
feSpaces[i] = NULL;
}
}
}
}
......@@ -106,6 +106,8 @@ namespace AMDiS {
return mesh;
}
int calcMemoryUsage();
static void clear();
protected:
......@@ -116,7 +118,7 @@ namespace AMDiS {
FiniteElemSpace(DOFAdmin* admin_,
const BasisFunction* basisFcts,
Mesh* mesh,
const std::string& name_ = "");
const std::string& name = "");
protected:
/** \brief
......
......@@ -75,7 +75,10 @@ namespace AMDiS {
{
std::list<Lagrange*>::iterator it;
for (it = allBasFcts.begin(); it != allBasFcts.end(); it++) {
DELETE *it;
if (*it) {
DELETE *it;
*it = NULL;
}
}
}
......
......@@ -1058,6 +1058,12 @@ namespace AMDiS {
{
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++) {
result += macroElements[i]->calcMemoryUsage();
}
......
......@@ -53,26 +53,12 @@ namespace AMDiS {
void push(T *solution,
double timestamp);
/** \brief
*
*/
void push(T *solution,
typename SolutionHelper<T>::type feSpace,
double timestamp);
/** \brief
*
*/
bool pop(T **solution,
double *timestep);
/** \brief
*
*/
bool pop(T **solution,
typename SolutionHelper<T>::type feSpace,
double *timestep);
/** \brief
* Deletes all pointers and empties all internal vectors.
*/
......@@ -88,18 +74,36 @@ namespace AMDiS {
return feSpaces[i];
}
/** \brief
*
*/
bool isPoped() {
return poped;
}
/** \brief
*
*/
void addContainer(std::string name);
/** \brief
*
*/
void push(std::string name, WorldVector<double> value);
/** \brief
*
*/
void pop(std::string name, WorldVector<double> &value);
/** \brief
*
*/
void reset(std::string name);
/** \brief
*
*/
void clear(std::string name);
protected:
......@@ -120,10 +124,16 @@ namespace AMDiS {
feSpaces.clear();
}
/** \brief
*
*/
int addMemoryUsage(FiniteElemSpace* feSpace) {
memoryUsage += feSpace->getMesh()->calcMemoryUsage();
}
/** \brief
*
*/
int addMemoryUsage(std::vector<FiniteElemSpace*> feSpaces) {
// Is used to determine equal meshes for different components.
std::vector<Mesh*> meshes;
......@@ -190,8 +200,14 @@ namespace AMDiS {
*/
int memoryUsage;
/** \brief
*
*/
std::map<std::string, std::vector<WorldVector<double > > > containers;
/** \brief
*
*/
std::map<std::string, int> containersPos;
};
......
......@@ -7,7 +7,8 @@ namespace AMDiS {
writeDirectory(""),
fixedFESpace(false),
lastPos(-1),
poped(false)
poped(false),
memoryUsage(0)
{
solutions.empty();
feSpaces.empty();
......@@ -43,34 +44,37 @@ namespace AMDiS {
void SolutionDataStorage<T>::push(T *solution,
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 (poped) {
clear();
poped = false;
}
solutions.push_back(solution);
solutions.push_back(vec);
timestamps.push_back(timestamp);
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>
......@@ -90,25 +94,6 @@ namespace AMDiS {
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>
void SolutionDataStorage<T>::clear()
{
......@@ -127,6 +112,7 @@ namespace AMDiS {
timestamps.clear();
lastPos = -1;
memoryUsage = 0;
}
template<typename T>
......
......@@ -341,6 +341,8 @@ namespace AMDiS {
result += vectors[i]->calcMemoryUsage();
}
result += sizeof(SystemVector);
return result;
}
......
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