diff --git a/Geo/ChainComplex.cpp b/Geo/ChainComplex.cpp index 87ce20442571e5a572c156be15a8e024bb1aa469..a26d89a19bb4c4bbcd0d70b98f51e143ab769ed8 100644 --- a/Geo/ChainComplex.cpp +++ b/Geo/ChainComplex.cpp @@ -391,7 +391,6 @@ void ChainComplex::computeHomology(bool dual) return; } - void ChainComplex::matrixTest() { const int rows = 3; @@ -401,11 +400,11 @@ void ChainComplex::matrixTest() for(int i = 1; i<=rows*cols; i++) elems[i-1] = i; gmp_matrix* matrix = create_gmp_matrix_int(rows, cols, elems); - gmp_matrix* copymatrix = copy_gmp_matrix(matrix, 3, 2, 3, 5); - printMatrix(matrix); printMatrix(copymatrix); + destroy_gmp_matrix(matrix); + destroy_gmp_matrix(copymatrix); } std::vector<int> ChainComplex::getCoeffVector(int dim, int chainNumber) @@ -453,8 +452,9 @@ void ChainComplex::getBasisChain(std::map<Cell*, int, Less_Cell>& chain, chain.clear(); if(dim < 0 || dim > 4) return; - if(basisMatrix == NULL - || (int)gmp_matrix_cols(basisMatrix) < num) return; + if(basisMatrix == NULL || (int)gmp_matrix_cols(basisMatrix) < num){ + return; + } int elemi; long int elemli; @@ -920,7 +920,11 @@ gmp_matrix* HomologySequence::createIncMap(gmp_matrix* domBasis, if(mpz_cmp_si(remainder, 0) == 0){ gmp_matrix_set_elem(result, i, j, LB); } - else return NULL; + else{ + destroy_gmp_normal_form(normalForm); + destroy_gmp_matrix(LB); + return NULL; + } } } diff --git a/Geo/ExtrudeParams.cpp b/Geo/ExtrudeParams.cpp index a1fe11b3c274adfff427f00e17ce9d23be879673..d895f5c9f4bdb60621d6cf1d89664acab67a4ca0 100644 --- a/Geo/ExtrudeParams.cpp +++ b/Geo/ExtrudeParams.cpp @@ -14,7 +14,7 @@ std::vector<SPoint3> ExtrudeParams::normalsCoherence; // If one section of the boundary layer index = 0 or 1 is not supposed to be // scaled...that section's normals will have scaleFactor = 1.0 (exactly 1.0 to all sig figs) // ...however, if that non-scaled -// section borders a scaled section, the boundary normals will extrude consistently (an +// section borders a scaled section, the boundary normals will extrude consistently (an // average of scaled and non-scaled heights). bool ExtrudeParams::calcLayerScaleFactor[2] = {0,0}; // Added by Trevor Strickler @@ -63,16 +63,18 @@ void ExtrudeParams::Extrude(int iLayer, int iElemLayer, double &x, double &y, double &z) { double t = u(iLayer, iElemLayer); - // Trevor Strickler (this definitely relies on fixing lateral boundary extruded - // surfaces if mesh.ScaleLast is changed by ReplaceDuplicates. This is done in BoundaryLayers.cpp right now. - if( geo.Type == BOUNDARY_LAYER && calcLayerScaleFactor[mesh.BoundaryLayerIndex] && iLayer == mesh.NbLayer-1 && - mesh.BoundaryLayerIndex >= 0 && mesh.BoundaryLayerIndex <= 1 && normals[mesh.BoundaryLayerIndex] ){ + // Trevor Strickler (this definitely relies on fixing lateral boundary + // extruded surfaces if mesh.ScaleLast is changed by ReplaceDuplicates. This + // is done in BoundaryLayers.cpp right now. + if(geo.Type == BOUNDARY_LAYER && calcLayerScaleFactor[mesh.BoundaryLayerIndex] && + iLayer == mesh.NbLayer-1 && mesh.BoundaryLayerIndex >= 0 && + mesh.BoundaryLayerIndex <= 1 && normals[mesh.BoundaryLayerIndex]){ double scale = 1.0; normals[mesh.BoundaryLayerIndex]->get_scale(x, y, z, &scale); - if( fabs(scale-1.0) <= xyzv::eps ) + if(fabs(scale-1.0) <= xyzv::eps) scale = 1.0; else{ - if( mesh.NbLayer == 1 ) + if(mesh.NbLayer <= 1) t = t * scale; else t = (t-mesh.hLayer[mesh.NbLayer-2])*scale + mesh.hLayer[mesh.NbLayer-2]; diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp index 546daf965c9d171376d14b373f16ced586890e45..7081ee26f0f58e93b26a31b17466b5d0121de932 100644 --- a/Geo/GFace.cpp +++ b/Geo/GFace.cpp @@ -1473,9 +1473,9 @@ void GFace::addLayersOfQuads(int nLayers, GVertex *gv, double hmin, double ratio hmin += hlayer; } fprintf(f,"};\n"); - fclose(f); } } + fclose(f); } void GFace::relocateMeshVertices() diff --git a/Geo/GFaceCompound.cpp b/Geo/GFaceCompound.cpp index 10ceb249831081f61f16acee256940dd92eb6e49..fd78dcc1a3b0121a71c06863cd9a4afc2e4c7c14 100644 --- a/Geo/GFaceCompound.cpp +++ b/Geo/GFaceCompound.cpp @@ -1668,6 +1668,7 @@ void GFaceCompound::parametrize(iterationStep step, typeOfMapping tom) const } } + delete mapping; delete lsys; } diff --git a/Geo/GModelFactory.cpp b/Geo/GModelFactory.cpp index 2bbac8659f93a3ab2224448f171b181eb55542c4..158208870803cde67b08df74117bd0986729305f 100644 --- a/Geo/GModelFactory.cpp +++ b/Geo/GModelFactory.cpp @@ -391,6 +391,9 @@ std::vector<GEntity*> GeoFactory::extrudeBoundaryLayer(GModel *gm, GEntity *e, } } + List_Delete(list_out); + List_Delete(tmp); + return extrudedEntities; // //return the new created entity @@ -601,7 +604,7 @@ GEdge *OCCFactory::addSpline(GModel *gm, const splineType &type, } else if (type == BSPLINE) { - Handle(Geom_BSplineCurve) Bez = GeomAPI_PointsToBSpline(ctrlPoints).Curve(); + Handle(Geom_BSplineCurve) Bez = GeomAPI_PointsToBSpline(ctrlPoints).Curve(); if (occv1 && occv2) occEdge = BRepBuilderAPI_MakeEdge(Bez,occv1->getShape(),occv2->getShape()).Edge(); diff --git a/Geo/GModelIO_CELUM.cpp b/Geo/GModelIO_CELUM.cpp index 74a29cb61f31dbe2c1c856ad5f40e61c56971ea3..79783b768959ffbb62db3a37922c76d74777b3ae 100644 --- a/Geo/GModelIO_CELUM.cpp +++ b/Geo/GModelIO_CELUM.cpp @@ -28,6 +28,7 @@ int GModel::writeCELUM(const std::string &name, bool saveAll, FILE *fps = Fopen(names.c_str(), "w"); if(!fps){ Msg::Error("Unable to open file '%s'", names.c_str()); + fclose(fpf); return 0; } diff --git a/Geo/GModelIO_MSH2.cpp b/Geo/GModelIO_MSH2.cpp index 4f3d7e057a008b2d78c397ad793b0fcc2fa6d950..c2a1f100dd3fe942dd325781021192feeb5b6f94 100644 --- a/Geo/GModelIO_MSH2.cpp +++ b/Geo/GModelIO_MSH2.cpp @@ -487,6 +487,8 @@ int GModel::_readMSH2(const std::string &name) Msg::Error("Domain element %d not found for element %d", dom2, num); #endif } + delete [] indices; + if (CTX::instance()->mesh.ignorePartBound && elementary<0) continue; MElement *e = createElementMSH2(this, num, type, physical, elementary, partition, vertices, elements, physicals, @@ -502,7 +504,6 @@ int GModel::_readMSH2(const std::string &name) _ghostCells.insert(std::pair<MElement*, short>(e, ghosts[j])); if(numElements > 100000) Msg::ProgressMeter(i + 1, numElements, true, "Reading elements"); - delete [] indices; } } else{ @@ -540,6 +541,7 @@ int GModel::_readMSH2(const std::string &name) } else{ if(!getVertices(numVertices, indices, vertexMap, vertices)){ + delete [] data; fclose(fp); return 0; } diff --git a/Geo/GModelIO_PLY.cpp b/Geo/GModelIO_PLY.cpp index 068d0046ec3be07e389074258fd3b440fba332cb..23a37e6c36dc6132e2e579c5cb9be739d6faa2b1 100644 --- a/Geo/GModelIO_PLY.cpp +++ b/Geo/GModelIO_PLY.cpp @@ -70,7 +70,7 @@ int GModel::readPLY(const std::string &name) char buffer[256], str[256], str2[256], str3[256]; std::string s1; int elementary = getMaxElementaryNumber(-1) + 1; - int nbv, nbf; + int nbv = 0, nbf = 0; int nbprop = 0; int nbView = 0; std::vector<std::string> propName; diff --git a/Geo/GModelIO_SU2.cpp b/Geo/GModelIO_SU2.cpp index 7e38f4c41c6d498606093a52482e1b424686ca9b..ec1170e614f3607dfc231d668ecc95f995e3bf9b 100644 --- a/Geo/GModelIO_SU2.cpp +++ b/Geo/GModelIO_SU2.cpp @@ -34,6 +34,7 @@ int GModel::writeSU2(const std::string &name, bool saveAll, double scalingFactor int ndime = getDim(); if(ndime != 2 && ndime != 3){ Msg::Error("SU2 mesh output valid only for 2D or 3D models (not %dD)", ndime); + fclose(fp); return 0; } diff --git a/Geo/Geo.cpp b/Geo/Geo.cpp index 2b25b50a6c815734c931150c6b860a1b842c78a0..10642482640ab8dd903490afe5be9015daf5a39c 100644 --- a/Geo/Geo.cpp +++ b/Geo/Geo.cpp @@ -2114,39 +2114,38 @@ static List_T *GetCompoundUniqueEdges(Surface *ps) // Part 2: Make the unique list std::vector<int> comp_surfs = ps->compound; - if( comp_surfs.size() == 0 || ps->Typ != MSH_SURF_COMPOUND ){ + if(comp_surfs.size() == 0 || ps->Typ != MSH_SURF_COMPOUND){ Msg::Error("Surface %d is not compound", ps->Num); - return (List_T*)(0); + return 0; } int num_surfs = comp_surfs.size(); - List_T *bnd_c= List_Create(4, 1, sizeof(Curve*)); + List_T *bnd_c = List_Create(4, 1, sizeof(Curve*)); std::map<int, unsigned int> count_map; for( int i = 0; i < num_surfs; i++ ){ Surface *s = FindSurface(std::abs(comp_surfs[i])); - if( !s ){ + if(!s){ Msg::Error("Unknown surface %d", std::abs(comp_surfs[i]) ); - return (List_T*)(0); + List_Delete(bnd_c); + return 0; } int num_in_surf = List_Nbr(s->Generatrices); for( int m = 0; m < num_in_surf; m++ ){ Curve *c=0; List_Read(s->Generatrices, m, &c); - - if( !c ){ + if(!c){ Msg::Error("Unknown curve"); - return (List_T*)(0); + List_Delete(bnd_c); + return 0; } - - if( !FindCurve(-c->Num) ) { + if(!FindCurve(-c->Num)) { Msg::Error("Unknown curve %d", -c->Num ); - return (List_T*)(0); + List_Delete(bnd_c); + return 0; } - int abs_Num = std::abs(c->Num) ; - if( count_map.find( abs_Num ) == count_map.end() ) count_map[ abs_Num ] = 1; else @@ -2156,7 +2155,7 @@ static List_T *GetCompoundUniqueEdges(Surface *ps) // Now, create the list of uniques. Exclude any repeats of abs(c->num) of // course. - for( int i = 0; i < num_surfs; i++ ){ + for(int i = 0; i < num_surfs; i++){ Surface *s = FindSurface(std::abs(comp_surfs[i])); int num_in_surf = List_Nbr(s->Generatrices); for( int m = 0; m < num_in_surf; m++ ){ @@ -2166,7 +2165,8 @@ static List_T *GetCompoundUniqueEdges(Surface *ps) if( itmap != count_map.end() ){ if( itmap->second == 1 ){ List_Add(bnd_c, &c); - // for duplicates -- if coherence on, do not need. if coherence off, should not try to find them + // for duplicates -- if coherence on, do not need. if coherence off, + // should not try to find them /*bool unique_flag = true; std::map<int, unsigned int>::iterator itmap2 = count_map.begin(); @@ -2188,8 +2188,9 @@ static List_T *GetCompoundUniqueEdges(Surface *ps) } else{ // if not found the curve in the count_map Msg::Error("A problem in finding unique curves in extrusion of compound surface %d", - std::abs(ps->Num) ); - return (List_T*)(0); + std::abs(ps->Num)); + List_Delete(bnd_c); + return 0; } } } @@ -2223,10 +2224,10 @@ static List_T* GetOrderedUniqueEdges( Surface *s ) Curve *ctemp = 0; List_Read(unique, i, &ctemp); if( !ctemp ){ - Msg::Error("No such curve."); + Msg::Error("No such curve"); + List_Delete(gen_nums); return 0; } - List_Add(gen_nums, &(ctemp->Num)); } @@ -2235,21 +2236,19 @@ static List_T* GetOrderedUniqueEdges( Surface *s ) // put sorted list of curve pointers back into compnd_gen and generatrices List_Reset(unique); for( int i = 0; i < List_Nbr(gen_nums); i++ ){ - Curve *ctemp = 0; int j; List_Read(gen_nums, i, &j); if( !(ctemp = FindCurve(j)) ){ - Msg::Error("No such curve %d.", j); + Msg::Error("No such curve %d", j); + List_Delete(gen_nums); return 0; } List_Add(unique, &ctemp); } List_Delete(gen_nums); - return unique; - } // Duplicate removal @@ -2518,6 +2517,9 @@ static void ReplaceDuplicateCurves(std::map<int, int> * c_report = 0) if(!(c2 = FindCurve(-c->Num))) { Msg::Error("Unknown curve %d", -c->Num); List_Delete(All); + Tree_Action(curves2delete, Free_Curve); + Tree_Delete(curves2delete); + Tree_Delete(allNonDuplicatedCurves); return; } Tree_Insert(allNonDuplicatedCurves, &c2); @@ -2552,6 +2554,7 @@ static void ReplaceDuplicateCurves(std::map<int, int> * c_report = 0) int end = Tree_Nbr(GModel::current()->getGEOInternals()->Curves); if(start == end) { + Tree_Action(curves2delete, Free_Curve); Tree_Delete(curves2delete); Tree_Delete(allNonDuplicatedCurves); return; @@ -2684,6 +2687,7 @@ static void ReplaceDuplicateSurfaces(std::map<int, int> *s_report = 0) int end = Tree_Nbr(GModel::current()->getGEOInternals()->Surfaces); if(start == end) { + Tree_Action(surfaces2delete, Free_Surface); Tree_Delete(surfaces2delete); Tree_Delete(allNonDuplicatedSurfaces); return; @@ -3840,6 +3844,7 @@ void sortEdgesInLoop(int num, List_T *edges, bool orient) if(c->Typ == MSH_SEGM_DISCRETE){ Msg::Debug("Aborting line loop sort for discrete edge: hope you know " "what you're doing ;-)"); + List_Delete(temp); return; } } diff --git a/Geo/Homology.cpp b/Geo/Homology.cpp index 97eab681e2542622a35cd80b4d31981c8b8f6864..8a01decd2dcfbd1c2eed0a20e9e9656ad9ebb7ac 100644 --- a/Geo/Homology.cpp +++ b/Geo/Homology.cpp @@ -472,8 +472,7 @@ std::vector<int> Homology::_addToModel(int dim, bool co, bool post, int physical void Homology::addChainsToModel(int dim, bool post, int physicalNumRequest) const { - //std::vector<int> physicals; - if(!_homologyComputed[dim]) + if(dim > -1 && !_homologyComputed[dim]) Msg::Warning("%d-Homology is not computed", dim); if(dim == -1) { for(int j = 0; j < 4; j++) { @@ -487,7 +486,7 @@ void Homology::addChainsToModel(int dim, bool post, int physicalNumRequest) cons void Homology::addCochainsToModel(int dim, bool post, int physicalNumRequest) const { - if(!_cohomologyComputed[dim]) + if(dim > -1 && !_cohomologyComputed[dim]) Msg::Warning("%d-Cohomology is not computed", dim); if(dim == -1) { for(int j = 0; j < 4; j++) { diff --git a/Geo/findLinks.cpp b/Geo/findLinks.cpp index 8f1973f8d7a95c32c588934f3d83dd5eab0af4de..d724282f09a63f517da3d60338869385eba498e5 100644 --- a/Geo/findLinks.cpp +++ b/Geo/findLinks.cpp @@ -22,8 +22,8 @@ typedef struct{ static void freeLink(void * link) { - List_Delete(((lnk*) link)->l); - Free(link); + List_Delete(((lnk*) link)->l); + Free(link); } static int complink(const void *a, const void *b) @@ -46,7 +46,7 @@ static void recurFindLinkedEdges(int ed, List_T *edges, Tree_T *points, return; } - int ip[2]; + int ip[2]; ip[0] = ge->getBeginVertex()->tag(); ip[1] = ge->getEndVertex()->tag(); @@ -110,7 +110,7 @@ static void orientAndSortEdges(List_T *edges, Tree_T *links) List_T *temp = List_Create(List_Nbr(edges), 1, sizeof(int)); List_Copy(edges, temp); List_Reset(edges); - + int num; List_Read(temp, 0, &num); List_Add(edges, &num); @@ -118,6 +118,7 @@ static void orientAndSortEdges(List_T *edges, Tree_T *links) GEdge *ge0 = GModel::current()->getEdgeByTag(abs(num)); if(!ge0){ Msg::Error("Unknown curve %d", abs(num)); + List_Delete(temp); return; } @@ -136,6 +137,7 @@ static void orientAndSortEdges(List_T *edges, Tree_T *links) GEdge *ge1 = GModel::current()->getEdgeByTag(abs(na.a)); if(!ge1){ Msg::Error("Unknown curve %d", abs(na.a)); + List_Delete(temp); return; } if(lk.n == ge1->getBeginVertex()->tag()){ @@ -152,7 +154,7 @@ static void orientAndSortEdges(List_T *edges, Tree_T *links) } } } - + List_Delete(temp); } @@ -161,8 +163,11 @@ int allEdgesLinked(int ed, List_T *edges) Tree_T *links = Tree_Create(sizeof(lnk), complink); Tree_T *points = Tree_Create(sizeof(int), fcmp_int); - if(!createEdgeLinks(links)) + if(!createEdgeLinks(links)){ + Tree_Delete(links, freeLink); + Tree_Delete(points); return 0; + } // initialize point tree with all hanging points for(int i = 0; i < List_Nbr(edges); i++){ @@ -171,6 +176,8 @@ int allEdgesLinked(int ed, List_T *edges) GEdge *ge = GModel::current()->getEdgeByTag(abs(num)); if(!ge){ Msg::Error("Unknown curve %d", abs(num)); + Tree_Delete(links, freeLink); + Tree_Delete(points); return 0; } int ip[2]; @@ -209,7 +216,7 @@ int allEdgesLinked(int ed, List_T *edges) // Find all linked faces -static void recurFindLinkedFaces(int fac, List_T *faces, Tree_T *edges, +static void recurFindLinkedFaces(int fac, List_T *faces, Tree_T *edges, Tree_T *links) { GFace *gf = GModel::current()->getFaceByTag(abs(fac)); @@ -273,7 +280,7 @@ int allFacesLinked(int fac, List_T *faces) { Tree_T *links = Tree_Create(sizeof(lnk), complink); Tree_T *edges = Tree_Create(sizeof(int), fcmp_int); - + createFaceLinks(links); // initialize edge tree with all boundary edges @@ -283,6 +290,8 @@ int allFacesLinked(int fac, List_T *faces) GFace *gf = GModel::current()->getFaceByTag(abs(num)); if(!gf){ Msg::Error("Unknown surface %d", abs(num)); + Tree_Delete(links, freeLink); + Tree_Delete(edges); return 0; } std::list<GEdge*> l = gf->edges(); @@ -313,7 +322,7 @@ int allFacesLinked(int fac, List_T *faces) // necessary... } - Tree_Delete(links,freeLink); + Tree_Delete(links, freeLink); Tree_Delete(edges); return found; diff --git a/Mesh/CenterlineField.cpp b/Mesh/CenterlineField.cpp index 56f5ad123bc77dc9e3d4aa75581ff2e46190c7fe..fa2d910d0a1694eb3a645c3776e95f9e191e30e0 100644 --- a/Mesh/CenterlineField.cpp +++ b/Mesh/CenterlineField.cpp @@ -296,21 +296,18 @@ static void cutTriangle(MTriangle *tri, Centerline::Centerline(std::string fileName): kdtree(0), kdtreeR(0) { recombine = (CTX::instance()->mesh.recombineAll) || (CTX::instance()->mesh.recombine3DAll); - - printf("centerline filename =%s \n", fileName.c_str()); - importFile(fileName); - buildKdTree(); nbPoints = 25; hLayer = 0.3; hSecondLayer = 0.3; nbElemLayer = 3; nbElemSecondLayer = 0; - - update_needed = false; is_cut = 0; is_closed = 0; is_extruded = 0; + importFile(fileName); + buildKdTree(); + update_needed = false; } Centerline::Centerline(): kdtree(0), kdtreeR(0) diff --git a/Mesh/DivideAndConquer.h b/Mesh/DivideAndConquer.h index f7cd848b36c0df72d5536b11de84447fa2ea7f1b..6e14346ab0b9a2194a113a8793d68afc042cbccb 100644 --- a/Mesh/DivideAndConquer.h +++ b/Mesh/DivideAndConquer.h @@ -9,8 +9,6 @@ #include <vector> #include <algorithm> #include "fullMatrix.h" - -// FIXME: should not introduce dependencies to Geo/ code in Numeric! #include "SPoint2.h" #include "simpleFunction.h" #include "Octree.h" @@ -32,7 +30,10 @@ struct PointRecord { int flag; //0:to be kept, 1:to be removed int identificator; std::vector<void*> vicinity; - PointRecord() : adjacent(0), data (0) {} + PointRecord() : adjacent(0), data(0), flag(0), identificator(0) + { + where.v = where.h = 0.; + } }; struct _CDLIST{ @@ -92,9 +93,9 @@ class DocRecord{ int numTriangles; // number of triangles Triangle *triangles; // 2D results DocRecord(int n); - double &x(int i){ return points[i].where.h; } - double &y(int i){ return points[i].where.v; } - void* &data(int i){ return points[i].data; } + double &x(int i){ return points[i].where.h; } + double &y(int i){ return points[i].where.v; } + void* &data(int i){ return points[i].data; } void setPoints(fullMatrix<double> *p); ~DocRecord(); void MakeMeshWithPoints(); @@ -105,7 +106,7 @@ class DocRecord{ void printMedialAxis(Octree *_octree, std::string, GFace *gf=NULL, GEdge *ge=NULL); double Lloyd (int); void voronoiCell (PointNumero pt, std::vector<SPoint2> &pts) const; - + std::set<std::pair<void*,void*> > boundaryEdges; void addBoundaryEdge(void* p1,void* p2) @@ -118,11 +119,11 @@ class DocRecord{ { void *a = (p1 < p2) ? p1 : p2; void *b = (p1 > p2) ? p1 : p2; - std::set<std::pair<void*,void*> >::iterator it = + std::set<std::pair<void*,void*> >::iterator it = boundaryEdges.find(std::make_pair(a,b)); return it != boundaryEdges.end(); - } - + } + void recur_tag_triangles(int, std::set<int>&, std::map<std::pair<void*,void*>, std::pair<int,int> >&); std::set<int> tagInterior(double,double); @@ -134,9 +135,9 @@ class DocRecord{ bool remove_point(int); void remove_all(); void add_point(double,double,GFace*); - + std::set<std::pair<void*,void*> > mesh_edges; - + void add_edge(void* p1,void* p2) { void *a = (p1 < p2) ? p1 : p2; @@ -147,27 +148,27 @@ class DocRecord{ { void *a = (p1 < p2) ? p1 : p2; void *b = (p1 > p2) ? p1 : p2; - std::set<std::pair<void*,void*> >::iterator it = + std::set<std::pair<void*,void*> >::iterator it = mesh_edges.find(std::make_pair(a,b)); return it != mesh_edges.end(); - } - + } + void build_edges(); void clear_edges(); - bool delaunay_conformity(GFace*); - + bool delaunay_conformity(GFace*); + PointNumero *ConvertDlistToArray(DListPeek *dlist, int *n); }; void centroidOfOrientedBox(std::vector<SPoint2> &pts, const double &angle, - double &xc, - double &yc, - double &inertia, + double &xc, + double &yc, + double &inertia, double &area); void centroidOfPolygon(SPoint2 &pc, std::vector<SPoint2> &pts, - double &xc, + double &xc, double &yc, double &inertia, double &areaCell, diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp index 64c979280341a4dd489a580a7f50ef6421a66b01..743c49a37d9d207f602f402f7cce2df273b048fd 100644 --- a/Mesh/meshGFace.cpp +++ b/Mesh/meshGFace.cpp @@ -1803,7 +1803,7 @@ static bool meshGeneratorPeriodic(GFace *gf, bool debug = true) if(!ok){ gf->meshStatistics.status = GFace::FAILED; Msg::Error("The 1D Mesh seems not to be forming a closed loop"); - m->scalingU = m->scalingV = 1.0; + delete m; return false; } nbPointsTotal += nbPointsLocal; @@ -1816,6 +1816,7 @@ static bool meshGeneratorPeriodic(GFace *gf, bool debug = true) "Only %d Mesh Vertices on The Contours", gf->tag(), nbPointsTotal); gf->meshStatistics.status = GFace::DONE; + delete m; return true; } if(nbPointsTotal == 3){ @@ -1827,6 +1828,7 @@ static bool meshGeneratorPeriodic(GFace *gf, bool debug = true) } gf->triangles.push_back(new MTriangle(vv[0], vv[1], vv[2])); gf->meshStatistics.status = GFace::DONE; + delete m; return true; } @@ -1927,6 +1929,7 @@ static bool meshGeneratorPeriodic(GFace *gf, bool debug = true) Msg::Error("Impossible to recover the edge %d %d", edgeLoop_BDS[j]->iD, edgeLoop_BDS[(j + 1) % edgeLoop_BDS.size()]->iD); gf->meshStatistics.status = GFace::FAILED; + delete m; return false; } else e->g = &CLASS_E; diff --git a/Mesh/meshGFaceOptimize.cpp b/Mesh/meshGFaceOptimize.cpp index 25bbf4f84ff1eae7ce6f34a9500fb2e11302790b..1d36e6db226802fcdd0e7fbe3643f44a15ce9a3b 100644 --- a/Mesh/meshGFaceOptimize.cpp +++ b/Mesh/meshGFaceOptimize.cpp @@ -1521,8 +1521,6 @@ struct quadBlob { v0 v01 v1 a1 a3 - - */ else if (ncorners == 5){ printBlob(iter,5); @@ -2830,7 +2828,6 @@ bool edgeSwap(std::set<swapquad> &configs, MTri3 *t1, GFace *gf, int iLocalEdge, MTriangle *t1b = new MTriangle(v2, v3, v4); MTriangle *t2b = new MTriangle(v4, v3, v1); - // const double v1b = surfaceTriangleUV(v2, v3, v4, data); // const double v2b = surfaceTriangleUV(v4, v3, v1, data); // const double volume = v1b + v2b; @@ -2856,7 +2853,6 @@ bool edgeSwap(std::set<swapquad> &configs, MTri3 *t1, GFace *gf, int iLocalEdge, return false; } } - // printf("coucou\n"); break; } case SWCR_DEL: diff --git a/Mesh/meshGFaceOptimize.h b/Mesh/meshGFaceOptimize.h index 6cf82660e4e46844de4c761ff0e6175c92134e14..c5682c3e4c1743d75812264edaf4b6be7526e972 100644 --- a/Mesh/meshGFaceOptimize.h +++ b/Mesh/meshGFaceOptimize.h @@ -130,6 +130,8 @@ struct RecombineTriangle { n1 = me.getVertex(0); n2 = me.getVertex(1); + n3 = 0; + n4 = 0; if(t1->getVertex(0) != n1 && t1->getVertex(0) != n2) n3 = t1->getVertex(0); else if(t1->getVertex(1) != n1 && t1->getVertex(1) != n2) n3 = t1->getVertex(1); diff --git a/Mesh/meshGFaceTransfinite.cpp b/Mesh/meshGFaceTransfinite.cpp index 671c031ab796cf921a643999b6e1b01dfab46f78..1fb80a2567ffe5415e51c9b22ed279be31fd0b90 100644 --- a/Mesh/meshGFaceTransfinite.cpp +++ b/Mesh/meshGFaceTransfinite.cpp @@ -193,11 +193,11 @@ int MeshTransfiniteSurface(GFace *gf) MVertex *v = m_vertices[i]; if(v == corners[0] || v == corners[1] || v == corners[2] || (corners.size() == 4 && v == corners[3])){ - N[iCorner++] = i; if(iCorner > 4){ Msg::Error("Surface %d transfinite parameters are incoherent", gf->tag()); return 0; } + N[iCorner++] = i; } SPoint2 param; reparamMeshVertexOnFace(v, gf, param); diff --git a/Mesh/meshGRegion.cpp b/Mesh/meshGRegion.cpp index 267c28d463752b56a9ebf7f2c6a865f85df99158..e65438c6ab8e9ce2f95aece80a5a2a79292cd1bd 100644 --- a/Mesh/meshGRegion.cpp +++ b/Mesh/meshGRegion.cpp @@ -1040,8 +1040,8 @@ static bool modifyInitialMeshForTakingIntoAccountBoundaryLayers(GRegion *gr) printf("%d tets\n", (int)gr->tetrahedra.size()); deMeshGFace _kill; _kill (nf); - delete nf; gr->model()->remove(nf); + delete nf; gr->set(faces); gr->mesh_vertices.insert(gr->mesh_vertices.begin(),verts.begin(),verts.end()); diff --git a/Numeric/MetricBasis.cpp b/Numeric/MetricBasis.cpp index 3e4ae55d3b1c6d078fee0365318388951e58d081..1b96d6f6df1a7e6f6bee81011092d8dad4375a57 100644 --- a/Numeric/MetricBasis.cpp +++ b/Numeric/MetricBasis.cpp @@ -282,12 +282,14 @@ void MetricCoefficient::interpolate(const double *uvw, double *minmaxQ) minmaxQ[1] = terms[0] + factor * tmp * std::cos(phi); } } - break; + break; default: Msg::Error("Wrong number of functions for metric: %d", _coefficientsLag.size2()); } + + delete [] terms; } double MetricCoefficient::getBoundRmin(double tol) @@ -394,7 +396,7 @@ void MetricCoefficient::_interpolateBezierPyramid(const double *uvw, double *min } } } - double terms[7]; + double terms[7] = {0,0,0,0,0,0,0}; for (int t = 0; t < _coefficientsBez.size2(); ++t) { terms[t] = 0; for (int j = 0; j < numCoeff; j++) { diff --git a/Plugin/Distance.cpp b/Plugin/Distance.cpp index 930cfec8c3446858855f9e9cc32625abc09ca941..2084cfcd1341f2badacd976d231faa153b0816e7 100644 --- a/Plugin/Distance.cpp +++ b/Plugin/Distance.cpp @@ -418,6 +418,8 @@ PView *GMSH_DistancePlugin::execute(PView *v) itv->second = dist; } + delete dofView; + printView(_entities, _distance_map); #endif diff --git a/Plugin/Integrate.cpp b/Plugin/Integrate.cpp index 4d22d96ec607934ed6080a621dddb74e41873c29..be2f25341d4081e0ec95563d7aff625ba871c897 100644 --- a/Plugin/Integrate.cpp +++ b/Plugin/Integrate.cpp @@ -79,7 +79,7 @@ PView *GMSH_IntegratePlugin::execute(PView * v) int numNodes = data1->getNumNodes(step, ent, ele); int dim = data1->getDimension(step, ent, ele); if((dimension>0) && (dim!=dimension)) continue; - double x[8], y[8], z[8], val[8 * 3]; + double x[8], y[8], z[8], val[8 * 3] = {0.}; for(int nod = 0; nod < numNodes; nod++){ data1->getNode(step, ent, ele, nod, x[nod], y[nod], z[nod]); for(int comp = 0; comp < numComp; comp++) diff --git a/Plugin/MathEval.cpp b/Plugin/MathEval.cpp index bdb926a5f7e19c91dbb7084dfbae488da59ed42a..1e52daa25cb25b500939d2e457f2701d746b808b 100644 --- a/Plugin/MathEval.cpp +++ b/Plugin/MathEval.cpp @@ -244,6 +244,8 @@ PView *GMSH_MathEvalPlugin::execute(PView *view) } } + if(octree) delete octree; + if(timeStep < 0){ for(int i = firstNonEmptyStep; i < data1->getNumTimeSteps(); i++) { if(!data1->hasTimeStep(i)) continue; diff --git a/Plugin/Tetrahedralize.cpp b/Plugin/Tetrahedralize.cpp index 38f9d1cac659fd01efc9ce142eb59956e84658dc..bb0ba2f57cef8c13433c32dba94312a75518c303 100644 --- a/Plugin/Tetrahedralize.cpp +++ b/Plugin/Tetrahedralize.cpp @@ -52,6 +52,10 @@ class PointData { v = new MVertex(x, y, z); val.resize(numVal); } + ~PointData() + { + delete v; + } }; PView *GMSH_TetrahedralizePlugin::execute(PView *v) @@ -156,8 +160,6 @@ PView *GMSH_TetrahedralizePlugin::execute(PView *v) for(unsigned int i = 0; i < tets.size(); i++) delete tets[i]; - for(unsigned int i = 0; i < vertices.size(); i++) - delete vertices[i]; for(int i = 0; i < data1->getNumTimeSteps(); i++) data2->Time.push_back(data1->getTime(i)); diff --git a/Plugin/Warp.cpp b/Plugin/Warp.cpp index 4bec27f2a37025cc9b4e6314818e9b458b526fbc..2c98b972194e51a5278d1c47695b102307f9b6f1 100644 --- a/Plugin/Warp.cpp +++ b/Plugin/Warp.cpp @@ -113,6 +113,7 @@ PView *GMSH_WarpPlugin::execute(PView *v) for(int ele = 0; ele < data1->getNumElements(step, ent); ele++){ if(data1->skipElement(step, ent, ele)) continue; int numNodes = data1->getNumNodes(step, ent, ele); + if(numNodes < 2) continue; double x[8], y[8], z[8], n[3] = {0., 0., 0.}; int tag[8]; for(int nod = 0; nod < numNodes; nod++) diff --git a/Post/PViewDataListIO.cpp b/Post/PViewDataListIO.cpp index 0ef1cd1e689ea286aefd0a9ff1ff9210fe0414ee..3228133e4c966436e71f273f56bef202828d75ee 100644 --- a/Post/PViewDataListIO.cpp +++ b/Post/PViewDataListIO.cpp @@ -392,6 +392,7 @@ bool PViewDataList::writePOS(const std::string &fileName, bool binary, bool pars int one = 1; if(!fwrite(&one, sizeof(int), 1, fp)){ Msg::Error("Write error"); + fclose(fp); return false; } } diff --git a/Post/PViewIO.cpp b/Post/PViewIO.cpp index b838a72893250bc27adf984dcc992bfe96fbae12..9932ded2a337542e4a192e6f8f8282218fd955c5 100644 --- a/Post/PViewIO.cpp +++ b/Post/PViewIO.cpp @@ -21,8 +21,8 @@ bool PView::readPOS(const std::string &fileName, int fileIndex) } char str[256] = "XXX"; - double version; - int format, size, index = -1; + double version = -1.; + int format = -1, size = -1, index = -1; while(1) { @@ -38,16 +38,19 @@ bool PView::readPOS(const std::string &fileName, int fileIndex) if(!fscanf(fp, "%lf %d %d\n", &version, &format, &size)){ Msg::Error("Read error"); + fclose(fp); return false; } if(version < 1.0) { Msg::Error("Post-processing file too old (ver. %g < 1.0)", version); + fclose(fp); return false; } if(size == sizeof(double)) Msg::Debug("Data is in double precision format (size==%d)", size); else { Msg::Error("Unknown data size (%d) in post-processing file", size); + fclose(fp); return false; } @@ -59,6 +62,7 @@ bool PView::readPOS(const std::string &fileName, int fileIndex) if(!d->readPOS(fp, version, format ? true : false)){ Msg::Error("Could not read data in list format"); delete d; + fclose(fp); return false; } else{ @@ -78,7 +82,6 @@ bool PView::readPOS(const std::string &fileName, int fileIndex) } fclose(fp); - return true; } diff --git a/Post/adaptiveData.cpp b/Post/adaptiveData.cpp index efdf29e9cb249cecd6e0556499e9929ebda733e4..2d91ede6edfbb80a30420243d61998917fca87d6 100644 --- a/Post/adaptiveData.cpp +++ b/Post/adaptiveData.cpp @@ -47,7 +47,7 @@ int adaptiveHexahedron::numEdges = 12; template <class T> static void cleanElement() -{ +{ for(typename std::list<T*>::iterator it = T::all.begin(); it != T::all.end(); ++it) delete *it; T::all.clear(); @@ -123,7 +123,7 @@ void adaptiveLine::recurCreate(adaptiveLine *e, int maxlevel, int level) adaptiveVertex *p1 = e->p[0]; adaptiveVertex *p2 = e->p[1]; adaptiveVertex *p12 = adaptiveVertex::add - ((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5, (p1->z + p2->z) * 0.5, + ((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5, (p1->z + p2->z) * 0.5, allVertices); adaptiveLine *e1 = new adaptiveLine(p1, p12); recurCreate(e1, maxlevel, level); @@ -201,13 +201,13 @@ void adaptiveTriangle::recurCreate(adaptiveTriangle *t, int maxlevel, int level) adaptiveVertex *p2 = t->p[1]; adaptiveVertex *p3 = t->p[2]; adaptiveVertex *p12 = adaptiveVertex::add - ((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5, (p1->z + p2->z) * 0.5, + ((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5, (p1->z + p2->z) * 0.5, allVertices); adaptiveVertex *p13 = adaptiveVertex::add - ((p1->x + p3->x) * 0.5, (p1->y + p3->y) * 0.5, (p1->z + p3->z) * 0.5, + ((p1->x + p3->x) * 0.5, (p1->y + p3->y) * 0.5, (p1->z + p3->z) * 0.5, allVertices); adaptiveVertex *p23 = adaptiveVertex::add - ((p3->x + p2->x) * 0.5, (p3->y + p2->y) * 0.5, (p3->z + p2->z) * 0.5, + ((p3->x + p2->x) * 0.5, (p3->y + p2->y) * 0.5, (p3->z + p2->z) * 0.5, allVertices); adaptiveTriangle *t1 = new adaptiveTriangle(p1, p12, p13); recurCreate(t1, maxlevel, level); @@ -315,19 +315,19 @@ void adaptiveQuadrangle::recurCreate(adaptiveQuadrangle *q, int maxlevel, int le adaptiveVertex *p3 = q->p[2]; adaptiveVertex *p4 = q->p[3]; adaptiveVertex *p12 = adaptiveVertex::add - ((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5, (p1->z + p2->z) * 0.5, + ((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5, (p1->z + p2->z) * 0.5, allVertices); adaptiveVertex *p23 = adaptiveVertex::add - ((p2->x + p3->x) * 0.5, (p2->y + p3->y) * 0.5, (p2->z + p3->z) * 0.5, + ((p2->x + p3->x) * 0.5, (p2->y + p3->y) * 0.5, (p2->z + p3->z) * 0.5, allVertices); adaptiveVertex *p34 = adaptiveVertex::add - ((p3->x + p4->x) * 0.5, (p3->y + p4->y) * 0.5, (p3->z + p4->z) * 0.5, + ((p3->x + p4->x) * 0.5, (p3->y + p4->y) * 0.5, (p3->z + p4->z) * 0.5, allVertices); adaptiveVertex *p14 = adaptiveVertex::add - ((p1->x + p4->x) * 0.5, (p1->y + p4->y) * 0.5, (p1->z + p4->z) * 0.5, + ((p1->x + p4->x) * 0.5, (p1->y + p4->y) * 0.5, (p1->z + p4->z) * 0.5, allVertices); adaptiveVertex *pc = adaptiveVertex::add - ((p1->x + p2->x + p3->x + p4->x) * 0.25, (p1->y + p2->y + p3->y + p4->y) * 0.25, + ((p1->x + p2->x + p3->x + p4->x) * 0.25, (p1->y + p2->y + p3->y + p4->y) * 0.25, (p1->z + p2->z + p3->z + p4->z) * 0.25, allVertices); adaptiveQuadrangle *q1 = new adaptiveQuadrangle(p1, p12, pc, p14); recurCreate(q1, maxlevel, level); @@ -441,7 +441,7 @@ void adaptiveTetrahedron::recurCreate(adaptiveTetrahedron *t, int maxlevel, int ((p0->x + p3->x) * 0.5, (p0->y + p3->y) * 0.5, (p0->z + p3->z) * 0.5, allVertices); adaptiveVertex *pe3 = adaptiveVertex::add - ((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5, (p1->z + p2->z) * 0.5, + ((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5, (p1->z + p2->z) * 0.5, allVertices); adaptiveVertex *pe4 = adaptiveVertex::add ((p1->x + p3->x) * 0.5, (p1->y + p3->y) * 0.5, (p1->z + p3->z) * 0.5, @@ -578,7 +578,7 @@ void adaptiveHexahedron::recurCreate(adaptiveHexahedron *h, int maxlevel, int le adaptiveVertex *p6 = h->p[6]; adaptiveVertex *p7 = h->p[7]; adaptiveVertex *p01 = adaptiveVertex::add - ((p0->x + p1->x) * 0.5, (p0->y + p1->y) * 0.5, (p0->z + p1->z) * 0.5, + ((p0->x + p1->x) * 0.5, (p0->y + p1->y) * 0.5, (p0->z + p1->z) * 0.5, allVertices); adaptiveVertex *p12 = adaptiveVertex::add ((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5, (p1->z + p2->z) * 0.5, @@ -614,19 +614,19 @@ void adaptiveHexahedron::recurCreate(adaptiveHexahedron *h, int maxlevel, int le ((p7->x + p3->x) * 0.5, (p7->y + p3->y) * 0.5, (p7->z + p3->z) * 0.5, allVertices); adaptiveVertex *p0145 = adaptiveVertex::add - ((p45->x + p01->x) * 0.5, (p45->y + p01->y) * 0.5,(p45->z + p01->z) * 0.5, + ((p45->x + p01->x) * 0.5, (p45->y + p01->y) * 0.5,(p45->z + p01->z) * 0.5, allVertices); adaptiveVertex *p1256 = adaptiveVertex::add - ((p12->x + p56->x) * 0.5, (p12->y + p56->y) * 0.5, (p12->z + p56->z) * 0.5, + ((p12->x + p56->x) * 0.5, (p12->y + p56->y) * 0.5, (p12->z + p56->z) * 0.5, allVertices); adaptiveVertex *p2367 = adaptiveVertex::add - ((p23->x + p67->x) * 0.5, (p23->y + p67->y) * 0.5, (p23->z + p67->z) * 0.5, + ((p23->x + p67->x) * 0.5, (p23->y + p67->y) * 0.5, (p23->z + p67->z) * 0.5, allVertices); adaptiveVertex *p0347 = adaptiveVertex::add ((p03->x + p47->x) * 0.5, (p03->y + p47->y) * 0.5, (p03->z + p47->z) * 0.5, allVertices); adaptiveVertex *p4756 = adaptiveVertex::add - ((p47->x + p56->x) * 0.5, (p47->y + p56->y) * 0.5, (p47->z + p56->z) * 0.5, + ((p47->x + p56->x) * 0.5, (p47->y + p56->y) * 0.5, (p47->z + p56->z) * 0.5, allVertices); adaptiveVertex *p0312 = adaptiveVertex::add ((p03->x + p12->x) * 0.5, (p03->y + p12->y) * 0.5, (p03->z + p12->z) * 0.5, @@ -773,40 +773,40 @@ void adaptivePrism::recurCreate(adaptivePrism *p, int maxlevel, int level) adaptiveVertex *p5 = p->p[4]; adaptiveVertex *p6 = p->p[5]; adaptiveVertex *p14 = adaptiveVertex::add - ((p1->x + p4->x) * 0.5, (p1->y + p4->y) * 0.5, (p1->z + p4->z) * 0.5, + ((p1->x + p4->x) * 0.5, (p1->y + p4->y) * 0.5, (p1->z + p4->z) * 0.5, allVertices); adaptiveVertex *p25 = adaptiveVertex::add - ((p2->x + p5->x) * 0.5, (p2->y + p5->y) * 0.5, (p2->z + p5->z) * 0.5, + ((p2->x + p5->x) * 0.5, (p2->y + p5->y) * 0.5, (p2->z + p5->z) * 0.5, allVertices); adaptiveVertex *p36 = adaptiveVertex::add - ((p3->x + p6->x) * 0.5, (p3->y + p6->y) * 0.5, (p3->z + p6->z) * 0.5, + ((p3->x + p6->x) * 0.5, (p3->y + p6->y) * 0.5, (p3->z + p6->z) * 0.5, allVertices); adaptiveVertex *p12 = adaptiveVertex::add - ((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5, (p1->z + p2->z) * 0.5, + ((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5, (p1->z + p2->z) * 0.5, allVertices); adaptiveVertex *p23 = adaptiveVertex::add - ((p2->x + p3->x) * 0.5, (p2->y + p3->y) * 0.5, (p2->z + p3->z) * 0.5, + ((p2->x + p3->x) * 0.5, (p2->y + p3->y) * 0.5, (p2->z + p3->z) * 0.5, allVertices); adaptiveVertex *p31 = adaptiveVertex::add - ((p3->x + p1->x) * 0.5, (p3->y + p1->y) * 0.5, (p3->z + p1->z) * 0.5, + ((p3->x + p1->x) * 0.5, (p3->y + p1->y) * 0.5, (p3->z + p1->z) * 0.5, allVertices); adaptiveVertex *p1425 = adaptiveVertex::add - ((p14->x + p25->x) * 0.5, (p14->y + p25->y) * 0.5, (p14->z + p25->z) * 0.5, + ((p14->x + p25->x) * 0.5, (p14->y + p25->y) * 0.5, (p14->z + p25->z) * 0.5, allVertices); adaptiveVertex *p2536 = adaptiveVertex::add - ((p25->x + p36->x) * 0.5, (p25->y + p36->y) * 0.5, (p25->z + p36->z) * 0.5, + ((p25->x + p36->x) * 0.5, (p25->y + p36->y) * 0.5, (p25->z + p36->z) * 0.5, allVertices); adaptiveVertex *p3614 = adaptiveVertex::add - ((p36->x + p14->x) * 0.5, (p36->y + p14->y) * 0.5, (p36->z + p14->z) * 0.5, + ((p36->x + p14->x) * 0.5, (p36->y + p14->y) * 0.5, (p36->z + p14->z) * 0.5, allVertices); adaptiveVertex *p45 = adaptiveVertex::add - ((p4->x + p5->x) * 0.5, (p4->y + p5->y) * 0.5, (p4->z + p5->z) * 0.5, + ((p4->x + p5->x) * 0.5, (p4->y + p5->y) * 0.5, (p4->z + p5->z) * 0.5, allVertices); adaptiveVertex *p56 = adaptiveVertex::add - ((p5->x + p6->x) * 0.5, (p5->y + p6->y) * 0.5, (p5->z + p6->z) * 0.5, + ((p5->x + p6->x) * 0.5, (p5->y + p6->y) * 0.5, (p5->z + p6->z) * 0.5, allVertices); adaptiveVertex *p64 = adaptiveVertex::add - ((p6->x + p4->x) * 0.5, (p6->y + p4->y) * 0.5, (p6->z + p4->z) * 0.5, + ((p6->x + p4->x) * 0.5, (p6->y + p4->y) * 0.5, (p6->z + p4->z) * 0.5, allVertices); p->e[0] = new adaptivePrism(p1, p12, p31, p14, p1425, p3614); recurCreate(p->e[0], maxlevel, level); @@ -916,24 +916,24 @@ void adaptiveElements<T>::init(int level) T::create(level); int numVals = _coeffsVal ? _coeffsVal->size1() : T::numNodes; int numNodes = _coeffsGeom ? _coeffsGeom->size1() : T::numNodes; - + if(_interpolVal) delete _interpolVal; _interpolVal = new fullMatrix<double>(T::allVertices.size(), numVals); - + if(_interpolGeom) delete _interpolGeom; _interpolGeom = new fullMatrix<double>(T::allVertices.size(), numNodes); - + fullVector<double> sfv(numVals), *tmpv = 0; fullVector<double> sfg(numNodes), *tmpg = 0; if(_eexpsVal) tmpv = new fullVector<double>(_eexpsVal->size1()); if(_eexpsGeom) tmpg = new fullVector<double>(_eexpsGeom->size1()); int i = 0; - for(std::set<adaptiveVertex>::iterator it = T::allVertices.begin(); + for(std::set<adaptiveVertex>::iterator it = T::allVertices.begin(); it != T::allVertices.end(); ++it) { if(_coeffsVal && _eexpsVal) - computeShapeFunctions(_coeffsVal, _eexpsVal, + computeShapeFunctions(_coeffsVal, _eexpsVal, it->x, it->y, it->z, &sfv, tmpv); else T::GSF(it->x, it->y, it->z, sfv); @@ -941,7 +941,7 @@ void adaptiveElements<T>::init(int level) (*_interpolVal)(i, j) = sfv(j); if(_coeffsGeom && _eexpsGeom) - computeShapeFunctions(_coeffsGeom, _eexpsGeom, + computeShapeFunctions(_coeffsGeom, _eexpsGeom, it->x, it->y, it->z, &sfg, tmpg); else T::GSF(it->x, it->y, it->z, sfg); @@ -961,10 +961,10 @@ void adaptiveElements<T>::init(int level) } template <class T> -void adaptiveElements<T>::adapt(double tol, int numComp, +void adaptiveElements<T>::adapt(double tol, int numComp, std::vector<PCoords> &coords, - std::vector<PValues> &values, - double &minVal, double &maxVal, + std::vector<PValues> &values, + double &minVal, double &maxVal, GMSH_PostPlugin *plug, bool onlyComputeMinMax) { @@ -972,17 +972,17 @@ void adaptiveElements<T>::adapt(double tol, int numComp, Msg::Error("Can only adapt scalar or vector data"); return; } - + int numVertices = T::allVertices.size(); if(!numVertices){ Msg::Error("No adapted vertices to interpolate"); return; } - + int numVals = _coeffsVal ? _coeffsVal->size1() : T::numNodes; if(numVals != (int)values.size()){ - Msg::Error("Wrong number of values in adaptation %d != %i", + Msg::Error("Wrong number of values in adaptation %d != %i", numVals, values.size()); return; } @@ -990,7 +990,7 @@ void adaptiveElements<T>::adapt(double tol, int numComp, #ifdef TIMER double t1 = GetTimeInSeconds(); #endif - + fullVector<double> val(numVals), res(numVertices); if(numComp == 1){ for(int i = 0; i < numVals; i++) @@ -1003,14 +1003,14 @@ void adaptiveElements<T>::adapt(double tol, int numComp, } _interpolVal->mult(val, res); - //minVal = VAL_INF; - //maxVal = -VAL_INF; + //minVal = VAL_INF; + //maxVal = -VAL_INF; for(int i = 0; i < numVertices; i++){ minVal = std::min(minVal, res(i)); maxVal = std::max(maxVal, res(i)); } if(onlyComputeMinMax) return; - + fullMatrix<double> *resxyz = 0; if(numComp == 3){ fullMatrix<double> valxyz(numVals, 3); @@ -1022,14 +1022,15 @@ void adaptiveElements<T>::adapt(double tol, int numComp, } _interpolVal->mult(valxyz, *resxyz); } - + int numNodes = _coeffsGeom ? _coeffsGeom->size1() : T::numNodes; if(numNodes != (int)coords.size()){ - Msg::Error("Wrong number of nodes in adaptation %d != %i", + Msg::Error("Wrong number of nodes in adaptation %d != %i", numNodes, coords.size()); + if(resxyz) delete resxyz; return; } - + fullMatrix<double> xyz(numNodes, 3), XYZ(numVertices, 3); for(int i = 0; i < numNodes; i++){ xyz(i, 0) = coords[i].c[0]; @@ -1059,22 +1060,22 @@ void adaptiveElements<T>::adapt(double tol, int numComp, p->Z = XYZ(i, 2); i++; } - + if(resxyz) delete resxyz; - - for(typename std::list<T*>::iterator it = T::all.begin(); + + for(typename std::list<T*>::iterator it = T::all.begin(); it != T::all.end(); it++) (*it)->visible = false; - + if(!plug || tol != 0.){ double avg = fabs(maxVal - minVal); if(tol < 0) avg = 1.; // force visibility to the smallest subdivision T::error(avg, tol); } - + if(plug) plug->assignSpecificVisibility(); - + coords.clear(); values.clear(); for(typename std::list<T*>::iterator it = T::all.begin(); @@ -1093,23 +1094,23 @@ void adaptiveElements<T>::adapt(double tol, int numComp, } template <class T> -void adaptiveElements<T>::addInView(double tol, int step, - PViewData *in, PViewDataList *out, +void adaptiveElements<T>::addInView(double tol, int step, + PViewData *in, PViewDataList *out, GMSH_PostPlugin *plug) { int numComp = in->getNumComponents(0, 0, 0); if(numComp != 1 && numComp != 3) return; - + int numEle = 0, *outNb = 0; std::vector<double> *outList = 0; switch(T::numEdges){ - case 0: - numEle = in->getNumPoints(); + case 0: + numEle = in->getNumPoints(); outNb = (numComp == 1) ? &out->NbSP : &out->NbVP; outList = (numComp == 1) ? &out->SP : &out->VP; break; - case 1: - numEle = in->getNumLines(); + case 1: + numEle = in->getNumLines(); outNb = (numComp == 1) ? &out->NbSL : &out->NbVL; outList = (numComp == 1) ? &out->SL : &out->VL; break; @@ -1128,22 +1129,22 @@ void adaptiveElements<T>::addInView(double tol, int step, outNb = (numComp == 1) ? &out->NbSS : &out->NbVS; outList = (numComp == 1) ? &out->SS : &out->VS; break; - case 9: + case 9: numEle = in->getNumPrisms(); outNb = (numComp == 1) ? &out->NbSI : &out->NbVI; outList = (numComp == 1) ? &out->SI : &out->VI; break; - case 12: + case 12: numEle = in->getNumHexahedra(); outNb = (numComp == 1) ? &out->NbSH : &out->NbVH; outList = (numComp == 1) ? &out->SH : &out->VH; break; } if(!numEle) return; - + outList->clear(); *outNb = 0; - + for(int ent = 0; ent < in->getNumEntities(step); ent++){ for(int ele = 0; ele < in->getNumElements(step, ent); ele++){ if(in->skipElement(step, ent, ele) || @@ -1167,20 +1168,20 @@ void adaptiveElements<T>::addInView(double tol, int step, else if(numComp == 3){ for(int i = 0; i < numVal / 3; i++){ double vx, vy, vz; - in->getValue(step, ent, ele, 3 * i, vx); - in->getValue(step, ent, ele, 3 * i + 1, vy); - in->getValue(step, ent, ele, 3 * i + 2, vz); + in->getValue(step, ent, ele, 3 * i, vx); + in->getValue(step, ent, ele, 3 * i + 1, vy); + in->getValue(step, ent, ele, 3 * i + 2, vz); values.push_back(PValues(vx, vy, vz)); } } adapt(tol, numComp, coords, values, out->Min, out->Max, plug); *outNb += coords.size() / T::numNodes; for(unsigned int i = 0; i < coords.size() / T::numNodes; i++){ - for(int k = 0; k < T::numNodes; ++k) + for(int k = 0; k < T::numNodes; ++k) outList->push_back(coords[T::numNodes * i + k].c[0]); - for(int k = 0; k < T::numNodes; ++k) + for(int k = 0; k < T::numNodes; ++k) outList->push_back(coords[T::numNodes * i + k].c[1]); - for(int k = 0; k < T::numNodes; ++k) + for(int k = 0; k < T::numNodes; ++k) outList->push_back(coords[T::numNodes * i + k].c[2]); for(int k = 0; k < T::numNodes; ++k) for(int l = 0; l < numComp; ++l) @@ -1191,8 +1192,8 @@ void adaptiveElements<T>::addInView(double tol, int step, } adaptiveData::adaptiveData(PViewData *data) - : _step(-1), _level(-1), _tol(-1.), _inData(data), - _points(0), _lines(0), _triangles(0), _quadrangles(0), + : _step(-1), _level(-1), _tol(-1.), _inData(data), + _points(0), _lines(0), _triangles(0), _quadrangles(0), _tetrahedra(0), _hexahedra(0), _prisms(0) { _outData = new PViewDataList(true); @@ -1243,7 +1244,7 @@ adaptiveData::~adaptiveData() double adaptiveData::timerInit = 0.; double adaptiveData::timerAdapt = 0.; -void adaptiveData::changeResolution(int step, int level, double tol, +void adaptiveData::changeResolution(int step, int level, double tol, GMSH_PostPlugin *plug) { timerInit = timerAdapt = 0.; @@ -1271,7 +1272,7 @@ void adaptiveData::changeResolution(int step, int level, double tol, _step = step; _level = level; _tol = tol; - + #ifdef TIMER printf("init time = %g\n", timerInit); printf("adapt time = %g\n", timerAdapt);