diff --git a/AMDiS/src/AdaptInstationary.cc b/AMDiS/src/AdaptInstationary.cc index 0d061a80fcbe19f43e449802a1e83682471d0fad..e57ba42d52cdae8c025167e37e724e48b9dd1691 100644 --- a/AMDiS/src/AdaptInstationary.cc +++ b/AMDiS/src/AdaptInstationary.cc @@ -78,10 +78,9 @@ namespace AMDiS { FUNCNAME("AdaptInstationary::explicitTimeStrategy()"); // estimate before first adaption - if (adaptInfo->getTime() <= adaptInfo->getStartTime()) { + if (adaptInfo->getTime() <= adaptInfo->getStartTime()) problemIteration_->oneIteration(adaptInfo, ESTIMATE); - } - + // increment time adaptInfo->setTime(adaptInfo->getTime() + adaptInfo->getTimestep()); @@ -136,21 +135,20 @@ namespace AMDiS { if (problemIteration_->oneIteration(adaptInfo, FULL_ITERATION)) { if (!fixedTimestep_ && !adaptInfo->timeToleranceReached() && - !(adaptInfo->getTimestep() <= adaptInfo->getMinTimestep())) - { - adaptInfo->setTime(adaptInfo->getTime() - adaptInfo->getTimestep()); - adaptInfo->setTimestep(adaptInfo->getTimestep() * time_delta_1); - problemIteration_->endIteration(adaptInfo); - adaptInfo->incSpaceIteration(); - break; - } + !(adaptInfo->getTimestep() <= adaptInfo->getMinTimestep())) { + adaptInfo->setTime(adaptInfo->getTime() - adaptInfo->getTimestep()); + adaptInfo->setTimestep(adaptInfo->getTimestep() * time_delta_1); + problemIteration_->endIteration(adaptInfo); + adaptInfo->incSpaceIteration(); + break; + } } adaptInfo->incSpaceIteration(); problemIteration_->endIteration(adaptInfo); - } while(!adaptInfo->spaceToleranceReached() && - adaptInfo->getSpaceIteration() <= adaptInfo->getMaxSpaceIteration()); + } while (!adaptInfo->spaceToleranceReached() && + adaptInfo->getSpaceIteration() <= adaptInfo->getMaxSpaceIteration()); } else { problemIteration_->endIteration(adaptInfo); @@ -162,7 +160,7 @@ namespace AMDiS { adaptInfo->getTimestepIteration() <= adaptInfo->getMaxTimestepIteration()); if (!fixedTimestep_ && adaptInfo->timeErrorLow()) { - adaptInfo->setTimestep(adaptInfo->getTimestep() *time_delta_2); + adaptInfo->setTimestep(adaptInfo->getTimestep() * time_delta_2); if (dbgMode) { // print information about timestep increase } @@ -170,12 +168,10 @@ namespace AMDiS { if (dbgMode) { std::cout << "=== ADAPT INFO DEBUG MODE ===\n"; std::cout << " Do not increase timestep: \n"; - if (fixedTimestep_) { + if (fixedTimestep_) std::cout << " fixedTimestep = true\n"; - } - if (!adaptInfo->timeErrorLow()) { + if (!adaptInfo->timeErrorLow()) adaptInfo->printTimeErrorLowInfo(); - } } } } diff --git a/AMDiS/src/DOFVector.hh b/AMDiS/src/DOFVector.hh index b96362f14fc4d8759e69d33c8baf1133c549476e..7783223ad6fe0d22167d9371e534802162f31be3 100644 --- a/AMDiS/src/DOFVector.hh +++ b/AMDiS/src/DOFVector.hh @@ -84,8 +84,8 @@ namespace AMDiS { D2Phis.resize(omp_get_overall_max_threads()); for (int i = 0; i < omp_get_overall_max_threads(); i++) { - localIndices[i] = GET_MEMORY(DegreeOfFreedom, this->nBasFcts); - localVectors[i] = GET_MEMORY(T, this->nBasFcts); + localIndices[i] = new DegreeOfFreedom[this->nBasFcts]; + localVectors[i] = new T[this->nBasFcts]; grdPhis[i] = new DimVec<double>(dim, DEFAULT_VALUE, 0.0); grdTmp[i] = new DimVec<double>(dim, DEFAULT_VALUE, 0.0); D2Phis[i] = new DimMat<double>(dim, NO_INIT); @@ -96,8 +96,8 @@ namespace AMDiS { DOFVectorBase<T>::~DOFVectorBase() { for (int i = 0; i < static_cast<int>(localIndices.size()); i++) { - FREE_MEMORY(localIndices[i], DegreeOfFreedom, this->nBasFcts); - FREE_MEMORY(localVectors[i], T, this->nBasFcts); + delete [] localIndices[i]; + delete [] localVectors[i]; delete grdPhis[i]; delete grdTmp[i]; delete D2Phis[i]; diff --git a/AMDiS/src/Element.cc b/AMDiS/src/Element.cc index 8dfd646b8921eea80a142da24adb225f1ad1a4db..fce1d89439e6a13176a2dc5165d5ddec8cb4ce21 100644 --- a/AMDiS/src/Element.cc +++ b/AMDiS/src/Element.cc @@ -94,9 +94,8 @@ namespace AMDiS { GeoIndex position = INDEX_OF_DIM(pos, dim); 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); - } if (ndof > 0) { for (int i = 0; i < mesh->getGeo(position); i++) { @@ -111,7 +110,7 @@ namespace AMDiS { } } - FREE_MEMORY(dof, DegreeOfFreedom*, mesh->getNumberOfNodes()); + delete [] dof; if (child[0]) child[0]->deleteElementDOFs(); diff --git a/AMDiS/src/FixVec.h b/AMDiS/src/FixVec.h index 7b189d9898b0f8e2d784782907c16a69c476f9fc..cffc0ce9ac14c8a4040a5fe9c03a3af37ddc29d1 100644 --- a/AMDiS/src/FixVec.h +++ b/AMDiS/src/FixVec.h @@ -286,19 +286,18 @@ namespace AMDiS { : rows(r), columns(c) { TEST_EXIT_DBG(initType == NO_INIT)("wrong initType or wrong initializer\n"); - vec = GET_MEMORY(VectorOfFixVecs<FixVecType>*, rows); - for (VectorOfFixVecs<FixVecType>** i = &vec[0]; i < &vec[rows]; i++) { + vec = new VectorOfFixVecs<FixVecType>*[rows]; + for (VectorOfFixVecs<FixVecType>** i = &vec[0]; i < &vec[rows]; i++) *i = new VectorOfFixVecs<FixVecType>(dim, columns, NO_INIT); - } } /// destructor virtual ~MatrixOfFixVecs() { - for (VectorOfFixVecs<FixVecType>** i = &vec[0]; i < &vec[rows]; i++) { + for (VectorOfFixVecs<FixVecType>** i = &vec[0]; i < &vec[rows]; i++) delete *i; - } - FREE_MEMORY(vec, VectorOfFixVecs<FixVecType>*, rows); + + delete [] vec; } /// assignment operator @@ -412,52 +411,38 @@ namespace AMDiS { class WorldVector : public FixVec<T, WORLD> { public: - /** \brief - * Calls the corresponding constructor of AlgoVec - */ + /// Calls the corresponding constructor of AlgoVec WorldVector() : FixVec<T, WORLD>(Global::getGeo(WORLD), NO_INIT) {} - /** \brief - * Calls the corresponding constructor of AlgoVec - */ + /// Calls the corresponding constructor of AlgoVec WorldVector(InitType initType, T* ini) : FixVec<T, WORLD>(Global::getGeo(WORLD), initType, ini) {} - /** \brief - * Calls the corresponding constructor of AlgoVec - */ + /// Calls the corresponding constructor of AlgoVec WorldVector(InitType initType, const T& ini) : FixVec<T, WORLD>(Global::getGeo(WORLD), initType, ini) {} - /** \brief - * Sets all entries to d - */ + /// Sets all entries to d inline const WorldVector<T>& operator=(const T& d) { this->set(d); return (*this); } - /** \brief - * Sets the arrays value to the geometric midpoint of the points - * p1 and p2; - */ + /// Sets the arrays value to the geometric midpoint of the points p1 and p2. inline void setMidpoint(const WorldVector<T> &p1, const WorldVector<T> &p2) { int dow = Global::getGeo(WORLD); - for (int i = 0; i < dow; i++) { + for (int i = 0; i < dow; i++) this->valArray[i] = 0.5 * (p1[i] + p2[i]); - } } - /** \brief - * Multplication of a matrix with a vector. - */ + /// Multplication of a matrix with a vector. void multMatrixVec(WorldMatrix<T> &m, WorldVector<T> &v); }; diff --git a/AMDiS/src/GridWriter.hh b/AMDiS/src/GridWriter.hh index c15e334124460078af764b92c9f2f96e1c9c1589..2aa699ebb2d54e72189d7b562811d4309a93b108 100644 --- a/AMDiS/src/GridWriter.hh +++ b/AMDiS/src/GridWriter.hh @@ -26,9 +26,9 @@ namespace AMDiS { ("not for DIM != DIM_OF_WORLD\n"); - WorldVector<double> *basis = new WorldVector<double>[dim]; - double *lengthBasis = GET_MEMORY(double, dim); - WorldVector<double> *step = new WorldVector<double>[3]; + WorldVector<double> *basis = new WorldVector<double>[dim]; + double *lengthBasis = new double[dim]; + WorldVector<double> *step = new WorldVector<double>[3]; for (int i = 0; i < dim; i++) { TEST_EXIT(numPoints[i] > 0)("numPoints < 1\n"); @@ -121,7 +121,7 @@ namespace AMDiS { } delete [] basis; - FREE_MEMORY(lengthBasis, double, dim); + delete [] lengthBasis; delete [] step; delete outFile; } diff --git a/AMDiS/src/Lagrange.cc b/AMDiS/src/Lagrange.cc index ead066766c94c1d0d3d9c2f610efcda76eed8fe7..03fd2070728a005e38068dc2d93a07309f3ed5db 100644 --- a/AMDiS/src/Lagrange.cc +++ b/AMDiS/src/Lagrange.cc @@ -227,7 +227,7 @@ namespace AMDiS { TEST_EXIT_DBG((*vertices) == NULL)("vertices != NULL\n"); int dimOfPosition = DIM_OF_INDEX(position, dim); - *vertices = GET_MEMORY(int, dimOfPosition + 1); + *vertices = new int[dimOfPosition + 1]; if ((degree == 4) && (dimOfPosition==1)) { (*vertices)[(nodeIndex != 2) ? 0 : 1] = @@ -667,14 +667,15 @@ namespace AMDiS { for (int i = 0; i <= dim; i++) { // for all positions int partsAtPos = Global::getGeo(INDEX_OF_DIM(i, dim), dim); for (int j = 0; j < partsAtPos; j++) { // for all vertices/edges/faces/... - int *coordInd = GET_MEMORY(int, i + 1); // indices of relevant coords + int *coordInd = new int[i + 1]; // indices of relevant coords for (int k = 0; k < i + 1; k++) { coordInd[k] = Global::getReferenceElement(dim)-> getVertexOfPosition(INDEX_OF_DIM(i,dim), j, k); } createCoords(coordInd, i + 1, 0, degree); - FREE_MEMORY(coordInd, int, i + 1); - if(static_cast<int>(bary->size()) == nBasFcts) return; + delete [] coordInd; + if (static_cast<int>(bary->size()) == nBasFcts) + return; } } } @@ -683,9 +684,9 @@ namespace AMDiS { int Lagrange::getNumberOfDOFs(int dim, int degree) { int result = 0; - for (int i = 0; i <= degree; i++) { + for (int i = 0; i <= degree; i++) result += fac(dim - 1 + i) / (fac(i) * fac(dim - 1)); - } + return result; } @@ -828,8 +829,9 @@ namespace AMDiS { if (vec) { rvec = vec; } else { - if(inter) FREE_MEMORY(inter, double, nBasFcts); - inter = GET_MEMORY(double, nBasFcts); + if (inter) + delete [] inter; + inter = new double[nBasFcts]; inter_size = nBasFcts; rvec = inter; } @@ -928,8 +930,8 @@ namespace AMDiS { result = indices; } else { if (localVec) - FREE_MEMORY(localVec, DegreeOfFreedom, localVecSize); - localVec = GET_MEMORY(DegreeOfFreedom, nBasFcts); + delete [] localVec; + localVec = new DegreeOfFreedom[nBasFcts]; localVecSize = nBasFcts; result = localVec; } @@ -946,9 +948,8 @@ namespace AMDiS { for (int i = 0; i < num; node0++, i++) { const int *indi = orderOfPositionIndices(el, posIndex, i); - for (int k = 0; k < nrDOFs; k++) { + for (int k = 0; k < nrDOFs; k++) result[j++] = dof[node0][n0 + indi[k]]; - } } } } @@ -1005,7 +1006,7 @@ namespace AMDiS { if ((parametric = mesh->getParametric())) { ERROR_EXIT("not yet implemented\n"); } else { - wdetf_qp = GET_MEMORY(double, q->getNumPoints()); + wdetf_qp = new double[q->getNumPoints()]; } ElInfo *el_info = stack.traverseFirst(mesh, -1, Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS); @@ -1030,7 +1031,7 @@ namespace AMDiS { el_info = stack.traverseNext(el_info); } - FREE_MEMORY(wdetf_qp, double, q->getNumPoints()); + delete [] wdetf_qp; } @@ -1272,7 +1273,7 @@ namespace AMDiS { Element *el = list->getElement(0); const DOFAdmin *admin = drv->getFESpace()->getAdmin(); - DegreeOfFreedom *pdof = GET_MEMORY(DegreeOfFreedom, basFct->getNumber()); + DegreeOfFreedom *pdof = new DegreeOfFreedom[basFct->getNumber()]; basFct->getLocalIndices(el, admin, pdof); /****************************************************************************/ @@ -1314,7 +1315,7 @@ namespace AMDiS { + 0.75 * (*drv)[pdof[9]]); if (n <= 1) { - FREE_MEMORY(pdof, DegreeOfFreedom, basFct->getNumber()); + delete [] pdof; return; } /****************************************************************************/ @@ -1352,7 +1353,7 @@ namespace AMDiS { - 0.125 * (*drv)[pdof[6]] + 0.1875 * (-(*drv)[pdof[7]] + (*drv)[pdof[8]]) + 0.75 *(*drv)[pdof[9]]); - FREE_MEMORY(pdof, DegreeOfFreedom, basFct->getNumber()); + delete [] pdof; } void Lagrange::refineInter3_2d(DOFIndexed<double> *drv, @@ -1681,14 +1682,9 @@ namespace AMDiS { if (n < 1) return; - Element *el; - DegreeOfFreedom *pdof = GET_MEMORY(DegreeOfFreedom, basFct->getNumber()); - const DegreeOfFreedom *cdof; - const DOFAdmin *admin; - - el = list->getElement(0); - - admin = drv->getFESpace()->getAdmin(); + DegreeOfFreedom *pdof = new DegreeOfFreedom[basFct->getNumber()]; + const DOFAdmin *admin = drv->getFESpace()->getAdmin(); + Element *el = list->getElement(0); basFct->getLocalIndices(el, admin, pdof); @@ -1696,7 +1692,8 @@ namespace AMDiS { /* values on child[0] */ /****************************************************************************/ - cdof = basFct->getLocalIndices(el->getChild(0), admin, NULL); + const DegreeOfFreedom *cdof = + basFct->getLocalIndices(el->getChild(0), admin, NULL); (*drv)[cdof[2]] = (*drv)[pdof[10]]; (*drv)[cdof[3]] = @@ -1763,7 +1760,7 @@ namespace AMDiS { (*drv)[cdof[14]] = (*drv)[pdof[13]]; if (n <= 1) { - FREE_MEMORY(pdof, DegreeOfFreedom, basFct->getNumber()); + delete [] pdof; return; } /****************************************************************************/ @@ -1825,7 +1822,7 @@ namespace AMDiS { - 0.03125*(*drv)[pdof[11]] + 0.75*(*drv)[pdof[14]]); (*drv)[cdof[14]] = (*drv)[pdof[13]]; - FREE_MEMORY(pdof, DegreeOfFreedom, basFct->getNumber()); + delete [] pdof; } void Lagrange::refineInter4_2d(DOFIndexed<double> *drv, diff --git a/AMDiS/src/MacroReader.cc b/AMDiS/src/MacroReader.cc index f8f12a47c9a20f17efd188cd4ad94283167fefee..bf5c01f227b403172982b39539e3caa456982ddd 100644 --- a/AMDiS/src/MacroReader.cc +++ b/AMDiS/src/MacroReader.cc @@ -49,8 +49,8 @@ namespace AMDiS { int dim = mesh->getDim(); int el1, el2; - int *verticesEl1 = GET_MEMORY(int, dim); - int *verticesEl2 = GET_MEMORY(int, dim); + int *verticesEl1 = new int[dim]; + int *verticesEl2 = new int[dim]; int mode = -1; // 0: drop dofs, 1: associate dofs int result; BoundaryType boundaryType; @@ -172,8 +172,8 @@ namespace AMDiS { } } - FREE_MEMORY(verticesEl1, int, dim); - FREE_MEMORY(verticesEl2, int, dim); + delete [] verticesEl1; + delete [] verticesEl2; // change periodic vertex dofs for (int i = 0; i < mesh->getNumberOfVertices(); i++) { @@ -362,25 +362,22 @@ namespace AMDiS { mesh->addMacroElement(mel[i]); } - dof = GET_MEMORY(DegreeOfFreedom*, nv); - coords = GET_MEMORY(WorldVector<double>, nv); - mel_vertex = GET_MEMORY(int*, ne); + dof = new DegreeOfFreedom*[nv]; + coords = new WorldVector<double>[nv]; + mel_vertex = new int*[ne]; - for (int i = 0; i < ne; i++) { - mel_vertex[i] = GET_MEMORY(int, mesh->getGeo(VERTEX)); - } + for (int i = 0; i < ne; i++) + mel_vertex[i] = new int[mesh->getGeo(VERTEX)]; - for (int i = 0; i < nv; i++) { + for (int i = 0; i < nv; i++) dof[i] = mesh->getDOF(VERTEX); - } for (int i = 0; i < ne; i++) { mel[i]->element = mesh->createNewElement(); (mel)[i]->index = i; - if (dim == 3) { + if (dim == 3) (mel)[i]->elType = 0; - } } neigh_set = false; bound_set = false; @@ -389,12 +386,12 @@ namespace AMDiS { void MacroInfo::clear(int ne, int nv) { for (int i = 0; i < mesh->getNumberOfMacros(); i++) - FREE_MEMORY(mel_vertex[i], int, mesh->getGeo(VERTEX)); + delete [] mel_vertex[i]; - FREE_MEMORY(mel_vertex, int*, ne); - FREE_MEMORY(coords, WorldVector<double>, nv); + delete [] mel_vertex; + delete [] coords; coords = NULL; - FREE_MEMORY(dof, DegreeOfFreedom*, nv); + delete [] dof; dof = NULL; mesh = NULL; @@ -417,10 +414,9 @@ namespace AMDiS { { int dim = mesh->getDim(); - for (int i = 0; i <= dim; i++) { + for (int i = 0; i <= dim; i++) if (fscanf(file, "%d", &id[i]) != 1) return(false); - } return(true); } @@ -846,7 +842,7 @@ namespace AMDiS { std::deque<MacroElement*>::iterator melIt; - BoundaryType *bound = GET_MEMORY(BoundaryType, nv); + BoundaryType *bound = new BoundaryType[nv]; int dim = mesh->getDim(); @@ -931,7 +927,7 @@ namespace AMDiS { default: ERROR_EXIT("invalid dim\n"); } - FREE_MEMORY(bound, BoundaryType, nv); + delete [] bound; } void MacroReader::computeNeighbours(Mesh *mesh) @@ -1147,9 +1143,9 @@ namespace AMDiS { } if (3 == dim) { - mesh->setMaxEdgeNeigh(std::max(8, 2*max_n_neigh)); + mesh->setMaxEdgeNeigh(std::max(8, 2 * max_n_neigh)); } else { - mesh->setMaxEdgeNeigh(dim-1); + mesh->setMaxEdgeNeigh(dim - 1); } } @@ -1173,9 +1169,8 @@ namespace AMDiS { ERROR("Entries in MacroElement structures get reordered\n"); umb(NULL, mesh, umbVkantMacro); - if (nameneu) { + if (nameneu) ERROR_EXIT("mesh->feSpace\n"); - } } } @@ -1201,12 +1196,11 @@ namespace AMDiS { int zykstart; int dim = mesh->getDim(); - test = GET_MEMORY(int, mesh->getNumberOfMacros()); - zykl = GET_MEMORY(int, mesh->getNumberOfMacros()); + test = new int[mesh->getNumberOfMacros()]; + zykl = new int[mesh->getNumberOfMacros()]; - for (int i = 0; i < mesh->getNumberOfMacros(); i++) { + for (int i = 0; i < mesh->getNumberOfMacros(); i++) test[i] = 0; - } zykstart = -1; macrolfd = mesh->firstMacroElement(); @@ -1255,8 +1249,8 @@ namespace AMDiS { } } - FREE_MEMORY(zykl, int, mesh->getNumberOfMacros()); - FREE_MEMORY(test, int, mesh->getNumberOfMacros()); + delete [] zykl; + delete [] test; return zykstart; } @@ -1285,17 +1279,14 @@ namespace AMDiS { { FUNCNAME("MacroReader::umb"); - int *test; - int i; - - test=GET_MEMORY(int, mesh->getNumberOfMacros()); + int *test = new int[mesh->getNumberOfMacros()]; - for (i=0; i < static_cast<int>(mesh->getNumberOfMacros()); i++) - test[i]=0; + for (int i = 0; i < static_cast<int>(mesh->getNumberOfMacros()); i++) + test[i] = 0; - recumb(mesh, (*mesh->firstMacroElement()), NULL,test,0,0,ele,umbvk); + recumb(mesh, (*mesh->firstMacroElement()), NULL, test, 0, 0, ele, umbvk); - FREE_MEMORY(test, int, mesh->getNumberOfMacros()); + delete [] test; } bool MacroReader::newEdge(Mesh *mesh, MacroElement *mel, @@ -1714,7 +1705,6 @@ namespace AMDiS { int *test, double lg, int ka, int *ele, void (*umbvk)(Mesh *mesh, MacroElement*, int k, int *el)) { - int i; double l[3]; int v[3]; int k = 0; @@ -1729,69 +1719,60 @@ namespace AMDiS { laengstekante(mel->coord,l,v); - if (v[1] == mesh->getGeo(VERTEX)) /*nur eine laengste Kante*/ - { - umbvk(mesh,mel,v[0],ele); + if (v[1] == mesh->getGeo(VERTEX)) { /*nur eine laengste Kante*/ + umbvk(mesh, mel, v[0], ele); - for (i=0; i < vertices; i++) { - recumb(mesh, - mel->neighbour[i], - mel, - test, - l[0], - 0, - ele, - umbvk); - } - return; + for (int i = 0; i < vertices; i++) { + recumb(mesh, + mel->neighbour[i], + mel, + test, + l[0], + 0, + ele, + umbvk); } - else - { - if (ka == 1) - { - if (fabs((l[0]-lg)/lg) < 0.0000001) - { - for (i=0; i < vertices; i++) - { - if (mel->neighbour[i] == macroalt) - { - k=i; - } - } + return; + } else { + if (ka == 1) { + if (fabs((l[0]-lg)/lg) < 0.0000001) { + for (int i = 0; i < vertices; i++) + if (mel->neighbour[i] == macroalt) + k = i; - umbvk(mesh,mel,k,ele); + umbvk(mesh,mel,k,ele); - for (i=0; i < vertices; i++) { - recumb(mesh, - mel->neighbour[i], - mel, - test, - l[0], - 0, - ele, - umbvk); - } - return; - } + for (int i = 0; i < vertices; i++) { + recumb(mesh, + mel->neighbour[i], + mel, + test, + l[0], + 0, + ele, + umbvk); } + return; + } + } - n=const_cast<MacroElement*>(mel->getNeighbour(v[0])); - /*Nachbar an fiktiv verlaengerter Kante*/ - umbvk(mesh,mel,v[0],ele); + n = const_cast<MacroElement*>(mel->getNeighbour(v[0])); + /*Nachbar an fiktiv verlaengerter Kante*/ + umbvk(mesh, mel, v[0], ele); - recumb(mesh, n, mel,test,l[0],1,ele,umbvk); - for (i=0; i < vertices; i++) { - recumb(mesh, - mel->neighbour[i], - mel, - test, - l[0], - 0, - ele, + recumb(mesh, n, mel,test,l[0],1,ele,umbvk); + for (int i = 0; i < vertices; i++) { + recumb(mesh, + mel->neighbour[i], + mel, + test, + l[0], + 0, + ele, umbvk); - } - return; } + return; + } } } diff --git a/AMDiS/src/MpCCIAdapter.cc b/AMDiS/src/MpCCIAdapter.cc index a7b4e3cf0e0be391f8db51e2cd8dd675110cf8a0..cc655f27f99f4bfae52e314a1c29ae04349183ab 100644 --- a/AMDiS/src/MpCCIAdapter.cc +++ b/AMDiS/src/MpCCIAdapter.cc @@ -178,7 +178,6 @@ namespace AMDiS smiAdapter_->transferMeshToSMI(); // read SMI data - int i; int error; int dow = Global::getGeo(WORLD); int dim = feSpace_->getMesh()->getDim(); @@ -201,7 +200,7 @@ namespace AMDiS &nodeIDs); TEST_EXIT(error == SMI_OK)("SMI_Get_all_nodes() failed\n"); - coords = GET_MEMORY(double, numNodes * dow); + coords = new double[numNodes * dow]; error = SMI_Get_nodes(applicationID_, meshID_, @@ -240,10 +239,9 @@ namespace AMDiS default: ERROR_EXIT("invalid dim\n"); } - nodesPerElem = GET_MEMORY(int, numElems); - for(i = 0; i < numElems; i++) { + nodesPerElem = new int[numElems]; + for (int i = 0; i < numElems; i++) nodesPerElem[i] = dim + 1; - } error = SMI_End_read_transaction(applicationID_, meshID_); TEST_EXIT(error == SMI_OK)("SMI_End_read_transaction() failed\n"); @@ -272,8 +270,8 @@ namespace AMDiS TEST_EXIT(error == 0)("CCI_Def_elems() failed\n"); // free memory - FREE_MEMORY(coords, double, numNodes * dow); - FREE_MEMORY(nodesPerElem, int, numElems); + delete [] coords; + delete [] nodesPerElem; } void MpCCIAdapter::remesh() @@ -327,7 +325,7 @@ namespace AMDiS TEST_EXIT(error == SMI_OK)("SMI_Get_quantity_info() failed\n"); - values = GET_MEMORY(double, dim * numNodes); + values = new double[dim * numNodes]; error = SMI_Get_quantity_values(applicationID_, meshID_, @@ -344,13 +342,11 @@ namespace AMDiS TEST_EXIT(error == SMI_OK)("SMI_End_read_transaction() failed\n"); // copy double to float - float *floatValues = GET_MEMORY(float, dim * numNodes); + float *floatValues = new float[dim * numNodes]; #if 0 - int i; - for(i=0; i < dim*numNodes; i++) { + for (int i = 0; i < dim*numNodes; i++) floatValues[i] = static_cast<float>(values[i]); - } error = CCI_Put_nodes(meshID_, partitionID_, @@ -363,7 +359,7 @@ namespace AMDiS floatValues); TEST_EXIT(error == 0)("CCI_Put_nodes() failed\n"); - FREE_MEMORY(floatValues, float, dim * numNodes); + delete [] floatValues; #endif error = CCI_Put_nodes(meshID_, @@ -377,7 +373,7 @@ namespace AMDiS values); TEST_EXIT(error == 0)("CCI_Put_nodes() failed\n"); - FREE_MEMORY(values, double, dim * numNodes); + delete [] values; } void MpCCIAdapter::getNodes(int quantityID) @@ -410,11 +406,11 @@ namespace AMDiS error = SMI_End_read_transaction(applicationID_, meshID_); TEST_EXIT(error == SMI_OK)("SMI_End_read_transaction() failed\n"); - values = GET_MEMORY(double, dim * numNodes); + values = new double[dim * numNodes]; #if 0 // copy double to float - float *floatValues = GET_MEMORY(float, dim * numNodes); + float *floatValues = new float[dim * numNodes]; error = CCI_Get_nodes(meshID_, partitionID_, @@ -430,12 +426,10 @@ namespace AMDiS &numEmptyNodes); TEST_EXIT(error == 0)("CCI_Get_nodes() failed\n"); - int i; - for(i=0; i < dim*numNodes; i++) { + for (int i = 0; i < dim * numNodes; i++) values[i] = static_cast<double>(floatValues[i]); - } - FREE_MEMORY(floatValues, float, dim * numNodes); + delete [] floatValues; #endif error = CCI_Get_nodes(meshID_, @@ -472,7 +466,7 @@ namespace AMDiS smiAdapter_->getQuantitiesFromSMI(quantityID); - FREE_MEMORY(values, double, dim * numNodes); + delete [] values; } void MpCCIAdapter::send(int numQuantities, int *quantityIDs) diff --git a/AMDiS/src/Operator.cc b/AMDiS/src/Operator.cc index 1d1e7752669c4c1b4c133beba3cc64c9a5c983e6..20f676dce03dd08e2ac664a4ff0c2a6b3ebb1518 100644 --- a/AMDiS/src/Operator.cc +++ b/AMDiS/src/Operator.cc @@ -1084,9 +1084,6 @@ namespace AMDiS { SubAssembler* subAssembler, Quadrature *quad) { - TEST_EXIT(vec1->getFESpace() == vec2->getFESpace()) - ("Not yet implemented!\n"); - vecAtQPs1 = getVectorAtQPs(vec1, elInfo, subAssembler, quad); vecAtQPs2 = getVectorAtQPs(vec2, elInfo, subAssembler, quad); } diff --git a/AMDiS/src/ParMetisPartitioner.cc b/AMDiS/src/ParMetisPartitioner.cc index 304662b6a73e401d54b0ae1d17eced9a08e8b989..1cf80cc9fe997733b8bad938d9c0bed997f28d50 100644 --- a/AMDiS/src/ParMetisPartitioner.cc +++ b/AMDiS/src/ParMetisPartitioner.cc @@ -46,14 +46,13 @@ namespace AMDiS { TEST_EXIT(nElements > 0)("no elements in ParMETIS mesh\n"); // allocate memory - eptr = GET_MEMORY(int, nElements + 1); - eind = GET_MEMORY(int, nElements * (dim + 1)); - elmdist = GET_MEMORY(int, mpiSize + 1); - - elem_p2a = GET_MEMORY(int, nElements); + eptr = new int[nElements + 1]; + eind = new int[nElements * (dim + 1))]; + elmdist = new int[mpiSize + 1]; + elem_p2a = new int[nElements]; if (dim == dow) { - xyz = GET_MEMORY(float, nElements * dim); + xyz = new float[nElements * dim]; } else { xyz = NULL; } @@ -126,19 +125,19 @@ namespace AMDiS { ParMetisMesh::~ParMetisMesh() { if (eptr) - FREE_MEMORY(eptr, int, nElements + 1); + delete [] eptr; if (eind) - FREE_MEMORY(eind, int, nElements * (dim + 1)); + delete [] eind; if (elmdist) - FREE_MEMORY(elmdist, int, mpiComm->Get_size() + 1); + delete [] elmdist; if (xyz) - FREE_MEMORY(xyz, float, nElements * dim); + delete [] xyz; if (elem_p2a) - FREE_MEMORY(elem_p2a, int, nElements); + delete [] elem_p2a; } ParMetisGraph::ParMetisGraph(ParMetisMesh *parMesh, @@ -230,8 +229,8 @@ namespace AMDiS { int nElements = parMetisMesh->getNumElements(); // === create weight array === - int *wgts = elemWeights ? GET_MEMORY(int, nElements) : NULL; - float *floatWgts = elemWeights ? GET_MEMORY(float, nElements) : NULL; + int *wgts = elemWeights ? new int[nElements] : NULL; + float *floatWgts = elemWeights ? new float[nElements] : NULL; float maxWgt = 0.0; float *ptr_floatWgts = floatWgts; @@ -271,23 +270,21 @@ namespace AMDiS { int numflag = 0; // c numbering style! int ncon = elemWeights ? 1 : 0; // one weight at each vertex! int nparts = mpiSize; // number of partitions - float *tpwgts = elemWeights ? GET_MEMORY(float, mpiSize) : NULL; + float *tpwgts = elemWeights ? new float[mpiSize] : NULL; float ubvec = 1.05; int options[3] = {0, 0, 0}; // default options int edgecut = -1; - int *part = GET_MEMORY(int, nElements); + int *part = new int[nElements]; if (elemWeights) { - for (int i = 0; i < mpiSize; i++) { - // set tpwgts + // set tpwgts + for (int i = 0; i < mpiSize; i++) tpwgts[i] = 1.0 / nparts; - } float scale = 10000 / maxWgt; - for (int i = 0; i < nElements; i++) { - // scale wgts + // scale wgts + for (int i = 0; i < nElements; i++) wgts[i] = static_cast<int>(floatWgts[i] * scale); - } } MPI_Comm tmpComm = MPI_Comm(*mpiComm); @@ -312,10 +309,9 @@ namespace AMDiS { break; case ADAPTIVE_REPART: { - int *vsize = GET_MEMORY(int, nElements); - for (int i = 0; i < nElements; i++) { + int *vsize = new int[nElements]; + for (int i = 0; i < nElements; i++) vsize[i] = 1; - } ParMETIS_V3_AdaptiveRepart(parMetisMesh->getElementDist(), parMetisGraph.getXAdj(), parMetisGraph.getAdjncy(), @@ -333,7 +329,7 @@ namespace AMDiS { &edgecut, part, &tmpComm); - FREE_MEMORY(vsize, int, nElements); + delete [] vsize; } break; case REFINE_PART: @@ -361,12 +357,13 @@ namespace AMDiS { distributePartitioning(part); if (floatWgts) - FREE_MEMORY(floatWgts, float, nElements); + delete [] floatWgts; if (wgts) - FREE_MEMORY(wgts, int, nElements); + delete [] wgts; if (tpwgts) - FREE_MEMORY(tpwgts, float, mpiSize); - FREE_MEMORY(part, int, nElements); + delete [] tpwgts; + + delete [] part; } void ParMetisPartitioner::fillCoarsePartitionVec(std::map<int, int> *partitionVec) @@ -381,19 +378,18 @@ namespace AMDiS { int mpiRank = mpiComm->Get_rank(); int mpiSize = mpiComm->Get_size(); - int *nPartitionElements = GET_MEMORY(int, mpiSize); + int *nPartitionElements = new int[mpiSize]; int *elmdist = parMetisMesh->getElementDist(); - for (int i = 0; i < mpiSize; i++) { + for (int i = 0; i < mpiSize; i++) nPartitionElements[i] = elmdist[i + 1] - elmdist[i]; - } // === count number of elements === int nElements = 0; int localElements = parMetisMesh->getNumElements(); mpiComm->Allreduce(&localElements, &nElements, 1, MPI_INT, MPI_SUM); - int *partitionElements = GET_MEMORY(int, nElements); + int *partitionElements = new int[nElements]; // distribute partition elements mpiComm->Allgatherv(parMetisMesh->getAMDiSIndices(), @@ -405,14 +401,12 @@ namespace AMDiS { MPI_INT); // fill partitionVec - for (int i = 0; i < mpiSize; i++) { - for (int j = 0; j < nPartitionElements[i]; j++) { + for (int i = 0; i < mpiSize; i++) + for (int j = 0; j < nPartitionElements[i]; j++) (*partitionVec)[partitionElements[elmdist[i] + j]] = i; - } - } - FREE_MEMORY(partitionElements, int, nElements); - FREE_MEMORY(nPartitionElements, int, mpiSize); + delete [] partitionElements; + delete [] nPartitionElements; } void ParMetisPartitioner::distributePartitioning(int *part) @@ -422,37 +416,34 @@ namespace AMDiS { int nElements = parMetisMesh->getNumElements(); // nPartitionElements[i] is the number of elements for the i-th partition - int *nPartitionElements = GET_MEMORY(int, mpiSize); + int *nPartitionElements = new int[mpiSize]; for (int i = 0; i < mpiSize; i++) nPartitionElements[i] = 0; - for (int i = 0; i < nElements; i++) { + for (int i = 0; i < nElements; i++) nPartitionElements[part[i]]++; - } // collect number of partition elements from all ranks for this rank - int *nRankElements = GET_MEMORY(int, mpiSize); + int *nRankElements = new int[mpiSize]; mpiComm->Alltoall(nPartitionElements, 1, MPI_INT, nRankElements, 1, MPI_INT); // sum up partition elements over all ranks - int *sumPartitionElements = GET_MEMORY(int, mpiSize); + int *sumPartitionElements = new int[mpiSize]; mpiComm->Allreduce(nPartitionElements, sumPartitionElements, mpiSize, MPI_INT, MPI_SUM); // prepare distribution (fill partitionElements with AMDiS indices) - int *bufferOffset = GET_MEMORY(int, mpiSize); + int *bufferOffset = new int[mpiSize]; bufferOffset[0] = 0; - for (int i = 1; i < mpiSize; i++) { + for (int i = 1; i < mpiSize; i++) bufferOffset[i] = bufferOffset[i - 1] + nPartitionElements[i - 1]; - } - int *partitionElements = GET_MEMORY(int, nElements); - int **partitionPtr = GET_MEMORY(int*, mpiSize); + int *partitionElements = new int[nElements]; + int **partitionPtr = new int*[mpiSize]; - for (int i = 0; i < mpiSize; i++) { + for (int i = 0; i < mpiSize; i++) partitionPtr[i] = partitionElements + bufferOffset[i]; - } for (int i = 0; i < nElements; i++) { int partition = part[i]; @@ -462,12 +453,11 @@ namespace AMDiS { } // all to all: partition elements to rank elements - int *rankElements = GET_MEMORY(int, sumPartitionElements[mpiRank]); - int *recvBufferOffset = GET_MEMORY(int, mpiSize); + int *rankElements = new int[sumPartitionElements[mpiRank]]; + int *recvBufferOffset = new int[mpiSize]; recvBufferOffset[0] = 0; - for (int i = 1; i < mpiSize; i++) { + for (int i = 1; i < mpiSize; i++) recvBufferOffset[i] = recvBufferOffset[i - 1] + nRankElements[i - 1]; - } mpiComm->Alltoallv(partitionElements, nPartitionElements, @@ -515,14 +505,14 @@ namespace AMDiS { delete parMetisMesh; parMetisMesh = NULL; - FREE_MEMORY(rankElements, int, sumPartitionElements[mpiRank]); - FREE_MEMORY(nPartitionElements, int, mpiSize); - FREE_MEMORY(nRankElements, int, mpiSize); - FREE_MEMORY(sumPartitionElements, int, mpiSize); - FREE_MEMORY(partitionElements, int, nElements); - FREE_MEMORY(partitionPtr, int*, mpiSize); - FREE_MEMORY(bufferOffset, int, mpiSize); - FREE_MEMORY(recvBufferOffset, int, mpiSize); + delete [] rankElements; + delete [] nPartitionElements; + delete [] nRankElements; + delete [] sumPartitionElements; + delete [] partitionElements; + delete [] partitionPtr; + delete [] bufferOffset; + delete [] recvBufferOffse; } void ParMetisPartitioner::descendPartitionData(Element *element) diff --git a/AMDiS/src/ParallelProblem.cc b/AMDiS/src/ParallelProblem.cc index ea1dafe7558ecc4d9c890634b8f50a38d80aefdf..988bb1f268e802fe09a6533847c90ed3ad1e4319 100644 --- a/AMDiS/src/ParallelProblem.cc +++ b/AMDiS/src/ParallelProblem.cc @@ -47,7 +47,7 @@ namespace AMDiS { public: MyDualTraverse(int coarseLevel) : coarseLevel_(coarseLevel) - {}; + {} bool skipEl1(ElInfo *elInfo) { @@ -61,12 +61,12 @@ namespace AMDiS { return false; } return true; - }; + } /*bool skipEl2(ElInfo *elInfo) { return skipEl1(elInfo); - };*/ + }*/ private: int coarseLevel_; }; @@ -93,10 +93,10 @@ namespace AMDiS { MPI::Group group = MPI::COMM_WORLD.Get_group(); int rankSize = mpiSize - 1; - int *ranks = GET_MEMORY(int, rankSize); - for (int i = 0; i < rankSize; i++) { + int *ranks = new int[rankSize]; + for (int i = 0; i < rankSize; i++) ranks[i] = i + 1; - } + std::cout<<"set amdis-group"<<std::endl; amdisGroup = group.Incl(rankSize, ranks); groupIsSet=true; @@ -110,7 +110,7 @@ namespace AMDiS { debugServerProcess = true; } - FREE_MEMORY(ranks, int, rankSize); + delete [] ranks; } else { mpiComm = MPI::COMM_WORLD; } @@ -180,19 +180,19 @@ namespace AMDiS { } // synchronize adaption flag - unsigned long *flagBuffer = GET_MEMORY(unsigned long, mpiSize); + unsigned long *flagBuffer = new unsigned long[mpiSize]; unsigned long localFlag = flag.getFlags(); mpiComm.Allgather(&localFlag, 1, MPI_UNSIGNED_LONG, flagBuffer, 1, MPI_UNSIGNED_LONG); - for (int i = 0; i < mpiSize; i++) { + for (int i = 0; i < mpiSize; i++) flag.setFlag(flagBuffer[i]); - } - FREE_MEMORY(flagBuffer, unsigned long, mpiSize); + + delete [] flagBuffer; return flag; - }; + } // ========================================================================= // ===== class ParallelProblem ============================================= @@ -270,8 +270,8 @@ namespace AMDiS { { FUNCNAME("ParallelProblem::doPartitioning()"); - double *weightSum = GET_MEMORY(double, mpiSize); - int *partArray = GET_MEMORY(int, mpiSize); + double *weightSum = new double[mpiSize]; + int *partArray = new int[mpiSize]; int part = 0; mpiComm.Gather(&localWeightSum, 1, MPI_DOUBLE, weightSum, 1, MPI_DOUBLE, 0); @@ -279,9 +279,8 @@ namespace AMDiS { if (mpiRank == 0) { double average = 0.0; - for (int i = 0; i < mpiSize; i++) { + for (int i = 0; i < mpiSize; i++) average += weightSum[i]; - } average /= mpiSize; @@ -328,13 +327,14 @@ namespace AMDiS { mpiComm.Scatter(partArray, 1, MPI_INT, &part, 1, MPI_INT, 0); - FREE_MEMORY(weightSum, double, mpiSize); - FREE_MEMORY(partArray, int, mpiSize); + delete [] weightSum; + delete [] partArray; return (part == 1); } - bool ParallelProblem::doBuildGlobalSolution(AdaptInfo *adaptInfo) { + bool ParallelProblem::doBuildGlobalSolution(AdaptInfo *adaptInfo) + { return true; } @@ -478,7 +478,7 @@ namespace AMDiS { const std::vector<unsigned long int>& myCode = structures[mpiRank].getCode(); // broadcast code sizes - int *codeSize = GET_MEMORY(int, mpiSize); + int *codeSize = new int[mpiSize]; int tmp = static_cast<int>(myCode.size()); mpiComm.Allgather(&tmp, 1, MPI_INT, codeSize, 1, MPI_INT); if (debugMode) { @@ -487,7 +487,7 @@ namespace AMDiS { } // broadcast number of elements - int *elements = GET_MEMORY(int, mpiSize); + int *elements = new int[mpiSize]; tmp = structures[mpiRank].getNumElements(); mpiComm.Allgather(&tmp, 1, MPI_INT, elements, 1, MPI_INT); if (debugMode) { @@ -496,23 +496,20 @@ namespace AMDiS { } // broadcast codes - int *codeOffset = GET_MEMORY(int, mpiSize); + int *codeOffset = new int[mpiSize]; int codeSizeSum = 0; for (int rank = 0; rank < mpiSize; rank++) { codeOffset[rank] = codeSizeSum; codeSizeSum += codeSize[rank]; } - unsigned long int *code = GET_MEMORY(unsigned long int, codeSizeSum); - unsigned long int *localCode = GET_MEMORY(unsigned long int, codeSize[mpiRank]); + unsigned long int *code = new unsigned long int[codeSizeSum]; + unsigned long int *localCode = new unsigned long int[codeSize[mpiRank]]; unsigned long int *ptr; std::vector<unsigned long int>::const_iterator it, end = myCode.end(); - for (ptr = localCode, it = myCode.begin(); - it != end; - ++it, ++ptr) { + for (ptr = localCode, it = myCode.begin(); it != end; ++it, ++ptr) *ptr = *it; - } mpiComm.Allgatherv(localCode, codeSize[mpiRank], MPI_UNSIGNED_LONG, @@ -537,13 +534,11 @@ namespace AMDiS { } } - // free memory - FREE_MEMORY(elements, int, mpiSize); - FREE_MEMORY(code, unsigned long int, codeSizeSum); - FREE_MEMORY(localCode, unsigned long int, codeSize[mpiRank]); - FREE_MEMORY(codeOffset, int, mpiSize); - FREE_MEMORY(codeSize, int, mpiSize); - + delete [] elements; + delete [] code; + delete [] localCode; + delete [] codeOffset; + delete [] codeSize; } void ParallelProblem::synchronizeMeshes(AdaptInfo *adaptInfo) @@ -556,11 +551,9 @@ namespace AMDiS { exchangeMeshStructureCodes(structures); // merge codes - for (int rank = 0; rank < mpiSize; rank++) { - if (rank != mpiRank) { + for (int rank = 0; rank < mpiSize; rank++) + if (rank != mpiRank) structures[mpiRank].merge(&structures[rank]); - } - } // build finest mesh on the rank partition structures[mpiRank].fitMeshToStructure(mesh, @@ -597,8 +590,8 @@ namespace AMDiS { int dim = workMesh->getDim(); const BasisFunction *basFcts = feSpace->getBasisFcts(); int numFcts = basFcts->getNumber(); - DegreeOfFreedom *coarseDOFs = GET_MEMORY(DegreeOfFreedom, numFcts); - DegreeOfFreedom *fineDOFs = GET_MEMORY(DegreeOfFreedom, numFcts); + DegreeOfFreedom *coarseDOFs = new DegreeOfFreedom[numFcts]; + DegreeOfFreedom *fineDOFs = new DegreeOfFreedom[numFcts]; DOFAdmin *admin = feSpace->getAdmin(); std::vector<std::vector<DegreeOfFreedom> > sendOrder(mpiSize); @@ -683,21 +676,17 @@ namespace AMDiS { sendBufferSize[partition] = sendSize; recvBufferSize[partition] = recvSize; if (sendSize > 0) { - sendBuffer[partition] = GET_MEMORY(double, sendSize); + sendBuffer[partition] = new double[sendSize]; std::vector<DegreeOfFreedom>::iterator dofIt; dofIt = sendOrder[partition].begin(); double *bufferIt, *bufferBegin, *bufferEnd; bufferBegin = sendBuffer[partition]; bufferEnd = bufferBegin + sendSize; - for (bufferIt = bufferBegin; - bufferIt < bufferEnd; - ++bufferIt, ++dofIt) { + for (bufferIt = bufferBegin; bufferIt < bufferEnd; ++bufferIt, ++dofIt) *bufferIt = (*solution)[*dofIt]; - } - } - if (recvSize > 0) { - recvBuffer[partition] = GET_MEMORY(double, recvSize); } + if (recvSize > 0) + recvBuffer[partition] = new double[recvSize]; } } @@ -744,17 +733,15 @@ namespace AMDiS { // free send and recv buffers for (int partition = 0; partition < mpiSize; partition++) { if (partition != mpiRank) { - if (sendBufferSize[partition] > 0) { - FREE_MEMORY(sendBuffer[partition], double, sendBufferSize[partition]); - } - if (recvBufferSize[partition] > 0) { - FREE_MEMORY(recvBuffer[partition], double, recvBufferSize[partition]); - } + if (sendBufferSize[partition] > 0) + delete [] sendBuffer[partition]; + if (recvBufferSize[partition] > 0) + delete [] recvBuffer[partition]; } } - FREE_MEMORY(coarseDOFs, DegreeOfFreedom, numFcts); - FREE_MEMORY(fineDOFs, DegreeOfFreedom, numFcts); + delete [] coarseDOFs; + delete [] fineDOFs; } void ParallelProblem::exchangeDOFVector(AdaptInfo *adaptInfo, @@ -769,11 +756,10 @@ namespace AMDiS { sendOrder.resize(mpiSize); recvOrder.resize(mpiSize); - int i; const FiniteElemSpace *feSpace = values->getFESpace(); const BasisFunction *basFcts = feSpace->getBasisFcts(); int numFcts = basFcts->getNumber(); - DegreeOfFreedom *dofs = GET_MEMORY(DegreeOfFreedom, numFcts); + DegreeOfFreedom *dofs = new DegreeOfFreedom[numFcts]; DOFAdmin *admin = feSpace->getAdmin(); Mesh *mesh = feSpace->getMesh(); @@ -787,28 +773,26 @@ namespace AMDiS { int oldPartition = oldPartitionVec[index]; int newPartition = partitionVec[index]; - if(oldPartition != newPartition) { + if (oldPartition != newPartition) { // get dof indices basFcts->getLocalIndices(element, admin, dofs); - if(oldPartition == mpiRank) { - for(i = 0; i < numFcts; i++) { - // send element values to new partition + if (oldPartition == mpiRank) { + // send element values to new partition + for (int i = 0; i < numFcts; i++) sendOrder[newPartition].push_back(dofs[i]); - } } - if(newPartition == mpiRank) { - for(i = 0; i < numFcts; i++) { - // recv element values from old partition + if (newPartition == mpiRank) { + // recv element values from old partition + for (int i = 0; i < numFcts; i++) recvOrder[oldPartition].push_back(dofs[i]); - } } } elInfo = stack.traverseNext(elInfo); } - FREE_MEMORY(dofs, DegreeOfFreedom, numFcts); + delete [] dofs; // === create send and recv buffers and fill send buffers === std::map<int, double*> sendBuffer; @@ -825,20 +809,17 @@ namespace AMDiS { sendBufferSize[partition] = sendSize; recvBufferSize[partition] = recvSize; if (sendSize > 0) { - sendBuffer[partition] = GET_MEMORY(double, sendSize); + sendBuffer[partition] = new double[sendSize]; std::vector<DegreeOfFreedom>::iterator dofIt; dofIt = sendOrder[partition].begin(); double *bufferIt, *bufferBegin, *bufferEnd; bufferBegin = sendBuffer[partition]; bufferEnd = bufferBegin + sendSize; - for (bufferIt = bufferBegin; - bufferIt < bufferEnd; - ++bufferIt, ++dofIt) { + for (bufferIt = bufferBegin; bufferIt < bufferEnd; ++bufferIt, ++dofIt) *bufferIt = (*values)[*dofIt]; - } } if (recvSize > 0) - recvBuffer[partition] = GET_MEMORY(double, recvSize); + recvBuffer[partition] = new double[recvSize]; } } @@ -875,7 +856,7 @@ namespace AMDiS { for (partition = 0; partition < mpiSize; partition++) { if (partition != mpiRank) { std::vector<DegreeOfFreedom>::iterator dofIt = recvOrder[partition].begin(); - for (i = 0; i < recvBufferSize[partition]; i++) { + for (int i = 0; i < recvBufferSize[partition]; i++) { (*values)[*dofIt] = recvBuffer[partition][i]; ++dofIt; } @@ -886,13 +867,9 @@ namespace AMDiS { for (partition = 0; partition < mpiSize; partition++) { if (partition != mpiRank) { if (sendBufferSize[partition] > 0) - FREE_MEMORY(sendBuffer[partition], - double, - sendBufferSize[partition]); + delete [] sendBuffer[partition]; if (recvBufferSize[partition] > 0) - FREE_MEMORY(recvBuffer[partition], - double, - recvBufferSize[partition]); + delete [] recvBuffer[partition]; } } } @@ -907,10 +884,9 @@ namespace AMDiS { int dim = mesh->getDim(); const BasisFunction *basFcts = feSpace->getBasisFcts(); int numFcts = basFcts->getNumber(); - DegreeOfFreedom *coarseDOFs = GET_MEMORY(DegreeOfFreedom, numFcts); - DegreeOfFreedom *fineDOFs = GET_MEMORY(DegreeOfFreedom, numFcts); - DOFAdmin *admin = feSpace->getAdmin(); - + DegreeOfFreedom *coarseDOFs = new DegreeOfFreedom[numFcts]; + DegreeOfFreedom *fineDOFs = new DegreeOfFreedom[numFcts]; + DOFAdmin *admin = feSpace->getAdmin(); Lagrange *linearFunctions = Lagrange::getLagrange(dim, 1); MSG("Building global solution\n"); @@ -996,8 +972,8 @@ namespace AMDiS { &small, &large); } - FREE_MEMORY(coarseDOFs, DegreeOfFreedom, numFcts); - FREE_MEMORY(fineDOFs, DegreeOfFreedom, numFcts); + delete [] coarseDOFs; + delete [] fineDOFs; MSG("PU ...\n"); @@ -1267,29 +1243,28 @@ namespace AMDiS { // === exchange 'inner' overlap elements === // exchange number of overlap elements - int *numOverlapElements = GET_MEMORY(int, mpiSize); + int *numOverlapElements = new int[mpiSize]; int tmp = static_cast<int>(innerOverlapElements.size()); mpiComm.Allgather(&tmp, 1, MPI_INT, numOverlapElements, 1, MPI_INT); // exchange overlap elements - int *offset = GET_MEMORY(int, mpiSize); + int *offset = new int[mpiSize]; int sum = 0; for (int rank = 0; rank < mpiSize; rank++) { offset[rank] = sum; sum += numOverlapElements[rank]; } - int *recvBuffer = GET_MEMORY(int, sum); - int *sendBuffer = GET_MEMORY(int, numOverlapElements[mpiRank]); + int *recvBuffer = new int[sum]; + int *sendBuffer = new int[numOverlapElements[mpiRank]]; int *ptr; std::vector<int>::iterator elemIt, elemEnd = innerOverlapElements.end(); for (ptr = sendBuffer, elemIt = innerOverlapElements.begin(); elemIt != elemEnd; - ++elemIt, ++ptr) { + ++elemIt, ++ptr) *ptr = *elemIt; - } mpiComm.Allgatherv(sendBuffer, numOverlapElements[mpiRank], MPI_INT, recvBuffer, numOverlapElements, offset, MPI_INT); @@ -1309,9 +1284,9 @@ namespace AMDiS { // free memory delete [] structures; - FREE_MEMORY(recvBuffer, int, sum); - FREE_MEMORY(sendBuffer, int, numOverlapElements[mpiRank]); - FREE_MEMORY(numOverlapElements, int, mpiSize); + delete [] recvBuffer; + delete [] sendBuffer; + delete [] numOverlapElements; } } @@ -1684,7 +1659,7 @@ namespace AMDiS { int sendSize = partitionVec.size() * 2; MPI::COMM_WORLD.Send(&sendSize, 1, MPI_INT, 0, 100); - int *sendBuffer = GET_MEMORY(int, sendSize); + int *sendBuffer = new int[sendSize]; int bufferPos = 0; for (std::map<int, int>::iterator it = partitionVec.begin(); it != partitionVec.end(); @@ -1693,7 +1668,7 @@ namespace AMDiS { sendBuffer[bufferPos++] = it->second; } MPI::COMM_WORLD.Send(sendBuffer, sendSize, MPI_INT, 0, 100); - FREE_MEMORY(sendBuffer, int, sendSize); + delete [] sendBuffer; } } @@ -1702,9 +1677,9 @@ namespace AMDiS { std::vector<DOFVector<double>*> rankSol(mpiSize); for (int i = 0; i < nComponents; i++) { - for (int j = 0; j < mpiSize; j++) { + for (int j = 0; j < mpiSize; j++) rankSol[j] = rankSolution[j]->getDOFVector(i); - } + ParallelProblem::buildGlobalSolution(adaptInfo, rankSol, problem->getSolution()->getDOFVector(i)); @@ -1716,7 +1691,7 @@ namespace AMDiS { const BasisFunction *basFcts = feSpace->getBasisFcts(); DOFAdmin *admin = feSpace->getAdmin(); int numFcts = basFcts->getNumber(); - DegreeOfFreedom *elDOFs = GET_MEMORY(DegreeOfFreedom, numFcts); + DegreeOfFreedom *elDOFs = new DegreeOfFreedom[numFcts]; int elementPartition = -1; std::vector<double> sendDOFs(0); @@ -1728,17 +1703,15 @@ namespace AMDiS { PartitionElementData *partitionData = dynamic_cast<PartitionElementData*> (element->getElementData(PARTITION_ED)); - if (partitionData && (partitionData->getLevel() == 0)) { + if (partitionData && (partitionData->getLevel() == 0)) elementPartition = partitionVec[element->getIndex()]; - } // On leaf level, each rank assemble its own solution part. if (element->isLeaf() && (elementPartition == mpiRank)) { basFcts->getLocalIndices(element, admin, elDOFs); - for (int i = 0; i < numFcts; i++) { + for (int i = 0; i < numFcts; i++) sendDOFs.push_back((*problem->getSolution()->getDOFVector(0))[elDOFs[i]]); - } } elInfo = stack.traverseNext(elInfo); @@ -1749,14 +1722,13 @@ namespace AMDiS { MPI::COMM_WORLD.Send(&sendSize, 1, MPI_INT, 0, 100); // Create send buffer of values and send it to the debug server. - double *sendBuffer = GET_MEMORY(double, sendSize); - for (int i = 0; i < sendSize; i++) { + double *sendBuffer = new double[sendSize]; + for (int i = 0; i < sendSize; i++) sendBuffer[i] = sendDOFs[i]; - } MPI::COMM_WORLD.Send(sendBuffer, sendSize, MPI_DOUBLE, 0, 100); - FREE_MEMORY(sendBuffer, double, sendSize); - FREE_MEMORY(elDOFs, DegreeOfFreedom, numFcts); + delete [] sendBuffer; + delete [] elDOFs; } } @@ -1801,9 +1773,9 @@ namespace AMDiS { const BasisFunction *basFcts = feSpace->getBasisFcts(); int numFcts = basFcts->getNumber(); int mpiWorldSize = MPI::COMM_WORLD.Get_size(); - int *codeSize = GET_MEMORY(int, mpiWorldSize); - int *nElements = GET_MEMORY(int, mpiWorldSize); - DegreeOfFreedom *elDOFs = GET_MEMORY(DegreeOfFreedom, numFcts); + int *codeSize = new int[mpiWorldSize]; + int *nElements = new int[mpiWorldSize]; + DegreeOfFreedom *elDOFs = new DegreeOfFreedom[numFcts]; unsigned long int *code; int mpiTag = 100; @@ -1833,27 +1805,24 @@ namespace AMDiS { // Get all mesh structure codes for (int i = 1; i < mpiWorldSize; i++) { - code = GET_MEMORY(unsigned long int, codeSize[i]); + code = new unsigned long int[codeSize[i]]; - MPI::COMM_WORLD.Recv(code, codeSize[i], MPI_UNSIGNED_LONG, - i, mpiTag); + MPI::COMM_WORLD.Recv(code, codeSize[i], MPI_UNSIGNED_LONG, i, mpiTag); std::vector<unsigned long int> codeVec(codeSize[i]); - for (int j = 0; j < codeSize[i]; j++) { + for (int j = 0; j < codeSize[i]; j++) codeVec[j] = code[j]; - } structures[i].init(codeVec, nElements[i]); - FREE_MEMORY(code, unsigned long int, codeSize[i]); + delete [] code; } /* ======== Simulate synchronizeMeshes() ======= */ // Build finest mesh starting from rank 1 solution - for (int rank = 2; rank < mpiWorldSize; rank++) { + for (int rank = 2; rank < mpiWorldSize; rank++) structures[1].merge(&structures[rank]); - } structures[1].fitMeshToStructure(mesh, refinementManager, false); @@ -1867,13 +1836,12 @@ namespace AMDiS { int recvSize = 0; MPI::COMM_WORLD.Recv(&recvSize, 1, MPI_INT, 1, mpiTag); - int *recvBuffer = GET_MEMORY(int, recvSize); + int *recvBuffer = new int[recvSize]; MPI::COMM_WORLD.Recv(recvBuffer, recvSize, MPI_INT, 1, mpiTag); partitionVec.clear(); - for (int i = 0; i < recvSize; i += 2) { + for (int i = 0; i < recvSize; i += 2) partitionVec[recvBuffer[i]] = recvBuffer[i + 1]; - } - FREE_MEMORY(recvBuffer, int, recvSize); + delete [] recvBuffer; /* ======= Communication with buildGlobalSolution() ======= */ @@ -1884,7 +1852,7 @@ namespace AMDiS { MPI::COMM_WORLD.Recv(&recvSize, 1, MPI_INT, i, mpiTag); // Now, receive the solution DOFS of rank i - double *recvBufferDouble = GET_MEMORY(double, recvSize); + double *recvBufferDouble = new double[recvSize]; MPI::COMM_WORLD.Recv(recvBufferDouble, recvSize, MPI_DOUBLE, i, mpiTag); // Traverse through the overall mesh, get all elements that are refined from @@ -1913,7 +1881,7 @@ namespace AMDiS { elInfo = stack.traverseNext(elInfo); } - FREE_MEMORY(recvBufferDouble, double, recvSize); + delete [] recvBufferDouble; } @@ -1921,8 +1889,8 @@ namespace AMDiS { debugFunction(adaptInfo); } - FREE_MEMORY(elDOFs, DegreeOfFreedom, numFcts); - FREE_MEMORY(codeSize, int, mpiWorldSize); - FREE_MEMORY(nElements, int, mpiWorldSize); + delete [] elDOFs; + delete [] codeSize; + delete [] nElements; } } diff --git a/AMDiS/src/ProblemScal.cc b/AMDiS/src/ProblemScal.cc index 13c0a9ff577b7d9e3c070ca9d56b181041e655cc..daa80b7d4520d116aa8778515148fbe3d77cad6e 100644 --- a/AMDiS/src/ProblemScal.cc +++ b/AMDiS/src/ProblemScal.cc @@ -573,7 +573,7 @@ namespace AMDiS { while (elInfo) { if (useGetBound) { - bound = GET_MEMORY(BoundaryType, feSpace->getBasisFcts()->getNumber()); + bound = new BoundaryType[feSpace->getBasisFcts()->getNumber()]; feSpace->getBasisFcts()->getBound(elInfo, bound); } else { bound = NULL; @@ -583,7 +583,7 @@ namespace AMDiS { rhs->assemble(1.0, elInfo, bound); if (useGetBound) - FREE_MEMORY(bound, BoundaryType, feSpace->getBasisFcts()->getNumber()); + delete [] bound; if (systemMatrix->getBoundaryManager()) systemMatrix->getBoundaryManager()->fillBoundaryConditions(elInfo, systemMatrix); diff --git a/AMDiS/src/ProblemVec.cc b/AMDiS/src/ProblemVec.cc index ba7df9c032a1a29fde80b295b1184f06be57c635..728525639e26f2e19d8fde8a0abdbf7f92f7baae 100644 --- a/AMDiS/src/ProblemVec.cc +++ b/AMDiS/src/ProblemVec.cc @@ -1002,7 +1002,7 @@ namespace AMDiS { #endif { BoundaryType *bound = - useGetBound ? GET_MEMORY(BoundaryType, basisFcts->getNumber()) : NULL; + useGetBound ? new BoundaryType[basisFcts->getNumber()] : NULL; // Create for every thread its private matrix and vector, on that // the thread will assemble its part of the mesh. @@ -1109,8 +1109,7 @@ namespace AMDiS { } if (useGetBound) - FREE_MEMORY(bound, BoundaryType, basisFcts->getNumber()); - + delete [] bound; } // pragma omp parallel } @@ -1124,7 +1123,7 @@ namespace AMDiS { const BasisFunction *basisFcts = rowFeSpace->getBasisFcts(); BoundaryType *bound = NULL; if (useGetBound) - bound = GET_MEMORY(BoundaryType, basisFcts->getNumber()); + bound = new BoundaryType[basisFcts->getNumber()]; if (matrix) matrix->startInsertion(); @@ -1159,7 +1158,7 @@ namespace AMDiS { } if (useGetBound) - FREE_MEMORY(bound, BoundaryType, basisFcts->getNumber()); + delete [] bound; } @@ -1175,7 +1174,7 @@ namespace AMDiS { const BasisFunction *basisFcts = mainFeSpace->getBasisFcts(); BoundaryType *bound = NULL; if (useGetBound) - bound = GET_MEMORY(BoundaryType, basisFcts->getNumber()); + bound = new BoundaryType[basisFcts->getNumber()]; if (matrix) matrix->startInsertion(); @@ -1204,7 +1203,7 @@ namespace AMDiS { } if (useGetBound) - FREE_MEMORY(bound, BoundaryType, basisFcts->getNumber()); + delete [] bound; } void ProblemVec::assembleBoundaryConditions(DOFVector<double> *rhs, diff --git a/AMDiS/src/QPInfo.cc b/AMDiS/src/QPInfo.cc index 86f8f792648819866df3f085780db54493a7f89f..93047902d7afbb2b20b1f9a82e5f0b703566d466 100644 --- a/AMDiS/src/QPInfo.cc +++ b/AMDiS/src/QPInfo.cc @@ -23,49 +23,37 @@ namespace AMDiS { QPInfo::~QPInfo() { - int i; + if (coordsAtQPs_) delete [] coordsAtQPs_; - if(coordsAtQPs_) delete [] coordsAtQPs_; - - if(elementNormalAtQPs_) { - for(i = 0; i < numPoints_; i++) { + if (elementNormalAtQPs_) { + for (int i = 0; i < numPoints_; i++) delete elementNormalAtQPs_[i]; - } - FREE_MEMORY(elementNormalAtQPs_, - WorldVector<double>*, - numPoints_); - } - if(elementNormalConst_) { - FREE_MEMORY(elementNormalConst_, - WorldVector<double>*, - numPoints_); + delete [] elementNormalAtQPs_; } - if(grdLambdaAtQPs_) { - for(i = 0; i < numPoints_; i++) { + if (elementNormalConst_) + delete [] elementNormalConst_; + + if (grdLambdaAtQPs_) { + for (int i = 0; i < numPoints_; i++) delete grdLambdaAtQPs_[i]; - } - FREE_MEMORY(grdLambdaAtQPs_, - DimVec<WorldVector<double> >*, - numPoints_); - } - if(grdLambdaConst_) { - FREE_MEMORY(grdLambdaConst_, - DimVec<WorldVector<double> >*, - numPoints_); + delete [] grdLambdaAtQPs_; } + if (grdLambdaConst_) + delete [] grdLambdaConst_; + std::map<const DOFVector<double>*, VecQPInfo*>::iterator - it, itEnd = vecQPInfos_.end(); + it, itEnd = vecQPInfos_.end(); - for(it = vecQPInfos_.begin(); it != itEnd; ++it) { - if(it->second->valAtQPs_) - FREE_MEMORY(it->second->valAtQPs_, double, numPoints_); - if(it->second->grdAtQPs_) + for (it = vecQPInfos_.begin(); it != itEnd; ++it) { + if (it->second->valAtQPs_) + delete [] it->second->valAtQPs_; + if (it->second->grdAtQPs_) delete [] it->second->grdAtQPs_; - if(it->second->D2AtQPs_) + if (it->second->D2AtQPs_) delete [] it->second->D2AtQPs_; delete it->second; } @@ -74,17 +62,14 @@ namespace AMDiS { void QPInfo::initElement(const ElInfo *elInfo) { currentElInfo_ = elInfo; - coordsNumPointsValid_ = 0; - elementNormalNumPointsValid_ = 0; - grdLambdaNumPointsValid_ = 0; std::map<const DOFVector<double>*, VecQPInfo*>::iterator it, itEnd = vecQPInfos_.end(); - for(it = vecQPInfos_.begin(); it != itEnd; ++it) { + for (it = vecQPInfos_.begin(); it != itEnd; ++it) { it->second->valNumPointsValid_ = 0; it->second->grdNumPointsValid_ = 0; it->second->D2NumPointsValid_ = 0; @@ -93,12 +78,11 @@ namespace AMDiS { WorldVector<double> *QPInfo::getCoordsAtQPs(int numPoints) { - if(coordsNumPointsValid_ < numPoints) { - if(!coordsAtQPs_) { + if (coordsNumPointsValid_ < numPoints) { + if (!coordsAtQPs_) coordsAtQPs_ = new WorldVector<double>[numPoints_]; - } - int i; - for(i = 0; i < numPoints; i++) { + + for (int i = 0; i < numPoints; i++) { const DimVec<double>& lambda = quadrature_->getLambda(i); TEST_EXIT_DBG(currentElInfo_)("currentElInfo_ not set\n"); currentElInfo_->coordToWorld(lambda, coordsAtQPs_[i]); @@ -113,25 +97,22 @@ namespace AMDiS { const FastQuadrature *quadFast) { // check fast quadrature - if(quadFast) { + if (quadFast) TEST_EXIT_DBG(quadrature_ == quadFast->getQuadrature()) - ("quadrature_ != quadFast->quadrature\n"); - } + ("quadrature_ != quadFast->quadrature\n"); // create new info if necessary - if(vecQPInfos_[vec] == NULL) { + if (vecQPInfos_[vec] == NULL) vecQPInfos_[vec] = new VecQPInfo; - } VecQPInfo *localVecQPInfo = vecQPInfos_[vec]; // update values if necessary - if(localVecQPInfo->valNumPointsValid_ < numPoints) { + if (localVecQPInfo->valNumPointsValid_ < numPoints) { // allocate memory if necessary - if(localVecQPInfo->valAtQPs_ == NULL) { - localVecQPInfo->valAtQPs_ = GET_MEMORY(double, numPoints_); - } + if (localVecQPInfo->valAtQPs_ == NULL) + localVecQPInfo->valAtQPs_ = new double[numPoints_]; // fill memory vec->getVecAtQPs(currentElInfo_, @@ -229,18 +210,15 @@ namespace AMDiS { { TEST_EXIT_DBG(currentElInfo_)("currentElInfo_ not set\n"); - int i; - if(currentElInfo_->getParametricOrder() > 1) { - if(!elementNormalAtQPs_) { - elementNormalAtQPs_ = GET_MEMORY(WorldVector<double>*, - numPoints_); - for(i = 0; i < numPoints_; i++) { + if (currentElInfo_->getParametricOrder() > 1) { + if (!elementNormalAtQPs_) { + elementNormalAtQPs_ = new WorldVector<double>*[numPoints_]; + for (int i = 0; i < numPoints_; i++) elementNormalAtQPs_[i] = new WorldVector<double>; - } } - if(elementNormalNumPointsValid_ < numPoints) { - for(i = 0; i < numPoints; i++) { + if (elementNormalNumPointsValid_ < numPoints) { + for (int i = 0; i < numPoints; i++) { const DimVec<double>& lambda = quadrature_->getLambda(i); currentElInfo_->getElementNormal(*(elementNormalAtQPs_[i]), &lambda); } @@ -248,14 +226,12 @@ namespace AMDiS { } return elementNormalAtQPs_; } else { - if(!elementNormalConst_) { - elementNormalConst_ = GET_MEMORY(WorldVector<double>*, - numPoints_); + if (!elementNormalConst_) { + elementNormalConst_ = new WorldVector<double>*[numPoints_]; elementNormalConst_[0] = new WorldVector<double>; - for(i = 1; i < numPoints_; i++) { + for (int i = 1; i < numPoints_; i++) elementNormalConst_[i] = elementNormalConst_[0]; - } } currentElInfo_->getElementNormal(*(elementNormalConst_[0])); return elementNormalConst_; @@ -266,19 +242,15 @@ namespace AMDiS { { TEST_EXIT_DBG(currentElInfo_)("currentElInfo_ not set\n"); - int i; - if(currentElInfo_->getParametricOrder() > 1) { - if(!grdLambdaAtQPs_) { - grdLambdaAtQPs_ = GET_MEMORY(DimVec<WorldVector<double> >*, - numPoints_); - for(i = 0; i < numPoints_; i++) { - grdLambdaAtQPs_[i] = - new DimVec<WorldVector<double> >(quadrature_->getDim()); - } + if (currentElInfo_->getParametricOrder() > 1) { + if (!grdLambdaAtQPs_) { + grdLambdaAtQPs_ = new DimVec<WorldVector<double> >*[numPoints_]; + for (int i = 0; i < numPoints_; i++) + grdLambdaAtQPs_[i] = new DimVec<WorldVector<double> >(quadrature_->getDim()); } - if(grdLambdaNumPointsValid_ < numPoints) { - for(i = 0; i < numPoints; i++) { + if (grdLambdaNumPointsValid_ < numPoints) { + for (int i = 0; i < numPoints; i++) { const DimVec<double>& lambda = quadrature_->getLambda(i); currentElInfo_->calcGrdLambda(*(grdLambdaAtQPs_[i]), &lambda); } @@ -286,15 +258,12 @@ namespace AMDiS { } return grdLambdaAtQPs_; } else { - if(!grdLambdaConst_) { - grdLambdaConst_ = GET_MEMORY(DimVec<WorldVector<double> >*, - numPoints_); - grdLambdaConst_[0] = - new DimVec<WorldVector<double> >(quadrature_->getDim()); + if (!grdLambdaConst_) { + grdLambdaConst_ = new DimVec<WorldVector<double> >*[numPoints_]; + grdLambdaConst_[0] = new DimVec<WorldVector<double> >(quadrature_->getDim()); - for(i = 1; i < numPoints_; i++) { + for (int i = 1; i < numPoints_; i++) grdLambdaConst_[i] = grdLambdaConst_[0]; - } } currentElInfo_->calcGrdLambda(*(grdLambdaConst_[0])); return grdLambdaConst_; diff --git a/AMDiS/src/QPsiPhi.cc b/AMDiS/src/QPsiPhi.cc index d96acb69c54e2f622b3253368577daad0a11fccb..01e9f8d6e06115f889376a7c5560196017f7dab7 100644 --- a/AMDiS/src/QPsiPhi.cc +++ b/AMDiS/src/QPsiPhi.cc @@ -60,16 +60,16 @@ namespace AMDiS { n_phi = phi->getNumber(); q_phi = FastQuadrature::provideFastQuadrature(phi, *quadrature, INIT_GRD_PHI); - nrEntries = GET_MEMORY(int*, n_psi); - values = GET_MEMORY(double**, n_psi); - k = GET_MEMORY(int**, n_psi); - l = GET_MEMORY(int**, n_psi); - for(i=0;i<n_psi;i++){ - nrEntries[i]=GET_MEMORY(int, n_phi); - values[i]= GET_MEMORY(double*, n_phi); - k[i]= GET_MEMORY(int*, n_phi); - l[i]= GET_MEMORY(int*, n_phi); - }; + nrEntries = new int*[n_psi]; + values = new double**[n_psi]; + k = new int**[n_psi]; + l = new int**[n_psi]; + for (int i = 0; i <n_psi; i++) { + nrEntries[i] = new int[n_phi]; + values[i] = new double*[n_phi]; + k[i] = new int*[n_phi]; + l[i] = new int*[n_phi]; + } //**************************************************************************** @@ -79,11 +79,11 @@ namespace AMDiS { int numPoints = quadrature->getNumPoints(); all_entries = 0; - for(i = 0; i < n_psi; i++) { - for(j = 0; j < n_phi; j++) { - for(lk = 0; lk < d+1; lk++) { - for(ll = 0; ll < d+1; ll++) { - for(val = iq = 0; iq < numPoints; iq++) { + for (int i = 0; i < n_psi; i++) { + for (j = 0; j < n_phi; j++) { + for (lk = 0; lk < d+1; lk++) { + for (ll = 0; ll < d+1; ll++) { + for (val = iq = 0; iq < numPoints; iq++) { grdi = q_psi->getGradient(iq,i,lk); grdj = q_phi->getGradient(iq,j,ll); @@ -101,15 +101,15 @@ namespace AMDiS { //**************************************************************************** allEntries = all_entries; - val_vec = GET_MEMORY(double, all_entries); - k_vec = GET_MEMORY(int, all_entries); - l_vec = GET_MEMORY(int, all_entries); + val_vec = new double[all_entries]; + k_vec = new int[all_entries]; + l_vec = new int[all_entries]; //*************************************************************************** // and now, fill information * //*************************************************************************** - for (i = 0; i < n_psi; i++) { + for (int i = 0; i < n_psi; i++) { for (j = 0; j < n_phi; j++) { values[i][j] = val_vec; k[i][j] = k_vec; @@ -143,21 +143,20 @@ namespace AMDiS { Q11PsiPhi::~Q11PsiPhi() { - if(nrEntries) { - for(int i=0; i < psi->getNumber(); i++) { - FREE_MEMORY(nrEntries[i], int, phi->getNumber()); - FREE_MEMORY(values[i], double*, phi->getNumber()); - FREE_MEMORY(k[i], int*, phi->getNumber()); - FREE_MEMORY(l[i], int*, phi->getNumber()); + if (nrEntries) { + for (int i = 0; i < psi->getNumber(); i++) { + delete [] nrEntries[i]; + delete [] values[i]; + delete [] k[i]; + delete [] l[i]; } - FREE_MEMORY(nrEntries, int*, psi->getNumber()); - FREE_MEMORY(values, double**, psi->getNumber()); - FREE_MEMORY(k, int**, psi->getNumber()); - FREE_MEMORY(l, int**, psi->getNumber()); - - FREE_MEMORY(val_vec, double, allEntries); - FREE_MEMORY(k_vec, int, allEntries); - FREE_MEMORY(l_vec, int, allEntries); + delete [] nrEntries; + delete [] values; + delete [] k; + delete [] l; + delete [] val_vec; + delete [] k_vec; + delete [] l_vec; } } @@ -241,14 +240,14 @@ namespace AMDiS { n_phi = phi->getNumber(); q_phi = FastQuadrature::provideFastQuadrature(phi, *quadrature, INIT_GRD_PHI); - nrEntries = GET_MEMORY(int*, n_psi); - values = GET_MEMORY(double**, n_psi); - k = GET_MEMORY(int**, n_psi); - for(i=0;i<n_psi;i++){ - nrEntries[i]= GET_MEMORY(int, n_phi); - values[i] = GET_MEMORY(double*, n_phi); - k[i] = GET_MEMORY(int*, n_phi); - }; + nrEntries = new int*[n_psi]; + values = new double**[n_psi]; + k = new int**[n_psi]; + for (int i = 0; i < n_psi; i++) { + nrEntries[i] = new int[n_phi]; + values[i] = new double*[n_phi]; + k[i] = new int*[n_phi]; + } /****************************************************************************/ /* compute first the number of all non zero entries */ @@ -274,8 +273,8 @@ namespace AMDiS { /* now, access memory for all information */ /****************************************************************************/ - val_vec = GET_MEMORY(double, all_entries); - k_vec = GET_MEMORY(int, all_entries); + val_vec = new double[all_entries]; + k_vec = new int[all_entries]; /****************************************************************************/ /* and now, fill information */ @@ -308,18 +307,18 @@ namespace AMDiS { Q10PsiPhi::~Q10PsiPhi() { - if(nrEntries) { - for(int i=0; i < psi->getNumber(); i++) { - FREE_MEMORY(nrEntries[i], int, phi->getNumber()); - FREE_MEMORY(values[i], double*, phi->getNumber()); - FREE_MEMORY(k[i], int*, phi->getNumber()); + if (nrEntries) { + for (int i = 0; i < psi->getNumber(); i++) { + delete [] nrEntries[i]; + delete [] values[i]; + delete [] k[i]; } - FREE_MEMORY(nrEntries, int*, psi->getNumber()); - FREE_MEMORY(values, double**, psi->getNumber()); - FREE_MEMORY(k, int**, psi->getNumber()); + delete [] nrEntries; + delete [] values; + delete [] k; - FREE_MEMORY(val_vec, double, allEntries); - FREE_MEMORY(k_vec, int, allEntries); + delete [] val_vec; + delete [] k_vec; } } @@ -401,14 +400,14 @@ namespace AMDiS { n_phi = phi->getNumber(); q_phi = FastQuadrature::provideFastQuadrature(phi, *quadrature, INIT_PHI); - nrEntries = GET_MEMORY(int*, n_psi); - values = GET_MEMORY(double**, n_psi); - l = GET_MEMORY(int**, n_psi); - for(i=0;i<n_psi;i++){ - nrEntries[i]=GET_MEMORY(int, n_phi); - values[i]= GET_MEMORY(double*, n_phi); - l[i]= GET_MEMORY(int*, n_phi); - }; + nrEntries = new int*[n_psi]; + values = new double**[n_psi]; + l = new int**[n_psi]; + for (int i = 0; i < n_psi; i++) { + nrEntries[i] = new int[n_phi]; + values[i] = new double*[n_phi]; + l[i] = new int*[n_phi]; + } /****************************************************************************/ @@ -435,8 +434,8 @@ namespace AMDiS { /* now, access memory for all information */ /****************************************************************************/ - val_vec = GET_MEMORY(double, all_entries); - l_vec = GET_MEMORY(int, all_entries); + val_vec = new double[all_entries]; + l_vec = new int[all_entries]; /****************************************************************************/ /* and now, fill information */ @@ -469,18 +468,18 @@ namespace AMDiS { Q01PsiPhi::~Q01PsiPhi() { - if(nrEntries) { - for(int i=0; i < psi->getNumber(); i++) { - FREE_MEMORY(nrEntries[i], int, phi->getNumber()); - FREE_MEMORY(values[i], double*, phi->getNumber()); - FREE_MEMORY(l[i], int*, phi->getNumber()); + if (nrEntries) { + for (int i = 0; i < psi->getNumber(); i++) { + delete [] nrEntries[i]; + delete [] values[i]; + delete [] l[i]; } - FREE_MEMORY(nrEntries, int*, psi->getNumber()); - FREE_MEMORY(values, double**, psi->getNumber()); - FREE_MEMORY(l, int**, psi->getNumber()); + delete [] nrEntries; + delete [] values; + delete [] l; - FREE_MEMORY(val_vec, double, allEntries); - FREE_MEMORY(l_vec, int, allEntries); + delete [] val_vec; + delete [] l_vec; } } @@ -577,10 +576,9 @@ namespace AMDiS { n_phi = phi->getNumber(); q_phi = FastQuadrature::provideFastQuadrature(phi, *quadrature, INIT_PHI); - values = GET_MEMORY(double*, n_psi); - for(i=0;i<n_psi;i++){ - values[i]= GET_MEMORY(double, n_phi); - }; + values = new double*[n_psi]; + for (int i = 0; i < n_psi; i++) + values[i] = new double[n_phi]; /****************************************************************************/ @@ -602,10 +600,10 @@ namespace AMDiS { Q00PsiPhi::~Q00PsiPhi() { - for(int i=0; i < psi->getNumber(); i++) { - FREE_MEMORY(values[i], double, phi->getNumber()); - } - FREE_MEMORY(values, double*, psi->getNumber()); + for (int i = 0; i < psi->getNumber(); i++) + delete [] values[i]; + + delete [] values; } const bool Q00PsiPhi::operator==(const Q00PsiPhi& q00pp) const @@ -672,10 +670,10 @@ namespace AMDiS { n_psi = psi->getNumber(); q_psi = FastQuadrature::provideFastQuadrature(psi, *quadrature, INIT_PHI); - values = GET_MEMORY(double, n_psi); + values = new double[n_psi]; - for(i = 0; i < n_psi; i++) { - for(val = iq = 0; iq < numPoints; iq++) { + for (int i = 0; i < n_psi; i++) { + for (val = iq = 0; iq < numPoints; iq++) { psii = q_psi->getPhi(iq,i); val += quadrature->getWeight(iq)*psii; } @@ -689,7 +687,7 @@ namespace AMDiS { Q0Psi::~Q0Psi() { - FREE_MEMORY(values, double, psi->getNumber()); + delete [] values; } const bool Q0Psi::operator==(const Q0Psi& q0p) const @@ -741,9 +739,9 @@ namespace AMDiS { n_psi = psi->getNumber(); q_psi = FastQuadrature::provideFastQuadrature(psi, *quadrature, INIT_GRD_PHI); - nrEntries = GET_MEMORY(int, n_psi); - values = GET_MEMORY(double*, n_psi); - k = GET_MEMORY(int*, n_psi); + nrEntries = new int[n_psi]; + values = new double*[n_psi]; + k = new int*[n_psi]; //**************************************************************************** //* compute first the number of all non zero entries * @@ -772,8 +770,8 @@ namespace AMDiS { //**************************************************************************** allEntries = all_entries; - val_vec = GET_MEMORY(double, all_entries); - k_vec = GET_MEMORY(int, all_entries); + val_vec = new double[all_entries]; + k_vec = new int[all_entries]; //*************************************************************************** // and now, fill information * @@ -805,13 +803,12 @@ namespace AMDiS { Q1Psi::~Q1Psi() { - if(nrEntries) { - FREE_MEMORY(nrEntries, int, psi->getNumber()); - FREE_MEMORY(values, double*, psi->getNumber()); - FREE_MEMORY(k, int*, psi->getNumber()); - - FREE_MEMORY(val_vec, double, allEntries); - FREE_MEMORY(k_vec, int, allEntries); + if (nrEntries) { + delete [] nrEntries; + delete [] values; + delete [] k; + delete [] val_vec; + delete [] k_vec; } }