Commit efd6a256 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Removed some *_MEMORY macros

parent f696ed01
...@@ -15,7 +15,7 @@ namespace AMDiS { ...@@ -15,7 +15,7 @@ namespace AMDiS {
dofIndices.resize(omp_get_overall_max_threads()); dofIndices.resize(omp_get_overall_max_threads());
allocatedMemoryLocalBounds = feSpace->getBasisFcts()->getNumber(); allocatedMemoryLocalBounds = feSpace->getBasisFcts()->getNumber();
for (int i = 0; i < static_cast<int>(localBounds.size()); i++) for (int i = 0; i < static_cast<int>(localBounds.size()); i++)
localBounds[i] = GET_MEMORY(BoundaryType, allocatedMemoryLocalBounds); localBounds[i] = new BoundaryType[allocatedMemoryLocalBounds];
} }
BoundaryManager::BoundaryManager(BoundaryManager &bm) BoundaryManager::BoundaryManager(BoundaryManager &bm)
...@@ -25,13 +25,13 @@ namespace AMDiS { ...@@ -25,13 +25,13 @@ namespace AMDiS {
localBounds.resize(bm.localBounds.size()); localBounds.resize(bm.localBounds.size());
dofIndices.resize(bm.localBounds.size()); dofIndices.resize(bm.localBounds.size());
for (int i = 0; i < static_cast<int>(localBounds.size()); i++) for (int i = 0; i < static_cast<int>(localBounds.size()); i++)
localBounds[i] = GET_MEMORY(BoundaryType, allocatedMemoryLocalBounds); localBounds[i] = new BoundaryType[allocatedMemoryLocalBounds];
} }
BoundaryManager::~BoundaryManager() BoundaryManager::~BoundaryManager()
{ {
for (int i = 0; i < static_cast<int>(localBounds.size()); i++) for (int i = 0; i < static_cast<int>(localBounds.size()); i++)
FREE_MEMORY(localBounds[i], BoundaryType, allocatedMemoryLocalBounds); delete [] localBounds[i];
} }
double BoundaryManager::boundResidual(ElInfo *elInfo, double BoundaryManager::boundResidual(ElInfo *elInfo,
...@@ -40,10 +40,10 @@ namespace AMDiS { ...@@ -40,10 +40,10 @@ namespace AMDiS {
{ {
double result = 0.0; double result = 0.0;
std::map<BoundaryType, BoundaryCondition*>::iterator it; std::map<BoundaryType, BoundaryCondition*>::iterator it;
for (it = localBCs.begin(); it != localBCs.end(); ++it) { for (it = localBCs.begin(); it != localBCs.end(); ++it)
if ((*it).second) if ((*it).second)
result += (*it).second->boundResidual(elInfo, matrix, dv); result += (*it).second->boundResidual(elInfo, matrix, dv);
}
return result; return result;
} }
......
...@@ -484,7 +484,7 @@ namespace AMDiS { ...@@ -484,7 +484,7 @@ namespace AMDiS {
this->set(0.0); this->set(0.0);
DegreeOfFreedom *myLocalIndices = localIndices[omp_get_thread_num()]; DegreeOfFreedom *myLocalIndices = localIndices[omp_get_thread_num()];
double *sourceLocalCoeffs = GET_MEMORY(double, nSourceBasisFcts); double *sourceLocalCoeffs = new double[nSourceBasisFcts];
if (feSpace->getMesh() == sourceFeSpace->getMesh()) { if (feSpace->getMesh() == sourceFeSpace->getMesh()) {
DimVec<double> *coords = NULL; DimVec<double> *coords = NULL;
...@@ -552,7 +552,7 @@ namespace AMDiS { ...@@ -552,7 +552,7 @@ namespace AMDiS {
} }
} }
FREE_MEMORY(sourceLocalCoeffs, double, nSourceBasisFcts); delete [] sourceLocalCoeffs;
} }
...@@ -564,12 +564,10 @@ namespace AMDiS { ...@@ -564,12 +564,10 @@ namespace AMDiS {
this->set(nul); this->set(nul);
DimVec<double> *coords = NULL; DimVec<double> *coords = NULL;
const FiniteElemSpace *vFESpace = v->getFESpace(); const FiniteElemSpace *vFESpace = v->getFESpace();
if (feSpace == vFESpace) { if (feSpace == vFESpace)
WARNING("same FE-spaces\n"); WARNING("same FE-spaces\n");
}
const BasisFunction *basFcts = feSpace->getBasisFcts(); const BasisFunction *basFcts = feSpace->getBasisFcts();
const BasisFunction *vBasFcts = vFESpace->getBasisFcts(); const BasisFunction *vBasFcts = vFESpace->getBasisFcts();
......
...@@ -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_ = new DegreeOfFreedom[nBasisFcts_];
TraverseStack stack; TraverseStack stack;
...@@ -161,10 +161,10 @@ namespace AMDiS { ...@@ -161,10 +161,10 @@ namespace AMDiS {
} }
} }
FREE_MEMORY(localDOFs_, DegreeOfFreedom, nBasisFcts_); delete [] localDOFs_;
valueDataCollected_ = true; valueDataCollected_ = true;
return(0); return 0;
} }
int DataCollector::startCollectingPeriodicData() int DataCollector::startCollectingPeriodicData()
......
...@@ -103,7 +103,7 @@ namespace AMDiS { ...@@ -103,7 +103,7 @@ namespace AMDiS {
if (dof[j]) { if (dof[j]) {
if (deletedDOFs.count(dof[j]) == 0) { if (deletedDOFs.count(dof[j]) == 0) {
deletedDOFs[dof[j]] = true; deletedDOFs[dof[j]] = true;
FREE_MEMORY(dof[j], DegreeOfFreedom, ndof); delete [] dof[j];
} }
} }
j++; j++;
...@@ -113,12 +113,10 @@ namespace AMDiS { ...@@ -113,12 +113,10 @@ namespace AMDiS {
FREE_MEMORY(dof, DegreeOfFreedom*, mesh->getNumberOfNodes()); FREE_MEMORY(dof, DegreeOfFreedom*, mesh->getNumberOfNodes());
if (child[0]) { if (child[0])
child[0]->deleteElementDOFs(); child[0]->deleteElementDOFs();
} if (child[1])
if (child[1]) {
child[1]->deleteElementDOFs(); child[1]->deleteElementDOFs();
}
} }
Element* Element::cloneWithDOFs() Element* Element::cloneWithDOFs()
...@@ -144,7 +142,7 @@ namespace AMDiS { ...@@ -144,7 +142,7 @@ namespace AMDiS {
/* =========== And here we clone the DOFs =========== */ /* =========== And here we clone the DOFs =========== */
el->dof = GET_MEMORY(DegreeOfFreedom*, mesh->getNumberOfNodes()); el->dof = new DegreeOfFreedom*[mesh->getNumberOfNodes()];
int dim = mesh->getDim(); int dim = mesh->getDim();
int j = 0; int j = 0;
...@@ -153,18 +151,17 @@ namespace AMDiS { ...@@ -153,18 +151,17 @@ namespace AMDiS {
GeoIndex position = INDEX_OF_DIM(pos, dim); GeoIndex position = INDEX_OF_DIM(pos, dim);
int ndof = 0; int ndof = 0;
for (int i = 0; i < mesh->getNumberOfDOFAdmin(); i++) { for (int i = 0; i < mesh->getNumberOfDOFAdmin(); i++)
ndof += mesh->getDOFAdmin(i).getNumberOfDOFs(position); ndof += mesh->getDOFAdmin(i).getNumberOfDOFs(position);
}
if (ndof > 0) { if (ndof > 0) {
for (int i = 0; i < mesh->getGeo(position); i++) { for (int i = 0; i < mesh->getGeo(position); i++) {
if (dof[j] != NULL) { if (dof[j] != NULL) {
if (Mesh::serializedDOFs[dof[j][0]] == NULL) { if (Mesh::serializedDOFs[dof[j][0]] == NULL) {
el->dof[j] = GET_MEMORY(DegreeOfFreedom, ndof); el->dof[j] = new DegreeOfFreedom[ndof];
for (int k = 0; k < ndof; k++) { for (int k = 0; k < ndof; k++)
el->dof[j][k] = dof[j][k]; el->dof[j][k] = dof[j][k];
}
Mesh::serializedDOFs[dof[j][0]] = el->dof[j]; Mesh::serializedDOFs[dof[j][0]] = el->dof[j];
} else { } else {
el->dof[j] = Mesh::serializedDOFs[dof[j][0]]; el->dof[j] = Mesh::serializedDOFs[dof[j][0]];
...@@ -466,7 +463,7 @@ namespace AMDiS { ...@@ -466,7 +463,7 @@ namespace AMDiS {
int nodes; int nodes;
in.read(reinterpret_cast<char*>(&nodes), sizeof(int)); in.read(reinterpret_cast<char*>(&nodes), sizeof(int));
dof = GET_MEMORY(DegreeOfFreedom*, nodes); dof = new DegreeOfFreedom*[nodes];
for (int i = 0; i < nodes; i++) { for (int i = 0; i < nodes; i++) {
int dofs; int dofs;
...@@ -474,11 +471,11 @@ namespace AMDiS { ...@@ -474,11 +471,11 @@ namespace AMDiS {
if (dofs) { if (dofs) {
if (dofs != -1) { if (dofs != -1) {
dof[i] = GET_MEMORY(DegreeOfFreedom, dofs); dof[i] = new DegreeOfFreedom[dofs];
in.read(reinterpret_cast<char*>(dof[i]), dofs * sizeof(DegreeOfFreedom)); in.read(reinterpret_cast<char*>(dof[i]), dofs * sizeof(DegreeOfFreedom));
if (Mesh::serializedDOFs[dof[i][0]] != NULL) { if (Mesh::serializedDOFs[dof[i][0]] != NULL) {
DegreeOfFreedom *dofPtr = Mesh::serializedDOFs[dof[i][0]]; DegreeOfFreedom *dofPtr = Mesh::serializedDOFs[dof[i][0]];
FREE_MEMORY(dof[i], DegreeOfFreedom, dofs); delete [] dof[i];
dof[i] = dofPtr; dof[i] = dofPtr;
} else { } else {
Mesh::serializedDOFs[dof[i][0]] = dof[i]; Mesh::serializedDOFs[dof[i][0]] = dof[i];
......
...@@ -9,24 +9,21 @@ namespace AMDiS { ...@@ -9,24 +9,21 @@ namespace AMDiS {
va_start(arg, size); va_start(arg, size);
VectorOfFixVecs<DimVec<double> > *result = VectorOfFixVecs<DimVec<double> > *result =
new VectorOfFixVecs<DimVec<double> >(dim, size, NO_INIT); new VectorOfFixVecs<DimVec<double> >(dim, size, NO_INIT);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++)
for (int j = 0; j < dim + 1; j++) { for (int j = 0; j < dim + 1; j++)
(*result)[i][j] = va_arg(arg, double); (*result)[i][j] = va_arg(arg, double);
}
}
va_end(arg); va_end(arg);
return result; return result;
}; }
double* createAndInitArray(int size, ...) double* createAndInitArray(int size, ...)
{ {
va_list arg; va_list arg;
va_start(arg, size); va_start(arg, size);
double *result = GET_MEMORY(double, size); double *result = new double[size];
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++)
result[i] = va_arg(arg, double); result[i] = va_arg(arg, double);
}
va_end(arg); va_end(arg);
return result; return result;
......
...@@ -22,51 +22,44 @@ namespace AMDiS { ...@@ -22,51 +22,44 @@ namespace AMDiS {
void GNUPlotWriter::writeFiles(AdaptInfo *adaptInfo, bool force) void GNUPlotWriter::writeFiles(AdaptInfo *adaptInfo, bool force)
{ {
DOFVector<WorldVector<double> > coords(feSpace_, "coords"); DOFVector<WorldVector<double> > coords(feSpace_, "coords");
Mesh *mesh = feSpace_->getMesh(); Mesh *mesh = feSpace_->getMesh();
int dow = Global::getGeo(WORLD); int dow = Global::getGeo(WORLD);
const BasisFunction *basFcts = feSpace_->getBasisFcts(); const BasisFunction *basFcts = feSpace_->getBasisFcts();
int i, numFcts = basFcts->getNumber(); int numFcts = basFcts->getNumber();
DegreeOfFreedom *localDOFs = GET_MEMORY(DegreeOfFreedom, numFcts); DegreeOfFreedom *localDOFs = new DegreeOfFreedom[numFcts];
TraverseStack stack; TraverseStack stack;
ElInfo *elInfo = stack.traverseFirst(mesh, -1, ElInfo *elInfo = stack.traverseFirst(mesh, -1,
Mesh::CALL_LEAF_EL | Mesh::CALL_LEAF_EL |
Mesh::FILL_COORDS); Mesh::FILL_COORDS);
while(elInfo) { while (elInfo) {
basFcts->getLocalIndices(elInfo->getElement(), basFcts->getLocalIndices(elInfo->getElement(),
feSpace_->getAdmin(), feSpace_->getAdmin(),
localDOFs); localDOFs);
for(i = 0; i < numFcts; i++) { for (int i = 0; i < numFcts; i++)
coords[localDOFs[i]] = elInfo->getCoord(i); coords[localDOFs[i]] = elInfo->getCoord(i);
}
elInfo = stack.traverseNext(elInfo); elInfo = stack.traverseNext(elInfo);
} }
FREE_MEMORY(localDOFs, DegreeOfFreedom, numFcts); delete [] localDOFs;
FILE *file = NULL; FILE *file = NULL;
if (!(file = fopen(filename_.c_str(), "w"))) if (!(file = fopen(filename_.c_str(), "w")))
{ ERROR("could not open file %s for writing\n", filename_.c_str());
ERROR("could not open file %s for writing\n", filename_.c_str());
}
fprintf(file, "# line format: time x y z val1[x,y,z] val2[x,y,z] ...\n"); fprintf(file, "# line format: time x y z val1[x,y,z] val2[x,y,z] ...\n");
DOFVector<WorldVector<double> >::Iterator coordsIt(&coords, USED_DOFS); DOFVector<WorldVector<double> >::Iterator coordsIt(&coords, USED_DOFS);
int index, numVecs = static_cast<int>(dofVectors_.size()); int index, numVecs = static_cast<int>(dofVectors_.size());
for(coordsIt.reset(); !coordsIt.end(); ++coordsIt) { for (coordsIt.reset(); !coordsIt.end(); ++coordsIt) {
index = coordsIt.getDOFIndex(); index = coordsIt.getDOFIndex();
fprintf(file, "%e ", adaptInfo->getTime()); fprintf(file, "%e ", adaptInfo->getTime());
for(i = 0; i < dow; i++) { for (int i = 0; i < dow; i++)
fprintf(file, "%e ", (*coordsIt)[i]); fprintf(file, "%e ", (*coordsIt)[i]);
} for (int i = 0; i < numVecs; i++)
for(i = 0; i < numVecs; i++) {
fprintf(file, "%e ", (*(dofVectors_[i]))[index]); fprintf(file, "%e ", (*(dofVectors_[i]))[index]);
}
fprintf(file, "\n"); fprintf(file, "\n");
} }
} }
......
...@@ -494,7 +494,7 @@ namespace AMDiS { ...@@ -494,7 +494,7 @@ namespace AMDiS {
if (ndof <= 0) if (ndof <= 0)
return NULL; return NULL;
DegreeOfFreedom *dof = GET_MEMORY(DegreeOfFreedom, ndof); DegreeOfFreedom *dof = new DegreeOfFreedom[ndof];
for (int i = 0; i < getNumberOfDOFAdmin(); i++) { for (int i = 0; i < getNumberOfDOFAdmin(); i++) {
const DOFAdmin *localAdmin = &getDOFAdmin(i); const DOFAdmin *localAdmin = &getDOFAdmin(i);
...@@ -505,9 +505,8 @@ namespace AMDiS { ...@@ -505,9 +505,8 @@ namespace AMDiS {
TEST_EXIT_DBG(n + n0 <= ndof)("n=%d, n0=%d too large: ndof=%d\n", n, n0, ndof); TEST_EXIT_DBG(n + n0 <= ndof)("n=%d, n0=%d too large: ndof=%d\n", n, n0, ndof);
for (int j = 0; j < n; j++) { for (int j = 0; j < n; j++)
dof[n0 + j] = const_cast<DOFAdmin*>(localAdmin)->getDOFIndex(); dof[n0 + j] = const_cast<DOFAdmin*>(localAdmin)->getDOFIndex();
}
} }
return dof; return dof;
...@@ -521,7 +520,7 @@ namespace AMDiS { ...@@ -521,7 +520,7 @@ namespace AMDiS {
if (nNodeEl <= 0) if (nNodeEl <= 0)
return NULL; return NULL;
DegreeOfFreedom **ptrs = GET_MEMORY(DegreeOfFreedom*, nNodeEl); DegreeOfFreedom **ptrs = new DegreeOfFreedom*[nNodeEl];
for (int i = 0; i < nNodeEl; i++) for (int i = 0; i < nNodeEl; i++)
ptrs[i] = NULL; ptrs[i] = NULL;
...@@ -537,7 +536,7 @@ namespace AMDiS { ...@@ -537,7 +536,7 @@ namespace AMDiS {
if (nNodeEl <= 0) if (nNodeEl <= 0)
return; return;
FREE_MEMORY(ptrs, DegreeOfFreedom*, nNodeEl); delete [] ptrs;
} }
...@@ -606,7 +605,7 @@ namespace AMDiS { ...@@ -606,7 +605,7 @@ namespace AMDiS {
localAdmin->freeDOFIndex(dof[n0 + j]); localAdmin->freeDOFIndex(dof[n0 + j]);
} }
FREE_MEMORY(dof, DegreeOfFreedom, ndof); delete [] dof;
} }
void Mesh::freeElement(Element* el) void Mesh::freeElement(Element* el)
......
...@@ -26,9 +26,8 @@ namespace AMDiS { ...@@ -26,9 +26,8 @@ namespace AMDiS {
const FiniteElemSpace *feSpace = const FiniteElemSpace *feSpace =
F ? F->getFESpace() : df->getFESpace(); F ? F->getFESpace() : df->getFESpace();
if (updateDF) { if (updateDF)
df->clear(); df->clear();
}
BasisFunction *basFcts = const_cast<BasisFunction*>(feSpace->getBasisFcts()); BasisFunction *basFcts = const_cast<BasisFunction*>(feSpace->getBasisFcts());
...@@ -43,24 +42,21 @@ namespace AMDiS { ...@@ -43,24 +42,21 @@ namespace AMDiS {
Mesh::FILL_DET| Mesh::FILL_DET|
Mesh::FILL_GRD_LAMBDA; Mesh::FILL_GRD_LAMBDA;
BoundaryType *bound = GET_MEMORY(BoundaryType, feSpace->getBasisFcts()->getNumber()); BoundaryType *bound = new BoundaryType[feSpace->getBasisFcts()->getNumber()];
el_info = stack.traverseFirst(feSpace->getMesh(), -1, fill_flag); el_info = stack.traverseFirst(feSpace->getMesh(), -1, fill_flag);
while (el_info) { while (el_info) {
basFcts->getBound(el_info, bound); basFcts->getBound(el_info, bound);
if (updateDF) { if (updateDF)
df->assemble(1.0, el_info, bound); df->assemble(1.0, el_info, bound);
} if (F)
if (F) {
F->assemble(1.0, el_info, bound); F->assemble(1.0, el_info, bound);
}
el_info = stack.traverseNext(el_info); el_info = stack.traverseNext(el_info);
} }
FREE_MEMORY(bound, BoundaryType, feSpace->getBasisFcts()->getNumber()); delete [] bound;
} }
void NonLinUpdaterVec::update(bool updateDF, void NonLinUpdaterVec::update(bool updateDF,
...@@ -89,13 +85,10 @@ namespace AMDiS { ...@@ -89,13 +85,10 @@ namespace AMDiS {
if (updateDF) { if (updateDF) {
TEST_EXIT(df)("df not set but update tried!\n"); TEST_EXIT(df)("df not set but update tried!\n");
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++)
for (int j = 0; j < size; j++) { for (int j = 0; j < size; j++)
if ((*df)[i][j]) { if ((*df)[i][j])
(*df)[i][j]->clear(); (*df)[i][j]->clear();
}
}
}
} }
BasisFunction *basFcts = const_cast<BasisFunction*>(feSpace->getBasisFcts()); BasisFunction *basFcts = const_cast<BasisFunction*>(feSpace->getBasisFcts());
...@@ -113,32 +106,26 @@ namespace AMDiS { ...@@ -113,32 +106,26 @@ namespace AMDiS {
Mesh::FILL_DET| Mesh::FILL_DET|
Mesh::FILL_GRD_LAMBDA; Mesh::FILL_GRD_LAMBDA;
BoundaryType *bound = GET_MEMORY(BoundaryType, basFcts->getNumber()); BoundaryType *bound = new BoundaryType[basFcts->getNumber()];
el_info = stack.traverseFirst(feSpace->getMesh(), -1, fill_flag); el_info = stack.traverseFirst(feSpace->getMesh(), -1, fill_flag);
while (el_info) { while (el_info) {
basFcts->getBound(el_info, bound); basFcts->getBound(el_info, bound);
if (updateDF) { if (updateDF)
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++)
for (int j = 0; j < size; j++) { for (int j = 0; j < size; j++)
if ((*df)[i][j]) { if ((*df)[i][j])
(*df)[i][j]->assemble(1.0, el_info, bound); (*df)[i][j]->assemble(1.0, el_info, bound);
}
}
}
}
if (F) { if (F)
for(int i = 0; i < size; i++) { for(int i = 0; i < size; i++)
F->getDOFVector(i)->assemble(1.0, el_info, bound); F->getDOFVector(i)->assemble(1.0, el_info, bound);
}
}
el_info = stack.traverseNext(el_info); el_info = stack.traverseNext(el_info);
} }
FREE_MEMORY(bound, BoundaryType, basFcts->getNumber()); delete [] bound;
}; }
} }
...@@ -9,18 +9,17 @@ ...@@ -9,18 +9,17 @@
namespace AMDiS { namespace AMDiS {