diff --git a/Geo/CGNSZone.cpp b/Geo/CGNSZone.cpp index 8ab881a409c68c81bda2843b709ad5b31cfc0697..dfd74a52d7a632f233af62b0b909795387d3f322 100644 --- a/Geo/CGNSZone.cpp +++ b/Geo/CGNSZone.cpp @@ -350,8 +350,8 @@ int CGNSZone::readBoundaryConditionRange(int iZoneBC, int cgnsErr; std::vector<cgsize_t> bcData(indexDataSize(2)); - cgnsErr = - cg_boco_read(fileIndex(), baseIndex(), index(), iZoneBC, bcData.data(), nullptr); + cgnsErr = cg_boco_read(fileIndex(), baseIndex(), index(), iZoneBC, + bcData.data(), nullptr); if(cgnsErr != CG_OK) return cgnsError(__FILE__, __LINE__, fileIndex()); // get list of elements from range data @@ -367,8 +367,8 @@ int CGNSZone::readBoundaryConditionList(int iZoneBC, cgsize_t nbVal, // read data std::vector<cgsize_t> bcData(indexDataSize(nbVal)); - cgnsErr = - cg_boco_read(fileIndex(), baseIndex(), index(), iZoneBC, bcData.data(), nullptr); + cgnsErr = cg_boco_read(fileIndex(), baseIndex(), index(), iZoneBC, + bcData.data(), nullptr); if(cgnsErr != CG_OK) return cgnsError(__FILE__, __LINE__, fileIndex()); // get list of elements from list data diff --git a/Geo/CGNSZoneUnstruct.cpp b/Geo/CGNSZoneUnstruct.cpp index e34328f1e621930be9b355b150868e38ed274bd5..b441db1073468939c4f091a1972f4ddcdc50d948 100644 --- a/Geo/CGNSZoneUnstruct.cpp +++ b/Geo/CGNSZoneUnstruct.cpp @@ -132,8 +132,9 @@ int CGNSZoneUnstruct::readSection( std::vector<cgsize_t> sectData(dataSize), offsetData(endElt - startElt + 2); if(sectEltType == CGNS_ENUMV(MIXED)) { #if CGNS_VERSION >= 4000 - cgnsErr = cg_poly_elements_read(fileIndex(), baseIndex(), index(), iSect, - sectData.data(), offsetData.data(), nullptr); + cgnsErr = + cg_poly_elements_read(fileIndex(), baseIndex(), index(), iSect, + sectData.data(), offsetData.data(), nullptr); #endif } else { diff --git a/Geo/ChainComplex.cpp b/Geo/ChainComplex.cpp index 34069852d8081041ac11a7cc36b8fb16adf8a4b6..3b96d4c78e4b6f59eee05531e56970a743ede404 100644 --- a/Geo/ChainComplex.cpp +++ b/Geo/ChainComplex.cpp @@ -413,7 +413,8 @@ std::vector<int> ChainComplex::getCoeffVector(int dim, int chainNumber) std::vector<int> coeffVector; if(dim < 0 || dim > 4) return coeffVector; - if(_hbasis[dim] == nullptr || (int)gmp_matrix_cols(_hbasis[dim]) < chainNumber) + if(_hbasis[dim] == nullptr || + (int)gmp_matrix_cols(_hbasis[dim]) < chainNumber) return coeffVector; int rows = gmp_matrix_rows(_hbasis[dim]); @@ -456,7 +457,9 @@ void ChainComplex::getBasisChain(std::map<Cell *, int, CellPtrLessThan> &chain, chain.clear(); if(dim < 0 || dim > 3) return; - if(basisMatrix == nullptr || (int)gmp_matrix_cols(basisMatrix) < num) { return; } + if(basisMatrix == nullptr || (int)gmp_matrix_cols(basisMatrix) < num) { + return; + } int elemi; long int elemli; @@ -512,7 +515,8 @@ int ChainComplex::getBasisSize(int dim, int basis) int ChainComplex::getTorsion(int dim, int num) { if(dim < 0 || dim > 4) return 0; - if(_hbasis[dim] == nullptr || (int)gmp_matrix_cols(_hbasis[dim]) < num) return 0; + if(_hbasis[dim] == nullptr || (int)gmp_matrix_cols(_hbasis[dim]) < num) + return 0; if(_torsion[dim].empty() || (int)_torsion[dim].size() < num) return 1; else diff --git a/Geo/GEdge.cpp b/Geo/GEdge.cpp index 2b7db06efb9edf76e4f11700c728ae2286828957..ed167ade0a3bfbc017350e4bcc0fb0bf2458e260 100644 --- a/Geo/GEdge.cpp +++ b/Geo/GEdge.cpp @@ -34,8 +34,8 @@ GEdge::GEdge(GModel *model, int tag, GVertex *v0, GVertex *v1) } GEdge::GEdge(GModel *model, int tag) - : GEntity(model, tag), _length(0.), _tooSmall(false), _cp(nullptr), _v0(nullptr), _v1(nullptr), - masterOrientation(0), compoundCurve(nullptr) + : GEntity(model, tag), _length(0.), _tooSmall(false), _cp(nullptr), + _v0(nullptr), _v1(nullptr), masterOrientation(0), compoundCurve(nullptr) { meshStatistics.status = GEdge::PENDING; GEdge::resetMeshAttributes(); diff --git a/Geo/GEntity.cpp b/Geo/GEntity.cpp index 6a732d9f9d9dd3c85019941885694ba9f1949030..e7384127acbc03e8114a7d91bdaed6afbf36ba1f 100644 --- a/Geo/GEntity.cpp +++ b/Geo/GEntity.cpp @@ -18,7 +18,8 @@ GEntity::GEntity(GModel *m, int t) : _model(m), _tag(t), _meshMaster(this), _visible(1), _selection(0), - _allElementsVisible(1), _obb(nullptr), va_lines(nullptr), va_triangles(nullptr) + _allElementsVisible(1), _obb(nullptr), va_lines(nullptr), + va_triangles(nullptr) { _color = CTX::instance()->packColor(0, 0, 255, 0); } diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp index d5bfe85ee0c98cc9e50fc3bc7acf00cde9a39ab6..621006ff7eeaee73e4381b43bae7d533b18c7e95 100644 --- a/Geo/GFace.cpp +++ b/Geo/GFace.cpp @@ -34,7 +34,8 @@ #endif GFace::GFace(GModel *model, int tag) - : GEntity(model, tag), r1(nullptr), r2(nullptr), va_geom_triangles(nullptr), compoundSurface(nullptr) + : GEntity(model, tag), r1(nullptr), r2(nullptr), va_geom_triangles(nullptr), + compoundSurface(nullptr) { meshStatistics.status = GFace::PENDING; meshStatistics.refineAllEdges = false; diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index 332cd8690b6c55d403c216ba24b55a086f605fba..beb63ecd10aab06220f1ae81cd2c91615ac7a7af 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -67,8 +67,8 @@ int GModel::_current = -1; GModel::GModel(const std::string &name) : _destroying(false), _name(name), _visible(1), _elementOctree(nullptr), _geo_internals(nullptr), _occ_internals(nullptr), _acis_internals(nullptr), - _parasolid_internals(nullptr), _fields(nullptr), _currentMeshEntity(nullptr), - _numPartitions(0), normals(nullptr) + _parasolid_internals(nullptr), _fields(nullptr), + _currentMeshEntity(nullptr), _numPartitions(0), normals(nullptr) { _maxVertexNum = CTX::instance()->mesh.firstNodeTag - 1; _maxElementNum = CTX::instance()->mesh.firstElementTag - 1; diff --git a/Geo/GModelCreateTopologyFromMesh.cpp b/Geo/GModelCreateTopologyFromMesh.cpp index 2e2ecd9c6bc267b2540d406be7744f79351d5a44..84f62e1a831f831f0b0a101b897f14e341182d94 100644 --- a/Geo/GModelCreateTopologyFromMesh.cpp +++ b/Geo/GModelCreateTopologyFromMesh.cpp @@ -105,7 +105,8 @@ std::vector<GEdge *> ensureSimplyConnectedEdge(GEdge *ge) ge->lines = _parts[i]; else { discreteEdge *newE = new discreteEdge( - ge->model(), ge->model()->getMaxElementaryNumber(1) + 1, nullptr, nullptr); + ge->model(), ge->model()->getMaxElementaryNumber(1) + 1, nullptr, + nullptr); ge->model()->add(newE); newE->lines = _parts[i]; _all.push_back(newE); @@ -420,8 +421,8 @@ void createTopologyFromMesh2D(GModel *gm, int &num) std::set<GFace *> &gfaces = it->second; auto gfIter = gFacesToGEdge.find(gfaces); if(gfIter == gFacesToGEdge.end()) { - discreteEdge *de = - new discreteEdge(gm, gm->getMaxElementaryNumber(1) + 1, nullptr, nullptr); + discreteEdge *de = new discreteEdge(gm, gm->getMaxElementaryNumber(1) + 1, + nullptr, nullptr); num++; gm->add(de); auto gfIter = gfaces.begin(); diff --git a/Geo/GModelIO_GEO.cpp b/Geo/GModelIO_GEO.cpp index 50a5665224902d2ccaa5b052fd48b9c211486435..0ec7d6bad3644390fa29249e657460b41f0cf172 100644 --- a/Geo/GModelIO_GEO.cpp +++ b/Geo/GModelIO_GEO.cpp @@ -163,7 +163,8 @@ bool GEO_Internals::addLine(int &tag, const std::vector<int> &pointTags) List_Add(tmp, &t); } bool ok = true; - Curve *c = CreateCurve(tag, MSH_SEGM_LINE, 1, tmp, nullptr, -1, -1, 0., 1., ok); + Curve *c = + CreateCurve(tag, MSH_SEGM_LINE, 1, tmp, nullptr, -1, -1, 0., 1., ok); Tree_Add(Curves, &c); CreateReversedCurve(c); List_Delete(tmp); @@ -184,7 +185,8 @@ bool GEO_Internals::addCircleArc(int &tag, int startTag, int centerTag, List_Add(tmp, ¢erTag); List_Add(tmp, &endTag); bool ok = true; - Curve *c = CreateCurve(tag, MSH_SEGM_CIRC, 2, tmp, nullptr, -1, -1, 0., 1., ok); + Curve *c = + CreateCurve(tag, MSH_SEGM_CIRC, 2, tmp, nullptr, -1, -1, 0., 1., ok); if(nx || ny || nz) { c->Circle.n[0] = nx; c->Circle.n[1] = ny; @@ -219,7 +221,8 @@ bool GEO_Internals::addEllipseArc(int &tag, int startTag, int centerTag, List_Add(tmp, &majorTag); List_Add(tmp, &endTag); bool ok = true; - Curve *c = CreateCurve(tag, MSH_SEGM_ELLI, 2, tmp, nullptr, -1, -1, 0., 1., ok); + Curve *c = + CreateCurve(tag, MSH_SEGM_ELLI, 2, tmp, nullptr, -1, -1, 0., 1., ok); if(nx || ny || nz) { c->Circle.n[0] = nx; c->Circle.n[1] = ny; @@ -256,7 +259,8 @@ bool GEO_Internals::addSpline(int &tag, const std::vector<int> &pointTags) List_Add(tmp, &t); } bool ok = true; - Curve *c = CreateCurve(tag, MSH_SEGM_SPLN, 3, tmp, nullptr, -1, -1, 0., 1., ok); + Curve *c = + CreateCurve(tag, MSH_SEGM_SPLN, 3, tmp, nullptr, -1, -1, 0., 1., ok); Tree_Add(Curves, &c); CreateReversedCurve(c); List_Delete(tmp); @@ -1812,8 +1816,8 @@ int GModel::exportDiscreteGEOInternals() for(auto it = firstEdge(); it != lastEdge(); it++) { if((*it)->geomType() == GEntity::DiscreteCurve) { bool ok = true; - Curve *c = CreateCurve((*it)->tag(), MSH_SEGM_DISCRETE, 1, nullptr, nullptr, -1, - -1, 0., 1., ok); + Curve *c = CreateCurve((*it)->tag(), MSH_SEGM_DISCRETE, 1, nullptr, + nullptr, -1, -1, 0., 1., ok); c->Control_Points = List_Create(2, 1, sizeof(Vertex *)); GVertex *gvb = (*it)->getBeginVertex(); if(gvb) { diff --git a/Geo/GModelIO_MED.cpp b/Geo/GModelIO_MED.cpp index cab954ca7db0e5538aaa6186bafeae849539a3dc..378ae2547dfaab698f32c2ef647e029becc26910 100644 --- a/Geo/GModelIO_MED.cpp +++ b/Geo/GModelIO_MED.cpp @@ -392,8 +392,8 @@ int GModel::readMED(const std::string &name, int meshIndex) for(int i = 0; i < numNodes; i++) verts[i] = new MVertex(coord[spaceDim * i], (spaceDim > 1) ? coord[spaceDim * i + 1] : 0., - (spaceDim > 2) ? coord[spaceDim * i + 2] : 0., nullptr, - nodeTags.empty() ? 0 : nodeTags[i]); + (spaceDim > 2) ? coord[spaceDim * i + 2] : 0., + nullptr, nodeTags.empty() ? 0 : nodeTags[i]); std::vector<med_int> nodeFamily(numNodes, 0); #if(MED_MAJOR_NUM >= 3) @@ -637,8 +637,8 @@ static void writeElementsMED(med_idt &fid, char *meshName, #if(MED_MAJOR_NUM >= 3) if(MEDmeshElementWr(fid, meshName, MED_NO_DT, MED_NO_IT, 0., MED_CELL, type, MED_NODAL, MED_FULL_INTERLACE, (med_int)fam.size(), - &conn[0], MED_FALSE, nullptr, MED_TRUE, &tags[0], MED_TRUE, - &fam[0]) < 0) + &conn[0], MED_FALSE, nullptr, MED_TRUE, &tags[0], + MED_TRUE, &fam[0]) < 0) #else if(MEDelementsEcr(fid, meshName, (med_int)3, &conn[0], MED_FULL_INTERLACE, 0, MED_FAUX, &tags[0], MED_VRAI, &fam[0], (med_int)fam.size(), diff --git a/Geo/GModelIO_MSH2.cpp b/Geo/GModelIO_MSH2.cpp index 5f558f1e539a17d822af222703048c8c0abb67a5..e1f1b712b260224a65445d5e7b1051f598e3efb4 100644 --- a/Geo/GModelIO_MSH2.cpp +++ b/Geo/GModelIO_MSH2.cpp @@ -71,8 +71,8 @@ createElementMSH2(GModel *m, int num, int typeMSH, int physical, int reg, unsigned int part, std::vector<MVertex *> &v, std::map<int, std::vector<MElement *> > elements[10], std::map<int, std::map<int, std::string> > physicals[4], - bool owner = false, MElement *parent = nullptr, MElement *d1 = nullptr, - MElement *d2 = nullptr) + bool owner = false, MElement *parent = nullptr, + MElement *d1 = nullptr, MElement *d2 = nullptr) { if(CTX::instance()->mesh.switchElementTags) { int tmp = reg; diff --git a/Geo/GModelIO_MSH3.cpp b/Geo/GModelIO_MSH3.cpp index 09c412df961fe59760022f9c4b56fb90f8842469..d9e833796e73504af722c6193cf3db147f267c2a 100644 --- a/Geo/GModelIO_MSH3.cpp +++ b/Geo/GModelIO_MSH3.cpp @@ -320,7 +320,9 @@ int GModel::_readMSH3(const std::string &name) } if(swap) SwapBytes((char *)&entity, sizeof(int), 1); } - if(!entity) { vertex = new MVertex(xyz[0], xyz[1], xyz[2], nullptr, num); } + if(!entity) { + vertex = new MVertex(xyz[0], xyz[1], xyz[2], nullptr, num); + } else { if(!binary) { if(fscanf(fp, "%d", &dim) != 1) { diff --git a/Geo/GModelIO_MSH4.cpp b/Geo/GModelIO_MSH4.cpp index adebb682106a068d83ec5f53287cc777873f0be4..054bc27e836d041a6773fb79bd76bb68da187804 100644 --- a/Geo/GModelIO_MSH4.cpp +++ b/Geo/GModelIO_MSH4.cpp @@ -484,7 +484,9 @@ readMSH4Nodes(GModel *const model, FILE *fp, bool binary, bool &dense, } } else { - if(fscanf(fp, "%lu %lu", &numBlock, &totalNumNodes) != 2) { return nullptr; } + if(fscanf(fp, "%lu %lu", &numBlock, &totalNumNodes) != 2) { + return nullptr; + } } } @@ -734,7 +736,9 @@ readMSH4Elements(GModel *const model, FILE *fp, bool binary, bool &dense, } } else { - if(fscanf(fp, "%lu %lu", &numBlock, &totalNumElements) != 2) { return nullptr; } + if(fscanf(fp, "%lu %lu", &numBlock, &totalNumElements) != 2) { + return nullptr; + } } } @@ -825,8 +829,8 @@ readMSH4Elements(GModel *const model, FILE *fp, bool binary, bool &dense, } MElementFactory elementFactory; - MElement *element = elementFactory.create(elmType, vertices, data[j], 0, - false, 0, nullptr, nullptr, nullptr); + MElement *element = elementFactory.create( + elmType, vertices, data[j], 0, false, 0, nullptr, nullptr, nullptr); if(!element) { Msg::Error("Could not create element %lu of type %d", data[j], elmType); @@ -888,8 +892,8 @@ readMSH4Elements(GModel *const model, FILE *fp, bool binary, bool &dense, } MElementFactory elementFactory; - MElement *element = elementFactory.create(elmType, vertices, elmTag, 0, - false, 0, nullptr, nullptr, nullptr); + MElement *element = elementFactory.create( + elmType, vertices, elmTag, 0, false, 0, nullptr, nullptr, nullptr); if(!element) { Msg::Error("Could not create element %lu of type %d", elmTag, elmType); diff --git a/Geo/GModelIO_OCC.cpp b/Geo/GModelIO_OCC.cpp index 31b358866ee9e3bcaaf783cb12ce80524c9a9b22..2435e5146496f2c0a83ac591facf827f31e4ca91 100644 --- a/Geo/GModelIO_OCC.cpp +++ b/Geo/GModelIO_OCC.cpp @@ -2911,8 +2911,8 @@ bool OCC_Internals::_extrudePerDim( } result = p.Shape(); const BRepSweep_Prism &prism(p.Prism()); - _setExtrudedAttributes(c, (BRepSweep_Prism *)&prism, nullptr, e, 0., 0., 0., dx, - dy, dz, 0., 0., 0., 0.); + _setExtrudedAttributes(c, (BRepSweep_Prism *)&prism, nullptr, e, 0., 0., + 0., dx, dy, dz, 0., 0., 0., 0.); dim = getReturnedShapes(c, (BRepSweep_Prism *)&prism, top, body, lateral); } else if(mode == 1) { // revolve @@ -2925,8 +2925,8 @@ bool OCC_Internals::_extrudePerDim( } result = r.Shape(); const BRepSweep_Revol &revol(r.Revol()); - _setExtrudedAttributes(c, nullptr, (BRepSweep_Revol *)&revol, e, x, y, z, 0., - 0., 0., ax, ay, az, angle); + _setExtrudedAttributes(c, nullptr, (BRepSweep_Revol *)&revol, e, x, y, z, + 0., 0., 0., ax, ay, az, angle); dim = getReturnedShapes(c, (BRepSweep_Revol *)&revol, top, body, lateral); } else if(mode == 2) { // pipe diff --git a/Geo/Geo.cpp b/Geo/Geo.cpp index 591d66a6d293e4c7780693e87656dffc88eec4c4..e982574d3d4c3a03c0cc713741a2cfe5e2bc1eaf 100644 --- a/Geo/Geo.cpp +++ b/Geo/Geo.cpp @@ -807,7 +807,8 @@ static void CopyCurve(Curve *c, Curve *cc) Curve *DuplicateCurve(Curve *c) { bool ok = true; - Curve *pc = CreateCurve(NEWLINE(), 0, 1, nullptr, nullptr, -1, -1, 0., 1., ok); + Curve *pc = + CreateCurve(NEWLINE(), 0, 1, nullptr, nullptr, -1, -1, 0., 1., ok); CopyCurve(c, pc); Tree_Insert(GModel::current()->getGEOInternals()->Curves, &pc); for(int i = 0; i < List_Nbr(c->Control_Points); i++) { @@ -1086,7 +1087,8 @@ void DeletePhysicalVolume(int num) Curve *CreateReversedCurve(Curve *c) { bool ok = true; - Curve *newc = CreateCurve(-c->Num, c->Typ, 1, nullptr, nullptr, -1, -1, 0., 1., ok); + Curve *newc = + CreateCurve(-c->Num, c->Typ, 1, nullptr, nullptr, -1, -1, 0., 1., ok); if(List_Nbr(c->Control_Points)) { newc->Control_Points = @@ -2501,8 +2503,8 @@ int ExtrudePoint(int type, int ip, double T0, double T1, double T2, double A0, List_Reset(ListOfTransformedPoints); ApplyTransformationToPoint(matrix, chapeau); if(!ComparePosition(&pv, &chapeau)) return pv->Num; - c = - CreateCurve(NEWLINE(), MSH_SEGM_LINE, 1, nullptr, nullptr, -1, -1, 0., 1., ok); + c = CreateCurve(NEWLINE(), MSH_SEGM_LINE, 1, nullptr, nullptr, -1, -1, 0., + 1., ok); c->Control_Points = List_Create(2, 1, sizeof(Vertex *)); c->Extrude = new ExtrudeParams; c->Extrude->fill(type, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha); @@ -2515,8 +2517,8 @@ int ExtrudePoint(int type, int ip, double T0, double T1, double T2, double A0, case BOUNDARY_LAYER: chapeau->Typ = MSH_POINT_BND_LAYER; if(e) chapeau->boundaryLayerIndex = e->mesh.BoundaryLayerIndex; - c = CreateCurve(NEWLINE(), MSH_SEGM_BND_LAYER, 1, nullptr, nullptr, -1, -1, 0., - 1., ok); + c = CreateCurve(NEWLINE(), MSH_SEGM_BND_LAYER, 1, nullptr, nullptr, -1, -1, + 0., 1., ok); c->Control_Points = List_Create(2, 1, sizeof(Vertex *)); c->Extrude = new ExtrudeParams; c->Extrude->fill(type, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha); @@ -2546,8 +2548,8 @@ int ExtrudePoint(int type, int ip, double T0, double T1, double T2, double A0, List_Reset(ListOfTransformedPoints); ApplyTransformationToPoint(matrix, chapeau); if(!ComparePosition(&pv, &chapeau)) return pv->Num; - c = - CreateCurve(NEWLINE(), MSH_SEGM_CIRC, 1, nullptr, nullptr, -1, -1, 0., 1., ok); + c = CreateCurve(NEWLINE(), MSH_SEGM_CIRC, 1, nullptr, nullptr, -1, -1, 0., + 1., ok); c->Control_Points = List_Create(3, 1, sizeof(Vertex *)); c->Extrude = new ExtrudeParams; c->Extrude->fill(type, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha); @@ -2574,8 +2576,8 @@ int ExtrudePoint(int type, int ip, double T0, double T1, double T2, double A0, case TRANSLATE_ROTATE: d = CTX::instance()->geom.extrudeSplinePoints; d = d ? d : 1; - c = - CreateCurve(NEWLINE(), MSH_SEGM_SPLN, 1, nullptr, nullptr, -1, -1, 0., 1., ok); + c = CreateCurve(NEWLINE(), MSH_SEGM_SPLN, 1, nullptr, nullptr, -1, -1, 0., + 1., ok); c->Control_Points = List_Create( CTX::instance()->geom.extrudeSplinePoints + 1, 1, sizeof(Vertex *)); c->Extrude = new ExtrudeParams; diff --git a/Geo/Homology.cpp b/Geo/Homology.cpp index f7a934344daa5825fed1fa74df8b624f1a7ba7ef..aee413c215cea480cc649601bba96ca9abdbcd5e 100644 --- a/Geo/Homology.cpp +++ b/Geo/Homology.cpp @@ -16,7 +16,8 @@ Homology::Homology(GModel *model, const std::vector<int> &physicalDomain, int combine, bool omit, bool smoothen, int heuristic) : _model(model), _domain(physicalDomain), _subdomain(physicalSubdomain), _imdomain(physicalImdomain), _saveOrig(saveOrig), _combine(combine), - _omit(omit), _smoothen(smoothen), _heuristic(heuristic), _cellComplex(nullptr) + _omit(omit), _smoothen(smoothen), _heuristic(heuristic), + _cellComplex(nullptr) { _fileName = ""; diff --git a/Geo/MElementCut.cpp b/Geo/MElementCut.cpp index 0023395d74510763121a2041abfdd7877c1ca951..2a06079a7e6ce6e0a4a186a3153f5c431fe32ab3 100644 --- a/Geo/MElementCut.cpp +++ b/Geo/MElementCut.cpp @@ -1532,7 +1532,8 @@ GModel *buildCutMesh(GModel *gm, gLevelset *ls, if(primS > 1) verticesLs(k, vi->getIndex()) = (*ls)(vi->x(), vi->y(), vi->z()); - MVertex *vn = new MVertex(vi->x(), vi->y(), vi->z(), nullptr, vi->getNum()); + MVertex *vn = + new MVertex(vi->x(), vi->y(), vi->z(), nullptr, vi->getNum()); vertexMap[vi->getNum()] = vn; } } diff --git a/Geo/discreteEdge.cpp b/Geo/discreteEdge.cpp index 9154d8566de2390df16c8f0a34ff8431012b0aaa..1cdea3b9b0e9bedb2beec7bd140ae7a36643c750 100644 --- a/Geo/discreteEdge.cpp +++ b/Geo/discreteEdge.cpp @@ -21,7 +21,8 @@ discreteEdge::discreteEdge(GModel *model, int num, GVertex *_v0, GVertex *_v1) : GEdge(model, num, _v0, _v1) { bool ok; - Curve *c = CreateCurve(num, MSH_SEGM_DISCRETE, 0, nullptr, nullptr, -1, -1, 0., 1., ok); + Curve *c = CreateCurve(num, MSH_SEGM_DISCRETE, 0, nullptr, nullptr, -1, -1, + 0., 1., ok); Tree_Add(model->getGEOInternals()->Curves, &c); CreateReversedCurve(c); } @@ -29,7 +30,8 @@ discreteEdge::discreteEdge(GModel *model, int num, GVertex *_v0, GVertex *_v1) discreteEdge::discreteEdge(GModel *model, int num) : GEdge(model, num) { bool ok; - Curve *c = CreateCurve(num, MSH_SEGM_DISCRETE, 0, nullptr, nullptr, -1, -1, 0., 1., ok); + Curve *c = CreateCurve(num, MSH_SEGM_DISCRETE, 0, nullptr, nullptr, -1, -1, + 0., 1., ok); Tree_Add(model->getGEOInternals()->Curves, &c); CreateReversedCurve(c); } diff --git a/Geo/discreteFace.cpp b/Geo/discreteFace.cpp index 870c8b2c5071335db0010942bd8c76a09ffd8800..58e724951a149696ad6b70e9fd9986be794eb293 100644 --- a/Geo/discreteFace.cpp +++ b/Geo/discreteFace.cpp @@ -166,7 +166,8 @@ public: double _distance; SPoint3 _closestPoint; MTriangle *_t3d, *_t2d; - dfWrapper(const SPoint3 &p) : _p(p), _distance(1.e22), _t3d(nullptr), _t2d(nullptr) + dfWrapper(const SPoint3 &p) + : _p(p), _distance(1.e22), _t3d(nullptr), _t2d(nullptr) { } }; diff --git a/Mesh/BDS.cpp b/Mesh/BDS.cpp index 1f1ecc5686e563481a922ad4b29c6a70231f7c6e..f297c09e969bb983951930671efeb4bd91d66794 100644 --- a/Mesh/BDS.cpp +++ b/Mesh/BDS.cpp @@ -378,12 +378,10 @@ BDS_Edge *BDS_Mesh::recover_edge(int num1, int num2, bool &_fatal, if(Intersect_Edges_2d(e->p1->u, e->p1->v, e->p2->u, e->p2->v, p1->u, p1->v, p2->u, p2->v, x)) { // intersect - if(e2r && - e2r->find(EdgeToRecover(e->p1->iD, e->p2->iD, nullptr)) != e2r->end()) { - auto itr1 = - e2r->find(EdgeToRecover(e->p1->iD, e->p2->iD, nullptr)); - auto itr2 = - e2r->find(EdgeToRecover(num1, num2, nullptr)); + if(e2r && e2r->find(EdgeToRecover(e->p1->iD, e->p2->iD, nullptr)) != + e2r->end()) { + auto itr1 = e2r->find(EdgeToRecover(e->p1->iD, e->p2->iD, nullptr)); + auto itr2 = e2r->find(EdgeToRecover(num1, num2, nullptr)); Msg::Debug("edge %d %d on model edge %d cannot be recovered because" " it intersects %d %d on model edge %d", num1, num2, itr2->ge->tag(), e->p1->iD, e->p2->iD, @@ -655,8 +653,7 @@ void BDS_Mesh::cleanup() triangles.erase(last, triangles.end()); } { - auto last = - std::partition(edges.begin(), edges.end(), is_not_deleted()); + auto last = std::partition(edges.begin(), edges.end(), is_not_deleted()); auto it = last; while(it != edges.end()) { delete *it; diff --git a/Mesh/BackgroundMesh.cpp b/Mesh/BackgroundMesh.cpp index fd709a4b45f0db77a5d6cedf10a165e0838128e6..4dde361bba2c1b03b8b89108128cb41cf829edad 100644 --- a/Mesh/BackgroundMesh.cpp +++ b/Mesh/BackgroundMesh.cpp @@ -40,7 +40,7 @@ std::vector<backgroundMesh *> backgroundMesh::_current = void backgroundMesh::set(GFace *gf) { int t = Msg::GetThreadNum(); - if(t >= MAX_THREADS){ + if(t >= MAX_THREADS) { Msg::Error("Maximum number of threads (%d) exceeded in background mesh", MAX_THREADS); return; @@ -74,7 +74,8 @@ backgroundMesh *backgroundMesh::current() backgroundMesh::backgroundMesh(GFace *_gf, bool cfd) #if defined(HAVE_ANN) - : _octree(nullptr), uv_kdtree(nullptr), nodes(nullptr), angle_nodes(nullptr), angle_kdtree(nullptr) + : _octree(nullptr), uv_kdtree(nullptr), nodes(nullptr), angle_nodes(nullptr), + angle_kdtree(nullptr) #endif { if(cfd) { @@ -133,9 +134,7 @@ backgroundMesh::backgroundMesh(GFace *_gf, bool cfd) _octree = new MElementOctree(_triangles); // compute the mesh sizes at nodes - if(CTX::instance()->mesh.lcFromPoints) { - propagate1dMesh(_gf); - } + if(CTX::instance()->mesh.lcFromPoints) { propagate1dMesh(_gf); } else { auto itv2 = _2Dto3D.begin(); for(; itv2 != _2Dto3D.end(); ++itv2) { @@ -218,9 +217,7 @@ static void propagateValuesOnFace(GFace *_gf, } // Solve - if(myAssembler.sizeOfR()) { - _lsys->systemSolve(); - } + if(myAssembler.sizeOfR()) { _lsys->systemSolve(); } // save solution for(auto it = vs.begin(); it != vs.end(); ++it) { @@ -563,7 +560,7 @@ bool backgroundMesh::inDomain(double u, double v, double w) const double backgroundMesh::operator()(double u, double v, double w) const { - if(!_octree){ + if(!_octree) { Msg::Error("No octree in background mesh"); return 0.; } @@ -575,7 +572,8 @@ double backgroundMesh::operator()(double u, double v, double w) const if(uv_kdtree->nPoints() < 2) return -1000.; double pt[3] = {u, v, 0.0}; #if defined(_OPENMP) -#pragma omp critical // just to avoid crash (still incorrect) - should use nanoflann +#pragma omp \ + critical // just to avoid crash (still incorrect) - should use nanoflann #endif uv_kdtree->annkSearch(pt, 2, index, dist); SPoint3 p1(nodes[index[0]][0], nodes[index[0]][1], nodes[index[0]][2]); @@ -591,12 +589,9 @@ double backgroundMesh::operator()(double u, double v, double w) const } } e->xyz2uvw(uv, uv2); - auto itv1 = - _sizes.find(e->getVertex(0)); - auto itv2 = - _sizes.find(e->getVertex(1)); - auto itv3 = - _sizes.find(e->getVertex(2)); + auto itv1 = _sizes.find(e->getVertex(0)); + auto itv2 = _sizes.find(e->getVertex(1)); + auto itv3 = _sizes.find(e->getVertex(2)); return itv1->second * (1 - uv2[0] - uv2[1]) + itv2->second * uv2[0] + itv3->second * uv2[1]; } @@ -611,7 +606,8 @@ double backgroundMesh::getAngle(double u, double v, double w) const if(angle_kdtree->nPoints() >= NBANN) { double pt[3] = {u, v, 0.0}; #if defined(_OPENMP) -#pragma omp critical // just to avoid crash (still incorrect) - should use nanoflann +#pragma omp \ + critical // just to avoid crash (still incorrect) - should use nanoflann #endif angle_kdtree->annkSearch(pt, NBANN, index, dist); double SINE = 0.0, COSINE = 0.0; @@ -644,7 +640,8 @@ double backgroundMesh::getAngle(double u, double v, double w) const if(uv_kdtree->nPoints() < 2) return -1000.0; double pt[3] = {u, v, 0.0}; #if defined(_OPENMP) -#pragma omp critical // just to avoid crash (still incorrect) - should use nanoflann +#pragma omp \ + critical // just to avoid crash (still incorrect) - should use nanoflann #endif uv_kdtree->annkSearch(pt, 2, index, dist); SPoint3 p1(nodes[index[0]][0], nodes[index[0]][1], nodes[index[0]][2]); @@ -660,12 +657,9 @@ double backgroundMesh::getAngle(double u, double v, double w) const } } e->xyz2uvw(uv, uv2); - auto itv1 = - _angles.find(e->getVertex(0)); - auto itv2 = - _angles.find(e->getVertex(1)); - auto itv3 = - _angles.find(e->getVertex(2)); + auto itv1 = _angles.find(e->getVertex(0)); + auto itv2 = _angles.find(e->getVertex(1)); + auto itv3 = _angles.find(e->getVertex(2)); double cos4 = cos(4 * itv1->second) * (1 - uv2[0] - uv2[1]) + cos(4 * itv2->second) * uv2[0] + cos(4 * itv3->second) * uv2[1]; diff --git a/Mesh/BackgroundMeshTools.cpp b/Mesh/BackgroundMeshTools.cpp index 7a146286e00507cbb7fd7fe2489da16ccc7d0734..ff000e3a13a561e207ae96ba04f43e34be3a54e0 100644 --- a/Mesh/BackgroundMeshTools.cpp +++ b/Mesh/BackgroundMeshTools.cpp @@ -30,8 +30,7 @@ static double max_edge_curvature(const GVertex *gv) { double val = 0; std::vector<GEdge *> const &l_edges = gv->edges(); - for(auto ite = l_edges.begin(); - ite != l_edges.end(); ++ite) { + for(auto ite = l_edges.begin(); ite != l_edges.end(); ++ite) { GEdge *_myGEdge = *ite; Range<double> range = _myGEdge->parBounds(0); double cc; @@ -67,8 +66,9 @@ static double LC_MVertex_CURV(GEntity *ge, double U, double V) Crv = gf->curvature(SPoint2(U, V)); } break; } - double lc = - Crv > 0 ? 2 * M_PI / Crv / CTX::instance()->mesh.minElementsPerTwoPi : MAX_LC; + double lc = Crv > 0 ? + 2 * M_PI / Crv / CTX::instance()->mesh.minElementsPerTwoPi : + MAX_LC; return lc; } @@ -76,8 +76,8 @@ SMetric3 max_edge_curvature_metric(const GEdge *ge, double u) { SVector3 t = ge->firstDer(u); t.normalize(); - double l_t = - (2 * M_PI) / (fabs(ge->curvature(u)) * CTX::instance()->mesh.minElementsPerTwoPi); + double l_t = (2 * M_PI) / (fabs(ge->curvature(u)) * + CTX::instance()->mesh.minElementsPerTwoPi); double l_n = 1.e12; return buildMetricTangentToCurve(t, l_t, l_n); } @@ -218,7 +218,7 @@ double BGM_MeshSizeWithoutScaling(GEntity *ge, double U, double V, double X, // lc from fields double l3 = MAX_LC; - if(ge){ + if(ge) { FieldManager *fields = ge->model()->getFields(); if(fields->getBackgroundField() > 0) { Field *f = fields->get(fields->getBackgroundField()); @@ -230,7 +230,8 @@ double BGM_MeshSizeWithoutScaling(GEntity *ge, double U, double V, double X, double l4 = ge ? ge->getMeshSize() : MAX_LC; double l5 = (ge && ge->dim() == 1) ? - ((GEdge*)ge)->prescribedMeshSizeAtParam(U) : MAX_LC; + ((GEdge *)ge)->prescribedMeshSizeAtParam(U) : + MAX_LC; // lc from callback double l6 = MAX_LC; @@ -241,8 +242,8 @@ double BGM_MeshSizeWithoutScaling(GEntity *ge, double U, double V, double X, } // take the minimum - double lc = std::min(std::min(std::min(std::min(std::min(l1, l2), l3), l4), - l5), l6); + double lc = + std::min(std::min(std::min(std::min(std::min(l1, l2), l3), l4), l5), l6); return lc; } @@ -251,8 +252,7 @@ double BGM_MeshSizeWithoutScaling(GEntity *ge, double U, double V, double X, double BGM_MeshSize(GEntity *ge, double U, double V, double X, double Y, double Z) { - if(!ge) - Msg::Warning("No entity in background mesh size evaluation"); + if(!ge) Msg::Warning("No entity in background mesh size evaluation"); // default size to size of model double lc = CTX::instance()->lc; @@ -311,9 +311,7 @@ SMetric3 BGM_MeshMetric(GEntity *ge, double U, double V, double X, double Y, Field *f = fields->get(fields->getBackgroundField()); if(f) { SMetric3 l4; - if(!f->isotropic()) { - (*f)(X, Y, Z, l4, ge); - } + if(!f->isotropic()) { (*f)(X, Y, Z, l4, ge); } else { const double L = (*f)(X, Y, Z, ge); l4 = SMetric3(1 / (L * L)); @@ -328,7 +326,8 @@ SMetric3 BGM_MeshMetric(GEntity *ge, double U, double V, double X, double Y, m1; // apply global size factor - if(CTX::instance()->mesh.lcFactor != 0 && CTX::instance()->mesh.lcFactor != 1.) + if(CTX::instance()->mesh.lcFactor != 0 && + CTX::instance()->mesh.lcFactor != 1.) m *= 1. / (CTX::instance()->mesh.lcFactor * CTX::instance()->mesh.lcFactor); return m; @@ -348,8 +347,7 @@ SMetric3 max_edge_curvature_metric(const GVertex *gv) { SMetric3 val(1.e-12); std::vector<GEdge *> const &l_edges = gv->edges(); - for(auto ite = l_edges.begin(); - ite != l_edges.end(); ++ite) { + for(auto ite = l_edges.begin(); ite != l_edges.end(); ++ite) { GEdge *_myGEdge = *ite; Range<double> range = _myGEdge->parBounds(0); SMetric3 cc; diff --git a/Mesh/BoundaryLayers.cpp b/Mesh/BoundaryLayers.cpp index c343f60d8184c0b49d18c77bbedb1fe2b18e3eed..b5cd49590309a513aad29b38035795ee4ea6b7af 100644 --- a/Mesh/BoundaryLayers.cpp +++ b/Mesh/BoundaryLayers.cpp @@ -72,8 +72,7 @@ static void addExtrudeNormals(std::vector<T *> &elements, int invert, } } } - for(auto it = verts.begin(); it != verts.end(); - it++) { + for(auto it = verts.begin(); it != verts.end(); it++) { MVertex *v = *it; double nn[3] = {0., 0., 0.}; #if defined(HAVE_POST) @@ -135,8 +134,7 @@ static void addExtrudeNormals(std::set<T *> &entities, bool normalize = true, special3dbox = false, extrudeField = false; std::vector<OctreePost *> octrees; - for(auto it = entities.begin(); - it != entities.end(); it++) { + for(auto it = entities.begin(); it != entities.end(); it++) { T *ge = *it; infoset info = infos[ge->tag()]; for(auto it2 = info.begin(); it2 != info.end(); it2++) { @@ -338,9 +336,7 @@ int Mesh2DWithBoundaryLayers(GModel *m) // 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 scaled. - if(!ep->mesh.ScaleLast) { - edgeSkipScaleCalc[from->tag()] = true; - } + if(!ep->mesh.ScaleLast) { edgeSkipScaleCalc[from->tag()] = true; } else { edgeSkipScaleCalc[from->tag()] = false; ExtrudeParams::calcLayerScaleFactor[ep->mesh.BoundaryLayerIndex] = @@ -373,9 +369,7 @@ int Mesh2DWithBoundaryLayers(GModel *m) // 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 scaled - if(!ep->mesh.ScaleLast) { - faceSkipScaleCalc[from->tag()] = true; - } + if(!ep->mesh.ScaleLast) { faceSkipScaleCalc[from->tag()] = true; } else { faceSkipScaleCalc[from->tag()] = false; ExtrudeParams::calcLayerScaleFactor[ep->mesh.BoundaryLayerIndex] = @@ -383,8 +377,7 @@ int Mesh2DWithBoundaryLayers(GModel *m) } std::vector<GEdge *> const &e = from->edges(); sourceEdges.insert(e.begin(), e.end()); - for(auto ite = e.begin(); - ite != e.end(); ite++) { + for(auto ite = e.begin(); ite != e.end(); ite++) { if(edgeSkipScaleCalc.find((*ite)->tag()) == edgeSkipScaleCalc.end()) edgeSkipScaleCalc[(*ite)->tag()] = true; // a default if(ep->mesh.ScaleLast) edgeSkipScaleCalc[(*ite)->tag()] = false; @@ -412,8 +405,7 @@ int Mesh2DWithBoundaryLayers(GModel *m) // compute mesh dependencies in source faces (so we can e.g. create a boundary // layer on an extruded mesh) std::set<GFace *> sourceFacesDependencies; - for(auto it = sourceFaces.begin(); - it != sourceFaces.end(); it++) + for(auto it = sourceFaces.begin(); it != sourceFaces.end(); it++) checkDepends(m, *it, sourceFacesDependencies); Msg::Info("%d dependencies in mesh of source faces", sourceFacesDependencies.size()); @@ -445,8 +437,7 @@ int Mesh2DWithBoundaryLayers(GModel *m) if(!nPending) break; if(nIter++ > CTX::instance()->mesh.maxRetries) break; } - for(auto it = sourceFaces.begin(); - it != sourceFaces.end(); it++) + for(auto it = sourceFaces.begin(); it != sourceFaces.end(); it++) (*it)->mesh(true); // make sure the source surfaces for the boundary layers are oriented @@ -480,7 +471,7 @@ int Mesh2DWithBoundaryLayers(GModel *m) vsrc = ge->getBeginVertex(); vdest = ge->getEndVertex(); } - if(vsrc && vdest){ + if(vsrc && vdest) { GPoint p = vsrc->point(); ep->Extrude(ep->mesh.NbLayer - 1, ep->mesh.NbElmLayer[ep->mesh.NbLayer - 1], p.x(), p.y(), @@ -494,8 +485,7 @@ int Mesh2DWithBoundaryLayers(GModel *m) // remesh non-source edges (since they might have been modified by the change // in boundary layer points) std::for_each(otherFaces.begin(), otherFaces.end(), deMeshGFace()); - for(auto it = otherEdges.begin(); - it != otherEdges.end(); it++) + for(auto it = otherEdges.begin(); it != otherEdges.end(); it++) (*it)->mesh(true); // mesh the curves bounding the boundary layers by extrusion using the smooth @@ -511,15 +501,13 @@ int Mesh2DWithBoundaryLayers(GModel *m) } // recompute mean plane for plane surfaces just in case - for(auto it = otherFaces.begin(); - it != otherFaces.end(); it++) { + for(auto it = otherFaces.begin(); it != otherFaces.end(); it++) { GFace *gf = *it; if(gf->geomType() == GEntity::Plane) gf->computeMeanPlane(); } // mesh non-source surfaces - for(auto it = otherFaces.begin(); - it != otherFaces.end(); it++) + for(auto it = otherFaces.begin(); it != otherFaces.end(); it++) (*it)->mesh(true); // mesh the surfaces bounding the boundary layers by extrusion using the diff --git a/Mesh/DivideAndConquer.cpp b/Mesh/DivideAndConquer.cpp index 93273dc85245c0e24a487939685c8302d1225483..fdb9845dfc4051c0f4649b694f5ff92a7b8be266 100644 --- a/Mesh/DivideAndConquer.cpp +++ b/Mesh/DivideAndConquer.cpp @@ -428,9 +428,7 @@ int DocRecord::DListDelete(DListPeek *dlist, PointNumero oldPoint) if(p->point_num == oldPoint) { Succ(Pred(p)) = Succ(p); Pred(Succ(p)) = Pred(p); - if(p == *dlist) { - *dlist = Succ(p); - } + if(p == *dlist) { *dlist = Succ(p); } delete p; return 1; } @@ -610,9 +608,7 @@ void DocRecord::makePosView(const std::string &fileName, GFace *gf) fprintf(f, "View \"scalar\" {\n"); for(PointNumero iPoint = 0; iPoint < numPoints; iPoint++) { DListPeek p = points[iPoint].adjacent; - if(!p) { - continue; - } + if(!p) { continue; } std::vector<PointNumero> adjacentPoints; do { adjacentPoints.push_back(p->point_num); @@ -830,8 +826,8 @@ void DocRecord::RemoveAllDList() } DocRecord::DocRecord(int n) - : _hullSize(0), _hull(nullptr), _adjacencies(nullptr), numPoints(n), points(nullptr), - numTriangles(0), triangles(nullptr) + : _hullSize(0), _hull(nullptr), _adjacencies(nullptr), numPoints(n), + points(nullptr), numTriangles(0), triangles(nullptr) { if(numPoints) points = new PointRecord[numPoints + 3000]; } @@ -860,9 +856,7 @@ void DocRecord::MakeMeshWithPoints() if(numPoints < 3) return; BuildDelaunay(); - if(AdjacentNullptrExists()) { - ConvertDListToTriangles(); - } + if(AdjacentNullptrExists()) { ConvertDListToTriangles(); } else { Msg::Error("Adjacent nullptrs found"); } @@ -940,8 +934,7 @@ std::set<int> DocRecord::tagInterior(double x, double y) std::pair<void *, void *> ab = std::make_pair(std::min(p[j]->data, p[(j + 1) % 3]->data), std::max(p[j]->data, p[(j + 1) % 3]->data)); - auto it = - edgesToTriangles.find(ab); + auto it = edgesToTriangles.find(ab); if(it == edgesToTriangles.end()) { edgesToTriangles[ab] = std::make_pair(i, -1); } @@ -980,9 +973,7 @@ void DocRecord::concave(double x, double y, GFace *gf) } } - for(int i = 0; i < numPoints; i++) { - points[i].vicinity.clear(); - } + for(int i = 0; i < numPoints; i++) { points[i].vicinity.clear(); } try { MakeMeshWithPoints(); @@ -1032,9 +1023,7 @@ void DocRecord::add(int index1, int index2) void DocRecord::initialize() { - for(int i = 0; i < numPoints; i++) { - points[i].flag = 0; - } + for(int i = 0; i < numPoints; i++) { points[i].flag = 0; } } bool DocRecord::remove_point(int index) @@ -1051,9 +1040,7 @@ void DocRecord::remove_all() { int numPoints2 = 0; for(int i = 0; i < numPoints; i++) { - if(points[i].flag == 0) { - numPoints2++; - } + if(points[i].flag == 0) { numPoints2++; } } PointRecord *points2 = new PointRecord[numPoints2]; int index = 0; @@ -1101,8 +1088,7 @@ bool DocRecord::delaunay_conformity(GFace *gf) { std::vector<GEdge *> const &list = gf->edges(); - for(auto it = list.begin(); it != list.end(); - it++) { + for(auto it = list.begin(); it != list.end(); it++) { GEdge *edge = *it; for(std::size_t i = 0; i < edge->getNumMeshElements(); i++) { MElement *element = edge->getMeshElement(i); diff --git a/Mesh/Field.cpp b/Mesh/Field.cpp index dc232798fc6d7ccdc0ce81ce980c682cabf0670a..8de61a581f90d5af7dd4709a0ae7a24e4f8a5135 100644 --- a/Mesh/Field.cpp +++ b/Mesh/Field.cpp @@ -51,11 +51,8 @@ Field::~Field() { - for(auto it = options.begin(); - it != options.end(); ++it) - delete it->second; - for(auto it = callbacks.begin(); - it != callbacks.end(); ++it) + for(auto it = options.begin(); it != options.end(); ++it) delete it->second; + for(auto it = callbacks.begin(); it != callbacks.end(); ++it) delete it->second; } @@ -71,9 +68,7 @@ FieldOption *Field::getOption(const std::string &optionName) void FieldManager::reset() { - for(auto it = begin(); it != end(); it++) { - delete it->second; - } + for(auto it = begin(); it != end(); it++) { delete it->second; } clear(); } @@ -280,8 +275,8 @@ public: _stereoRadius, "Radius of the sphere of the stereograpic coordinates"); // deprecated names - options["IField"] = - new FieldOptionInt(_inField, "Tag of the field to evaluate", nullptr, true); + options["IField"] = new FieldOptionInt( + _inField, "Tag of the field to evaluate", nullptr, true); } const char *getName() { return "LonLat"; } using Field::operator(); @@ -650,12 +645,12 @@ public: "F = a very big value if Field[InField] > DistMax)"); // deprecated names - options["IField"] = - new FieldOptionInt(_inField, "Tag of the field to evaluate", nullptr, true); - options["LcMin"] = - new FieldOptionDouble(_lcMin, "Element size inside DistMin", nullptr, true); - options["LcMax"] = - new FieldOptionDouble(_lcMax, "Element size outside DistMax", nullptr, true); + options["IField"] = new FieldOptionInt( + _inField, "Tag of the field to evaluate", nullptr, true); + options["LcMin"] = new FieldOptionDouble( + _lcMin, "Element size inside DistMin", nullptr, true); + options["LcMax"] = new FieldOptionDouble( + _lcMax, "Element size outside DistMax", nullptr, true); } using Field::operator(); double operator()(double x, double y, double z, GEntity *ge = nullptr) @@ -959,8 +954,7 @@ public: variables[1] = "y"; variables[2] = "z"; i = 3; - for(auto it = _fields.begin(); it != _fields.end(); - it++) { + for(auto it = _fields.begin(); it != _fields.end(); it++) { std::ostringstream sstream; sstream << "F" << *it; variables[i++] = sstream.str(); @@ -982,8 +976,7 @@ public: values[1] = y; values[2] = z; int i = 3; - for(auto it = _fields.begin(); it != _fields.end(); - it++) { + for(auto it = _fields.begin(); it != _fields.end(); it++) { Field *field = GModel::current()->getFields()->get(*it); values[i++] = field ? (*field)(x, y, z) : MAX_LC; } @@ -1034,8 +1027,8 @@ public: variables[1] = "y"; variables[2] = "z"; i = 3; - for(auto it = _fields[iFunction].begin(); - it != _fields[iFunction].end(); it++) { + for(auto it = _fields[iFunction].begin(); it != _fields[iFunction].end(); + it++) { std::ostringstream sstream; sstream << "F" << *it; variables[i++] = sstream.str(); @@ -1157,7 +1150,8 @@ public: options["m23"] = new FieldOptionString( _f[5], "Element 23 of the metric tensor", &updateNeeded, true); } - void operator()(double x, double y, double z, SMetric3 &metr, GEntity *ge = nullptr) + void operator()(double x, double y, double z, SMetric3 &metr, + GEntity *ge = nullptr) { #if defined(_OPENMP) #pragma omp critical @@ -1564,7 +1558,8 @@ public: if(l <= 0 && _cropNegativeValues) return MAX_LC; return l; } - void operator()(double x, double y, double z, SMetric3 &metr, GEntity *ge = nullptr) + void operator()(double x, double y, double z, SMetric3 &metr, + GEntity *ge = nullptr) { PView *v = getView(); if(!v) return; @@ -1627,8 +1622,7 @@ public: GEntity *ge = nullptr) { SMetric3 v(1. / MAX_LC); - for(auto it = _fieldIds.begin(); it != _fieldIds.end(); - it++) { + for(auto it = _fieldIds.begin(); it != _fieldIds.end(); it++) { Field *f = (GModel::current()->getFields()->get(*it)); SMetric3 ff; if(f && *it != id) { @@ -1648,8 +1642,7 @@ public: { SMetric3 metr(1. / MAX_LC); double v = MAX_LC; - for(auto it = _fieldIds.begin(); it != _fieldIds.end(); - it++) { + for(auto it = _fieldIds.begin(); it != _fieldIds.end(); it++) { Field *f = (GModel::current()->getFields()->get(*it)); SMetric3 m; if(f && *it != id) { @@ -1691,8 +1684,7 @@ public: { // check if _fieldIds contains 2 elements other error message SMetric3 v; - for(auto it = _fieldIds.begin(); it != _fieldIds.end(); - it++) { + for(auto it = _fieldIds.begin(); it != _fieldIds.end(); it++) { Field *f = (GModel::current()->getFields()->get(*it)); SMetric3 ff; if(f && *it != id) { @@ -1715,8 +1707,7 @@ public: { // check if _fieldIds contains 2 elements other error message SMetric3 metr; - for(auto it = _fieldIds.begin(); it != _fieldIds.end(); - it++) { + for(auto it = _fieldIds.begin(); it != _fieldIds.end(); it++) { Field *f = (GModel::current()->getFields()->get(*it)); SMetric3 m; if(f && *it != id) { @@ -1757,8 +1748,7 @@ public: double operator()(double x, double y, double z, GEntity *ge = nullptr) { double v = MAX_LC; - for(auto it = _fieldIds.begin(); it != _fieldIds.end(); - it++) { + for(auto it = _fieldIds.begin(); it != _fieldIds.end(); it++) { Field *f = (GModel::current()->getFields()->get(*it)); if(f && *it != id) { if(f->isotropic()) @@ -1796,8 +1786,7 @@ public: double operator()(double x, double y, double z, GEntity *ge = nullptr) { double v = -MAX_LC; - for(auto it = _fieldIds.begin(); it != _fieldIds.end(); - it++) { + for(auto it = _fieldIds.begin(); it != _fieldIds.end(); it++) { Field *f = (GModel::current()->getFields()->get(*it)); if(f && *it != id) { if(f->isotropic()) @@ -1998,8 +1987,7 @@ public: if(totpoints) { _zeroNodes = annAllocPts(totpoints, 3); } _tg.resize(totpoints); int k = 0; - for(auto it = _curveTags.begin(); - it != _curveTags.end(); ++it) { + for(auto it = _curveTags.begin(); it != _curveTags.end(); ++it) { GEdge *e = GModel::current()->getEdgeByTag(*it); if(e) { for(int i = 1; i < _numPointsPerCurve - 1; i++) { @@ -2020,7 +2008,8 @@ public: _kdTree = new ANNkd_tree(_zeroNodes, totpoints, 3); updateNeeded = false; } - void operator()(double x, double y, double z, SMetric3 &metr, GEntity *ge = nullptr) + void operator()(double x, double y, double z, SMetric3 &metr, + GEntity *ge = nullptr) { if(updateNeeded) update(); double xyz[3] = {x, y, z}; @@ -2175,8 +2164,7 @@ public: std::vector<SPoint2> uvpoints; std::vector<int> offset; offset.push_back(0); - for(auto it = _surfaceTags.begin(); - it != _surfaceTags.end(); ++it) { + for(auto it = _surfaceTags.begin(); it != _surfaceTags.end(); ++it) { GFace *f = GModel::current()->getFaceByTag(*it); if(f) { if(f->mesh_vertices.size()) { @@ -2202,8 +2190,7 @@ public: double x, y, z; std::vector<double> px, py, pz; - for(auto it = _pointTags.begin(); - it != _pointTags.end(); ++it) { + for(auto it = _pointTags.begin(); it != _pointTags.end(); ++it) { GVertex *gv = GModel::current()->getVertexByTag(*it); if(gv) { getCoord(gv->x(), gv->y(), gv->z(), x, y, z, gv); @@ -2214,8 +2201,7 @@ public: } } - for(auto it = _curveTags.begin(); - it != _curveTags.end(); ++it) { + for(auto it = _curveTags.begin(); it != _curveTags.end(); ++it) { GEdge *e = GModel::current()->getEdgeByTag(*it); if(e) { if(e->mesh_vertices.size()) { @@ -2247,8 +2233,7 @@ public: // This can lead to weird results as we generate attractors over the whole // parametric plane (we should really use a mesh, e.g. a refined STL.) int count = 0; - for(auto it = _surfaceTags.begin(); - it != _surfaceTags.end(); ++it) { + for(auto it = _surfaceTags.begin(); it != _surfaceTags.end(); ++it) { GFace *f = GModel::current()->getFaceByTag(*it); if(f) { if(points.size()) { @@ -2643,8 +2628,7 @@ public: _infos.clear(); std::vector<SPoint3> &points = _P.pts; points.clear(); - for(auto it = _surfaceTags.begin(); - it != _surfaceTags.end(); ++it) { + for(auto it = _surfaceTags.begin(); it != _surfaceTags.end(); ++it) { GFace *f = GModel::current()->getFaceByTag(*it); if(f) { if(f->mesh_vertices.size()) { @@ -2670,8 +2654,7 @@ public: } } - for(auto it = _pointTags.begin(); - it != _pointTags.end(); ++it) { + for(auto it = _pointTags.begin(); it != _pointTags.end(); ++it) { GVertex *gv = GModel::current()->getVertexByTag(*it); if(gv) { points.push_back(SPoint3(gv->x(), gv->y(), gv->z())); @@ -2679,8 +2662,7 @@ public: } } - for(auto it = _curveTags.begin(); - it != _curveTags.end(); ++it) { + for(auto it = _curveTags.begin(); it != _curveTags.end(); ++it) { GEdge *e = GModel::current()->getEdgeByTag(*it); if(e) { if(e->mesh_vertices.size()) { @@ -2823,8 +2805,8 @@ BoundaryLayerField::BoundaryLayerField() nullptr, true); options["ratio"] = new FieldOptionDouble( ratio, "Size ratio between two successive layers", nullptr, true); - options["hfar"] = - new FieldOptionDouble(hFar, "Element size far from the wall", nullptr, true); + options["hfar"] = new FieldOptionDouble( + hFar, "Element size far from the wall", nullptr, true); options["thickness"] = new FieldOptionDouble( thickness, "Maximal thickness of the boundary layer", nullptr, true); options["ExcludedFaceList"] = @@ -2836,9 +2818,7 @@ BoundaryLayerField::BoundaryLayerField() void BoundaryLayerField::removeAttractors() { - for(auto it = _attFields.begin(); - it != _attFields.end(); ++it) - delete *it; + for(auto it = _attFields.begin(); it != _attFields.end(); ++it) delete *it; _attFields.clear(); updateNeeded = true; } @@ -2908,8 +2888,7 @@ bool BoundaryLayerField::setupFor2d(int iF) if(found) { std::vector<GFace *> fc = (*it)->faces(); int numf = 0; - for(auto it = fc.begin(); it != fc.end(); - it++) { + for(auto it = fc.begin(); it != fc.end(); it++) { if((*it)->meshAttributes.extrude && (*it)->meshAttributes.extrude->geo.Mode == EXTRUDED_ENTITY) { // ok @@ -2948,12 +2927,10 @@ bool BoundaryLayerField::setupFor2d(int iF) double BoundaryLayerField::operator()(double x, double y, double z, GEntity *ge) { if(updateNeeded) { - for(auto it = _pointTags.begin(); - it != _pointTags.end(); ++it) { + for(auto it = _pointTags.begin(); it != _pointTags.end(); ++it) { _attFields.push_back(new DistanceField(0, *it, 100000)); } - for(auto it = _curveTags.begin(); - it != _curveTags.end(); ++it) { + for(auto it = _curveTags.begin(); it != _curveTags.end(); ++it) { _attFields.push_back(new DistanceField(1, *it, 300000)); } updateNeeded = false; @@ -2961,8 +2938,7 @@ double BoundaryLayerField::operator()(double x, double y, double z, GEntity *ge) double dist = 1.e22; if(_attFields.empty()) return dist; - for(auto it = _attFields.begin(); - it != _attFields.end(); ++it) { + for(auto it = _attFields.begin(); it != _attFields.end(); ++it) { double cdist = (*(*it))(x, y, z); if(cdist < dist) { dist = cdist; } } @@ -2983,8 +2959,7 @@ void BoundaryLayerField::computeFor1dMesh(double x, double y, double z, { double xpk = 0., ypk = 0., zpk = 0.; double distk = 1.e22; - for(auto it = _pointTags.begin(); it != _pointTags.end(); - ++it) { + for(auto it = _pointTags.begin(); it != _pointTags.end(); ++it) { GVertex *v = GModel::current()->getVertexByTag(*it); double xp = v->x(); double yp = v->y(); @@ -3102,12 +3077,10 @@ void BoundaryLayerField::operator()(double x, double y, double z, SMetric3 &metr, GEntity *ge) { if(updateNeeded) { - for(auto it = _pointTags.begin(); - it != _pointTags.end(); ++it) { + for(auto it = _pointTags.begin(); it != _pointTags.end(); ++it) { _attFields.push_back(new DistanceField(0, *it, 100000)); } - for(auto it = _curveTags.begin(); - it != _curveTags.end(); ++it) { + for(auto it = _curveTags.begin(); it != _curveTags.end(); ++it) { _attFields.push_back(new DistanceField(1, *it, 10000)); } updateNeeded = false; @@ -3118,8 +3091,7 @@ void BoundaryLayerField::operator()(double x, double y, double z, std::vector<SMetric3> hop; SMetric3 v(1. / (CTX::instance()->mesh.lcMax * CTX::instance()->mesh.lcMax)); hop.push_back(v); - for(auto it = _attFields.begin(); - it != _attFields.end(); ++it) { + for(auto it = _attFields.begin(); it != _attFields.end(); ++it) { double cdist = (*(*it))(x, y, z); SPoint3 CLOSEST = (*it)->getAttractorInfo().second; SMetric3 localMetric; @@ -3188,8 +3160,7 @@ void FieldManager::initialize() FieldManager::~FieldManager() { - for(auto it = mapTypeName.begin(); - it != mapTypeName.end(); it++) + for(auto it = mapTypeName.begin(); it != mapTypeName.end(); it++) delete it->second; for(auto it = begin(); it != end(); it++) delete it->second; } @@ -3270,16 +3241,14 @@ double GenericField::operator()(double x, double y, double z, GEntity *ge) auto it = sizes.begin(); // Go over all callback functions - for(auto itcbs = - cbs_with_data.begin(); - itcbs != cbs_with_data.end(); itcbs++, it++) { + for(auto itcbs = cbs_with_data.begin(); itcbs != cbs_with_data.end(); + itcbs++, it++) { bool ok = (itcbs->first)(x, y, z, itcbs->second, (*it)); if(!ok) { Msg::Warning("GenericField::ERROR from callback "); } } // Go over all extended callback functions - for(auto itcbs = - cbs_extended_with_data.begin(); + for(auto itcbs = cbs_extended_with_data.begin(); itcbs != cbs_extended_with_data.end(); itcbs++, it++) { bool ok = (itcbs->first)(x, y, z, ge, itcbs->second, (*it)); if(!ok) { Msg::Warning("GenericField::ERROR from callback "); } diff --git a/Mesh/Generator.cpp b/Mesh/Generator.cpp index ed2f0cb135f9593135f558d27dd32c564580340d..9aacfdd25925c198fe89e1b5136dd5b9da1145cf 100644 --- a/Mesh/Generator.cpp +++ b/Mesh/Generator.cpp @@ -102,13 +102,12 @@ public: char name[256]; sprintf(name, "missingEdgesOnRegion%d.pos", gr->tag()); Msg::Warning("Region %d : %d mesh edges that should be embedded are " - "missing in the final mesh", - gr->tag(), (int)edges.size()); + "missing in the final mesh", + gr->tag(), (int)edges.size()); Msg::Info("Saving the missing edges in file %s", name); FILE *f = fopen(name, "w"); fprintf(f, "View \" \" {\n"); - for(auto it = edges.begin(); - it != edges.end(); ++it) { + for(auto it = edges.begin(); it != edges.end(); ++it) { MVertex *v1 = it->first.getVertex(0); MVertex *v2 = it->first.getVertex(1); fprintf(f, "SL(%g,%g,%g,%g,%g,%g){%d,%d};\n", v1->x(), v1->y(), v1->z(), @@ -122,13 +121,12 @@ public: char name[256]; sprintf(name, "missingFacesOnRegion%d.pos", gr->tag()); Msg::Warning("Volume %d : %d mesh faces that should be embedded are " - "missing in the final mesh", - gr->tag(), (int)faces.size()); + "missing in the final mesh", + gr->tag(), (int)faces.size()); Msg::Info("Saving the missing faces in file %s", name); FILE *f = fopen(name, "w"); fprintf(f, "View \" \" {\n"); - for(auto it = faces.begin(); - it != faces.end(); ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { MVertex *v1 = it->first.getVertex(0); MVertex *v2 = it->first.getVertex(1); MVertex *v3 = it->first.getVertex(2); @@ -512,8 +510,7 @@ static void Mesh2D(GModel *m) // surface mesh of the source surfaces if(!Mesh2DWithBoundaryLayers(m)) { std::set<GFace *, GEntityPtrLessThan> f; - for(auto it = m->firstFace(); it != m->lastFace(); ++it) - f.insert(*it); + for(auto it = m->firstFace(); it != m->lastFace(); ++it) f.insert(*it); int nIter = 0, nTot = m->getNumFaces(); @@ -583,8 +580,7 @@ FindConnectedRegions(const std::vector<GRegion *> &del, _stack.pop(); oneDomain.insert(r); std::vector<GFace *> faces = r->faces(); - for(auto it = faces.begin(); it != faces.end(); - ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { GFace *gf = *it; GRegion *other = (gf->getRegion(0) == r) ? gf->getRegion(1) : gf->getRegion(0); @@ -650,8 +646,7 @@ bool MakeMeshConformal(GModel *gm, int howto) // bnd2 contains non conforming faces std::set<MFace, MFaceLessThan> bnd2; - for(auto itf = bnd.begin(); - itf != bnd.end(); ++itf) { + for(auto itf = bnd.begin(); itf != bnd.end(); ++itf) { GFace *gfound = findInFaceSearchStructure(*itf, search); if(!gfound) { bnd2.insert(*itf); } } @@ -660,8 +655,7 @@ bool MakeMeshConformal(GModel *gm, int howto) Msg::Info("%d hanging faces", bnd2.size()); std::set<MFace, MFaceLessThan> ncf; - for(auto itf = bnd2.begin(); - itf != bnd2.end(); ++itf) { + for(auto itf = bnd2.begin(); itf != bnd2.end(); ++itf) { const MFace &f = *itf; if(f.getNumVertices() == 4) { // quad face auto it1 = @@ -794,8 +788,7 @@ static void TestConformity(GModel *gm) } printf("vol(%d) = %12.5E\n", gr->tag(), vol); - for(auto itf = bnd.begin(); - itf != bnd.end(); ++itf) { + for(auto itf = bnd.begin(); itf != bnd.end(); ++itf) { GFace *gfound = findInFaceSearchStructure(*itf, search); if(!gfound) { count++; } } @@ -956,8 +949,7 @@ static void Mesh3D(GModel *m) bool emptyRegionFound = false; for(auto it = m->firstRegion(); it != m->lastRegion(); ++it) { GRegion *gr = *it; - if(CTX::instance()->mesh.meshOnlyVisible && !gr->getVisibility()) - continue; + if(CTX::instance()->mesh.meshOnlyVisible && !gr->getVisibility()) continue; if(CTX::instance()->mesh.meshOnlyEmpty && gr->getNumMeshElements()) continue; if(gr->getNumMeshElements() == 0) { @@ -1079,8 +1071,8 @@ void OptimizeMesh(GModel *m, const std::string &how, bool force, int niter) EmbeddedCompatibilityTest()); double t2 = Cpu(), w2 = TimeOfDay(); - Msg::StatusBar(true, "Done optimizing mesh (Wall %gs, CPU %gs)", - w2 - w1, t2 - t1); + Msg::StatusBar(true, "Done optimizing mesh (Wall %gs, CPU %gs)", w2 - w1, + t2 - t1); } void AdaptMesh(GModel *m) @@ -1094,8 +1086,8 @@ void AdaptMesh(GModel *m) std::for_each(m->firstRegion(), m->lastRegion(), adaptMeshGRegion()); double t2 = Cpu(), w2 = TimeOfDay(); - Msg::StatusBar(true, "Done adaptating 3D mesh (Wall %gs, CPU %gs)", - w2 - w1, t2 - t1); + Msg::StatusBar(true, "Done adaptating 3D mesh (Wall %gs, CPU %gs)", w2 - w1, + t2 - t1); } void RecombineMesh(GModel *m) @@ -1114,8 +1106,8 @@ void RecombineMesh(GModel *m) } double t2 = Cpu(), w2 = TimeOfDay(); - Msg::StatusBar(true, "Done recombining 2D mesh (Wall %gs, CPU %gs)", - w2 - w1, t2 - t1); + Msg::StatusBar(true, "Done recombining 2D mesh (Wall %gs, CPU %gs)", w2 - w1, + t2 - t1); } static SPoint3 transform(MVertex *vsource, const std::vector<double> &tfo) @@ -1133,8 +1125,7 @@ static void relocateSlaveVertices(GFace *slave, std::map<MVertex *, MVertex *> &vertS2M, bool useClosestPoint) { - for(auto vit = vertS2M.begin(); - vit != vertS2M.end(); ++vit) { + for(auto vit = vertS2M.begin(); vit != vertS2M.end(); ++vit) { MFaceVertex *v = dynamic_cast<MFaceVertex *>(vit->first); if(v && v->onWhat() == slave) { SPoint3 p = transform(vit->second, slave->affineTransform); @@ -1161,8 +1152,7 @@ static void relocateSlaveVertices(GEdge *slave, std::map<MVertex *, MVertex *> &vertS2M, bool useClosestPoint) { - for(auto vit = vertS2M.begin(); - vit != vertS2M.end(); ++vit) { + for(auto vit = vertS2M.begin(); vit != vertS2M.end(); ++vit) { MEdgeVertex *v = dynamic_cast<MEdgeVertex *>(vit->first); if(v && v->onWhat() == slave) { SPoint3 p = transform(vit->second, slave->affineTransform); @@ -1194,8 +1184,7 @@ static void relocateSlaveVertices(std::vector<GEntity *> &entities, } } - for(auto it = master2slave.begin(); - it != master2slave.end(); ++it) { + for(auto it = master2slave.begin(); it != master2slave.end(); ++it) { if(it->first->dim() == 2) { GFace *master = dynamic_cast<GFace *>(it->first); GFace *slave = dynamic_cast<GFace *>(it->second); @@ -1275,8 +1264,7 @@ void FixPeriodicMesh(GModel *m) vtcs[iVtx] = tIter->second; } - auto srcIter = - srcEdges.find(MEdge(vtcs[0], vtcs[1])); + auto srcIter = srcEdges.find(MEdge(vtcs[0], vtcs[1])); if(srcIter == srcEdges.end()) { Msg::Error("Can't find periodic counterpart of mesh edge %d-%d " "on curve %d, connected to mesh edge %d-%d on curve %d", @@ -1357,8 +1345,7 @@ void FixPeriodicMesh(GModel *m) } MFace tgtFace(vtcs); - auto srcIter = - srcFaces.find(tgtFace); + auto srcIter = srcFaces.find(tgtFace); if(srcIter == srcFaces.end()) { std::ostringstream faceDef; for(int iVtx = 0; iVtx < nbVtcs; iVtx++) diff --git a/Mesh/HighOrder.cpp b/Mesh/HighOrder.cpp index 1f54f0e00c575b91a252c9be187257eb08399ef9..5631454744f49f404b8457f9535bf366b9ff3fce 100644 --- a/Mesh/HighOrder.cpp +++ b/Mesh/HighOrder.cpp @@ -774,7 +774,8 @@ static void getFaceVertices(GFace *gf, MElement *ele, // (translation): this allows to speed up a common case (extruded OCC // models) by orders of magnitudes, where OCC closestPoint() is atrociously // slow - if(!getFaceVerticesOnExtrudedGeo(gf, *coefficients, boundaryVertices, vFace)) + if(!getFaceVerticesOnExtrudedGeo(gf, *coefficients, boundaryVertices, + vFace)) getFaceVerticesOnGeo(gf, *coefficients, boundaryVertices, vFace); } else { // ... otherwise, create from mesh interpolation diff --git a/Mesh/automaticMeshSizeField.cpp b/Mesh/automaticMeshSizeField.cpp index 2dd204163de9a31034bc37b12a5fdc189d7d0ddd..9d8a89d9b14207ed4368c96b3aa3ff0c95ca61a5 100644 --- a/Mesh/automaticMeshSizeField.cpp +++ b/Mesh/automaticMeshSizeField.cpp @@ -447,9 +447,10 @@ p8est_connectivity_new_cube(ForestOptions *forestOptions) const p4est_topidx_t tree_to_tree[1 * 6] = {0, 0, 0, 0, 0, 0}; const int8_t tree_to_face[1 * 6] = {0, 1, 2, 3, 4, 5}; - return p4est_connectivity_new_copy( - num_vertices, num_trees, 0, 0, vertices, tree_to_vertex, tree_to_tree, - tree_to_face, nullptr, &num_ett, nullptr, nullptr, nullptr, &num_ctt, nullptr, nullptr); + return p4est_connectivity_new_copy(num_vertices, num_trees, 0, 0, vertices, + tree_to_vertex, tree_to_tree, tree_to_face, + nullptr, &num_ett, nullptr, nullptr, + nullptr, &num_ctt, nullptr, nullptr); } static p4est_connectivity_t * @@ -480,9 +481,10 @@ p8est_connectivity_new_square(ForestOptions *forestOptions) const p4est_topidx_t tree_to_tree[1 * 6] = {0, 0, 0, 0, 0, 0}; const int8_t tree_to_face[1 * 6] = {0, 1, 2, 3, 4, 5}; - return p4est_connectivity_new_copy( - num_vertices, num_trees, 0, 0, vertices, tree_to_vertex, tree_to_tree, - tree_to_face, nullptr, &num_ett, nullptr, nullptr, nullptr, &num_ctt, nullptr, nullptr); + return p4est_connectivity_new_copy(num_vertices, num_trees, 0, 0, vertices, + tree_to_vertex, tree_to_tree, tree_to_face, + nullptr, &num_ett, nullptr, nullptr, + nullptr, &num_ctt, nullptr, nullptr); } static inline double bulkSize(double x, double y, double z, double hBulk) { @@ -715,8 +717,7 @@ static int curvatureRefineCallback(p4est_t *p4est, p4est_topidx_t which_tree, double kmax = -1.e22; // To get min curvature size double kmin = 1.e22; double hf = DBL_MAX; // To get min feature size - for(auto tri = candidates.begin(); - tri != candidates.end(); ++tri) { + for(auto tri = candidates.begin(); tri != candidates.end(); ++tri) { for(int i = 0; i < 3; ++i) { int node = forestOptions->mesh->triangles.node[(size_t)3 * (*tri) + i]; @@ -842,8 +843,7 @@ static void assignSizeAfterRefinement(p4est_iter_volume_info_t *info, if(!candidates.empty()) { double kmax = -1.0e22; double hf = DBL_MAX; - for(auto tri = candidates.begin(); - tri != candidates.end(); ++tri) { + for(auto tri = candidates.begin(); tri != candidates.end(); ++tri) { for(int i = 0; i < 3; ++i) { int node = forestOptions->mesh->triangles.node[(size_t)3 * (*tri) + i]; @@ -1015,7 +1015,8 @@ HXTStatus forestRefine(Forest *forest) p4est_refine_ext(forest->p4est, 1, P4EST_QMAXLEVEL, curvatureRefineCallback, initializeCell, nullptr); // Coarsen - p4est_coarsen_ext(forest->p4est, 1, 0, coarsenCallback, initializeCell, nullptr); + p4est_coarsen_ext(forest->p4est, 1, 0, coarsenCallback, initializeCell, + nullptr); // Balance the octree to get 2:1 ratio between adjacent cells p4est_balance_ext(forest->p4est, P4EST_CONNECT_FACE, initializeCell, nullptr); // Assign size on the new cells @@ -1201,10 +1202,11 @@ static void computeGradientCenter(p4est_iter_face_info_t *info, void *user_data) HXTStatus forestComputeGradient(Forest *forest) { // Iterate on each cell to reset size gradient and half lengths. - p4est_iterate(forest->p4est, nullptr, nullptr, resetCell, nullptr, nullptr, nullptr); - // Compute gradient at cell center using finite differences - p4est_iterate(forest->p4est, nullptr, nullptr, nullptr, computeGradientCenter, nullptr, + p4est_iterate(forest->p4est, nullptr, nullptr, resetCell, nullptr, nullptr, nullptr); + // Compute gradient at cell center using finite differences + p4est_iterate(forest->p4est, nullptr, nullptr, nullptr, computeGradientCenter, + nullptr, nullptr); return HXT_STATUS_OK; } @@ -1230,16 +1232,16 @@ static inline void getMinSize(p4est_iter_volume_info_t *info, void *user_data) HXTStatus forestGetMaxGradient(Forest *forest, double *gradMax) { - p4est_iterate(forest->p4est, nullptr, (void *)gradMax, getMaxGradient, nullptr, - nullptr, nullptr); + p4est_iterate(forest->p4est, nullptr, (void *)gradMax, getMaxGradient, + nullptr, nullptr, nullptr); return HXT_STATUS_OK; } HXTStatus forestGetMinSize(Forest *forest, double *minsize) { double minSize = 1e22; - p4est_iterate(forest->p4est, nullptr, (void *)&minSize, getMinSize, nullptr, nullptr, - nullptr); + p4est_iterate(forest->p4est, nullptr, (void *)&minSize, getMinSize, nullptr, + nullptr, nullptr); *minsize = minSize; return HXT_STATUS_OK; } @@ -2321,17 +2323,17 @@ static void drawDirections(p4est_iter_volume_info_t *info, void *user_data) HXTStatus forestInterpolateDirections(Forest *forest) { intersections = 0; - p4est_iterate(forest->p4est, nullptr, nullptr, markIntersectingCells, nullptr, nullptr, - nullptr); + p4est_iterate(forest->p4est, nullptr, nullptr, markIntersectingCells, nullptr, + nullptr, nullptr); std::vector<interpolation_data_t> cellCenters; cellCounter = 0; - p4est_iterate(forest->p4est, nullptr, &cellCenters, pushInterpolationData, nullptr, - nullptr, nullptr); + p4est_iterate(forest->p4est, nullptr, &cellCenters, pushInterpolationData, + nullptr, nullptr, nullptr); p4est_iterate(forest->p4est, nullptr, &cellCenters, addDistanceContribution, nullptr, nullptr, nullptr); - p4est_iterate(forest->p4est, nullptr, &cellCenters, assignDirections, nullptr, nullptr, - nullptr); + p4est_iterate(forest->p4est, nullptr, &cellCenters, assignDirections, nullptr, + nullptr, nullptr); forest->forestOptions->file3 = fopen("directions.pos", "w"); if(forest->forestOptions->file3 == nullptr) @@ -2339,7 +2341,8 @@ HXTStatus forestInterpolateDirections(Forest *forest) fprintf(forest->forestOptions->file3, "View \"directions\" {\n"); - p4est_iterate(forest->p4est, nullptr, nullptr, drawDirections, nullptr, nullptr, nullptr); + p4est_iterate(forest->p4est, nullptr, nullptr, drawDirections, nullptr, + nullptr, nullptr); fprintf(forest->forestOptions->file3, "};"); fclose(forest->forestOptions->file3); @@ -2430,12 +2433,12 @@ HXTStatus forestExport(Forest *forest, const char *forestFile) fprintf(f, "View \"sizeField\" {\n"); if(forest->forestOptions->dim == 3) { - p4est_iterate(forest->p4est, nullptr, (void *)f, exportToHexCallback, nullptr, - nullptr, nullptr); + p4est_iterate(forest->p4est, nullptr, (void *)f, exportToHexCallback, + nullptr, nullptr, nullptr); } else if(forest->forestOptions->dim == 2) { - p4est_iterate(forest->p4est, nullptr, (void *)f, exportToQuadCallback, nullptr, - nullptr, nullptr); + p4est_iterate(forest->p4est, nullptr, (void *)f, exportToQuadCallback, + nullptr, nullptr, nullptr); } fprintf(f, "};"); fclose(f); @@ -2559,8 +2562,7 @@ HXTStatus automaticMeshSizeField::updateHXT() // Get all faces of the model std::vector<GFace *> faces; std::vector<GRegion *> regions; - for(auto it = - GModel::current()->firstRegion(); + for(auto it = GModel::current()->firstRegion(); it != GModel::current()->lastRegion(); ++it) { regions.push_back(*it); } @@ -2569,8 +2571,7 @@ HXTStatus automaticMeshSizeField::updateHXT() } else { Msg::Info("No volume in the model : looping over faces instead."); - for(auto it = - GModel::current()->firstFace(); + for(auto it = GModel::current()->firstFace(); it != GModel::current()->lastFace(); ++it) { faces.push_back(*it); } diff --git a/Mesh/delaunay3d.cpp b/Mesh/delaunay3d.cpp index bfa339bf6f7edaebe3142872c4f8a85b8d957f73..106a665c4119c874839e99b2ff7d5e33bde327de 100644 --- a/Mesh/delaunay3d.cpp +++ b/Mesh/delaunay3d.cpp @@ -147,13 +147,13 @@ struct Face { V[0] = v[0] = v1; V[1] = v[1] = v2; V[2] = v[2] = v3; -#define cswap(a, b) \ - do { \ - if(a > b) { \ - Vert *tmp = a; \ - a = b; \ - b = tmp; \ - } \ +#define cswap(a, b) \ + do { \ + if(a > b) { \ + Vert *tmp = a; \ + a = b; \ + b = tmp; \ + } \ } while(0) cswap(v[0], v[1]); cswap(v[1], v[2]); @@ -210,9 +210,7 @@ struct Tet { V[3] = v3; for(int i = 0; i < 4; i++) if(V[i]) V[i]->setT(this); - if(val > 0) { - return 1; - } + if(val > 0) { return 1; } else if(val < 0) { V[0] = v1; V[1] = v0; @@ -288,9 +286,7 @@ public: } ~aBunchOfStuff() { - for(std::size_t i = 0; i < _all.size(); i++) { - delete[] _all[i]; - } + for(std::size_t i = 0; i < _all.size(); i++) { delete[] _all[i]; } } T *newStuff() { @@ -313,25 +309,18 @@ public: if((int)_perThread.size() <= thread) return 0; return _perThread[thread]->size(); } - Tet *operator()(int thread, int j) const - { - return (*_perThread[thread])(j); - } + Tet *operator()(int thread, int j) const { return (*_perThread[thread])(j); } tetContainer(int nbThreads, int preallocSizePerThread) { _perThread.resize(nbThreads); - for(std::size_t i = 0; i < _perThread.size(); i++){ + for(std::size_t i = 0; i < _perThread.size(); i++) { _perThread[i] = new aBunchOfStuff<Tet>(preallocSizePerThread); } } - Tet *newTet(int thread) - { - return _perThread[thread]->newStuff(); - } + Tet *newTet(int thread) { return _perThread[thread]->newStuff(); } ~tetContainer() { - for(std::size_t i = 0; i < _perThread.size(); i++) - delete _perThread[i]; + for(std::size_t i = 0; i < _perThread.size(); i++) delete _perThread[i]; } }; @@ -402,9 +391,7 @@ void HilbertSortB::ComputeGrayCode(int n) mask = (n == 2) ? 3 : 7; // Generate the Gray code sequence. - for(i = 0; i < N; i++) { - gc[i] = i ^ (i >> 1); - } + for(i = 0; i < N; i++) { gc[i] = i ^ (i >> 1); } for(e = 0; e < N; e++) { for(d = 0; d < n; d++) { @@ -429,9 +416,7 @@ void HilbertSortB::ComputeGrayCode(int n) for(i = 1; i < N; i++) { v = ~i; // Count the 0s. v = (v ^ (v - 1)) >> 1; // Set v's trailing 0s to 1s and zero rest - for(c = 0; v; c++) { - v >>= 1; - } + for(c = 0; v; c++) { v >>= 1; } tsb1mod3[i] = c % n; } } @@ -451,9 +436,7 @@ int HilbertSortB::Split(Vert **vertices, int arraysize, int GrayCode0, axis = (GrayCode0 ^ GrayCode1) >> 1; // Calulate the split position along the axis. - if(axis == 0) { - split = 0.5 * (BoundingBoxXmin + BoundingBoxXmax); - } + if(axis == 0) { split = 0.5 * (BoundingBoxXmin + BoundingBoxXmax); } else if(axis == 1) { split = 0.5 * (BoundingBoxYmin + BoundingBoxYmax); } @@ -563,9 +546,7 @@ void HilbertSortB::Sort(Vert **vertices, int arraysize, int e, int d, // Recursively sort the points in sub-boxes. for(w = 0; w < 8; w++) { if((p[w + 1] - p[w]) > Limit) { - if(w == 0) { - e_w = 0; - } + if(w == 0) { e_w = 0; } else { k = 2 * ((w - 1) / 2); e_w = k ^ (k >> 1); @@ -573,9 +554,7 @@ void HilbertSortB::Sort(Vert **vertices, int arraysize, int e, int d, k = e_w; e_w = ((k << (d + 1)) & mask) | ((k >> (n - d - 1)) & mask); ei = e ^ e_w; - if(w == 0) { - d_w = 0; - } + if(w == 0) { d_w = 0; } else { d_w = ((w % 2) == 0) ? tsb1mod3[w - 1] : tsb1mod3[w]; } @@ -620,9 +599,7 @@ static void computeAdjacencies(Tet *t, int iFace, connContainer &faceToTet) { conn c(t->getFace(iFace), iFace, t); auto it = std::find(faceToTet.begin(), faceToTet.end(), c); - if(it == faceToTet.end()) { - faceToTet.push_back(c); - } + if(it == faceToTet.end()) { faceToTet.push_back(c); } else { t->T[iFace] = it->t; it->t->T[it->i] = t; @@ -654,9 +631,7 @@ static void starShapeness(Vert *v, connContainer &bndK, const double val = robustPredicates::orient3d( (double *)bndK[i].f.V[0], (double *)bndK[i].f.V[1], (double *)bndK[i].f.V[2], (double *)v); - if(val <= 0.0) { - _negatives.push_back(i); - } + if(val <= 0.0) { _negatives.push_back(i); } } } @@ -668,9 +643,7 @@ static Tet *tetContainsV(Vert *v, cavityContainer &cavity) Face f = cavity[i]->getFace(j); const double val = robustPredicates::orient3d( (double *)f.V[0], (double *)f.V[1], (double *)f.V[2], (double *)v); - if(val >= 0) { - count++; - } + if(val >= 0) { count++; } } if(count == 4) return cavity[i]; } @@ -685,11 +658,8 @@ static void buildDelaunayBall(cavityContainer &cavity, connContainer &faceToTet) for(std::size_t iFace = 0; iFace < 4; iFace++) { Tet *neigh = t->T[iFace]; conn c(t->getFace(iFace), iFace, neigh); - auto it = - std::find(faceToTet.begin(), faceToTet.end(), c); - if(it == faceToTet.end()) { - faceToTet.push_back(c); - } + auto it = std::find(faceToTet.begin(), faceToTet.end(), c); + if(it == faceToTet.end()) { faceToTet.push_back(c); } else { faceToTet.erase(it); } @@ -730,9 +700,7 @@ static Tet *tetInsideCavityWithFAce(Face &f, cavityContainer &cavity) for(std::size_t i = 0; i < cavity.size(); i++) { Tet *t = cavity[i]; for(std::size_t iFace = 0; iFace < 4; iFace++) { - if(t->getFace(iFace) == f) { - return t; - } + if(t->getFace(iFace) == f) { return t; } } } return nullptr; @@ -765,11 +733,8 @@ static bool fixDelaunayCavity(Vert *v, cavityContainer &cavity, conn &c = bndK[_negatives[i]]; Tet *toRemove = tetInsideCavityWithFAce(c.f, cavity); if(toRemove) { - auto it = - std::find(cavity.begin(), cavity.end(), toRemove); - if(it != cavity.end()) { - cavity.erase(it); - } + auto it = std::find(cavity.begin(), cavity.end(), toRemove); + if(it != cavity.end()) { cavity.erase(it); } else { Msg::Error("Datastructure Broken in %s line %5d", __FILE__, __LINE__); break; @@ -828,11 +793,10 @@ static void delaunayCavity2(Tet *tet, Tet *prevTet, Vert *v, } } - if(stack.empty()) { - finished = true; - } + if(stack.empty()) { finished = true; } else { - const std::pair<std::pair<Tet *, Tet *>, std::pair<int, int> > &next = stack.top(); + const std::pair<std::pair<Tet *, Tet *>, std::pair<int, int> > &next = + stack.top(); prev = next.first.first; t = next.first.second; iNeighStart = next.second.first; @@ -920,7 +884,8 @@ static void print(const char *name, int thread, tetContainer &T, Vert *v) Tet *tt = T(thread, i); if(tt->V[0]) { // double val = robustPredicates::orient3d - // ((double*)tt->V[0],(double*)tt->V[1],(double*)tt->V[2],(double*)tt->V[3]); + // +((double*)tt->V[0],(double*)tt->V[1],(double*)tt->V[2],(double*)tt->V[3]); if(!v) { fprintf(f, "SS(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g){%g,%g,%g,%g};\n", tt->V[0]->x(), tt->V[0]->y(), tt->V[0]->z(), tt->V[1]->x(), @@ -998,9 +963,9 @@ static Tet *randomTet(int thread, tetContainer &allocator) //#define VERBOSE -void delaunayTrgl(const std::size_t numThreads, - const std::size_t NPTS_AT_ONCE, std::size_t Npts, - std::vector<Vert *> assignTo[], tetContainer &allocator) +void delaunayTrgl(const std::size_t numThreads, const std::size_t NPTS_AT_ONCE, + std::size_t Npts, std::vector<Vert *> assignTo[], + tetContainer &allocator) { #if defined(VERBOSE) double totSearchGlob = 0; @@ -1042,9 +1007,10 @@ void delaunayTrgl(const std::size_t numThreads, invalidCavities[myThread] = 0; for(std::size_t K = 0; K < NPTS_AT_ONCE; K++) { - for(std::size_t iP = 0; iP < assignTo[K + myThread * NPTS_AT_ONCE].size(); iP++) { - if(numThreads != 1) - assignTo[K + myThread * NPTS_AT_ONCE][iP]->_thread = myThread; + for(std::size_t iP = 0; iP < assignTo[K + myThread * NPTS_AT_ONCE].size(); + iP++) { + if(numThreads != 1) + assignTo[K + myThread * NPTS_AT_ONCE][iP]->_thread = myThread; } } @@ -1056,7 +1022,6 @@ void delaunayTrgl(const std::size_t numThreads, // Main loop for(std::size_t iPGlob = 0; iPGlob < maxLocSizeK; iPGlob++) { - #if defined(_OPENMP) #pragma omp barrier #endif @@ -1064,8 +1029,9 @@ void delaunayTrgl(const std::size_t numThreads, // FIND SEEDS for(std::size_t K = 0; K < NPTS_AT_ONCE; K++) { - vToAdd[K] = (iPGlob < assignTo[K + myThread * NPTS_AT_ONCE].size()) ? - assignTo[K + myThread * NPTS_AT_ONCE][iPGlob] : nullptr; + vToAdd[K] = (iPGlob < assignTo[K + myThread * NPTS_AT_ONCE].size()) ? + assignTo[K + myThread * NPTS_AT_ONCE][iPGlob] : + nullptr; if(vToAdd[K]) { // In 3D, insertion of a point may lead to deletion of tets !! @@ -1173,7 +1139,6 @@ void delaunayTrgl(const std::size_t numThreads, for(std::size_t i = 0; i < bnd[K].size(); i++) if(bnd[K][i].t) bnd[K][i].t->unset(myThread, K); } - } if(invalidCavities[0]) Msg::Error("%d invalid cavities", invalidCavities[0]); @@ -1202,14 +1167,22 @@ static void initialCube(std::vector<Vert *> &v, Vert *box[8], bbox += SPoint3(pv->x(), pv->y(), pv->z()); } bbox *= 1.3; - box[0] = new Vert(bbox.min().x(), bbox.min().y(), bbox.min().z(), bbox.diag()); - box[1] = new Vert(bbox.max().x(), bbox.min().y(), bbox.min().z(), bbox.diag()); - box[2] = new Vert(bbox.max().x(), bbox.max().y(), bbox.min().z(), bbox.diag()); - box[3] = new Vert(bbox.min().x(), bbox.max().y(), bbox.min().z(), bbox.diag()); - box[4] = new Vert(bbox.min().x(), bbox.min().y(), bbox.max().z(), bbox.diag()); - box[5] = new Vert(bbox.max().x(), bbox.min().y(), bbox.max().z(), bbox.diag()); - box[6] = new Vert(bbox.max().x(), bbox.max().y(), bbox.max().z(), bbox.diag()); - box[7] = new Vert(bbox.min().x(), bbox.max().y(), bbox.max().z(), bbox.diag()); + box[0] = + new Vert(bbox.min().x(), bbox.min().y(), bbox.min().z(), bbox.diag()); + box[1] = + new Vert(bbox.max().x(), bbox.min().y(), bbox.min().z(), bbox.diag()); + box[2] = + new Vert(bbox.max().x(), bbox.max().y(), bbox.min().z(), bbox.diag()); + box[3] = + new Vert(bbox.min().x(), bbox.max().y(), bbox.min().z(), bbox.diag()); + box[4] = + new Vert(bbox.min().x(), bbox.min().y(), bbox.max().z(), bbox.diag()); + box[5] = + new Vert(bbox.max().x(), bbox.min().y(), bbox.max().z(), bbox.diag()); + box[6] = + new Vert(bbox.max().x(), bbox.max().y(), bbox.max().z(), bbox.diag()); + box[7] = + new Vert(bbox.min().x(), bbox.max().y(), bbox.max().z(), bbox.diag()); Tet *t0 = allocator.newTet(0); t0->setVertices(box[7], box[2], box[3], box[1]); @@ -1243,9 +1216,7 @@ static void delaunayTriangulation(const int numThreads, const int nptsatonce, std::vector<int> indices; SortHilbert(S, indices); - if(!allocator.size(0)) { - initialCube(S, box, allocator); - } + if(!allocator.size(0)) { initialCube(S, box, allocator); } int nbBlocks = nptsatonce * numThreads; @@ -1259,8 +1230,8 @@ static void delaunayTriangulation(const int numThreads, const int nptsatonce, int localCounter = 0; for(int jPt = start; jPt < end; jPt++) { if(localCounter++ >= sizePerBlock && currentBlock != nbBlocks - 1) { - localCounter = 0; - currentBlock++; + localCounter = 0; + currentBlock++; } assignTo[currentBlock].push_back(S[jPt]); } @@ -1272,8 +1243,7 @@ static void delaunayTriangulation(const int numThreads, const int nptsatonce, void delaunayTriangulation(const int numThreads, const int nptsatonce, std::vector<MVertex *> &S, - std::vector<MTetrahedron *> &T, - bool removeBox) + std::vector<MTetrahedron *> &T, bool removeBox) { std::vector<MVertex *> _temp; std::vector<Vert *> _vertices; @@ -1292,9 +1262,12 @@ void delaunayTriangulation(const int numThreads, const int nptsatonce, for(std::size_t i = 0; i < N; i++) { MVertex *mv = S[i]; - double dx = d * CTX::instance()->mesh.randFactor3d * (double)rand() / RAND_MAX; - double dy = d * CTX::instance()->mesh.randFactor3d * (double)rand() / RAND_MAX; - double dz = d * CTX::instance()->mesh.randFactor3d * (double)rand() / RAND_MAX; + double dx = + d * CTX::instance()->mesh.randFactor3d * (double)rand() / RAND_MAX; + double dy = + d * CTX::instance()->mesh.randFactor3d * (double)rand() / RAND_MAX; + double dz = + d * CTX::instance()->mesh.randFactor3d * (double)rand() / RAND_MAX; mv->x() += dx; mv->y() += dy; mv->z() += dz; @@ -1311,9 +1284,7 @@ void delaunayTriangulation(const int numThreads, const int nptsatonce, for(int i = 0; i < 8; i++) { Vert *v = box[i]; - if(removeBox) { - v->setNum(0); - } + if(removeBox) { v->setNum(0); } else { v->setNum(N + i + 1); MVertex *mv = new MVertex(v->x(), v->y(), v->z(), nullptr, N + (i + 1)); diff --git a/Mesh/filterElements.cpp b/Mesh/filterElements.cpp index fe9d6cd1f0330ba7694af25b28c403fe054e1995..5836767a51d1807c1caf389dee22ac3c3893b4f3 100644 --- a/Mesh/filterElements.cpp +++ b/Mesh/filterElements.cpp @@ -136,7 +136,7 @@ bool overlap2D(MElement *e1, MElement *e2) MEdge ed2 = e2->getEdge(j); if(intersectEdge2d(ed1, ed2)) { // printf("apero time nnodes %d %d partitions %d %d : %g %g -- %g %g - //vs %g %g -- %g %g\n", + // vs %g %g -- %g %g\n", // e1->getNumVertices(),e2->getNumVertices(), // e1->getPartition(),e2->getPartition(), // ed1.getVertex(0)->x(),ed1.getVertex(0)->y(),ed1.getVertex(1)->x(),ed1.getVertex(1)->y(), @@ -185,9 +185,7 @@ void filterColumns(std::vector<MElement *> &elem, { std::sort(elem.begin(), elem.end()); std::vector<MElement *> toKeep; - for(auto it = - _elemColumns.begin(); - it != _elemColumns.end(); ++it) { + for(auto it = _elemColumns.begin(); it != _elemColumns.end(); ++it) { const std::vector<MElement *> &c = it->second; std::size_t MAX = c.size(); // printf("size of column %d\n",c.size()); diff --git a/Mesh/gmshCrossFields.cpp b/Mesh/gmshCrossFields.cpp index 345170fb75d713ce8a33ed734950ea0468014ca4..573e2e639036b1eee05f2646b747ecf07f6f4ccb 100644 --- a/Mesh/gmshCrossFields.cpp +++ b/Mesh/gmshCrossFields.cpp @@ -224,8 +224,7 @@ public: } for(size_t i = 0; i < _neighbors.size(); i++) { - auto it = - C.find(_neighbors[i]); + auto it = C.find(_neighbors[i]); if(it == C.end()) Msg::Error("impossible situation"); else @@ -515,7 +514,7 @@ struct groupOfCross2d { side[i]->getVertex(2)->z(), groupId, groupId, groupId); } }; - groupOfCross2d(int id) : groupId(id){} + groupOfCross2d(int id) : groupId(id) {} }; static void unDuplicateNodesInCutGraph( @@ -526,8 +525,7 @@ static void unDuplicateNodesInCutGraph( for(size_t j = 0; j < f[i]->triangles.size(); j++) { MTriangle *t = f[i]->triangles[j]; for(size_t k = 0; k < 3; k++) { - auto it = - new2old.find(t->getVertex(k)); + auto it = new2old.find(t->getVertex(k)); if(it != new2old.end()) t->setVertex(k, it->second); } } @@ -568,8 +566,7 @@ static void duplicateNodesInCutGraph( auto it0 = C.find(e0); if(!it0->second.inCutGraph) { for(size_t j = 0; j < it0->second._t.size(); j++) { - auto ite = - std::find(els.begin(), els.end(), it0->second._t[j]); + auto ite = std::find(els.begin(), els.end(), it0->second._t[j]); if(ite != els.end()) { els.erase(ite); _side.push_back(it0->second._t[j]); @@ -779,7 +776,6 @@ static void assembleLagrangeMultipliers(dofManager<double> &myAssembler, // g.mat[1][1]=-1; // } - // printf("GROUP %d\n",g.groupId); // printf("LEFT --- RIGHT\n"); // printf("%3lu %3lu\n",g.left[0]->getNum(),g.right[0]->getNum()); @@ -827,12 +823,10 @@ static void assembleLagrangeMultipliers(dofManager<double> &myAssembler, // TEST NO JUMP ON U for group 3 ... if(g.groupId == ZERO_) { - Dof E1(g.left[0]->getNum(), - Dof::createTypeWithTwoInts(0, 3 + 10000 * g.groupId)); + Dof::createTypeWithTwoInts(0, 3 + 10000 * g.groupId)); Dof U1(g.left[0]->getNum(), Dof::createTypeWithTwoInts(0, 2)); Dof U2(g.right[0]->getNum(), Dof::createTypeWithTwoInts(0, 1)); - } for(size_t K = 1; K < g.left.size(); K++) { @@ -893,12 +887,10 @@ LagrangeMultipliers2(dofManager<double> &myAssembler, int NUMDOF, for(size_t i = 0; i < groups.size(); i++) { size_t N = groups[i].size(); MEdge ed = groups[i][0]->_e; - auto ite = - duplicateEdges.find(ed); + auto ite = duplicateEdges.find(ed); if(ite != duplicateEdges.end()) ed = ite->second; MVertex *v = ed.getVertex(0); - auto it = - C.find(groups[i][0]->_e); + auto it = C.find(groups[i][0]->_e); SVector3 aaa = lift[it->second._t[0]]; double S = fabs(dot(it->second._tgt, aaa)); @@ -935,52 +927,49 @@ struct cutGraphPassage { int _id; int _uv; SPoint3 _p; - cutGraphPassage (int id, int uv, const SPoint3 &p) : _id(id), _uv(uv), _p(p){ - } + cutGraphPassage(int id, int uv, const SPoint3 &p) : _id(id), _uv(uv), _p(p) {} }; - static void createDofs(dofManager<double> &myAssembler, int NUMDOF, std::set<MVertex *, MVertexPtrLessThan> &vs) { - for(auto it = vs.begin(); - it != vs.end(); ++it) + for(auto it = vs.begin(); it != vs.end(); ++it) myAssembler.numberVertex(*it, 0, NUMDOF); } -void createExtraConnexions (dofManager<double> &myAssembler, - std::vector<groupOfCross2d> &G, - std::vector<cutGraphPassage> &passages){ +void createExtraConnexions(dofManager<double> &myAssembler, + std::vector<groupOfCross2d> &G, + std::vector<cutGraphPassage> &passages) +{ return; // give a number to the equation ... - myAssembler.numberVertex(G[0].left[0], 0, 10201020 ); + myAssembler.numberVertex(G[0].left[0], 0, 10201020); } -void assembleExtraConnexions (dofManager<double> &myAssembler, - std::vector<groupOfCross2d> &G, - std::vector<cutGraphPassage> &passages){ +void assembleExtraConnexions(dofManager<double> &myAssembler, + std::vector<groupOfCross2d> &G, + std::vector<cutGraphPassage> &passages) +{ int nConn = 2; - int groups [2][2] = {{14,1}, - {13,2}}; + int groups[2][2] = {{14, 1}, {13, 2}}; Dof E(G[0].left[0]->getNum(), Dof::createTypeWithTwoInts(0, 10201020)); - for (int i=0 ; i < nConn ; i++){ + for(int i = 0; i < nConn; i++) { groupOfCross2d &g = G[groups[i][0]]; int index = groups[i][1]; Dof U1(g.left[0]->getNum(), Dof::createTypeWithTwoInts(0, index)); Dof U2(g.right[0]->getNum(), Dof::createTypeWithTwoInts(0, 1)); Dof V2(g.right[0]->getNum(), Dof::createTypeWithTwoInts(0, 2)); myAssembler.assemble(E, U1, 1.0); - myAssembler.assemble(E, U2, -g.mat[index-1][0]); - myAssembler.assemble(E, V2, -g.mat[index-1][1]); + myAssembler.assemble(E, U2, -g.mat[index - 1][0]); + myAssembler.assemble(E, V2, -g.mat[index - 1][1]); myAssembler.assemble(U1, E, 1.0); - myAssembler.assemble(U2, E, -g.mat[index-1][0]); - myAssembler.assemble(V2, E, -g.mat[index-1][1]); + myAssembler.assemble(U2, E, -g.mat[index - 1][0]); + myAssembler.assemble(V2, E, -g.mat[index - 1][1]); } } - static void computePotential( GModel *gm, std::vector<GFace *> &f, dofManager<double> &dof, std::map<MEdge, cross2d, MEdgeLessThan> &C, @@ -989,8 +978,7 @@ static void computePotential( std::map<MEdge, MEdge, MEdgeLessThan> &duplicateEdges, std::map<MTriangle *, SVector3> &lift, std::map<MTriangle *, SVector3> &lift2, std::vector<groupOfCross2d> &G, std::map<MVertex *, double> &res, - std::map<MVertex *, double> &res2, - std::vector<cutGraphPassage> &passages) + std::map<MVertex *, double> &res2, std::vector<cutGraphPassage> &passages) { double a[3]; std::set<MVertex *, MVertexPtrLessThan> vs; @@ -1020,7 +1008,7 @@ static void computePotential( LagrangeMultipliers2(myAssembler, 1, C, groups, duplicateEdges, false, lift); LagrangeMultipliers2(myAssembler, 2, C, groups, duplicateEdges, false, lift2); - createExtraConnexions (myAssembler, G, passages); + createExtraConnexions(myAssembler, G, passages); for(size_t i = 0; i < G.size(); i++) { createLagrangeMultipliers(myAssembler, G[i]); @@ -1034,8 +1022,7 @@ static void computePotential( LagrangeMultipliers3(myAssembler, G[i], lift, true); } - assembleExtraConnexions (myAssembler, G, passages); - + assembleExtraConnexions(myAssembler, G, passages); simpleFunction<double> ONE(1.0); laplaceTerm l(nullptr, 1, &ONE); @@ -1050,8 +1037,7 @@ static void computePotential( SVector3 a0 = lift[t]; SVector3 a1 = lift2[t]; double va, vb, vc; - auto itx = - new2old.find(t->getVertex(0)); + auto itx = new2old.find(t->getVertex(0)); dof.getDofValue(itx == new2old.end() ? t->getVertex(0) : itx->second, 0, 1, va); itx = new2old.find(t->getVertex(1)); @@ -1158,8 +1144,7 @@ static double distance(MTriangle *t, // return drand48(); SPoint3 p = t->barycenter(); double dmin = 1.e22; - for(auto it = boundaries.begin(); - it != boundaries.end(); ++it) { + for(auto it = boundaries.begin(); it != boundaries.end(); ++it) { SPoint3 pp((*it)->x(), (*it)->y(), (*it)->z()); double d = p.distance(pp); if(d < dmin) { dmin = d; } @@ -1308,8 +1293,7 @@ computeSingularities(std::map<MEdge, cross2d, MEdgeLessThan> &C, FILE *f_ = fopen("sing.pos", "w"); fprintf(f_, "View \"S\"{\n"); std::multimap<MVertex *, cross2d *, MVertexPtrLessThan> conn; - for(auto it = C.begin(); - it != C.end(); ++it) { + for(auto it = C.begin(); it != C.end(); ++it) { std::pair<MVertex *, cross2d *> p = std::make_pair(it->first.getVertex(0), &it->second); conn.insert(p); @@ -1318,9 +1302,7 @@ computeSingularities(std::map<MEdge, cross2d, MEdgeLessThan> &C, } MVertex *v = nullptr; std::vector<cross2d *> adj; - for(auto it = - conn.begin(); - it != conn.end(); ++it) { + for(auto it = conn.begin(); it != conn.end(); ++it) { if(it->first == v) { adj.push_back(it->second); } else { double MAX; @@ -1345,8 +1327,6 @@ computeSingularities(std::map<MEdge, cross2d, MEdgeLessThan> &C, fclose(f_); } - - static void cutGraph(std::map<MEdge, cross2d, MEdgeLessThan> &C, std::set<MEdge, MEdgeLessThan> &cutG, std::set<MVertex *, MVertexPtrLessThan> &singularities, @@ -1401,8 +1381,7 @@ static void cutGraph(std::map<MEdge, cross2d, MEdgeLessThan> &C, for(; it != C.end(); ++it) { if(!std::binary_search(tree.begin(), tree.end(), &it->second)) { for(int i = 0; i < 2; i++) { - auto - it0 = _graph.find(it->first.getVertex(i)); + auto it0 = _graph.find(it->first.getVertex(i)); if(it0 == _graph.end()) { std::vector<MEdge> ee; ee.push_back(it->first); @@ -1441,8 +1420,7 @@ static void cutGraph(std::map<MEdge, cross2d, MEdgeLessThan> &C, if(boundaries.find(it->first) == boundaries.end() && singularities.find(it->first) == singularities.end()) { somethingDone = true; - auto - it2 = _graph.find(v1 == it->first ? v2 : v1); + auto it2 = _graph.find(v1 == it->first ? v2 : v1); auto position = std::find(it2->second.begin(), it2->second.end(), it->second[0]); it2->second.erase(position); @@ -1453,8 +1431,6 @@ static void cutGraph(std::map<MEdge, cross2d, MEdgeLessThan> &C, if(!somethingDone) break; } - - FILE *fff = fopen("cotree.pos", "w"); fprintf(fff, "View \"sides\"{\n"); { @@ -1508,8 +1484,7 @@ groupBoundaries(GModel *gm, std::map<MEdge, cross2d, MEdgeLessThan> &C, { std::set<MVertex *, MVertexPtrLessThan> cutgraph; std::set<MVertex *, MVertexPtrLessThan> boundaries; - for(auto it = C.begin(); - it != C.end(); ++it) { + for(auto it = C.begin(); it != C.end(); ++it) { MVertex *v0 = it->first.getVertex(0); MVertex *v1 = it->first.getVertex(1); if(it->second.inBoundary) { @@ -1525,8 +1500,7 @@ groupBoundaries(GModel *gm, std::map<MEdge, cross2d, MEdgeLessThan> &C, std::set<cross2d *> _all; std::multimap<MVertex *, cross2d *> conn; - for(auto it = C.begin(); - it != C.end(); ++it) { + for(auto it = C.begin(); it != C.end(); ++it) { std::pair<MVertex *, cross2d *> p = std::make_pair(it->first.getVertex(0), &it->second); conn.insert(p); @@ -1534,13 +1508,11 @@ groupBoundaries(GModel *gm, std::map<MEdge, cross2d, MEdgeLessThan> &C, conn.insert(p); } - for(auto it = boundaries.begin(); - it != boundaries.end(); ++it) { + for(auto it = boundaries.begin(); it != boundaries.end(); ++it) { MVertex *v = *it; std::vector<cross2d *> bnd; int countCutGraph = 0; - for(auto it2 = conn.lower_bound(v); - it2 != conn.upper_bound(v); ++it2) { + for(auto it2 = conn.lower_bound(v); it2 != conn.upper_bound(v); ++it2) { if(it2->second->inBoundary) { bnd.push_back(it2->second); } if(it2->second->inCutGraph) { countCutGraph++; } } @@ -1549,9 +1521,7 @@ groupBoundaries(GModel *gm, std::map<MEdge, cross2d, MEdgeLessThan> &C, corners.insert(v); cutgraph.insert(v); } - if(countCutGraph == 1) { - singularities.insert(v); - } + if(countCutGraph == 1) { singularities.insert(v); } } if(bnd.size() > 2) { cutgraph.insert(v); } } @@ -1565,11 +1535,9 @@ groupBoundaries(GModel *gm, std::map<MEdge, cross2d, MEdgeLessThan> &C, std::set<MVertex *, MVertexPtrLessThan> endPoints = singularities; { - for(auto it = conn.begin(); - it != conn.end(); ++it) { + for(auto it = conn.begin(); it != conn.end(); ++it) { int count = 0; - for(auto it2 = - conn.lower_bound(it->first); + for(auto it2 = conn.lower_bound(it->first); it2 != conn.upper_bound(it->first); ++it2) { if(it2->second->inCutGraph) { count++; } } @@ -1579,16 +1547,13 @@ groupBoundaries(GModel *gm, std::map<MEdge, cross2d, MEdgeLessThan> &C, for(int AA = 0; AA < 4; AA++) { if(cutGraph) { - for(auto it = - endPoints.begin(); - it != endPoints.end(); ++it) { + for(auto it = endPoints.begin(); it != endPoints.end(); ++it) { MVertex *v = *it; std::vector<cross2d *> group; do { MVertex *vnew = nullptr; - for(auto it2 = - conn.lower_bound(v); - it2 != conn.upper_bound(v); ++it2) { + for(auto it2 = conn.lower_bound(v); it2 != conn.upper_bound(v); + ++it2) { if((_all.find(it2->second) == _all.end()) && (group.empty() || group[group.size() - 1] != it2->second) && it2->second->inCutGraph) { @@ -1618,20 +1583,18 @@ groupBoundaries(GModel *gm, std::map<MEdge, cross2d, MEdgeLessThan> &C, } } else { - for(auto it = - boundaries.begin(); - it != boundaries.end(); ++it) { + for(auto it = boundaries.begin(); it != boundaries.end(); ++it) { MVertex *v = *it; if(cutgraph.find(v) != cutgraph.end() || singularities.find(v) != singularities.end()) { // printf("START POINT %lu %d %d\n",v->getNum(),cutgraph.find(v) - //!= cutgraph.end() , singularities.find(v) != singularities.end()); + //!= cutgraph.end() , singularities.find(v) != + //!singularities.end()); std::vector<cross2d *> group; do { MVertex *vnew = nullptr; - for(auto it2 = - conn.lower_bound(v); - it2 != conn.upper_bound(v); ++it2) { + for(auto it2 = conn.lower_bound(v); it2 != conn.upper_bound(v); + ++it2) { if((_all.find(it2->second) == _all.end()) && (group.empty() || group[group.size() - 1] != it2->second) && (it2->second->inBoundary)) { @@ -1781,8 +1744,7 @@ static dofManager<double> *computeH(GModel *gm, std::vector<GFace *> &f, dofManager<double> *myAssembler = new dofManager<double>(_lsys); // myAssembler.fixVertex(*vs.begin(), 0, 1, 0); - for(auto it = vs.begin(); - it != vs.end(); ++it) + for(auto it = vs.begin(); it != vs.end(); ++it) myAssembler->numberVertex(*it, 0, 1); std::string ss = gm->getName(); @@ -2014,9 +1976,10 @@ static void computeOneIsoRecur( SPoint3 &p, std::map<MVertex *, double> &pot, std::map<MEdge, int, MEdgeLessThan> &visited, std::map<MEdge, std::pair<std::map<MVertex *, double> *, double>, - MEdgeLessThan> &cutGraphEnds, + MEdgeLessThan> &cutGraphEnds, std::map<MEdge, MEdge, MEdgeLessThan> &d1, std::vector<groupOfCross2d> &G, - FILE *f, int COUNT, std::map<MEdge, edgeCuts, MEdgeLessThan> &cuts, int &NB, int &circular) + FILE *f, int COUNT, std::map<MEdge, edgeCuts, MEdgeLessThan> &cuts, int &NB, + int &circular) { MEdge e(v0, v1); @@ -2024,7 +1987,7 @@ static void computeOneIsoRecur( if(distance(&vvv, vsing) < 1.e-10) { circular++; - return ; + return; } bool added = addCut(p, e, COUNT, NB, cuts); @@ -2073,7 +2036,7 @@ static void computeOneIsoRecur( fprintf(f, "SL(%g,%g,%g,%g,%g,%g){%d,%d};\n", p.x(), p.y(), p.z(), pp.x(), pp.y(), pp.z(), COUNT, COUNT); computeOneIsoRecur(vsing, adj, VAL, v0, vs[i], pp, pot, visited, - cutGraphEnds, d1, G, f, COUNT, cuts, NB, circular); + cutGraphEnds, d1, G, f, COUNT, cuts, NB, circular); } else if((U[1] - VAL) * (U2 - VAL) <= 0) { double xi = coord1d(U[1], U2, VAL); @@ -2081,7 +2044,7 @@ static void computeOneIsoRecur( fprintf(f, "SL(%g,%g,%g,%g,%g,%g){%d,%d};\n", p.x(), p.y(), p.z(), pp.x(), pp.y(), pp.z(), COUNT, COUNT); computeOneIsoRecur(vsing, adj, VAL, v1, vs[i], pp, pot, visited, - cutGraphEnds, d1, G, f, COUNT, cuts, NB, circular); + cutGraphEnds, d1, G, f, COUNT, cuts, NB, circular); } else { printf("strange\n"); @@ -2091,14 +2054,14 @@ static void computeOneIsoRecur( return; } -static int computeOneIso(MVertex *vsing, v2t_cont &adj, double VAL, - MVertex *v0, MVertex *v1, SPoint3 &p, - std::map<MVertex *, double> *potU, - std::map<MVertex *, double> *potV, - std::map<MEdge, MEdge, MEdgeLessThan> &d1, - std::vector<groupOfCross2d> &G, FILE *f, int COUNT, - std::map<MEdge, edgeCuts, MEdgeLessThan> &cuts, - std::vector<cutGraphPassage> & passages) +static int computeOneIso(MVertex *vsing, v2t_cont &adj, double VAL, MVertex *v0, + MVertex *v1, SPoint3 &p, + std::map<MVertex *, double> *potU, + std::map<MVertex *, double> *potV, + std::map<MEdge, MEdge, MEdgeLessThan> &d1, + std::vector<groupOfCross2d> &G, FILE *f, int COUNT, + std::map<MEdge, edgeCuts, MEdgeLessThan> &cuts, + std::vector<cutGraphPassage> &passages) { std::map<MEdge, int, MEdgeLessThan> visited; std::map<MEdge, std::pair<std::map<MVertex *, double> *, double>, @@ -2108,8 +2071,7 @@ static int computeOneIso(MVertex *vsing, v2t_cont &adj, double VAL, int circular = 0; computeOneIsoRecur(vsing, adj, VAL, v0, v1, p, *potU, visited, cutGraphEnds, - d1, G, f, COUNT, cuts, NB, circular); - + d1, G, f, COUNT, cuts, NB, circular); int XX = 1; passages.clear(); @@ -2168,29 +2130,30 @@ static int computeOneIso(MVertex *vsing, v2t_cont &adj, double VAL, if(count > maxCount) { maxCount = count; ROT = fabs(G[i].mat[0][0]) > .6 ? 0 : 1; - cutGraphId = i; + cutGraphId = i; } } if(maxCount == 0) printf("IMPOSSIBLE\n"); int pot = POT == potU ? 0 : 1; - // printf(" --> cutting cut graph %5d %5d\n",cutGraphId, pot,passages.size()); + // printf(" --> cutting cut graph %5d %5d\n",cutGraphId, + // pot,passages.size()); int count = 0; - for (std::size_t k=0;k<passages.size();k++){ - if (pot == passages[k]._uv && cutGraphId == passages[k]._id)count++; + for(std::size_t k = 0; k < passages.size(); k++) { + if(pot == passages[k]._uv && cutGraphId == passages[k]._id) count++; } - if (count > 20){ - printf("CYCLE DETECTED for SING %lu : ",vsing->getNum()); - for (size_t k=0;k<passages.size();k++)printf("(%d,%d) ",passages[k]._id,passages[k]._uv); + if(count > 20) { + printf("CYCLE DETECTED for SING %lu : ", vsing->getNum()); + for(size_t k = 0; k < passages.size(); k++) + printf("(%d,%d) ", passages[k]._id, passages[k]._uv); printf("\n"); return -1; } - if (passages.empty() || - passages[passages.size()-1]._uv != pot || - passages[passages.size()-1]._id != cutGraphId){ - passages.push_back(cutGraphPassage(cutGraphId,pot,p)); + if(passages.empty() || passages[passages.size() - 1]._uv != pot || + passages[passages.size() - 1]._id != cutGraphId) { + passages.push_back(cutGraphPassage(cutGraphId, pot, p)); } if(ROT) { POT = (POT == potU ? potV : potU); } @@ -2203,7 +2166,8 @@ static int computeOneIso(MVertex *vsing, v2t_cont &adj, double VAL, else VAL = (1. - xi) * (*POT)[o.getVertex(1)] + xi * (*POT)[o.getVertex(0)]; computeOneIsoRecur(vsing, adj, VAL, o.getVertex(0), o.getVertex(1), p, *POT, - visited, cutGraphEnds, d1, G, f, COUNT, cuts, NB, circular); + visited, cutGraphEnds, d1, G, f, COUNT, cuts, NB, + circular); if(XX > 1200) break; } return circular; @@ -2215,7 +2179,7 @@ static bool computeIso(MVertex *vsing, v2t_cont &adj, double u, std::map<MEdge, MEdge, MEdgeLessThan> &d1, std::vector<groupOfCross2d> &G, int DIR, std::map<MEdge, edgeCuts, MEdgeLessThan> &cuts, - std::vector<cutGraphPassage> &passages) + std::vector<cutGraphPassage> &passages) { int COUNT = 100 * vsing->getNum() + 10 * DIR; std::vector<MElement *> faces = adj[vsing]; @@ -2233,24 +2197,24 @@ static bool computeIso(MVertex *vsing, v2t_cont &adj, double u, if(v2 == vsing && (U0 - u) * (U1 - u) <= 0) { double xi = coord1d(U0, U1, u); SPoint3 pp = p0 * (1 - xi) + p1 * xi; - circular = computeOneIso(vsing, adj, u, v0, v1, pp, &potU, &potV, d1, G, f, COUNT++, - cuts, passages); + circular = computeOneIso(vsing, adj, u, v0, v1, pp, &potU, &potV, d1, G, + f, COUNT++, cuts, passages); } else if(v1 == vsing && (U0 - u) * (U2 - u) <= 0) { double xi = coord1d(U0, U2, u); SPoint3 pp = p0 * (1 - xi) + p2 * xi; - circular =computeOneIso(vsing, adj, u, v0, v2, pp, &potU, &potV, d1, G, f, COUNT++, - cuts, passages); + circular = computeOneIso(vsing, adj, u, v0, v2, pp, &potU, &potV, d1, G, + f, COUNT++, cuts, passages); } else if(v0 == vsing && (U1 - u) * (U2 - u) <= 0) { double xi = coord1d(U1, U2, u); SPoint3 pp = p1 * (1 - xi) + p2 * xi; - circular = computeOneIso(vsing, adj, u, v1, v2, pp, &potU, &potV, d1, G, f, COUNT++, - cuts, passages); + circular = computeOneIso(vsing, adj, u, v1, v2, pp, &potU, &potV, d1, G, + f, COUNT++, cuts, passages); } - if (circular == 2) printf("ISO %d is circular %d\n",COUNT-1, circular); - if (circular == -1) { - printf("ISO %d is CYCLIC\n",COUNT-1); + if(circular == 2) printf("ISO %d is circular %d\n", COUNT - 1, circular); + if(circular == -1) { + printf("ISO %d is CYCLIC\n", COUNT - 1); return false; } } @@ -2276,8 +2240,7 @@ static bool computeIsos( } { - auto it = - new2old.begin(); + auto it = new2old.begin(); for(; it != new2old.end(); ++it) { if(singularities.find(it->second) != singularities.end()) { singularities.insert(it->first); @@ -2287,8 +2250,7 @@ static bool computeIsos( std::map<MVertex *, MVertex *, MVertexPtrLessThan> duplicates; { - auto it = - new2old.begin(); + auto it = new2old.begin(); for(; it != new2old.end(); ++it) { duplicates[it->first] = it->second; duplicates[it->second] = it->first; @@ -2331,17 +2293,19 @@ static bool computeIsos( for(; it != singularities.end(); ++it) { GEntity *ge = (*it)->onWhat(); if(ge->dim() == 2 || ge->edges().size() == 0) { - printf("%lu %d %d %lu %22.15E %22.15E\n",ge->edges().size(),ge->tag(), - ge->dim(),singularities.size(),potU[*it],potV[*it]); - bool success = computeIso(*it, adj, potU[*it], potU, potV, f, d1, G, 0, cuts, passages); - if (!success) { - printf("CYCLIC STUFF\n"); - // return false; + printf("%lu %d %d %lu %22.15E %22.15E\n", ge->edges().size(), ge->tag(), + ge->dim(), singularities.size(), potU[*it], potV[*it]); + bool success = computeIso(*it, adj, potU[*it], potU, potV, f, d1, G, 0, + cuts, passages); + if(!success) { + printf("CYCLIC STUFF\n"); + // return false; } - success = computeIso(*it, adj, potV[*it], potV, potU, f, d1, G, 1, cuts, passages); - if (!success) { - printf("CYCLIC STUFF\n"); - // return false; + success = computeIso(*it, adj, potV[*it], potV, potU, f, d1, G, 1, cuts, + passages); + if(!success) { + printf("CYCLIC STUFF\n"); + // return false; } } } @@ -2483,9 +2447,8 @@ static void createJumpyPairs( else Msg::Error("error in JumpyPairs 1"); } - for(auto it = - old2new.lower_bound(vv); - it != old2new.upper_bound(vv); ++it) { + for(auto it = old2new.lower_bound(vv); it != old2new.upper_bound(vv); + ++it) { MVertex *vvv = it->second; if(t1->getVertex(0) == vvv || t1->getVertex(1) == vvv || t1->getVertex(2) == vvv) { @@ -2626,12 +2589,9 @@ public: for(size_t i = 0; i < f.size(); i++) { for(size_t j = 0; j < f[i]->triangles.size(); j++) { MTriangle *t = f[i]->triangles[j]; - auto it0 = - C.find(t->getEdge(0)); - auto it1 = - C.find(t->getEdge(1)); - auto it2 = - C.find(t->getEdge(2)); + auto it0 = C.find(t->getEdge(0)); + auto it1 = C.find(t->getEdge(1)); + auto it2 = C.find(t->getEdge(2)); SVector3 d0 = it0->second.o_i; SVector3 d1 = it1->second.o_i; @@ -2783,8 +2743,7 @@ public: // AVERAGE dof->numberVertex(*vs.begin(), 1, 1); - for(auto it = vs.begin(); - it != vs.end(); ++it){ + for(auto it = vs.begin(); it != vs.end(); ++it) { dof->numberVertex(*it, 0, 1); } @@ -2824,7 +2783,7 @@ public: SVector3 xx = crossprod(vv, ww); double ccos = dot(vv, ww); double ANGLE = atan2(xx.norm(), ccos); - xx.normalize(); + xx.normalize(); MEdge edze(vi, vim); auto itip = C.find(edze); @@ -2843,15 +2802,15 @@ public: SVector3 aa(vrv->x() - vim->x(), vrv->y() - vim->y(), vrv->z() - vim->z()); SVector3 zz = crossprod(aa, ww); - zz.normalize(); - sign = -dot(zz, xx);// > 0 ? -1 : 1; - //sign = dot(zz, xx) > 0 ? -1 : 1; + zz.normalize(); + sign = -dot(zz, xx); // > 0 ? -1 : 1; + // sign = dot(zz, xx) > 0 ? -1 : 1; } else printf("ARGH\n"); - // if (vsorted.size() == 1)sign = -1; + // if (vsorted.size() == 1)sign = -1; CURVATURE[i] += ANGLE * sign; - //printf("%12.5E\n",sign); + // printf("%12.5E\n",sign); } for(size_t i = 0; i < vsorted[j].size(); ++i) { SUM += CURVATURE[i]; } @@ -2859,18 +2818,18 @@ public: // printf("%22.15E %22.15E\n",SUM, CORR ); for(size_t i = 0; i < vsorted[j].size(); ++i) { Dof E(vsorted[j][i]->getNum(), Dof::createTypeWithTwoInts(0, 1)); - _lsys->addToRightHandSide(dof->getDofNumber(E),CURVATURE[i]); + _lsys->addToRightHandSide(dof->getDofNumber(E), CURVATURE[i]); } } - for(auto it = gaussianCurvatures.begin();it != gaussianCurvatures.end(); ++it){ + for(auto it = gaussianCurvatures.begin(); it != gaussianCurvatures.end(); + ++it) { Dof E(it->first->getNum(), Dof::createTypeWithTwoInts(0, 1)); //_lsys->addToRightHandSide(dof->getDofNumber(E),-it->second); } double SSUM = 0; - for(auto it = sing.begin(); it != sing.end(); - ++it) { + for(auto it = sing.begin(); it != sing.end(); ++it) { Dof E(it->first->getNum(), Dof::createTypeWithTwoInts(0, 1)); _lsys->addToRightHandSide(dof->getDofNumber(E), 2.0 * M_PI * (double)it->second / nbTurns); @@ -2881,14 +2840,12 @@ public: // AVERAGE Dof EAVG((*vs.begin())->getNum(), Dof::createTypeWithTwoInts(1, 1)); - for(auto it = vs.begin(); - it != vs.end(); ++it){ + for(auto it = vs.begin(); it != vs.end(); ++it) { Dof E((*it)->getNum(), Dof::createTypeWithTwoInts(0, 1)); dof->assemble(EAVG, E, 1); dof->assemble(E, EAVG, 1); } - _lsys->systemSolve(); return dof; } @@ -2896,8 +2853,7 @@ public: int computeHFromSingularities(std::map<MVertex *, int> &s) { myAssembler = computeHFromSingularities(s, 4); - for(auto it = s.begin(); it != s.end(); - ++it) { + for(auto it = s.begin(); it != s.end(); ++it) { singularities.insert(it->first); } // printScalar(myAssembler, 'H'); @@ -2968,8 +2924,7 @@ public: double H[3]; for(int k = 0; k < 3; k++) { - auto itk = - new2old.find(t->getVertex(k)); + auto itk = new2old.find(t->getVertex(k)); if(itk == new2old.end()) myAssembler->getDofValue(t->getVertex(k), 0, 1, H[k]); else @@ -3001,7 +2956,7 @@ public: _lsys->getFromRightHandSide(i, a); SUM += a; } - printf("SUM = %12.5E\n",SUM); + printf("SUM = %12.5E\n", SUM); SUM /= aaa.size(); for(size_t i = 0; i < aaa.size(); i++) { // _lsys->addToRightHandSide(i, -SUM); @@ -3019,8 +2974,7 @@ public: double t; theta->getDofValue(d, t); MVertex *v0, *v1; - auto it0 = - new2old.find(it->first.getVertex(0)); + auto it0 = new2old.find(it->first.getVertex(0)); if(it0 == new2old.end()) v0 = it->first.getVertex(0); else @@ -3112,17 +3066,21 @@ public: MEdge e1 = t->getEdge((k + 1) % 3); MEdge e2 = t->getEdge((k + 2) % 3); - // Gaussian Curvatures - MVertex *vk = t->getVertex(k); - MVertex *vk1 = t->getVertex((k + 1) % 3); - MVertex *vk2 = t->getVertex((k + 2) % 3); - SVector3 v1 (vk1->x()-vk->x(),vk1->y()-vk->y(),vk1->z()-vk->z()); - SVector3 v2 (vk2->x()-vk->x(),vk2->y()-vk->y(),vk2->z()-vk->z()); - double CURV = angle(v1,v2); - auto itg = gaussianCurvatures.find(vk); - if (itg == gaussianCurvatures.end()) gaussianCurvatures[vk] = 2*M_PI - CURV; - else itg->second -= CURV; - //--------------------------------------------------------------------- + // Gaussian Curvatures + MVertex *vk = t->getVertex(k); + MVertex *vk1 = t->getVertex((k + 1) % 3); + MVertex *vk2 = t->getVertex((k + 2) % 3); + SVector3 v1(vk1->x() - vk->x(), vk1->y() - vk->y(), + vk1->z() - vk->z()); + SVector3 v2(vk2->x() - vk->x(), vk2->y() - vk->y(), + vk2->z() - vk->z()); + double CURV = angle(v1, v2); + auto itg = gaussianCurvatures.find(vk); + if(itg == gaussianCurvatures.end()) + gaussianCurvatures[vk] = 2 * M_PI - CURV; + else + itg->second -= CURV; + //--------------------------------------------------------------------- cross2d c(e, t, e1, e2); auto it = C.find(e); @@ -3153,15 +3111,17 @@ public: for(; it != C.end(); ++it) it->second.finish(C); it = C.begin(); for(; it != C.end(); ++it) it->second.finish2(); - FILE *F = fopen("gc.pos","w"); - fprintf(F,"View\"\"{\n"); + FILE *F = fopen("gc.pos", "w"); + fprintf(F, "View\"\"{\n"); double dd = 0; - for (auto it = gaussianCurvatures.begin(); it != gaussianCurvatures.end() ; ++it){ - fprintf(F,"SP(%g,%g,%g){%g};\n",it->first->x(),it->first->y(),it->first->z(),it->second); + for(auto it = gaussianCurvatures.begin(); it != gaussianCurvatures.end(); + ++it) { + fprintf(F, "SP(%g,%g,%g){%g};\n", it->first->x(), it->first->y(), + it->first->z(), it->second); dd += it->second; } - printf("%22.15E %22.15E\n",dd,dd-4*M_PI); - fprintf(F,"};\n"); + printf("%22.15E %22.15E\n", dd, dd - 4 * M_PI); + fprintf(F, "};\n"); fclose(F); } @@ -3225,9 +3185,7 @@ public: std::set<MVertex *, MVertexPtrLessThan> isolated_singularities; { - for(auto it = - singularities.begin(); - it != singularities.end(); ++it) { + for(auto it = singularities.begin(); it != singularities.end(); ++it) { int count = 0; for(size_t i = 0; i < groups_cg.size(); i++) { for(size_t k = 0; k < groups_cg[i].size(); k++) { @@ -3489,8 +3447,7 @@ public: // if (*iti != 313310)continue; GEdge *ge = gm->getEdgeByTag(*iti); if(tcuts.count(*iti) == 1) { - auto itt = - tcuts.lower_bound(*iti); + auto itt = tcuts.lower_bound(*iti); MVertex *v0 = itt->second.first; int k = itt->second.second.first; cutTriangles(ttt, f[i], v0, @@ -3498,16 +3455,14 @@ public: *iti, F); } else if(tcuts.count(*iti) == 2) { - auto itt = - tcuts.lower_bound(*iti); + auto itt = tcuts.lower_bound(*iti); MVertex *v0 = itt->second.first; ++itt; MVertex *v1 = itt->second.first; cutTriangles(ttt, f[i], v0, v1, ge, ecuts, *iti, F); } else if(tcuts.count(*iti) == 3) { - auto itt = - tcuts.lower_bound(*iti); + auto itt = tcuts.lower_bound(*iti); int k0 = itt->second.second.first; int id0 = itt->second.second.second; MVertex *v0 = itt->second.first; @@ -3547,8 +3502,7 @@ public: } } else if(tcuts.count(*iti) == 4) { - auto itt = - tcuts.lower_bound(*iti); + auto itt = tcuts.lower_bound(*iti); int id0 = itt->second.second.second; MVertex *v0 = itt->second.first; ++itt; @@ -3572,23 +3526,27 @@ public: cutTriangles(ttt, f[i], v0, v3, ge, ecuts, *iti, F); cutTriangles(ttt, f[i], v1, v2, ge, ecuts, *iti, F); } - else{ - printf("%d %d %d %d\n",id0,id1,id2,id3); - } - } + else { + printf("%d %d %d %d\n", id0, id1, id2, id3); + } + } else if(tcuts.count(*iti) == 6) { - auto itt = - tcuts.lower_bound(*iti); - std::pair<int,MVertex*> id[10]; - for (std::size_t kk=0;kk< tcuts.count(*iti);kk++){ - id[kk] = std::make_pair(itt->second.second.second, itt->second.first); - ++itt; - } - std::sort(id,id+6); - cutTriangles(ttt, f[i], id[0].second, id[1].second, ge, ecuts, *iti, F); - cutTriangles(ttt, f[i], id[2].second, id[3].second, ge, ecuts, *iti, F); - cutTriangles(ttt, f[i], id[4].second, id[5].second, ge, ecuts, *iti, F); - printf("%d %d %d %d %d %d\n",id[0].first,id[1].first,id[2].first,id[3].first,id[4].first,id[5].first); + auto itt = tcuts.lower_bound(*iti); + std::pair<int, MVertex *> id[10]; + for(std::size_t kk = 0; kk < tcuts.count(*iti); kk++) { + id[kk] = + std::make_pair(itt->second.second.second, itt->second.first); + ++itt; + } + std::sort(id, id + 6); + cutTriangles(ttt, f[i], id[0].second, id[1].second, ge, ecuts, *iti, + F); + cutTriangles(ttt, f[i], id[2].second, id[3].second, ge, ecuts, *iti, + F); + cutTriangles(ttt, f[i], id[4].second, id[5].second, ge, ecuts, *iti, + F); + printf("%d %d %d %d %d %d\n", id[0].first, id[1].first, id[2].first, + id[3].first, id[4].first, id[5].first); } else { Msg::Error("TODO %lu in CutMesh !!!!!!!", tcuts.count(*iti)); @@ -3605,8 +3563,7 @@ public: F = fopen("edges.pos", "w"); fprintf(F, "View \"\"{\n"); - for(auto it = ecuts.begin(); it != ecuts.end(); - ++it) { + for(auto it = ecuts.begin(); it != ecuts.end(); ++it) { GEdge *ge = gm->getEdgeByTag(it->second); ge->lines.push_back( new MLine(it->first.getVertex(0), it->first.getVertex(1))); @@ -3633,8 +3590,7 @@ public: { std::map<MEdge, MEdge, MEdgeLessThan> duplicateEdges; - for(auto it = cuts.begin(); - it != cuts.end(); ++it) { + for(auto it = cuts.begin(); it != cuts.end(); ++it) { MVertex *v0 = it->first.getVertex(0); MVertex *v1 = it->first.getVertex(1); MVertex *v2 = new2old.find(v0) == new2old.end() ? v0 : new2old[v0]; @@ -3644,13 +3600,9 @@ public: duplicateEdges[e0] = e1; } - for(auto it2 = - duplicateEdges.begin(); - it2 != duplicateEdges.end(); ++it2) { - auto it3 = - cuts.find(it2->first); - auto it4 = - cuts.find(it2->second); + for(auto it2 = duplicateEdges.begin(); it2 != duplicateEdges.end(); ++it2) { + auto it3 = cuts.find(it2->first); + auto it4 = cuts.find(it2->second); if(it3 != cuts.end() && it4 == cuts.end()) { cuts[it2->second] = it3->second; } @@ -3679,14 +3631,14 @@ public: std::map<MEdge, edgeCuts, MEdgeLessThan> &cuts) { std::vector<cutGraphPassage> passages; - while (1){ + while(1) { computePotential(gm, f, *myAssembler, C, new2old, groups, duplicateEdges, - d0, d1, G, potU, potV, passages); + d0, d1, G, potU, potV, passages); - if (computeIsos(gm, f, singularities, C, new2old, duplicateEdges, groups, - groups_cg, potU, potV, cutG, G, cuts, passages)==true){ - printf("COMPUTE ISOS DONE\n"); - break; + if(computeIsos(gm, f, singularities, C, new2old, duplicateEdges, groups, + groups_cg, potU, potV, cutG, G, cuts, passages) == true) { + printf("COMPUTE ISOS DONE\n"); + break; } break; } @@ -3698,12 +3650,13 @@ public: for(size_t i = 0; i < groups_cg.size(); i++) { double MAXD1 = -1.e22, MIND1 = 1.e22, MAXD2 = -1.e22, MIND2 = 1.e22; for(size_t j = 0; j < G[i].left.size(); j++) { - /* if (G[i].groupId == 5 || G[i].groupId == 6){ - printf("%lu %lu %12.5E %12.5E %12.5E %12.5E\n",G[i].left[j]->getNum(),G[i].right[j]->getNum(), - potU[G[i].left[j]],potU[G[i].right[j]], - potV[G[i].left[j]],potV[G[i].right[j]]); - } - */ + /* if (G[i].groupId == 5 || G[i].groupId == 6){ + printf("%lu %lu %12.5E %12.5E %12.5E + %12.5E\n",G[i].left[j]->getNum(),G[i].right[j]->getNum(), + potU[G[i].left[j]],potU[G[i].right[j]], + potV[G[i].left[j]],potV[G[i].right[j]]); + } + */ double Ul = potU[G[i].left[j]]; double Ur = potU[G[i].right[j]]; double Vl = potV[G[i].left[j]]; @@ -3714,17 +3667,15 @@ public: MAXD2 = std::max(D2, MAXD2); MIND1 = std::min(D1, MIND1); MIND2 = std::min(D2, MIND2); - } // SUM_LEFT += MAXD1; // SUM_RIGHT += MAXD2; // Dof E1(g.left[]->getNum(), // Dof::createTypeWithTwoInts(0, 3 + 100 * G[i].groupId)); - - Msg::Debug("group %3d ROT (%12.5E %12.5E) (%12.5E %12.5E)", - G[i].groupId, G[i].mat[0][0], G[i].mat[0][1], - G[i].mat[1][0],G[i].mat[1][1]); + Msg::Debug("group %3d ROT (%12.5E %12.5E) (%12.5E %12.5E)", G[i].groupId, + G[i].mat[0][0], G[i].mat[0][1], G[i].mat[1][0], + G[i].mat[1][1]); Msg::Debug("group %3d DA(%12.5E %12.5E %12.5E) D2(%12.5E %12.5E %12.5E)", G[i].groupId, MAXD1, MIND1, MAXD1 - MIND1, MAXD2, MIND2, @@ -3745,8 +3696,7 @@ static void findPhysicalGroupsForSingularities(GModel *gm, { std::map<int, std::vector<GEntity *> > groups[4]; gm->getPhysicalGroups(groups); - for(auto it = groups[0].begin(); - it != groups[0].end(); ++it) { + for(auto it = groups[0].begin(); it != groups[0].end(); ++it) { std::string name = gm->getPhysicalName(0, it->first); if(name == "SINGULARITY_OF_INDEX_THREE") { for(size_t j = 0; j < it->second.size(); j++) { @@ -3861,24 +3811,21 @@ static int computeCrossFieldAndH(GModel *gm, std::vector<GFace *> &f, V->addData(gm, dataV, 0, 0.0, 1, 1); V->finalize(); } - for(auto it = qLayout.d0.begin(); - it != qLayout.d0.end(); ++it) { + for(auto it = qLayout.d0.begin(); it != qLayout.d0.end(); ++it) { std::vector<double> jj; jj.push_back(it->second.x()); jj.push_back(it->second.y()); jj.push_back(it->second.z()); dataDir[it->first->getNum()] = jj; } - for(auto it = qLayout.d1.begin(); - it != qLayout.d1.end(); ++it) { + for(auto it = qLayout.d1.begin(); it != qLayout.d1.end(); ++it) { std::vector<double> jj; jj.push_back(it->second.x()); jj.push_back(it->second.y()); jj.push_back(it->second.z()); dataDirOrtho[it->first->getNum()] = jj; } - for(auto it = qLayout.vs.begin(); - it != qLayout.vs.end(); ++it) { + for(auto it = qLayout.vs.begin(); it != qLayout.vs.end(); ++it) { double h; qLayout.myAssembler->getDofValue(*it, 0, 1, h); std::vector<double> jj; @@ -3912,7 +3859,8 @@ static int computeCrossFieldAndH(GModel *gm, std::vector<GFace *> &f, Msg::Info("Classifying the model"); discreteEdge *de = new discreteEdge( - GModel::current(), GModel::current()->getMaxElementaryNumber(1) + 1, nullptr, nullptr); + GModel::current(), GModel::current()->getMaxElementaryNumber(1) + 1, + nullptr, nullptr); GModel::current()->add(de); computeNonManifoldEdges(GModel::current(), de->lines, true); classifyFaces(GModel::current(), M_PI / 4 * .999); diff --git a/Mesh/meshGEdge.cpp b/Mesh/meshGEdge.cpp index 845be37e33cedbe92876df68fb0093f9baddd332..4671152241c283d99b5ca080410eabe44b29d263 100644 --- a/Mesh/meshGEdge.cpp +++ b/Mesh/meshGEdge.cpp @@ -137,18 +137,18 @@ struct F_Lc_aniso { } }; - -//static double dfbeta2 (double t, double beta){ +// static double dfbeta2 (double t, double beta){ // double ratio = (1+beta)/(beta-1); // double zlog = log(ratio); // return 1.-acosh(beta*zlog/t - 1.0)/zlog; // return beta*zlog / (1+cosh(zlog*(1-t))); //} -static double dfbeta (double t, double beta){ - double ratio = (1+beta)/(beta-1); - double zlog = log(ratio); - return 2*beta/((1+beta-t)*(-1+beta+t)*zlog); +static double dfbeta(double t, double beta) +{ + double ratio = (1 + beta) / (beta - 1); + double zlog = log(ratio); + return 2 * beta / ((1 + beta - t) * (-1 + beta + t) * zlog); } struct F_Transfinite { @@ -184,8 +184,7 @@ struct F_Transfinite { } else { switch(atype) { - case 1: - { + case 1: { // geometric progression ar^i; Sum of n terms = length = a (r^n-1)/(r-1) double r = (gmsh_sign(type) >= 0) ? coef : 1. / coef; double a = length * (r - 1.) / (std::pow(r, nbpt - 1.) - 1.); @@ -193,38 +192,35 @@ struct F_Transfinite { val = d / (a * std::pow(r, (double)i)); } break; - case 2: - { + case 2: { // "bump" double a; if(coef > 1.0) { a = -4. * std::sqrt(coef - 1.) * - std::atan2(1.0, std::sqrt(coef - 1.)) / ((double)nbpt * length); + std::atan2(1.0, std::sqrt(coef - 1.)) / ((double)nbpt * length); } else { a = 2. * std::sqrt(1. - coef) * - std::log(std::abs((1. + 1. / std::sqrt(1. - coef)) / - (1. - 1. / std::sqrt(1. - coef)))) / - ((double)nbpt * length); + std::log(std::abs((1. + 1. / std::sqrt(1. - coef)) / + (1. - 1. / std::sqrt(1. - coef)))) / + ((double)nbpt * length); } double b = -a * length * length / (4. * (coef - 1.)); val = d / (-a * std::pow(t * length - (length)*0.5, 2) + b); break; } - case 3: - { + case 3: { // "beta" law - if(type < 0) - val = dfbeta(1. - t, coef); - else - val = dfbeta(t, coef); - break; + if(type < 0) + val = dfbeta(1. - t, coef); + else + val = dfbeta(t, coef); + break; } - case 4: - { + case 4: { // standard boundary layer progression: TODO - val = d / (length * t); - break; + val = d / (length * t); + break; } default: Msg::Warning("Unknown case in Transfinite Line mesh"); @@ -468,8 +464,8 @@ static void filterPoints(GEdge *ge, int nMinimumPoints) (((int)ge->mesh_vertices.size() - last) >= nMinimumPoints); if(filteringObservesMinimumN) { for(int i = 0; i < last; i++) { - auto it = std::find( - ge->mesh_vertices.begin(), ge->mesh_vertices.end(), lengths[i].second); + auto it = std::find(ge->mesh_vertices.begin(), ge->mesh_vertices.end(), + lengths[i].second); if(it != ge->mesh_vertices.end()) { ge->mesh_vertices.erase(it); } delete lengths[i].second; @@ -666,8 +662,7 @@ int meshGEdgeProcessing(GEdge *ge, const double t_begin, double t_end, int &N, if(CTX::instance()->mesh.algoRecombine == 2) N = increaseN(N); } else { - for(auto it = faces.begin(); - it != faces.end(); it++) { + for(auto it = faces.begin(); it != faces.end(); it++) { if((*it)->meshAttributes.recombine) { if(N % 2 == 0) N++; if(CTX::instance()->mesh.algoRecombine == 2) N = increaseN(N); diff --git a/Mesh/meshGEdgeExtruded.cpp b/Mesh/meshGEdgeExtruded.cpp index 1de74e13eb63e8a88ab7e4e85513eb9e84bd79e2..928a5e52f8bf22360fa771223dce4ccb8f52478d 100644 --- a/Mesh/meshGEdgeExtruded.cpp +++ b/Mesh/meshGEdgeExtruded.cpp @@ -13,12 +13,11 @@ static void createElements(GEdge *ge) { // create elements for(std::size_t i = 0; i < ge->mesh_vertices.size() + 1; i++) { - MVertex *v0 = (i == 0) ? - ge->getBeginVertex()->mesh_vertices[0] : - ge->mesh_vertices[i - 1]; + MVertex *v0 = (i == 0) ? ge->getBeginVertex()->mesh_vertices[0] : + ge->mesh_vertices[i - 1]; MVertex *v1 = (i == ge->mesh_vertices.size()) ? - ge->getEndVertex()->mesh_vertices[0] : - ge->mesh_vertices[i]; + ge->getEndVertex()->mesh_vertices[0] : + ge->mesh_vertices[i]; MLine *newElem = new MLine(v0, v1); ge->lines.push_back(newElem); } @@ -76,7 +75,7 @@ int MeshExtrudedCurve(GEdge *ge) if(!ep || !ep->mesh.ExtrudeMesh) return 0; - if(!ge->getBeginVertex() || !ge->getEndVertex()){ + if(!ge->getBeginVertex() || !ge->getEndVertex()) { Msg::Error("Cannot extrude curve %d with no begin or end point", ge->tag()); return 0; } diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp index 7a0710d598787894fe12d93603edcefe1cfb563e..f35ae05a3684076b0d2078eb811dd5582d9f7e82 100644 --- a/Mesh/meshGFace.cpp +++ b/Mesh/meshGFace.cpp @@ -136,8 +136,7 @@ private: MEdge E = _gf->triangles[i]->getEdge(j); SPoint2 p1, p2; reparamMeshEdgeOnFace(E.getVertex(0), E.getVertex(1), _gf, p1, p2); - auto it = - _middle.find(E); + auto it = _middle.find(E); auto it2 = eds.find(E); m[j] = p1; if(it == _middle.end() && it2 == eds.end()) { @@ -191,8 +190,7 @@ private: MEdge E = _gf->quadrangles[i]->getEdge(j); SPoint2 p1, p2; reparamMeshEdgeOnFace(E.getVertex(0), E.getVertex(1), _gf, p1, p2); - auto it = - _middle.find(E); + auto it = _middle.find(E); auto it2 = eds.find(E); m[j] = p1; if(it == _middle.end() && it2 == eds.end()) { @@ -355,8 +353,7 @@ static void copyMesh(GFace *source, GFace *target) for(std::vector<GVertex *>::const_iterator tvIter = t_vtcs.begin(); tvIter != t_vtcs.end(); ++tvIter) { GVertex *gvt = *tvIter; - auto gvsIter = - target->vertexCounterparts.find(gvt); + auto gvsIter = target->vertexCounterparts.find(gvt); if(gvsIter == target->vertexCounterparts.end()) { Msg::Error("Periodic meshing of surface %d with surface %d: " @@ -398,12 +395,10 @@ static void copyMesh(GFace *source, GFace *target) std::set<GEdge *> checkEdges; checkEdges.insert(s_edges.begin(), s_edges.end()); - for(auto te_iter = t_edges.begin(); - te_iter != t_edges.end(); ++te_iter) { + for(auto te_iter = t_edges.begin(); te_iter != t_edges.end(); ++te_iter) { GEdge *get = *te_iter; - auto gesIter = - target->edgeCounterparts.find(get); + auto gesIter = target->edgeCounterparts.find(get); if(gesIter == target->edgeCounterparts.end()) { Msg::Error("Periodic meshing of surface %d with surface %d: " "curve %d has no periodic counterpart", @@ -522,8 +517,7 @@ static void remeshUnrecoveredEdges( for(; itr != edgesNotRecovered.end(); ++itr) { std::vector<GFace *> l_faces = itr->ge->faces(); // un-mesh model faces adjacent to the model edge - for(auto it = l_faces.begin(); - it != l_faces.end(); ++it) { + for(auto it = l_faces.begin(); it != l_faces.end(); ++it) { if((*it)->triangles.size() || (*it)->quadrangles.size()) { (*it)->meshStatistics.status = GFace::PENDING; dem(*it); @@ -544,10 +538,8 @@ static void remeshUnrecoveredEdges( MVertex *v1 = itr->ge->lines[i]->getVertex(0); MVertex *v2 = itr->ge->lines[i]->getVertex(1); - auto itp1 = - recoverMultiMapInv.lower_bound(v1); - auto itp2 = - recoverMultiMapInv.lower_bound(v2); + auto itp1 = recoverMultiMapInv.lower_bound(v1); + auto itp2 = recoverMultiMapInv.lower_bound(v2); if(itp1 != recoverMultiMapInv.end() && itp2 != recoverMultiMapInv.end()) { BDS_Point *pp1 = itp1->second; @@ -640,8 +632,7 @@ remeshUnrecoveredEdges(std::map<MVertex *, BDS_Point *> &recoverMapInv, for(; itr != edgesNotRecovered.end(); ++itr) { std::vector<GFace *> l_faces = itr->ge->faces(); // un-mesh model faces adjacent to the model edge - for(auto it = l_faces.begin(); - it != l_faces.end(); ++it) { + for(auto it = l_faces.begin(); it != l_faces.end(); ++it) { if((*it)->triangles.size() || (*it)->quadrangles.size()) { (*it)->meshStatistics.status = GFace::PENDING; dem(*it); @@ -766,10 +757,8 @@ static bool recoverEdge(BDS_Mesh *m, GFace *gf, GEdge *ge, for(std::size_t i = 0; i < ge->lines.size(); i++) { MVertex *vstart = ge->lines[i]->getVertex(0); MVertex *vend = ge->lines[i]->getVertex(1); - auto itpstart = - recoverMapInv.find(vstart); - auto itpend = - recoverMapInv.find(vend); + auto itpstart = recoverMapInv.find(vstart); + auto itpend = recoverMapInv.find(vend); if(itpstart != recoverMapInv.end() && itpend != recoverMapInv.end()) { BDS_Point *pstart = itpstart->second; BDS_Point *pend = itpend->second; @@ -800,10 +789,8 @@ static bool recoverEdge(BDS_Mesh *m, GFace *gf, GEdge *ge, if(pass == 2 && ge->getBeginVertex()) { MVertex *vstart = *(ge->getBeginVertex()->mesh_vertices.begin()); MVertex *vend = *(ge->getEndVertex()->mesh_vertices.begin()); - auto itpstart = - recoverMapInv.find(vstart); - auto itpend = - recoverMapInv.find(vend); + auto itpstart = recoverMapInv.find(vstart); + auto itpend = recoverMapInv.find(vend); if(itpstart != recoverMapInv.end() && itpend != recoverMapInv.end()) { BDS_Point *pstart = itpstart->second; BDS_Point *pend = itpend->second; @@ -920,8 +907,7 @@ static void modifyInitialMeshForBoundaryLayers( ++ite; } - for(auto itf = _columns->beginf(); - itf != _columns->endf(); ++itf) { + for(auto itf = _columns->beginf(); itf != _columns->endf(); ++itf) { MVertex *v = itf->first; int nbCol = _columns->getNbColumns(v); @@ -1008,7 +994,8 @@ static void modifyInitialMeshForBoundaryLayers( verts.insert(blTris[i]->getVertex(j)); } - discreteEdge ne(gf->model(), 444444, nullptr, (*edges.begin())->getEndVertex()); + discreteEdge ne(gf->model(), 444444, nullptr, + (*edges.begin())->getEndVertex()); std::vector<GEdge *> hop; auto it = bedges.begin(); @@ -1086,8 +1073,7 @@ static void directions_storage(GFace *gf) gf->storage3.clear(); gf->storage4.clear(); - for(auto it = vertices.begin(); it != vertices.end(); - it++) { + for(auto it = vertices.begin(); it != vertices.end(); it++) { SPoint2 point; SVector3 v1; SVector3 v2; @@ -1239,8 +1225,7 @@ bool meshGenerator(GFace *gf, int RECUR_ITER, bool repairSelfIntersecting1dMesh, Msg::Error("The 1D mesh seems not to be forming a closed loop (%d boundary " "nodes are considered once)", boundary.size()); - for(auto it = boundary.begin(); - it != boundary.end(); it++) { + for(auto it = boundary.begin(); it != boundary.end(); it++) { Msg::Debug("Remaining node %lu", (*it)->getNum()); } gf->meshStatistics.status = GFace::FAILED; @@ -1282,9 +1267,7 @@ bool meshGenerator(GFace *gf, int RECUR_ITER, bool repairSelfIntersecting1dMesh, else if(all_vertices.size() == 3) { MVertex *vv[3] = {nullptr, nullptr, nullptr}; int i = 0; - for(auto it = - all_vertices.begin(); - it != all_vertices.end(); it++) { + for(auto it = all_vertices.begin(); it != all_vertices.end(); it++) { vv[i++] = *it; } gf->triangles.push_back(new MTriangle(vv[0], vv[1], vv[2])); @@ -1299,9 +1282,7 @@ bool meshGenerator(GFace *gf, int RECUR_ITER, bool repairSelfIntersecting1dMesh, std::vector<BDS_Point *> points(all_vertices.size()); SBoundingBox3d bbox; int count = 0; - for(auto it = - all_vertices.begin(); - it != all_vertices.end(); it++) { + for(auto it = all_vertices.begin(); it != all_vertices.end(); it++) { MVertex *here = *it; GEntity *ge = here->onWhat(); SPoint2 param; @@ -1478,8 +1459,8 @@ bool meshGenerator(GFace *gf, int RECUR_ITER, bool repairSelfIntersecting1dMesh, if(edgesNotRecovered.size() || gf->meshStatistics.refineAllEdges) { std::ostringstream sstream; - for(auto itr = edgesNotRecovered.begin(); - itr != edgesNotRecovered.end(); ++itr) + for(auto itr = edgesNotRecovered.begin(); itr != edgesNotRecovered.end(); + ++itr) sstream << " " << itr->ge->tag(); if(gf->meshStatistics.refineAllEdges) { Msg::Info("8-| Splitting all edges and trying again"); @@ -1609,8 +1590,7 @@ bool meshGenerator(GFace *gf, int RECUR_ITER, bool repairSelfIntersecting1dMesh, auto it = m->points.begin(); for(; it != m->points.end(); ++it) { BDS_Point *pp = *it; - auto itv = - recoverMap.find(pp); + auto itv = recoverMap.find(pp); if(itv != recoverMap.end()) { MVertex *here = itv->second; GEntity *ge = here->onWhat(); @@ -1976,9 +1956,8 @@ static bool buildConsecutiveListOfVertices( // It has not worked : either tolerance is wrong or the first seam edge // has to be taken with the other parametric coordinates (because it is // only present once in the closure of the domain). - for(auto it = - recoverMapLocal.begin(); - it != recoverMapLocal.end(); ++it) { + for(auto it = recoverMapLocal.begin(); it != recoverMapLocal.end(); + ++it) { m->del_point(it->first); } return false; @@ -2013,9 +1992,7 @@ static bool buildConsecutiveListOfVertices( if(ge->dim() == 0) { // Point might already be part of other loop double smallestDistance = std::numeric_limits<double>::infinity(); - for(auto it = - recoverMap.begin(); - it != recoverMap.end(); ++it) { + for(auto it = recoverMap.begin(); it != recoverMap.end(); ++it) { if(it->second == here) { // Also check on 2D coordinates as the point might lie on the seam SPoint2 param = coords[i]; @@ -2118,8 +2095,7 @@ static bool meshGeneratorPeriodic(GFace *gf, int RECUR_ITER, SBoundingBox3d bbox; int nbPointsTotal = 0; { - for(auto it = gf->edgeLoops.begin(); - it != gf->edgeLoops.end(); it++) { + for(auto it = gf->edgeLoops.begin(); it != gf->edgeLoops.end(); it++) { std::vector<BDS_Point *> edgeLoop_BDS; int nbPointsLocal; const double fact[4] = {1.e-12, 1.e-7, 1.e-5, 1.e-3}; @@ -2150,8 +2126,7 @@ static bool meshGeneratorPeriodic(GFace *gf, int RECUR_ITER, } { - auto it = - recoverMap.begin(); + auto it = recoverMap.begin(); std::map<MVertex *, BDS_Point *> INV; for(; it != recoverMap.end(); ++it) { recoverMultiMapInv.insert(std::make_pair(it->second, it->first)); @@ -2176,9 +2151,7 @@ static bool meshGeneratorPeriodic(GFace *gf, int RECUR_ITER, else if(nbPointsTotal == 3) { MVertex *vv[3] = {nullptr, nullptr, nullptr}; int i = 0; - for(auto it = - recoverMap.begin(); - it != recoverMap.end(); it++) { + for(auto it = recoverMap.begin(); it != recoverMap.end(); it++) { vv[i++] = it->second; } if(vv[0] && vv[1] && vv[2]) @@ -2202,9 +2175,7 @@ static bool meshGeneratorPeriodic(GFace *gf, int RECUR_ITER, auto itvx = emb_vertx.begin(); std::map<MVertex *, std::set<BDS_Point *> > invertedRecoverMap; - for(auto it = - recoverMap.begin(); - it != recoverMap.end(); it++) { + for(auto it = recoverMap.begin(); it != recoverMap.end(); it++) { invertedRecoverMap[it->second].insert(it->first); } @@ -2285,8 +2256,7 @@ static bool meshGeneratorPeriodic(GFace *gf, int RECUR_ITER, SPoint2 pointOnSurface = edge->reparamOnFace(gf, param, 1); const std::set<BDS_Point *> &possiblePoints = it->second; - for(auto pntIt = - possiblePoints.begin(); + for(auto pntIt = possiblePoints.begin(); pntIt != possiblePoints.end(); ++pntIt) { if(pointOnSurface.distance(SPoint2((*pntIt)->u, (*pntIt)->v)) < 1e-10) { @@ -2500,8 +2470,8 @@ static bool meshGeneratorPeriodic(GFace *gf, int RECUR_ITER, if(!gf->meshStatistics.refineAllEdges) { std::ostringstream sstream; - for(auto itr = edgesNotRecovered.begin(); - itr != edgesNotRecovered.end(); ++itr) + for(auto itr = edgesNotRecovered.begin(); itr != edgesNotRecovered.end(); + ++itr) sstream << " " << itr->ge->tag() << "(" << (itr->ge->getBeginVertex() ? itr->ge->getBeginVertex()->tag() : -1) @@ -2521,10 +2491,8 @@ static bool meshGeneratorPeriodic(GFace *gf, int RECUR_ITER, for(size_t j = 0; j < NN; j++) { MVertex *v1 = eds[i]->lines[j]->getVertex(0); MVertex *v2 = eds[i]->lines[j]->getVertex(1); - auto itp1 = - recoverMultiMapInv.lower_bound(v1); - auto itp2 = - recoverMultiMapInv.lower_bound(v2); + auto itp1 = recoverMultiMapInv.lower_bound(v1); + auto itp2 = recoverMultiMapInv.lower_bound(v2); if(itp1 != recoverMultiMapInv.end() && itp2 != recoverMultiMapInv.end()) edgesNotRecovered.insert( @@ -2729,8 +2697,7 @@ static bool meshGeneratorPeriodic(GFace *gf, int RECUR_ITER, std::map<MVertex *, SPoint2> parametricCoordinates; if(algoDelaunay2D(gf)) { std::map<MVertex *, BDS_Point *> invertMap; - auto it = - recoverMap.begin(); + auto it = recoverMap.begin(); while(it != recoverMap.end()) { // we have twice vertex MVertex with 2 different coordinates MVertex *mv1 = it->second; diff --git a/Mesh/meshGFaceBDS.cpp b/Mesh/meshGFaceBDS.cpp index 36d8450231e87f4fa04bb2a542ba18f13a8bfbf7..997e5caa75ced72fb1478c07ca5cee8b94b2bc07 100644 --- a/Mesh/meshGFaceBDS.cpp +++ b/Mesh/meshGFaceBDS.cpp @@ -35,10 +35,8 @@ static void getDegeneratedVertices( while(it != m.edges.end()) { BDS_Edge *e = *it; if(!e->deleted && e->numfaces() == 1) { - auto itp1 = - recoverMap->find(e->p1); - auto itp2 = - recoverMap->find(e->p2); + auto itp1 = recoverMap->find(e->p1); + auto itp2 = recoverMap->find(e->p2); if(itp1 != recoverMap->end() && itp2 != recoverMap->end() && itp1->second == itp2->second) { degenerated.insert(itp1->second); @@ -88,7 +86,7 @@ static double computeEdgeLinearLength(BDS_Edge *e, GFace *f) static double NewGetLc(BDS_Point *point, GFace *gf) { return Extend1dMeshIn2dSurfaces(gf) ? std::min(point->lc(), point->lcBGM()) : - point->lcBGM(); + point->lcBGM(); } static double correctLC_(BDS_Point *p1, BDS_Point *p2, GFace *f) @@ -410,12 +408,10 @@ static void splitEdgePass(GFace *gf, BDS_Mesh &m, double MAXE_, int &nb_split, double t1 = Cpu(); std::vector<std::pair<double, BDS_Edge *> > edges; - SPoint2 out(gf->parBounds(0).high() + 1.21982512, gf->parBounds(1).high() + 1.8635436432); - for(auto it = m.points.begin(); - it != m.points.end(); ++it) { + for(auto it = m.points.begin(); it != m.points.end(); ++it) { BDS_Point *p = *it; if(!p->_periodicCounterpart && (p->g && p->g->classif_degree == 2)) { for(size_t i = 0; i < p->edges.size(); i++) { @@ -555,10 +551,9 @@ void collapseEdgePass(GFace *gf, BDS_Mesh &m, double MINE_, int MAXNP, BDS_Edge *e = edges[i].second; if(!e->deleted && (neighboringModified(e->p1) || neighboringModified(e->p2))) { - double lone1 = 0.; bool collapseP1Allowed = false; - if (e->p1->iD > MAXNP){ + if(e->p1->iD > MAXNP) { lone1 = getMaxLcWhenCollapsingEdge(gf, m, e, e->p1); collapseP1Allowed = std::abs(lone1 - 1.0) < std::abs(edges[i].first - 1.0); @@ -584,8 +579,7 @@ void collapseEdgePass(GFace *gf, BDS_Mesh &m, double MINE_, int MAXNP, else if(collapseP2Allowed && !collapseP1Allowed) p = e->p2; - if(p && m.collapse_edge_parametric(e, p)) - nb_collaps++; + if(p && m.collapse_edge_parametric(e, p)) nb_collaps++; } } t += (Cpu() - t1); @@ -644,10 +638,8 @@ computeNodalSizes(GFace *gf, BDS_Mesh &m, bool degenerated = false; if(recoverMap) { - auto itp1 = - recoverMap->find((*it)->p1); - auto itp2 = - recoverMap->find((*it)->p2); + auto itp1 = recoverMap->find((*it)->p1); + auto itp2 = recoverMap->find((*it)->p2); if(itp1 != recoverMap->end() && itp2 != recoverMap->end() && itp1->second == itp2->second) { degenerated = true; @@ -704,16 +696,14 @@ void modifyInitialMeshToRemoveDegeneracies( std::vector<BDS_Edge *> degenerated_edges; getDegeneratedVertices(m, recoverMap, degenerated, degenerated_edges); - for(auto it = - recoverMap->begin(); - it != recoverMap->end(); ++it) { - auto it2 = - degenerated.find(it->second); + for(auto it = recoverMap->begin(); it != recoverMap->end(); ++it) { + auto it2 = degenerated.find(it->second); if(it2 != degenerated.end()) { for(size_t K = 0; K < degenerated_edges.size(); K++) { if(degenerated_edges[K]->p1 == it->first || degenerated_edges[K]->p2 == it->first) { - if(std::abs(degenerated_edges[K]->p1->u - degenerated_edges[K]->p2->u) < 1e-12) { + if(std::abs(degenerated_edges[K]->p1->u - + degenerated_edges[K]->p2->u) < 1e-12) { Msg::Debug( "Degenerated edge on u = cst axis: treated as well now!"); it->first->degenerated = 2; @@ -873,7 +863,7 @@ void refineMeshBDS(GFace *gf, BDS_Mesh &m, const int NIT, while(it != m.edges.end()) { if(!(*it)->deleted) { double lone = 2 * (*it)->length() / - (NewGetLc((*it)->p1, gf) + NewGetLc((*it)->p2, gf)); + (NewGetLc((*it)->p1, gf) + NewGetLc((*it)->p2, gf)); if(lone > maxE) LARGE++; if(lone < minE) SMALL++; TOTAL++; diff --git a/Mesh/meshGFaceBamg.cpp b/Mesh/meshGFaceBamg.cpp index 6b4638620b21b0b200289b74ba27777614583056..13ece057b5a3e270aa80481b2d4ea816417f0d24 100644 --- a/Mesh/meshGFaceBamg.cpp +++ b/Mesh/meshGFaceBamg.cpp @@ -72,8 +72,7 @@ void meshGFaceBamg(GFace *gf) { std::vector<GEdge *> const &edges = gf->edges(); std::set<MVertex *> bcVertex; - for(auto it = edges.begin(); - it != edges.end(); it++) { + for(auto it = edges.begin(); it != edges.end(); it++) { for(std::size_t i = 0; i < (*it)->lines.size(); i++) { bcVertex.insert((*it)->lines[i]->getVertex(0)); bcVertex.insert((*it)->lines[i]->getVertex(1)); @@ -139,15 +138,15 @@ void meshGFaceBamg(GFace *gf) bamgTriangles[i].init(bamgVertices, nodes, gf->tag()); } - const auto numEdges = std::accumulate(begin(edges), end(edges), std::size_t(0), [](std::size_t const partial_sum, const GEdge *const edge) - { - return partial_sum + edge->lines.size(); - }); + const auto numEdges = + std::accumulate(begin(edges), end(edges), std::size_t(0), + [](std::size_t const partial_sum, const GEdge *const edge) { + return partial_sum + edge->lines.size(); + }); Seg *bamgBoundary = new Seg[numEdges]; int count = 0; - for(auto it = edges.begin(); - it != edges.end(); ++it) { + for(auto it = edges.begin(); it != edges.end(); ++it) { for(std::size_t i = 0; i < (*it)->lines.size(); ++i) { int nodes[2] = {(int)(*it)->lines[i]->getVertex(0)->getIndex(), (int)(*it)->lines[i]->getVertex(1)->getIndex()}; @@ -235,12 +234,9 @@ void meshGFaceBamg(GFace *gf) // delete pointers if(refinedBamgMesh) delete refinedBamgMesh; if(_octree) delete _octree; - for(auto it = myParamElems.begin(); - it != myParamElems.end(); it++) - delete *it; - for(auto it = newVert.begin(); - it != newVert.end(); it++) + for(auto it = myParamElems.begin(); it != myParamElems.end(); it++) delete *it; + for(auto it = newVert.begin(); it != newVert.end(); it++) delete *it; } #else diff --git a/Mesh/meshGFaceDelaunayInsertion.cpp b/Mesh/meshGFaceDelaunayInsertion.cpp index ec24063e7a8465843f11099d51f925f97e2362cb..407f0bf99bc7fa15047db059f984d0be8ad5c552 100644 --- a/Mesh/meshGFaceDelaunayInsertion.cpp +++ b/Mesh/meshGFaceDelaunayInsertion.cpp @@ -590,8 +590,7 @@ static void recurFindCavityAniso(GFace *gf, std::list<edgeXface> &shell, MTri3 *neigh = t->getNeigh(i); edgeXface exf(t, i); // take care of untouchable internal edges - auto it = - data.internalEdges.find(MEdge(exf._v(0), exf._v(1))); + auto it = data.internalEdges.find(MEdge(exf._v(0), exf._v(1))); if(!neigh || it != data.internalEdges.end()) shell.push_back(exf); else if(!neigh->isDeleted()) { @@ -721,8 +720,8 @@ static int insertVertexB(std::list<edgeXface> &shell, data.vSizesBGM[index2]); double LL = std::min(lc, lcBGM); - MTri3 *t4 = - new MTri3(t, Extend1dMeshIn2dSurfaces(gf) ? LL : lcBGM, nullptr, &data, gf); + MTri3 *t4 = new MTri3(t, Extend1dMeshIn2dSurfaces(gf) ? LL : lcBGM, nullptr, + &data, gf); if(oneNewTriangle) { force = true; @@ -774,8 +773,7 @@ static int insertVertexB(std::list<edgeXface> &shell, // 30 % of the time is spent here! allTets.insert(newTris, newTris + shell.size()); if(activeTets) { - for(auto i = new_cavity.begin(); - i != new_cavity.end(); ++i) { + for(auto i = new_cavity.begin(); i != new_cavity.end(); ++i) { int active_edge; if(isActive(*i, LIMIT_, active_edge) && (*i)->getRadius() > LIMIT_) { if((*activeTets).find(*i) == (*activeTets).end()) @@ -891,10 +889,10 @@ static MTri3 *search4Triangle(MTri3 *t, double pt[2], bidimMeshData &data, if(ITER++ > (int)AllTris.size()) break; } - if(!force) return nullptr; // FIXME: removing this leads to horrible performance + if(!force) + return nullptr; // FIXME: removing this leads to horrible performance - for(auto itx = AllTris.begin(); - itx != AllTris.end(); ++itx) { + for(auto itx = AllTris.begin(); itx != AllTris.end(); ++itx) { if(!(*itx)->isDeleted()) { inside = invMapUV((*itx)->tri(), pt, data, uv, 1.e-8); if(inside) { return *itx; } @@ -904,14 +902,13 @@ static MTri3 *search4Triangle(MTri3 *t, double pt[2], bidimMeshData &data, return nullptr; } -static bool insertAPoint(GFace *gf, - std::set<MTri3 *, compareTri3Ptr>::iterator it, - double center[2], double metric[3], - bidimMeshData &data, - std::set<MTri3 *, compareTri3Ptr> &AllTris, - std::set<MTri3 *, compareTri3Ptr> *ActiveTris = nullptr, - MTri3 *worst = nullptr, MTri3 **oneNewTriangle = nullptr, - bool testStarShapeness = false) +static bool +insertAPoint(GFace *gf, std::set<MTri3 *, compareTri3Ptr>::iterator it, + double center[2], double metric[3], bidimMeshData &data, + std::set<MTri3 *, compareTri3Ptr> &AllTris, + std::set<MTri3 *, compareTri3Ptr> *ActiveTris = nullptr, + MTri3 *worst = nullptr, MTri3 **oneNewTriangle = nullptr, + bool testStarShapeness = false) { if(worst) { it = AllTris.find(worst); @@ -931,8 +928,7 @@ static bool insertAPoint(GFace *gf, // if the point is able to break the bad triangle "worst" if(inCircumCircleAniso(gf, worst->tri(), center, metric, data)) { recurFindCavityAniso(gf, shell, cavity, metric, center, worst, data); - for(auto itc = cavity.begin(); itc != cavity.end(); - ++itc) { + for(auto itc = cavity.begin(); itc != cavity.end(); ++itc) { if(invMapUV((*itc)->tri(), center, data, uv, 1.e-8)) { ptin = *itc; break; @@ -998,8 +994,7 @@ static bool insertAPoint(GFace *gf, worst->forceRadius(-1); AllTris.insert(worst); delete v; - for(auto itc = cavity.begin(); - itc != cavity.end(); ++itc) + for(auto itc = cavity.begin(); itc != cavity.end(); ++itc) (*itc)->setDeleted(false); return false; } @@ -1009,8 +1004,7 @@ static bool insertAPoint(GFace *gf, } } else { - for(auto itc = cavity.begin(); itc != cavity.end(); - ++itc) + for(auto itc = cavity.begin(); itc != cavity.end(); ++itc) (*itc)->setDeleted(false); AllTris.erase(it); worst->forceRadius(0); @@ -1536,8 +1530,7 @@ void bowyerWatsonFrontalLayers( _printTris (name, AllTris, Us,Vs,true); } */ - auto WORST_ITER = - ActiveTris.begin(); + auto WORST_ITER = ActiveTris.begin(); MTri3 *worst = (*WORST_ITER); ActiveTris.erase(WORST_ITER); @@ -1563,8 +1556,8 @@ void bowyerWatsonFrontalLayers( else optimalPointFrontalB(gf, worst, active_edge, DATA, newPoint, metric); - insertAPoint(gf, AllTris.end(), newPoint, nullptr, DATA, AllTris, &ActiveTris, - worst); + insertAPoint(gf, AllTris.end(), newPoint, nullptr, DATA, AllTris, + &ActiveTris, worst); // else if (!worst->isDeleted() && worst->getRadius() > LIMIT_){ // ActiveTrisNotInFront.insert(worst); // } @@ -1647,8 +1640,9 @@ void bowyerWatsonParallelograms( double metric[3]; buildMetric(gf, newPoint, metric); - bool success = insertAPoint(gf, AllTris.begin(), newPoint, metric, DATA, - AllTris, nullptr, oneNewTriangle, &oneNewTriangle); + bool success = + insertAPoint(gf, AllTris.begin(), newPoint, metric, DATA, AllTris, + nullptr, oneNewTriangle, &oneNewTriangle); if(!success) oneNewTriangle = nullptr; i++; } @@ -1711,8 +1705,9 @@ void bowyerWatsonParallelogramsConstrained( double metric[3]; buildMetric(gf, newPoint, metric); - bool success = insertAPoint(gf, AllTris.begin(), newPoint, metric, DATA, - AllTris, nullptr, oneNewTriangle, &oneNewTriangle); + bool success = + insertAPoint(gf, AllTris.begin(), newPoint, metric, DATA, AllTris, + nullptr, oneNewTriangle, &oneNewTriangle); if(!success) oneNewTriangle = nullptr; i++; } diff --git a/Mesh/meshGFaceExtruded.cpp b/Mesh/meshGFaceExtruded.cpp index 37aefde01f659ed33cdf5661ba2cf67ed509dbd4..38f177c45dec58baae71663c781871ac0b3b2703 100644 --- a/Mesh/meshGFaceExtruded.cpp +++ b/Mesh/meshGFaceExtruded.cpp @@ -105,8 +105,8 @@ extrudeMesh(GEdge *from, GFace *to, MVertexRTree &pos, if(from->geomType() != GEntity::DiscreteCurve && to->geomType() != GEntity::DiscreteSurface && to->geomType() != GEntity::BoundaryLayerSurface) { - // This can be inefficient, and sometimes useless. We could add an - // option to disable it. + // This can be inefficient, and sometimes useless. We could add + // an option to disable it. SPoint3 xyz(x, y, z); SPoint2 uv = to->parFromPoint(xyz); newv = new MFaceVertex(x, y, z, to, uv[0], uv[1]); @@ -137,7 +137,8 @@ extrudeMesh(GEdge *from, GFace *to, MVertexRTree &pos, bool quadToTri_valid = IsValidQuadToTriLateral(to, &tri_quad_flag, &detectQuadToTriLateral); if(detectQuadToTriLateral && !quadToTri_valid) - Msg::Error("Mesh of QuadToTri lateral surface %d likely has errors", to->tag()); + Msg::Error("Mesh of QuadToTri lateral surface %d likely has errors", + to->tag()); #endif // create elements (note that it would be faster to access the *interior* @@ -247,8 +248,8 @@ static void copyMesh(GFace *from, GFace *to, MVertexRTree &pos) MVertex *tmp = pos.find(x, y, z); if(!tmp) { Msg::Error( - "Could not find extruded node (%.16g, %.16g, %.16g) in surface %d", - x, y, z, to->tag()); + "Could not find extruded node (%.16g, %.16g, %.16g) in surface %d", x, + y, z, to->tag()); return; } verts.push_back(tmp); @@ -277,8 +278,8 @@ static void copyMesh(GFace *from, GFace *to, MVertexRTree &pos) MVertex *tmp = pos.find(x, y, z); if(!tmp) { Msg::Error( - "Could not find extruded node (%.16g, %.16g, %.16g) in surface %d", - x, y, z, to->tag()); + "Could not find extruded node (%.16g, %.16g, %.16g) in surface %d", x, + y, z, to->tag()); return; } verts.push_back(tmp); @@ -300,15 +301,13 @@ int MeshExtrudedSurface( MVertexRTree pos(CTX::instance()->geom.tolerance * CTX::instance()->lc); pos.insert(gf->mesh_vertices); std::vector<GEdge *> const &edges = gf->edges(); - for(auto it = edges.begin(); - it != edges.end(); it++) { + for(auto it = edges.begin(); it != edges.end(); it++) { pos.insert((*it)->mesh_vertices); if((*it)->getBeginVertex()) pos.insert((*it)->getBeginVertex()->mesh_vertices); - if((*it)->getEndVertex()) - pos.insert((*it)->getEndVertex()->mesh_vertices); + if((*it)->getEndVertex()) pos.insert((*it)->getEndVertex()->mesh_vertices); } - std::vector<MVertex*> embedded = gf->getEmbeddedMeshVertices(); + std::vector<MVertex *> embedded = gf->getEmbeddedMeshVertices(); pos.insert(embedded); if(ep->geo.Mode == EXTRUDED_ENTITY) { diff --git a/Mesh/meshGFaceOptimize.cpp b/Mesh/meshGFaceOptimize.cpp index 08d8c5fa0ef20ed9290aa43461b4fbaa1cf58696..4969aa23c2c5aec745b2dc80dcf31d3fccac8dde 100644 --- a/Mesh/meshGFaceOptimize.cpp +++ b/Mesh/meshGFaceOptimize.cpp @@ -171,26 +171,27 @@ bool buildMeshGenerationDataStructures( } } - for(auto it = vSizesMap.begin(); - it != vSizesMap.end(); ++it) { + for(auto it = vSizesMap.begin(); it != vSizesMap.end(); ++it) { SPoint2 param; reparamMeshVertexOnFace(it->first, gf, param); // Add size of background mesh to embedded vertices. For the other nodes, // use the size in vSizesMap const double lcBGM = (embeddedVertices.count(it->first) > 0) ? - BGM_MeshSize(gf, param[0], param[1], it->first->x(), it->first->y(), - it->first->z()) : it->second; - data.addVertex (it->first, param[0], param[1], it->second, lcBGM); + BGM_MeshSize(gf, param[0], param[1], it->first->x(), + it->first->y(), it->first->z()) : + it->second; + data.addVertex(it->first, param[0], param[1], it->second, lcBGM); } for(std::size_t i = 0; i < gf->triangles.size(); i++) { double lc = 0.3333333333 * (data.vSizes[data.getIndex(gf->triangles[i]->getVertex(0))] + data.vSizes[data.getIndex(gf->triangles[i]->getVertex(1))] + data.vSizes[data.getIndex(gf->triangles[i]->getVertex(2))]); - double lcBGM = 0.3333333333 * - (data.vSizesBGM[data.getIndex(gf->triangles[i]->getVertex(0))] + - data.vSizesBGM[data.getIndex(gf->triangles[i]->getVertex(1))] + - data.vSizesBGM[data.getIndex(gf->triangles[i]->getVertex(2))]); + double lcBGM = + 0.3333333333 * + (data.vSizesBGM[data.getIndex(gf->triangles[i]->getVertex(0))] + + data.vSizesBGM[data.getIndex(gf->triangles[i]->getVertex(1))] + + data.vSizesBGM[data.getIndex(gf->triangles[i]->getVertex(2))]); double LL = Extend1dMeshIn2dSurfaces(gf) ? std::min(lc, lcBGM) : lcBGM; AllTris.insert(new MTri3(gf->triangles[i], LL, nullptr, &data, gf)); @@ -210,11 +211,8 @@ void computeEquivalences(GFace *gf, bidimMeshData &data) MVertex *v[3]; for(int j = 0; j < 3; j++) { v[j] = t->getVertex(j); - auto it = - data.equivalence->find(v[j]); - if(it != data.equivalence->end()) { - v[j] = it->second; - } + auto it = data.equivalence->find(v[j]); + if(it != data.equivalence->end()) { v[j] = it->second; } } if(v[0] != v[1] && v[0] != v[2] && v[2] != v[1]) newT.push_back(new MTriangle(v[0], v[1], v[2])); @@ -270,8 +268,7 @@ bool computeEquivalentTriangles(GFace *gf, if(WTF.size()) { Msg::Info("%d triangles are equivalent", WTF.size()); - for(std::size_t i = 0; i < WTF.size(); i++) { - } + for(std::size_t i = 0; i < WTF.size(); i++) {} return true; } return false; @@ -406,9 +403,8 @@ void buildListOfEdgeAngle(e2t_cont adj, std::vector<edge_angle> &edges_detected, std::sort(edges_detected.begin(), edges_detected.end()); } -static void parametricCoordinates(MElement *t, GFace *gf, - double u[4], double v[4], - MVertex *close = nullptr) +static void parametricCoordinates(MElement *t, GFace *gf, double u[4], + double v[4], MVertex *close = nullptr) { for(std::size_t j = 0; j < t->getNumVertices(); j++) { MVertex *ver = t->getVertex(j); @@ -425,7 +421,7 @@ static void parametricCoordinates(MElement *t, GFace *gf, double surfaceFaceUV(MElement *t, GFace *gf, bool maximal = true) { const int N = t->getNumVertices(); - if(N > 4){ + if(N > 4) { Msg::Warning("surfaceFaceUV only for first order elements"); return 0; } @@ -461,8 +457,7 @@ static int _removeTwoQuadsNodes(GFace *gf) if(it->second.size() == 2 && v->onWhat() == gf) { MElement *q1 = it->second[0]; MElement *q2 = it->second[1]; - if(q1->getNumVertices() == 4 && - q2->getNumVertices() == 4 && + if(q1->getNumVertices() == 4 && q2->getNumVertices() == 4 && touched.find(q1) == touched.end() && touched.find(q2) == touched.end()) { int comm = 0; @@ -477,8 +472,7 @@ static int _removeTwoQuadsNodes(GFace *gf) MVertex *v3 = q1->getVertex((comm + 3) % 4); MVertex *v4 = nullptr; for(int i = 0; i < 4; i++) { - if(q2->getVertex(i) != v1 && - q2->getVertex(i) != v3 && + if(q2->getVertex(i) != v1 && q2->getVertex(i) != v3 && q2->getVertex(i) != v) { v4 = q2->getVertex(i); break; @@ -589,9 +583,7 @@ static bool _tryToCollapseThatVertex2(GFace *gf, std::vector<MElement *> &e1, for(std::size_t j = 0; j < e.size(); ++j) { if(e[j] != q) { for(int k = 0; k < 4; k++) { - if(e[j]->getVertex(k) == v2) { - e[j]->setVertex(k, v1); - } + if(e[j]->getVertex(k) == v2) { e[j]->setVertex(k, v1); } } } } @@ -666,9 +658,7 @@ static bool _tryToCollapseThatVertex(GFace *gf, std::vector<MElement *> &e1, for(std::size_t j = 0; j < e.size(); ++j) { if(e[j] != q) { for(int k = 0; k < 4; k++) { - if(e[j]->getVertex(k) == v2) { - e[j]->setVertex(k, v1); - } + if(e[j]->getVertex(k) == v2) { e[j]->setVertex(k, v1); } } } } @@ -720,16 +710,14 @@ static bool has_none_of(std::set<MVertex *> const &touched, MVertex *const v1, { return touched.find(v1) == touched.end() && touched.find(v2) == touched.end() && - touched.find(v3) == touched.end() && - touched.find(v4) == touched.end(); + touched.find(v3) == touched.end() && touched.find(v4) == touched.end(); } static bool are_all_on_surface(MVertex *const v1, MVertex *const v2, - MVertex *const v3, MVertex *const v4, - GFace *gf) + MVertex *const v3, MVertex *const v4, GFace *gf) { - return v1->onWhat() == gf && v2->onWhat() == gf && - v3->onWhat() == gf && v4->onWhat() == gf; + return v1->onWhat() == gf && v2->onWhat() == gf && v3->onWhat() == gf && + v4->onWhat() == gf; } template <class InputIterator> @@ -781,8 +769,10 @@ static int _removeDiamonds(GFace *const gf) diamonds.push_back(q); } - else if(are_all_on_surface(v1, v2, v3, v4, gf) && are_size_three(it2, it4) && - _tryToCollapseThatVertex(gf, it2->second, it4->second, q, v2, v4)) { + else if(are_all_on_surface(v1, v2, v3, v4, gf) && + are_size_three(it2, it4) && + _tryToCollapseThatVertex(gf, it2->second, it4->second, q, v2, + v4)) { touched.insert(v1); touched.insert(v2); touched.insert(v3); @@ -875,9 +865,7 @@ static void _relocate(GFace *gf, MVertex *ver, double metric[3]; SPoint2 after(0, 0); double COUNT = 0.0; - for(auto it = - pts.begin(); - it != pts.end(); ++it) { + for(auto it = pts.begin(); it != pts.end(); ++it) { SPoint2 adj = it->second; SVector3 d(adj.x() - before.x(), adj.y() - before.y(), 0.0); d.normalize(); @@ -915,9 +903,7 @@ void getAllBoundaryLayerVertices(GFace *gf, std::set<MVertex *> &vs) vs.clear(); BoundaryLayerColumns *_columns = gf->getColumns(); if(!_columns) return; - for(auto it = - _columns->_data.begin(); - it != _columns->_data.end(); it++) { + for(auto it = _columns->_data.begin(); it != _columns->_data.end(); it++) { BoundaryLayerData &data = it->second; for(size_t i = 0; i < data._column.size(); i++) vs.insert(data._column[i]); } @@ -926,9 +912,11 @@ void getAllBoundaryLayerVertices(GFace *gf, std::set<MVertex *> &vs) void laplaceSmoothing(GFace *gf, int niter, bool infinity_norm) { if((gf->triangles.size() > 0 && gf->triangles[0]->getPolynomialOrder() > 1) || - (gf->quadrangles.size() > 0 && gf->quadrangles[0]->getPolynomialOrder() > 1)){ - Msg::Error("Surface mesh smoothing only valid for first order mesh (use the high-" - "order optimization tools for high-order meshes)"); + (gf->quadrangles.size() > 0 && + gf->quadrangles[0]->getPolynomialOrder() > 1)) { + Msg::Error( + "Surface mesh smoothing only valid for first order mesh (use the high-" + "order optimization tools for high-order meshes)"); return; } @@ -985,9 +973,10 @@ static void _recombineIntoQuads(GFace *gf, bool blossom, bool cubicGraph = 1) (*ite)->mesh_vertices.begin(), (*ite)->mesh_vertices.end()); if((*ite)->getBeginVertex()) - emb_edgeverts.insert(emb_edgeverts.end(), - (*ite)->getBeginVertex()->mesh_vertices.begin(), - (*ite)->getBeginVertex()->mesh_vertices.end()); + emb_edgeverts.insert( + emb_edgeverts.end(), + (*ite)->getBeginVertex()->mesh_vertices.begin(), + (*ite)->getBeginVertex()->mesh_vertices.end()); if((*ite)->getEndVertex()) emb_edgeverts.insert(emb_edgeverts.end(), (*ite)->getEndVertex()->mesh_vertices.begin(), @@ -1023,8 +1012,7 @@ static void _recombineIntoQuads(GFace *gf, bool blossom, bool cubicGraph = 1) else if(!it->second.second && it->second.first->getNumVertices() == 3) { for(int i = 0; i < 2; i++) { MVertex *const v = it->first.getVertex(i); - auto itv = - makeGraphPeriodic.find(v); + auto itv = makeGraphPeriodic.find(v); if(itv == makeGraphPeriodic.end()) { makeGraphPeriodic[v] = std::make_pair(it->second.first, static_cast<MElement *>(nullptr)); @@ -1047,11 +1035,12 @@ static void _recombineIntoQuads(GFace *gf, bool blossom, bool cubicGraph = 1) int ncount = gf->triangles.size(); if(ncount % 2 != 0) { Msg::Warning("Cannot apply Blossom: odd number of triangles (%d) in " - "surface %d", ncount, gf->tag()); + "surface %d", + ncount, gf->tag()); } else { - int ecount = cubicGraph ? (pairs.size() + makeGraphPeriodic.size()) : - pairs.size(); + int ecount = + cubicGraph ? (pairs.size() + makeGraphPeriodic.size()) : pairs.size(); Msg::Info("Blossom: %d internal %d closed", (int)pairs.size(), (int)makeGraphPeriodic.size()); Msg::Debug("Perfect Match Starts %d edges %d nodes", ecount, ncount); @@ -1084,8 +1073,7 @@ static void _recombineIntoQuads(GFace *gf, bool blossom, bool cubicGraph = 1) } if(cubicGraph) { - auto itv = - makeGraphPeriodic.begin(); + auto itv = makeGraphPeriodic.begin(); std::size_t CC = pairs.size(); for(; itv != makeGraphPeriodic.end(); ++itv) { elist[2 * CC] = t2n[itv->second.first]; @@ -1097,9 +1085,10 @@ static void _recombineIntoQuads(GFace *gf, bool blossom, bool cubicGraph = 1) double matzeit = 0.0; char MATCHFILE[256]; sprintf(MATCHFILE, ".face.match"); - if(perfect_match(ncount, nullptr, ecount, &elist, &elen, nullptr, MATCHFILE, 0, - 0, 0, 0, &matzeit)) { - Msg::Error("Perfect Match failed in quadrangulation, try something else"); + if(perfect_match(ncount, nullptr, ecount, &elist, &elen, nullptr, + MATCHFILE, 0, 0, 0, 0, &matzeit)) { + Msg::Error( + "Perfect Match failed in quadrangulation, try something else"); free(elist); pairs.clear(); } @@ -1111,7 +1100,8 @@ static void _recombineIntoQuads(GFace *gf, bool blossom, bool cubicGraph = 1) // FIXME ! if(an == 100000 /*|| an == 1000*/) { // toProcess.push_back(std::make_pair(n2t[i1],n2t[i2])); - // Msg::Warning("Extra edge found in blossom algorithm, optimization" + // Msg::Warning("Extra edge found in blossom algorithm, + // optimization" // "will be required"); } else { @@ -1175,9 +1165,9 @@ static void _recombineIntoQuads(GFace *gf, bool blossom, bool cubicGraph = 1) break; } } - gf->quadrangles.push_back - (new MQuadrangle(itp->n1, orientation < 0 ? itp->n3 : itp->n4, itp->n2, - orientation < 0 ? itp->n4 : itp->n3)); + gf->quadrangles.push_back( + new MQuadrangle(itp->n1, orientation < 0 ? itp->n3 : itp->n4, itp->n2, + orientation < 0 ? itp->n4 : itp->n3)); } } ++itp; @@ -1209,10 +1199,11 @@ static double printStats(GFace *gf, const char *message) Qav += Q; Qmin = std::min(Q, Qmin); } - Msg::Info("%s: %d quads, %d triangles, %d invalid quads, %d quads with Q < 0.1, " - "avg Q = %g, min Q = %g", message, gf->quadrangles.size(), - gf->triangles.size(), nbInv, nbBad, Qav / gf->quadrangles.size(), - Qmin); + Msg::Info( + "%s: %d quads, %d triangles, %d invalid quads, %d quads with Q < 0.1, " + "avg Q = %g, min Q = %g", + message, gf->quadrangles.size(), gf->triangles.size(), nbInv, nbBad, + Qav / gf->quadrangles.size(), Qmin); return Qmin; } @@ -1223,11 +1214,11 @@ static double printStats(GFace *gf, const char *message) // remove nodes, this will produce an invalide model mesh (and crash). static bool _isModelOkForTopologicalOpti(GModel *m) { - for(auto it = m->firstFace(); it != m->lastFace(); it++){ + for(auto it = m->firstFace(); it != m->lastFace(); it++) { GFace *gf = *it; - for(std::size_t j = 0; j < gf->getNumMeshElements(); j++){ + for(std::size_t j = 0; j < gf->getNumMeshElements(); j++) { MElement *e = gf->getMeshElement(j); - for(std::size_t k = 0; k < e->getNumVertices(); k++){ + for(std::size_t k = 0; k < e->getNumVertices(); k++) { GEntity *ge = e->getVertex(k)->onWhat(); if(!ge) return false; if(ge->dim() == 2 && ge != gf) return false; @@ -1245,25 +1236,23 @@ void recombineIntoQuads(GFace *gf, bool blossom, int topologicalOptiPasses, bool haveParam = (gf->geomType() != GEntity::DiscreteSurface); bool debug = (Msg::GetVerbosity() == 99); - if(debug) - gf->model()->writeMSH("recombine_0before.msh"); + if(debug) gf->model()->writeMSH("recombine_0before.msh"); _recombineIntoQuads(gf, blossom); - if(debug) - gf->model()->writeMSH("recombine_1raw.msh"); + if(debug) gf->model()->writeMSH("recombine_1raw.msh"); - if(haveParam && nodeRepositioning){ + if(haveParam && nodeRepositioning) { RelocateVertices(gf, CTX::instance()->mesh.nbSmoothing); - if(debug) - gf->model()->writeMSH("recombine_2smoothed.msh"); + if(debug) gf->model()->writeMSH("recombine_2smoothed.msh"); } if(topologicalOptiPasses > 0) { - if(!_isModelOkForTopologicalOpti(gf->model())){ - Msg::Info("Skipping topological optimization - mesh topology is not complete"); + if(!_isModelOkForTopologicalOpti(gf->model())) { + Msg::Info( + "Skipping topological optimization - mesh topology is not complete"); } - else{ + else { int iter = 0, nbTwoQuadNodes = 1, nbDiamonds = 1; while(nbTwoQuadNodes || nbDiamonds) { Msg::Debug("Topological optimization of quad mesh: pass %d", iter); @@ -1275,16 +1264,14 @@ void recombineIntoQuads(GFace *gf, bool blossom, int topologicalOptiPasses, iter++; if(iter > topologicalOptiPasses) break; } - if(debug) - gf->model()->writeMSH("recombine_3topo.msh"); + if(debug) gf->model()->writeMSH("recombine_3topo.msh"); } } // re-split bad quads into triangles quadsToTriangles(gf, minqual); - if(debug) - gf->model()->writeMSH("recombine_4quality.msh"); + if(debug) gf->model()->writeMSH("recombine_4quality.msh"); if(haveParam && nodeRepositioning) RelocateVertices(gf, CTX::instance()->mesh.nbSmoothing); @@ -1296,8 +1283,7 @@ void recombineIntoQuads(GFace *gf, bool blossom, int topologicalOptiPasses, blossom ? "Blossom" : "Simple", w2 - w1, t2 - t1); printStats(gf, name); - if(debug) - gf->model()->writeMSH("recombine_5final.msh"); + if(debug) gf->model()->writeMSH("recombine_5final.msh"); } void quadsToTriangles(GFace *gf, double minqual) @@ -1315,8 +1301,10 @@ void quadsToTriangles(GFace *gf, double minqual) new MTriangle(q->getVertex(1), q->getVertex(2), q->getVertex(3)); MTriangle *t22 = new MTriangle(q->getVertex(3), q->getVertex(0), q->getVertex(1)); - double qual1 = std::min(t11->gammaShapeMeasure(), t12->gammaShapeMeasure()); - double qual2 = std::min(t21->gammaShapeMeasure(), t22->gammaShapeMeasure()); + double qual1 = + std::min(t11->gammaShapeMeasure(), t12->gammaShapeMeasure()); + double qual2 = + std::min(t21->gammaShapeMeasure(), t22->gammaShapeMeasure()); double ori2 = dot(t21->getFace(0).normal(), t22->getFace(0).normal()); // choose (t11, t12) if it leads to the best quality OR if choosing (t21, // t22) would revert the orientation (which can happen if q is not convex) diff --git a/Mesh/meshGFaceTransfinite.cpp b/Mesh/meshGFaceTransfinite.cpp index 8039346216ce713cf5a2944949e716fe134cef69..f47c9a28dea65131ecd78af1ac982c7795a73fc8 100644 --- a/Mesh/meshGFaceTransfinite.cpp +++ b/Mesh/meshGFaceTransfinite.cpp @@ -57,8 +57,7 @@ void findTransfiniteCorners(GFace *gf, std::vector<MVertex *> &corners) // try reaaally hard for 3-sided faces if(corners.size() == 3) { GEdge *first = nullptr, *last = nullptr; - for(auto it = fedges.begin(); - it != fedges.end(); it++) { + for(auto it = fedges.begin(); it != fedges.end(); it++) { if(((*it)->getBeginVertex()->mesh_vertices[0] == corners[0] && (*it)->getEndVertex()->mesh_vertices[0] == corners[1]) || ((*it)->getBeginVertex()->mesh_vertices[0] == corners[1] && @@ -159,8 +158,7 @@ int MeshTransfiniteSurface(GFace *gf) // make sure that all bounding edges have begin/end points: everything in here // depends on it const std::vector<GEdge *> &edges = gf->edges(); - for(auto it = edges.begin(); - it != edges.end(); it++) { + for(auto it = edges.begin(); it != edges.end(); it++) { if(!(*it)->getBeginVertex() || !(*it)->getEndVertex()) { Msg::Error("Transfinite algorithm cannot be applied with curve %d which " "has no begin or end point", diff --git a/Mesh/meshGRegion.cpp b/Mesh/meshGRegion.cpp index 7cff106eb0db364da049d21841f3f074f671cb63..52701030a8fe889453bd69762c0c8edf5ebcdbbc 100644 --- a/Mesh/meshGRegion.cpp +++ b/Mesh/meshGRegion.cpp @@ -49,32 +49,31 @@ int splitQuadRecovery::buildPyramids(GModel *gm) Msg::Info("Generating pyramids for hybrid mesh..."); int npyram = 0; - for(auto it = gm->firstRegion(); it != gm->lastRegion(); it++){ + for(auto it = gm->firstRegion(); it != gm->lastRegion(); it++) { GRegion *gr = *it; if(gr->meshAttributes.method == MESH_TRANSFINITE) continue; if(gr->isFullyDiscrete()) continue; ExtrudeParams *ep = gr->meshAttributes.extrude; if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY) continue; - std::vector<GFace*> faces = gr->faces(); - for(std::size_t i = 0; i < faces.size(); i++){ + std::vector<GFace *> faces = gr->faces(); + for(std::size_t i = 0; i < faces.size(); i++) { GFace *gf = faces[i]; - for(std::size_t j = 0; j < gf->quadrangles.size(); j++){ - auto it2 = - _quad.find(gf->quadrangles[j]->getFace(0)); - if(it2 != _quad.end()){ + for(std::size_t j = 0; j < gf->quadrangles.size(); j++) { + auto it2 = _quad.find(gf->quadrangles[j]->getFace(0)); + if(it2 != _quad.end()) { npyram++; - gr->pyramids.push_back - (new MPyramid(it2->first.getVertex(0), it2->first.getVertex(1), - it2->first.getVertex(2), it2->first.getVertex(3), - it2->second)); + gr->pyramids.push_back(new MPyramid( + it2->first.getVertex(0), it2->first.getVertex(1), + it2->first.getVertex(2), it2->first.getVertex(3), it2->second)); gr->mesh_vertices.push_back(it2->second); - if(it2->second->onWhat()->dim() == 3){ - Msg::Error("Pyramid top vertex already classified on volume %d (!= %d) - " - "non-manifold quad boundaries not supported yet", - it2->second->onWhat()->tag(), gr->tag()); + if(it2->second->onWhat()->dim() == 3) { + Msg::Error( + "Pyramid top vertex already classified on volume %d (!= %d) - " + "non-manifold quad boundaries not supported yet", + it2->second->onWhat()->tag(), gr->tag()); } - else{ + else { it2->second->setEntity(gr); } } @@ -90,9 +89,7 @@ void MeshDelaunayVolume(std::vector<GRegion *> ®ions) if(regions.empty()) return; if(CTX::instance()->mesh.algo3d == ALGO_3D_HXT) { - if(meshGRegionHxt(regions) != 0){ - Msg::Error("HXT 3D mesh failed"); - } + if(meshGRegionHxt(regions) != 0) { Msg::Error("HXT 3D mesh failed"); } return; } @@ -114,10 +111,9 @@ void MeshDelaunayVolume(std::vector<GRegion *> ®ions) // replace faces with compounds if elements from compound surface meshes are // not reclassified on the original surfaces - if(CTX::instance()->mesh.compoundClassify == 0){ + if(CTX::instance()->mesh.compoundClassify == 0) { std::set<GFace *, GEntityPtrLessThan> comp; - for(auto it = allFacesSet.begin(); - it != allFacesSet.end(); it++){ + for(auto it = allFacesSet.begin(); it != allFacesSet.end(); it++) { GFace *gf = *it; if(!gf->compoundSurface) comp.insert(gf); @@ -162,7 +158,7 @@ void MeshDelaunayVolume(std::vector<GRegion *> ®ions) } // restore set of faces and embedded edges/vertices - if(CTX::instance()->mesh.compoundClassify == 0){ + if(CTX::instance()->mesh.compoundClassify == 0) { std::set<GFace *, GEntityPtrLessThan> comp; for(std::size_t i = 0; i < faces.size(); i++) { GFace *gf = faces[i]; @@ -174,7 +170,7 @@ void MeshDelaunayVolume(std::vector<GRegion *> ®ions) std::vector<GFace *> lcomp(comp.begin(), comp.end()); gr->set(lcomp); } - else{ + else { gr->set(faces); } gr->embeddedEdges() = oldEmbEdges; @@ -189,22 +185,21 @@ void MeshDelaunayVolume(std::vector<GRegion *> ®ions) } } else if(CTX::instance()->mesh.algo3d != ALGO_3D_INITIAL_ONLY) { - insertVerticesInRegion(gr, CTX::instance()->mesh.maxIterDelaunay3D, - 1., true, &sqr); + insertVerticesInRegion(gr, CTX::instance()->mesh.maxIterDelaunay3D, 1., + true, &sqr); - if(sqr.buildPyramids(gr->model())){ + if(sqr.buildPyramids(gr->model())) { Msg::Info("Optimizing pyramids for hybrid mesh..."); gr->model()->setAllVolumesPositive(); RelocateVerticesOfPyramids(regions, 3); - //RelocateVertices(regions, 3); + // RelocateVertices(regions, 3); Msg::Info("Done optimizing pyramids for hybrid mesh"); } // test: - // bool createBoundaryLayerOneLayer(GRegion *gr, std::vector<GFace *> & bls); - // createBoundaryLayerOneLayer(gr, allFaces); + // bool createBoundaryLayerOneLayer(GRegion *gr, std::vector<GFace *> & + // bls); createBoundaryLayerOneLayer(gr, allFaces); } - } void deMeshGRegion::operator()(GRegion *gr) @@ -271,8 +266,7 @@ bool buildFaceSearchStructure(GModel *model, fs_cont &search, while(fit != faces_to_consider.end()) { for(std::size_t i = 0; i < (*fit)->getNumMeshElements(); i++) { MFace ff = (*fit)->getMeshElement(i)->getFace(0); - if(!onlyTriangles || ff.getNumVertices() == 3) - search[ff] = *fit; + if(!onlyTriangles || ff.getNumVertices() == 3) search[ff] = *fit; } ++fit; } @@ -318,8 +312,7 @@ GEdge *findInEdgeSearchStructure(MVertex *p1, MVertex *p2, { MVertex *p = std::min(p1, p2); - for(auto it = search.lower_bound(p); - it != search.upper_bound(p); ++it) { + for(auto it = search.lower_bound(p); it != search.upper_bound(p); ++it) { MLine *l = it->second.first; GEdge *ge = it->second.second; if((l->getVertex(0) == p1 || l->getVertex(0) == p2) && diff --git a/Mesh/meshGRegionBoundaryLayer.cpp b/Mesh/meshGRegionBoundaryLayer.cpp index 1b234477b2285dc2323e09c9063300a01c399e9b..ef41e9927a5bbac6f43ea3a7ec788f3449b911bb 100644 --- a/Mesh/meshGRegionBoundaryLayer.cpp +++ b/Mesh/meshGRegionBoundaryLayer.cpp @@ -246,7 +246,8 @@ public: for(int k = 0; k < 2; k++) { MVertex *v = edges[i]->lines[j]->getVertex(k); auto it = _vertices.find(v); - if(it == _vertices.end()) Msg::Error("Unknow node in boundary layer"); + if(it == _vertices.end()) + Msg::Error("Unknow node in boundary layer"); it->add_line(edges[i]->lines[j], edges[i]); } } @@ -260,8 +261,7 @@ public: for(size_t i = 0; i < bls.size(); i++) { for(size_t j = 0; j < bls[i]->triangles.size(); j++) { MTriangle *t = bls[i]->triangles[j]; - auto it = - t_normals.find(t->getFace(0)); + auto it = t_normals.find(t->getFace(0)); SVector3 n; if(it == t_normals.end()) Msg::Error("Unknown face in boundary layer"); @@ -270,7 +270,8 @@ public: for(int k = 0; k < 3; k++) { MVertex *v = t->getVertex(k); auto it = _vertices.find(v); - if(it == _vertices.end()) Msg::Error("Unknown node in boundary layer"); + if(it == _vertices.end()) + Msg::Error("Unknown node in boundary layer"); it->add_triangle(t, n, bls[i]); } } @@ -307,27 +308,21 @@ public: MVertex *v2 = it->_triangles[k]->getVertex(2); GFace *gf = it->_gfaces[k]; if((v0 == l0 && v1 == l1) || (v0 == l1 && v1 == l0)) { - if(gf == f0) { - N[0] = it->_normals[k]; - } + if(gf == f0) { N[0] = it->_normals[k]; } if(gf == f1) { N[1] = it->_normals[k]; op1 = v2; } } if((v0 == l0 && v2 == l1) || (v0 == l1 && v2 == l0)) { - if(gf == f0) { - N[0] = it->_normals[k]; - } + if(gf == f0) { N[0] = it->_normals[k]; } if(gf == f1) { N[1] = it->_normals[k]; op1 = v1; } } if((v1 == l0 && v2 == l1) || (v1 == l1 && v2 == l0)) { - if(gf == f0) { - N[0] = it->_normals[k]; - } + if(gf == f0) { N[0] = it->_normals[k]; } if(gf == f1) { N[1] = it->_normals[k]; op1 = v0; @@ -335,7 +330,7 @@ public: } } double alpha = angle(N[0], N[1]); - if(op1){ + if(op1) { SVector3 dir(0.5 * (l0->x() + l1->x()) - op1->x(), 0.5 * (l0->y() + l1->y()) - op1->y(), 0.5 * (l0->z() + l1->z()) - op1->z()); @@ -365,8 +360,7 @@ public: void classify_corners() { auto it = _vertices.begin(); - for(; it != _vertices.end(); ++it) { - } + for(; it != _vertices.end(); ++it) {} } void add_fan(const blyr_mvertex &v) @@ -430,8 +424,7 @@ public: mean_plane plane; computeMeanPlaneSimple(aaa, plane); - auto - it = v._v_per_ridge.begin(); + auto it = v._v_per_ridge.begin(); std::vector<MLine *> plane_lines; std::map<MVertex *, MVertex *> plane_vertices; @@ -528,8 +521,7 @@ public: } std::map<int, MVertex *> plane_vertices_inv; - for(auto it = plane_vertices.begin(); - it != plane_vertices.end(); ++it) + for(auto it = plane_vertices.begin(); it != plane_vertices.end(); ++it) plane_vertices_inv[it->second->getNum()] = it->first; // printf("%d vertices there\n",plane_vertices_inv.size()); // printf("%d triangles\n",mesh.size()); @@ -729,8 +721,8 @@ public: if(!gf) Msg::Error("Topological error in 3D boundary layer generation"); GPoint gp = gf->closestPoint(p, initialGuess); - printf("adding a point %g %g %g in face %d\n", - n.x(), n.y(), n.z(), gf->tag()); + printf("adding a point %g %g %g in face %d\n", n.x(), n.y(), n.z(), + gf->tag()); MVertex *vf = new MFaceVertex(gp.x(), gp.y(), gp.z(), gf, gp.u(), gp.v()); gf->mesh_vertices.push_back(vf); @@ -742,14 +734,11 @@ public: blv._normals.push_back(it->_normals[j]); if(it->_gfaces[j] == gf) { for(int k = 0; k < 3; k++) { - if(t->getVertex(k) == it->_v) { - t->setVertex(k, vf); - } + if(t->getVertex(k) == it->_v) { t->setVertex(k, vf); } } } } - auto ite = - _vertices.find(blyr_mvertex(_externals_v[0])); + auto ite = _vertices.find(blyr_mvertex(_externals_v[0])); if(ite != _vertices.end()) { blv._v_per_face.push_back(ite->_v_per_face[0]); blv._n_per_vertex.push_back(n); @@ -772,8 +761,7 @@ public: std::pair<GFace *, GFace *> pa = std::make_pair(_internals[k]->_f[0], _internals[k]->_f[1]); it->_v_per_ridge[pa] = fan; - auto iti = - _vertices.find(blyr_mvertex(_internals_v[k])); + auto iti = _vertices.find(blyr_mvertex(_internals_v[k])); MVertex *o = iti->_v_per_face[0]; gf->quadrangles.push_back( new MQuadrangle(it->_v, iti->_v, o, vf)); @@ -880,7 +868,8 @@ public: } else { Msg::Error("Corner with %d internal ridges and %d external ridges " - "should be coded", nINTERNAL, nEXTERNAL); + "should be coded", + nINTERNAL, nEXTERNAL); printf("EXTERNALS :"); for(size_t i = 0; i < _externals.size(); i++) printf("%d ", _externals[i]->_ge->tag()); @@ -1069,7 +1058,7 @@ public: //%p\n",v->getNum(),iGe,jGe,gei->tag(),gej->tag(),gf->tag(),vplus[iGe]._v,vplus[jGe]._v); // printf("-------------------------------------- > //%d -- %d %d -- %d %d\n",gf->tag(), gei->tag(), - //gej->tag(),iGe,jGe); + // gej->tag(),iGe,jGe); vf = vplus[iGe]._v; } if(!vf || vf->onWhat() != _gr) { @@ -1214,8 +1203,7 @@ public: std::vector<MVertex *> fan0; std::vector<MVertex *> fan1; - auto it = - it0->_v_per_ridge.find(pa_pos); + auto it = it0->_v_per_ridge.find(pa_pos); if(it != it0->_v_per_ridge.end()) fan0 = it->second; else { @@ -1262,7 +1250,7 @@ public: MTriangle *t = v._triangles_at_corner[j]; /// TEMPORARY --> SHOULD BE A TET BUT I PREFER THAT FOR NOW FOR VIZU // printf("%p %p %p\n", - //t->getVertex(0),t->getVertex(1),t->getVertex(2)); + // t->getVertex(0),t->getVertex(1),t->getVertex(2)); _gr->prisms.push_back(new MPrism(v._v, v._v, v._v, t->getVertex(0), t->getVertex(1), t->getVertex(2))); } @@ -1286,9 +1274,7 @@ bool createBoundaryLayerOneLayer(GRegion *gr, std::vector<GFace *> &bls) // gr->mesh_vertices[i]; gr->mesh_vertices.clear(); - if(basic) { - mgr.extrude_vertices_basic(); - } + if(basic) { mgr.extrude_vertices_basic(); } else { Msg::Info("Classifying ridges (INTERNAL / EXTERNAL / FLAT)"); mgr.classify_ridges(); diff --git a/Mesh/meshGRegionCarveHole.cpp b/Mesh/meshGRegionCarveHole.cpp index cb080336d04081244259e7871340ca429a96ef23..115051f420bb11b534ab285bf9fe0abdc256b57e 100644 --- a/Mesh/meshGRegionCarveHole.cpp +++ b/Mesh/meshGRegionCarveHole.cpp @@ -129,8 +129,7 @@ void carveHole(GRegion *gr, int num, double distance, addFaces(gr->pyramids, faces); std::set<MVertex *> verts; - for(auto it = faces.begin(); - it != faces.end(); it++) { + for(auto it = faces.begin(); it != faces.end(); it++) { for(std::size_t i = 0; i < it->getNumVertices(); i++) { it->getVertex(i)->setEntity(gf); verts.insert(it->getVertex(i)); diff --git a/Mesh/meshGRegionDelaunayInsertion.cpp b/Mesh/meshGRegionDelaunayInsertion.cpp index 38082e5fbba08764ba5ccd34a5e0288df5dc1c64..4603e2906148c8c4c3bc141b1033d3f8a402230f 100644 --- a/Mesh/meshGRegionDelaunayInsertion.cpp +++ b/Mesh/meshGRegionDelaunayInsertion.cpp @@ -111,12 +111,12 @@ struct edgeContainerB { } }; -static void createAllEmbeddedEdges(GRegion *gr, - std::set<MEdge, MEdgeLessThan> &allEmbeddedEdges) +static void +createAllEmbeddedEdges(GRegion *gr, + std::set<MEdge, MEdgeLessThan> &allEmbeddedEdges) { std::vector<GEdge *> const &e = gr->embeddedEdges(); - for(auto it = e.begin(); it != e.end(); - ++it) { + for(auto it = e.begin(); it != e.end(); ++it) { for(std::size_t i = 0; i < (*it)->lines.size(); i++) { allEmbeddedEdges.insert( MEdge((*it)->lines[i]->getVertex(0), (*it)->lines[i]->getVertex(1))); @@ -127,8 +127,7 @@ static void createAllEmbeddedEdges(GRegion *gr, static void createAllEmbeddedEdges(GRegion *gr, edgeContainerB &embedded) { std::vector<GEdge *> const &e = gr->embeddedEdges(); - for(auto it = e.begin(); it != e.end(); - ++it) { + for(auto it = e.begin(); it != e.end(); ++it) { for(std::size_t i = 0; i < (*it)->lines.size(); i++) { embedded.addNewEdge( MEdge((*it)->lines[i]->getVertex(0), (*it)->lines[i]->getVertex(1))); @@ -136,12 +135,12 @@ static void createAllEmbeddedEdges(GRegion *gr, edgeContainerB &embedded) } } -static void createAllEmbeddedFaces(GRegion *gr, - std::set<MFace, MFaceLessThan> &allEmbeddedFaces) +static void +createAllEmbeddedFaces(GRegion *gr, + std::set<MFace, MFaceLessThan> &allEmbeddedFaces) { std::vector<GFace *> const &f = gr->embeddedFaces(); - for(auto it = f.begin(); it != f.end(); - ++it) { + for(auto it = f.begin(); it != f.end(); ++it) { for(std::size_t i = 0; i < (*it)->triangles.size(); i++) { allEmbeddedFaces.insert((*it)->triangles[i]->getFace(0)); } @@ -248,8 +247,9 @@ void connectTets_vector2_templ(std::size_t _size, ITER beg, ITER end, } template <class ITER> -void connectTets(ITER beg, ITER end, - const std::set<MFace, MFaceLessThan> *allEmbeddedFaces = nullptr) +void connectTets( + ITER beg, ITER end, + const std::set<MFace, MFaceLessThan> *allEmbeddedFaces = nullptr) { std::set<faceXtet> conn; while(beg != end) { @@ -310,8 +310,7 @@ static void removeFromCavity(std::vector<faceXtet> &shell, for(int i = 0; i < 4; i++) { faceXtet fxt2(toRemove.t1, i); - auto it = - std::find(shell.begin(), shell.end(), fxt2); + auto it = std::find(shell.begin(), shell.end(), fxt2); if(it == shell.end()) { MTet4 *opposite = toRemove.t1->getNeigh(toRemove.i1); if(opposite) { @@ -333,8 +332,7 @@ static void extendCavity(std::vector<faceXtet> &shell, MTet4 *opposite = t->getNeigh(toExtend.i1); for(int i = 0; i < 4; i++) { faceXtet fxt(opposite, i); - auto it = - std::find(shell.begin(), shell.end(), fxt); + auto it = std::find(shell.begin(), shell.end(), fxt); if(it == shell.end()) shell.push_back(fxt); else @@ -355,8 +353,7 @@ static bool verifyShell(MVertex *v, MTet4 *t, std::vector<faceXtet> &shell) faceXtet fxt(t, i); bool starShaped = fxt.visible(v); if(!starShaped) { - auto its = - std::find(shell.begin(), shell.end(), fxt); + auto its = std::find(shell.begin(), shell.end(), fxt); if(its == shell.end()) NBAD_AFTER++; else @@ -371,8 +368,7 @@ int makeCavityStarShaped(std::vector<faceXtet> &shell, std::vector<MTet4 *> &cavity, MVertex *v) { std::vector<faceXtet> wrong; - for(auto it = shell.begin(); it != shell.end(); - ++it) { + for(auto it = shell.begin(); it != shell.end(); ++it) { faceXtet &fxt = *it; bool starShaped = fxt.visible(v); if(!starShaped) { wrong.push_back(fxt); } @@ -399,7 +395,8 @@ int makeCavityStarShaped(std::vector<faceXtet> &shell, } wrong.erase(wrong.begin()); } - // printf("after : shell size %d cavity size %d\n", shell.size(), cavity.size()); + // printf("after : shell size %d cavity size %d\n", shell.size(), + // cavity.size()); return 1; } @@ -532,10 +529,8 @@ static void setLcs(MTriangle *t, double dy = vi->y() - vj->y(); double dz = vi->z() - vj->z(); double l = std::sqrt(dx * dx + dy * dy + dz * dz); - auto iti = - vSizes.find(vi); - auto itj = - vSizes.find(vj); + auto iti = vSizes.find(vi); + auto itj = vSizes.find(vj); if(CTX::instance()->mesh.lcExtendFromBoundary == 2) { // use smallest edge length if(iti == vSizes.end() || iti->second > l) vSizes[vi] = l; @@ -586,8 +581,7 @@ static void setLcs(MTetrahedron *t, // smallest tet edge if(bndVertices.find(vi) == bndVertices.end()) { - auto iti = - vSizes.find(vi); + auto iti = vSizes.find(vi); double const length = hypotenuse(vi->x() - vj->x(), vi->y() - vj->y(), vi->z() - vj->z()); @@ -596,8 +590,7 @@ static void setLcs(MTetrahedron *t, } if(bndVertices.find(vj) == bndVertices.end()) { - auto itj = - vSizes.find(vj); + auto itj = vSizes.find(vj); double const length = hypotenuse(vi->x() - vj->x(), vi->y() - vj->y(), vi->z() - vj->z()); @@ -641,8 +634,7 @@ GRegion *getRegionFromBoundingFaces(GModel *model, std::vector<GFace *> _faces = (*git)->faces(); if(_faces.size() == faces_bound.size()) { bool ok = true; - for(auto it = _faces.begin(); - it != _faces.end(); ++it) { + for(auto it = _faces.begin(); it != _faces.end(); ++it) { if(faces_bound.find(*it) == faces_bound.end()) ok = false; } if(ok) return *git; @@ -844,8 +836,9 @@ void adaptMeshGRegion::operator()(GRegion *gr) double t2 = Cpu(), w2 = TimeOfDay(); Msg::Info("%d edge swaps, %d face swaps, %d node collapse, %d node " "relocations (volume = %g): worst = %g / average = %g " - "(Wall %gs, CPU %gs)", nbESwap, nbFSwap, nbCollapse, nbReloc, - totalVolumeb, worst, avg / count, w2 - w1, t2 - t1); + "(Wall %gs, CPU %gs)", + nbESwap, nbFSwap, nbCollapse, nbReloc, totalVolumeb, worst, + avg / count, w2 - w1, t2 - t1); break; } @@ -864,7 +857,8 @@ void adaptMeshGRegion::operator()(GRegion *gr) for(int i = 0; i < nbRanges; i++) { double low = (double)i / nbRanges; double high = (double)(i + 1) / nbRanges; - Msg::Info("%3.2f < quality < %3.2f: %9d elements", low, high, quality_ranges[i]); + Msg::Info("%3.2f < quality < %3.2f: %9d elements", low, high, + quality_ranges[i]); } for(auto it = allTets.begin(); it != allTets.end(); ++it) { @@ -936,8 +930,9 @@ void optimizeMesh(GRegion *gr, const qmTetrahedron::Measures &qm) } } } - Msg::Info("Optimization starts (volume = %g) with worst = %g / average = %g:", - totalVolumeb, worst, avg / count); + Msg::Info( + "Optimization starts (volume = %g) with worst = %g / average = %g:", + totalVolumeb, worst, avg / count); for(int i = 0; i < nbRanges; i++) { double low = (double)i / nbRanges; double high = (double)(i + 1) / nbRanges; @@ -997,7 +992,7 @@ void optimizeMesh(GRegion *gr, const qmTetrahedron::Measures &qm) for(auto it = allTets.begin(); it != allTets.end(); ++it) { if(!(*it)->isDeleted()) { double qq = (*it)->getQuality(); - if(qq < qMin){ + if(qq < qMin) { for(int i = 0; i < 4; i++) { if(smoothVertex(*it, i, qm)) nbReloc++; } @@ -1024,15 +1019,14 @@ void optimizeMesh(GRegion *gr, const qmTetrahedron::Measures &qm) double t2 = Cpu(), w2 = TimeOfDay(); Msg::Info("%d edge swaps, %d node relocations (volume = %g): " "worst = %g / average = %g (Wall %gs, CPU %gs)", - nbESwap, nbReloc, totalVolumeb, worst, avg / count, - w2 - w1, t2 - t1); + nbESwap, nbReloc, totalVolumeb, worst, avg / count, w2 - w1, + t2 - t1); if(worstA != 0.0 && worst - worstA < 1.e-6) break; worstA = worst; } if(illegals.size()) { - Msg::Warning("%d ill-shaped tets are still in the mesh", - illegals.size()); + Msg::Warning("%d ill-shaped tets are still in the mesh", illegals.size()); } else { Msg::Info("No ill-shaped tets in the mesh :-)"); @@ -1148,19 +1142,17 @@ static int isCavityCompatibleWithEmbeddedEdges(std::vector<MTet4 *> &cavity, std::vector<faceXtet> &shell, edgeContainerB &allEmbeddedEdges) { - if (allEmbeddedEdges.empty())return 1; + if(allEmbeddedEdges.empty()) return 1; std::vector<MEdge> ed; ed.reserve(shell.size() * 3); - for(auto it = shell.begin(); it != shell.end(); - it++) { + for(auto it = shell.begin(); it != shell.end(); it++) { ed.push_back(MEdge(it->v[0], it->v[1])); ed.push_back(MEdge(it->v[1], it->v[2])); ed.push_back(MEdge(it->v[2], it->v[0])); } - for(auto itc = cavity.begin(); itc != cavity.end(); - ++itc) { + for(auto itc = cavity.begin(); itc != cavity.end(); ++itc) { for(int j = 0; j < 6; j++) { MEdge e = (*itc)->tet()->getEdge(j); if(std::find(ed.begin(), ed.end(), e) == ed.end() && @@ -1176,19 +1168,17 @@ static int isCavityCompatibleWithEmbeddedFace( const std::vector<MTet4 *> &cavity, const std::vector<faceXtet> &shell, const std::set<MFace, MFaceLessThan> &allEmbeddedFaces) { - if (allEmbeddedFaces.empty())return 1; + if(allEmbeddedFaces.empty()) return 1; std::vector<MFace> shellFaces; shellFaces.reserve(shell.size()); - for(auto it = shell.begin(); - it != shell.end(); it++) { + for(auto it = shell.begin(); it != shell.end(); it++) { const faceXtet &face = (*it); shellFaces.push_back( MFace(face.unsorted[0], face.unsorted[1], face.unsorted[2])); } - for(auto itc = cavity.begin(); - itc != cavity.end(); ++itc) { + for(auto itc = cavity.begin(); itc != cavity.end(); ++itc) { for(int j = 0; j < 4; j++) { MFace f = (*itc)->tet()->getFace(j); if((std::find(shellFaces.begin(), shellFaces.end(), f) == @@ -1220,10 +1210,10 @@ static void _deleteUnusedVertices(GRegion *gr) allverts.end()); } -void insertVerticesInRegion(GRegion *gr, int maxIter, double worstTetRadiusTarget, - bool _classify, splitQuadRecovery *sqr) +void insertVerticesInRegion(GRegion *gr, int maxIter, + double worstTetRadiusTarget, bool _classify, + splitQuadRecovery *sqr) { - #ifdef DEBUG_BOUNDARY_RECOVERY testIfBoundaryIsRecovered(gr); #endif @@ -1238,11 +1228,10 @@ void insertVerticesInRegion(GRegion *gr, int maxIter, double worstTetRadiusTarge std::map<MVertex *, double, MVertexPtrLessThan> vSizesMap; std::set<MVertex *, MVertexPtrLessThan> bndVertices; - for(auto rit = gr->model()->firstRegion(); - rit != gr->model()->lastRegion(); ++rit) { + for(auto rit = gr->model()->firstRegion(); rit != gr->model()->lastRegion(); + ++rit) { std::vector<GEdge *> const &e = (*rit)->embeddedEdges(); - for(auto it = e.begin(); it != e.end(); - ++it) { + for(auto it = e.begin(); it != e.end(); ++it) { for(std::size_t i = 0; i < (*it)->lines.size(); i++) { MVertex *vi = (*it)->lines[i]->getVertex(0); MVertex *vj = (*it)->lines[i]->getVertex(1); @@ -1251,10 +1240,8 @@ void insertVerticesInRegion(GRegion *gr, int maxIter, double worstTetRadiusTarge double dz = vi->z() - vj->z(); double l = std::sqrt(dx * dx + dy * dy + dz * dz); - auto iti = - vSizesMap.find(vi); - auto itj = - vSizesMap.find(vj); + auto iti = vSizesMap.find(vi); + auto itj = vSizesMap.find(vj); // smallest tet edge if(iti == vSizesMap.end() || iti->second > l) vSizesMap[vi] = l; @@ -1263,21 +1250,19 @@ void insertVerticesInRegion(GRegion *gr, int maxIter, double worstTetRadiusTarge } } - for(auto rit = gr->model()->firstRegion(); - rit != gr->model()->lastRegion(); ++rit) { + for(auto rit = gr->model()->firstRegion(); rit != gr->model()->lastRegion(); + ++rit) { std::vector<GVertex *> const &vertices = (*rit)->embeddedVertices(); - for(auto it = vertices.begin(); - it != vertices.end(); ++it) { + for(auto it = vertices.begin(); it != vertices.end(); ++it) { MVertex *v = (*it)->getMeshVertex(0); double l = (*it)->prescribedMeshSizeAtVertex(); - auto itv = - vSizesMap.find(v); + auto itv = vSizesMap.find(v); if(itv == vSizesMap.end() || itv->second > l) vSizesMap[v] = l; } } - for(auto it = gr->model()->firstFace(); - it != gr->model()->lastFace(); ++it) { + for(auto it = gr->model()->firstFace(); it != gr->model()->lastFace(); + ++it) { GFace *gf = *it; for(std::size_t i = 0; i < gf->triangles.size(); i++) { setLcs(gf->triangles[i], vSizesMap, bndVertices); @@ -1286,9 +1271,7 @@ void insertVerticesInRegion(GRegion *gr, int maxIter, double worstTetRadiusTarge for(std::size_t i = 0; i < gr->tetrahedra.size(); i++) setLcs(gr->tetrahedra[i], vSizesMap, bndVertices); - for(auto it = - vSizesMap.begin(); - it != vSizesMap.end(); ++it) { + for(auto it = vSizesMap.begin(); it != vSizesMap.end(); ++it) { it->first->setIndex(NUM++); vSizes.push_back(it->second); vSizesBGM.push_back(it->second); @@ -1312,8 +1295,7 @@ void insertVerticesInRegion(GRegion *gr, int maxIter, double worstTetRadiusTarge buildFaceSearchStructure(gr->model(), search, true); // only triangles if(sqr) search.insert(sqr->getTri().begin(), sqr->getTri().end()); - for(auto it = allTets.begin(); it != allTets.end(); - ++it) { + for(auto it = allTets.begin(); it != allTets.end(); ++it) { if(!(*it)->onWhat()) { std::list<MTet4 *> theRegion; std::set<GFace *> faces_bound; @@ -1331,15 +1313,13 @@ void insertVerticesInRegion(GRegion *gr, int maxIter, double worstTetRadiusTarge // a geometrical region (with no mesh) associated to the list of faces // has been found Msg::Info("Found volume %d", myGRegion->tag()); - for(auto it2 = theRegion.begin(); - it2 != theRegion.end(); ++it2) { + for(auto it2 = theRegion.begin(); it2 != theRegion.end(); ++it2) { (*it2)->setOnWhat(myGRegion); // Make sure that Steiner points will end up in the right region std::vector<MVertex *> vertices; (*it2)->tet()->getVertices(vertices); - for(auto itv = vertices.begin(); - itv != vertices.end(); ++itv) { + for(auto itv = vertices.begin(); itv != vertices.end(); ++itv) { if((*itv)->onWhat() != nullptr && (*itv)->onWhat()->dim() == 3 && (*itv)->onWhat() != myGRegion) { myGRegion->addMeshVertex((*itv)); @@ -1351,8 +1331,7 @@ void insertVerticesInRegion(GRegion *gr, int maxIter, double worstTetRadiusTarge else { // the tets are in the void Msg::Info("Found void region"); - for(auto it2 = theRegion.begin(); - it2 != theRegion.end(); ++it2) + for(auto it2 = theRegion.begin(); it2 != theRegion.end(); ++it2) (*it2)->setDeleted(true); } } @@ -1374,8 +1353,8 @@ void insertVerticesInRegion(GRegion *gr, int maxIter, double worstTetRadiusTarge // store all embedded faces std::set<MFace, MFaceLessThan> allEmbeddedFaces; edgeContainerB allEmbeddedEdges; - for(auto it = gr->model()->firstRegion(); - it != gr->model()->lastRegion(); ++it) { + for(auto it = gr->model()->firstRegion(); it != gr->model()->lastRegion(); + ++it) { createAllEmbeddedFaces((*it), allEmbeddedFaces); createAllEmbeddedEdges((*it), allEmbeddedEdges); } @@ -1408,8 +1387,10 @@ void insertVerticesInRegion(GRegion *gr, int maxIter, double worstTetRadiusTarge } else { if(ITER++ % 500 == 0) - Msg::Info("It. %d - %d nodes created - worst tet radius %g (nodes removed %d %d)", - ITER - 1, REALCOUNT, worst->getRadius(), COUNT_MISS_1, COUNT_MISS_2); + Msg::Info("It. %d - %d nodes created - worst tet radius %g (nodes " + "removed %d %d)", + ITER - 1, REALCOUNT, worst->getRadius(), COUNT_MISS_1, + COUNT_MISS_2); if(worst->getRadius() < worstTetRadiusTarget) break; double center[3]; double uvw[3]; @@ -1432,8 +1413,7 @@ void insertVerticesInRegion(GRegion *gr, int maxIter, double worstTetRadiusTarge MVertex vv(center[0], center[1], center[2], worst->onWhat()); findCavity(shell, cavity, &vv, worst); bool FOUND = false; - for(auto itc = cavity.begin(); - itc != cavity.end(); ++itc) { + for(auto itc = cavity.begin(); itc != cavity.end(); ++itc) { MTetrahedron *toto = (*itc)->tet(); // (*itc)->setDeleted(false); toto->xyz2uvw(center, uvw); @@ -1447,7 +1427,8 @@ void insertVerticesInRegion(GRegion *gr, int maxIter, double worstTetRadiusTarge if(FOUND && (!allEmbeddedEdges.empty() || !allEmbeddedFaces.empty())) { FOUND = - isCavityCompatibleWithEmbeddedEdges(cavity, shell, allEmbeddedEdges) && + isCavityCompatibleWithEmbeddedEdges(cavity, shell, + allEmbeddedEdges) && isCavityCompatibleWithEmbeddedFace(cavity, shell, allEmbeddedFaces); } @@ -1458,7 +1439,7 @@ void insertVerticesInRegion(GRegion *gr, int maxIter, double worstTetRadiusTarge new MVertex(center[0], center[1], center[2], worst->onWhat()); v->setIndex(NUM++); #ifdef PRINT_TETS - printTets ("before.pos", cavity, true); + printTets("before.pos", cavity, true); #endif bool starShaped = true; bool correctCavity = false; @@ -1487,15 +1468,15 @@ void insertVerticesInRegion(GRegion *gr, int maxIter, double worstTetRadiusTarge uvw[0] * vSizes[worst->tet()->getVertex(1)->getIndex()] + uvw[1] * vSizes[worst->tet()->getVertex(2)->getIndex()] + uvw[2] * vSizes[worst->tet()->getVertex(3)->getIndex()]; - double lc2 = BGM_MeshSize(worst->onWhat(), 0, 0, center[0], center[1], center[2]); + double lc2 = + BGM_MeshSize(worst->onWhat(), 0, 0, center[0], center[1], center[2]); if(correctedCavityIncompatibleWithEmbeddedEntities || !starShaped || !insertVertexB(shell, cavity, v, lc1, lc2, vSizes, vSizesBGM, worst, myFactory, allTets, allEmbeddedFaces)) { COUNT_MISS_1++; myFactory.changeTetRadius(allTets.begin(), 0.); - for(auto itc = cavity.begin(); - itc != cavity.end(); ++itc) + for(auto itc = cavity.begin(); itc != cavity.end(); ++itc) (*itc)->setDeleted(false); delete v; NUM--; @@ -1511,8 +1492,7 @@ void insertVerticesInRegion(GRegion *gr, int maxIter, double worstTetRadiusTarge else { myFactory.changeTetRadius(allTets.begin(), 0.0); COUNT_MISS_2++; - for(auto itc = cavity.begin(); - itc != cavity.end(); ++itc) + for(auto itc = cavity.begin(); itc != cavity.end(); ++itc) (*itc)->setDeleted(false); } } @@ -1529,19 +1509,17 @@ void insertVerticesInRegion(GRegion *gr, int maxIter, double worstTetRadiusTarge double t2 = TimeOfDay(); double dt = (t2 - t1); int COUNT_MISS = COUNT_MISS_1 + COUNT_MISS_2; - Msg::Info("3D refinement terminated (%d nodes total):", - (int)vSizes.size()); + Msg::Info("3D refinement terminated (%d nodes total):", (int)vSizes.size()); Msg::Info(" - %d Delaunay cavities modified for star shapeness", NB_CORRECTION_OF_CAVITY); Msg::Info(" - %d nodes could not be inserted", COUNT_MISS); - Msg::Info(" - %d tetrahedra created in %g sec. (%d tets/s)", - allTets.size(), dt, (int)(allTets.size() / dt)); + Msg::Info(" - %d tetrahedra created in %g sec. (%d tets/s)", allTets.size(), + dt, (int)(allTets.size() / dt)); // relocate vertices int nbReloc = 0; for(int SM = 0; SM < CTX::instance()->mesh.nbSmoothing; SM++) { - for(auto it = allTets.begin(); it != allTets.end(); - ++it) { + for(auto it = allTets.begin(); it != allTets.end(); ++it) { if(!(*it)->isDeleted()) { double qq = (*it)->getQuality(); if(qq < .4) @@ -1569,13 +1547,12 @@ void insertVerticesInRegion(GRegion *gr, int maxIter, double worstTetRadiusTarge // do a 3D delaunay mesh assuming a set of vertices void delaunayMeshIn3D(std::vector<MVertex *> &v, - std::vector<MTetrahedron *> &result, - bool removeBox) + std::vector<MTetrahedron *> &result, bool removeBox) { Msg::Info("Tetrahedrizing %d nodes...", v.size()); double t1 = Cpu(), w1 = TimeOfDay(); delaunayTriangulation(1, 1, v, result, removeBox); double t2 = Cpu(), w2 = TimeOfDay(); - Msg::Info("Done tetrahedrizing %d nodes (Wall %gs, CPU %gs)", - v.size(), w2 - w1, t2 - t1); + Msg::Info("Done tetrahedrizing %d nodes (Wall %gs, CPU %gs)", v.size(), + w2 - w1, t2 - t1); } diff --git a/Mesh/meshGRegionExtruded.cpp b/Mesh/meshGRegionExtruded.cpp index d90d2e5ac52c799f6794f4bd5c1de23aca4d27f7..dfb9c0ecad9abb6fa9ea0558d62793c548ba254e 100644 --- a/Mesh/meshGRegionExtruded.cpp +++ b/Mesh/meshGRegionExtruded.cpp @@ -112,7 +112,8 @@ static void createHexPri(std::vector<MVertex *> &v, GRegion *to, addHexahedron(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], to); if(j && warningReg != to->tag()) { warningReg = to->tag(); - Msg::Warning("Degenerated hexahedron in extrusion of volume %d", to->tag()); + Msg::Warning("Degenerated hexahedron in extrusion of volume %d", + to->tag()); } } } @@ -164,8 +165,7 @@ static void extrudeMesh(GFace *from, GRegion *to, MVertexRTree &pos) // add all vertices on surface seams std::set<MVertex *> seam; std::vector<GEdge *> const &l_edges = from->edges(); - for(auto it = l_edges.begin(); - it != l_edges.end(); ++it) { + for(auto it = l_edges.begin(); it != l_edges.end(); ++it) { if((*it)->isSeam(from)) { seam.insert((*it)->mesh_vertices.begin(), (*it)->mesh_vertices.end()); if((*it)->getBeginVertex()) @@ -237,17 +237,15 @@ static void extrudeMesh(GFace *from, GRegion *to, MVertexRTree &pos) static void insertAllVertices(GRegion *gr, MVertexRTree &pos) { pos.insert(gr->mesh_vertices); - std::vector<MVertex*> embedded = gr->getEmbeddedMeshVertices(); + std::vector<MVertex *> embedded = gr->getEmbeddedMeshVertices(); pos.insert(embedded); std::vector<GFace *> faces = gr->faces(); - for(auto itf = faces.begin(); itf != faces.end(); - itf++) { + for(auto itf = faces.begin(); itf != faces.end(); itf++) { pos.insert((*itf)->mesh_vertices); std::vector<MVertex *> embedded = (*itf)->getEmbeddedMeshVertices(); pos.insert(embedded); std::vector<GEdge *> const &edges = (*itf)->edges(); - for(auto ite = edges.begin(); ite != edges.end(); - ite++) { + for(auto ite = edges.begin(); ite != edges.end(); ite++) { pos.insert((*ite)->mesh_vertices); if((*ite)->getBeginVertex()) pos.insert((*ite)->getBeginVertex()->mesh_vertices); @@ -318,8 +316,7 @@ static void deleteEdge(MVertex *v1, MVertex *v2, // subdivide the 3 lateral faces of each prism static void phase1(GRegion *gr, MVertexRTree &pos, - std::set<std::pair<MVertex *, MVertex *> > &edges, - int ntry) + std::set<std::pair<MVertex *, MVertex *> > &edges, int ntry) { ExtrudeParams *ep = gr->meshAttributes.extrude; GFace *from = gr->model()->getFaceByTag(std::abs(ep->geo.Source)); @@ -330,15 +327,12 @@ static void phase1(GRegion *gr, MVertexRTree &pos, for(int k = 0; k < ep->mesh.NbElmLayer[j]; k++) { std::vector<MVertex *> v; if(getExtrudedVertices(from->triangles[i], ep, j, k, pos, v) == 6) { - if(ntry == 1){ - if(!edgeExists(v[0], v[4], edges)) - createEdge(v[1], v[3], edges); - if(!edgeExists(v[4], v[2], edges)) - createEdge(v[1], v[5], edges); - if(!edgeExists(v[3], v[2], edges)) - createEdge(v[0], v[5], edges); + if(ntry == 1) { + if(!edgeExists(v[0], v[4], edges)) createEdge(v[1], v[3], edges); + if(!edgeExists(v[4], v[2], edges)) createEdge(v[1], v[5], edges); + if(!edgeExists(v[3], v[2], edges)) createEdge(v[0], v[5], edges); } - else{ // from Michel Benhamou + else { // from Michel Benhamou if(v[1]->getNum() < v[0]->getNum()) createEdge(v[1], v[3], edges); else @@ -536,9 +530,10 @@ int SubdivideExtrudedMesh(GModel *m) edges.clear(); break; } - else{ - Msg::Error("Unable to subdivide extruded mesh: change surface mesh or " - "recombine extrusion instead"); + else { + Msg::Error( + "Unable to subdivide extruded mesh: change surface mesh or " + "recombine extrusion instead"); return -1; } } @@ -556,21 +551,19 @@ int SubdivideExtrudedMesh(GModel *m) for(std::size_t i = 0; i < gr->hexahedra.size(); i++) delete gr->hexahedra[i]; gr->hexahedra.clear(); - for(std::size_t i = 0; i < gr->prisms.size(); i++) - delete gr->prisms[i]; + for(std::size_t i = 0; i < gr->prisms.size(); i++) delete gr->prisms[i]; gr->prisms.clear(); - for(std::size_t i = 0; i < gr->pyramids.size(); i++) - delete gr->pyramids[i]; + for(std::size_t i = 0; i < gr->pyramids.size(); i++) delete gr->pyramids[i]; gr->pyramids.clear(); phase3(gr, pos, edges); } // remesh bounding surfaces, to make them compatible with the volume mesh - std::set<GFace*> faces; + std::set<GFace *> faces; for(std::size_t i = 0; i < regions.size(); i++) { GRegion *gr = regions[i]; std::vector<GFace *> f = gr->faces(); - for(std::size_t i = 0; i < f.size(); i++){ + for(std::size_t i = 0; i < f.size(); i++) { ExtrudeParams *ep = f[i]->meshAttributes.extrude; // TODO: this does not yet handle swapping of edges in COPIED_ENTITY // surfaces, whose mesh is copied during extrusion (the "top" @@ -586,10 +579,9 @@ int SubdivideExtrudedMesh(GModel *m) int nIter = 0; while(1) { int nPending = 0; - for(auto it = faces.begin(); it != faces.end(); - it++) { + for(auto it = faces.begin(); it != faces.end(); it++) { GFace *gf = *it; - if(gf->meshStatistics.status == GFace::PENDING){ + if(gf->meshStatistics.status == GFace::PENDING) { Msg::Info("Remeshing surface %d", gf->tag()); for(std::size_t i = 0; i < gf->triangles.size(); i++) delete gf->triangles[i]; @@ -602,7 +594,7 @@ int SubdivideExtrudedMesh(GModel *m) } } if(!nPending) break; - if(nIter++ > 10){ + if(nIter++ > 10) { Msg::Warning("Could not remesh all subdivided surfaces"); break; } diff --git a/Mesh/meshGRegionHxt.cpp b/Mesh/meshGRegionHxt.cpp index 541f8fc82759937a0bcfe9c3a71c32dc0271ab1f..4a009caf8e06ea6d9ba1f6cd9e70801f6fced051 100644 --- a/Mesh/meshGRegionHxt.cpp +++ b/Mesh/meshGRegionHxt.cpp @@ -39,24 +39,22 @@ static HXTStatus messageCallback(HXTMessage *msg) return HXT_STATUS_OK; } -static HXTStatus nodalSizesCallBack(double *pts, uint32_t* volume, +static HXTStatus nodalSizesCallBack(double *pts, uint32_t *volume, size_t numPts, void *userData) { - std::vector<GRegion *>* allGR = (std::vector<GRegion *>*) userData; + std::vector<GRegion *> *allGR = (std::vector<GRegion *> *)userData; double lcGlob = CTX::instance()->lc; int useInterpolatedSize = CTX::instance()->mesh.lcExtendFromBoundary; - HXT_INFO("Mesh size callback %suse interpolated size", useInterpolatedSize ? - "" : "does not "); + HXT_INFO("Mesh size callback %suse interpolated size", + useInterpolatedSize ? "" : "does not "); for(size_t i = 0; i < numPts; i++) { GRegion *gr = (*allGR)[volume[i]]; - double lc = std::min(lcGlob, - BGM_MeshSizeWithoutScaling(gr, 0, 0, - pts[4 * i + 0], - pts[4 * i + 1], - pts[4 * i + 2])); + double lc = std::min( + lcGlob, BGM_MeshSizeWithoutScaling(gr, 0, 0, pts[4 * i + 0], + pts[4 * i + 1], pts[4 * i + 2])); if(useInterpolatedSize && pts[4 * i + 3] > 0.0) pts[4 * i + 3] = std::min(pts[4 * i + 3], lc); else @@ -66,8 +64,7 @@ static HXTStatus nodalSizesCallBack(double *pts, uint32_t* volume, return HXT_STATUS_OK; } -static HXTStatus getAllSurfaces(std::vector<GRegion *> ®ions, - HXTMesh *m, +static HXTStatus getAllSurfaces(std::vector<GRegion *> ®ions, HXTMesh *m, std::vector<GFace *> &allSurfaces) { std::set<GFace *, GEntityPtrLessThan> allSurfacesSet; @@ -109,8 +106,7 @@ static HXTStatus getAllSurfaces(std::vector<GRegion *> ®ions, } static HXTStatus getAllCurves(std::vector<GRegion *> ®ions, - std::vector<GFace *> &surfaces, - HXTMesh *m, + std::vector<GFace *> &surfaces, HXTMesh *m, std::vector<GEdge *> &allCurves) { if(m) { @@ -365,10 +361,10 @@ HXTStatus Gmsh2Hxt(std::vector<GRegion *> ®ions, HXTMesh *m, m->vertices.coord[4 * count + 1] = v->y(); m->vertices.coord[4 * count + 2] = v->z(); m->vertices.coord[4 * count + 3] = 0; - if(CTX::instance()->mesh.lcFromPoints) { // size on embedded points in volume + if(CTX::instance() + ->mesh.lcFromPoints) { // size on embedded points in volume auto it = vlc.find(v); - if(it != vlc.end()) - m->vertices.coord[4 * count + 3] = it->second; + if(it != vlc.end()) m->vertices.coord[4 * count + 3] = it->second; } v2c[v] = count; c2v[count++] = v; @@ -445,22 +441,21 @@ static HXTStatus _meshGRegionHxt(std::vector<GRegion *> ®ions) 1, // int stat; 1, // int refine; CTX::instance()->mesh.optimize, // int optimize; - { // quality + { + // quality nullptr, // double (*callback)(.., userData) nullptr, // void* userData; CTX::instance()->mesh.optimizeThreshold // double qualityMin; }, - { // nodalSize - - // FIXME: put NULL when the callback is not needed (when we use the - // interpolated point size anyway) - nodalSizesCallBack, // HXTStatus (*callback)(double*, size_t, void* userData) - ®ions, // void* meshSizeData; - CTX::instance()->mesh.lcMin, - CTX::instance()->mesh.lcMax, - CTX::instance()->mesh.lcFactor * regions[0]->getMeshSizeFactor() - } - }; + {// nodalSize + + // FIXME: put NULL when the callback is not needed (when we use the + // interpolated point size anyway) + nodalSizesCallBack, // HXTStatus (*callback)(double*, size_t, void* + // userData) + ®ions, // void* meshSizeData; + CTX::instance()->mesh.lcMin, CTX::instance()->mesh.lcMax, + CTX::instance()->mesh.lcFactor * regions[0]->getMeshSizeFactor()}}; HXT_CHECK(hxtTetMesh(mesh, &options)); @@ -483,8 +478,9 @@ static HXTStatus _delaunayMeshIn3DHxt(std::vector<MVertex *> &verts, HXT_CHECK(hxtMeshCreate(&mesh)); size_t nvert = verts.size(); - HXT_CHECK(hxtAlignedMalloc(&mesh->vertices.coord, nvert * 4 * sizeof(double))); - for (size_t i = 0; i < nvert; i++) { + HXT_CHECK( + hxtAlignedMalloc(&mesh->vertices.coord, nvert * 4 * sizeof(double))); + for(size_t i = 0; i < nvert; i++) { mesh->vertices.coord[4 * i + 0] = verts[i]->x(); mesh->vertices.coord[4 * i + 1] = verts[i]->y(); mesh->vertices.coord[4 * i + 2] = verts[i]->z(); @@ -505,23 +501,25 @@ static HXTStatus _delaunayMeshIn3DHxt(std::vector<MVertex *> &verts, 0 // delaunayThreads (0 = omp_get_max_threads) }; - //HXT_CHECK(hxtDelaunay(mesh, &delOptions)); - HXTNodeInfo* nodeInfo; - HXT_CHECK(hxtAlignedMalloc(&nodeInfo, sizeof(HXTNodeInfo) * mesh->vertices.num)); + // HXT_CHECK(hxtDelaunay(mesh, &delOptions)); + HXTNodeInfo *nodeInfo; + HXT_CHECK( + hxtAlignedMalloc(&nodeInfo, sizeof(HXTNodeInfo) * mesh->vertices.num)); for(uint32_t i = 0; i < mesh->vertices.num; i++) { nodeInfo[i].node = i; nodeInfo[i].status = HXT_STATUS_TRYAGAIN; } - HXT_CHECK(hxtDelaunaySteadyVertices(mesh, &delOptions, nodeInfo, mesh->vertices.num)); + HXT_CHECK( + hxtDelaunaySteadyVertices(mesh, &delOptions, nodeInfo, mesh->vertices.num)); HXT_CHECK(hxtAlignedFree(&nodeInfo)); for(size_t i = 0; i < mesh->tetrahedra.num; i++) { - if(mesh->tetrahedra.node[i*4 + 3] != UINT32_MAX){ + if(mesh->tetrahedra.node[i * 4 + 3] != UINT32_MAX) { uint32_t myColor = mesh->tetrahedra.color ? mesh->tetrahedra.color[i] : 0; - if (myColor != HXT_COLOR_OUT) { + if(myColor != HXT_COLOR_OUT) { uint32_t *n = &mesh->tetrahedra.node[4 * i]; - tets.push_back(new MTetrahedron(verts[n[0]], verts[n[1]], - verts[n[2]], verts[n[3]])); + tets.push_back( + new MTetrahedron(verts[n[0]], verts[n[1]], verts[n[2]], verts[n[3]])); } } } @@ -537,8 +535,8 @@ void delaunayMeshIn3DHxt(std::vector<MVertex *> &v, double t1 = Cpu(), w1 = TimeOfDay(); _delaunayMeshIn3DHxt(v, tets); double t2 = Cpu(), w2 = TimeOfDay(); - Msg::Info("Done tetrahedrizing %d nodes (Wall %gs, CPU %gs)", - v.size(), w2 - w1, t2 - t1); + Msg::Info("Done tetrahedrizing %d nodes (Wall %gs, CPU %gs)", v.size(), + w2 - w1, t2 - t1); } #else @@ -549,7 +547,8 @@ int meshGRegionHxt(std::vector<GRegion *> ®ions) return -1; } -void delaunayMeshIn3DHxt(std::vector<MVertex *> &v, std::vector<MTetrahedron *> &tets) +void delaunayMeshIn3DHxt(std::vector<MVertex *> &v, + std::vector<MTetrahedron *> &tets) { Msg::Error("Gmsh should be compiled with Hxt to enable this option"); } diff --git a/Mesh/meshGRegionLocalMeshMod.cpp b/Mesh/meshGRegionLocalMeshMod.cpp index aae87d6bc0a2bfe9aef3d449c59d93d71a2b1362..28db32c04c7f49463b58e83663301c25eacae062 100644 --- a/Mesh/meshGRegionLocalMeshMod.cpp +++ b/Mesh/meshGRegionLocalMeshMod.cpp @@ -49,9 +49,7 @@ void computeNeighboringTetsOfACavity(const std::vector<MTet4 *> &cavity, } if(!found) { for(std::size_t k = 0; k < cavity.size(); k++) { - if(cavity[k] == neigh) { - found = true; - } + if(cavity[k] == neigh) { found = true; } } } if(!found) outside.push_back(neigh); @@ -832,11 +830,9 @@ int LaplaceSmoothing(GRegion *gr) int N = 0; for(std::size_t i = 0; i < gr->mesh_vertices.size(); i++) { MVertex *v = gr->mesh_vertices[i]; - auto it = - vertexToElement.lower_bound(v); + auto it = vertexToElement.lower_bound(v); auto it_low = it; - auto it_up = - vertexToElement.upper_bound(v); + auto it_up = vertexToElement.upper_bound(v); double minQual = 1.e22; double volTot = 0.0; double xold = v->x(), yold = v->y(), zold = v->z(); diff --git a/Mesh/meshGRegionMMG.cpp b/Mesh/meshGRegionMMG.cpp index 392101dbd40ffef470577b51e1c687b5a9ab5c47..607340a31683014894e671a745747bb3371ed95a 100644 --- a/Mesh/meshGRegionMMG.cpp +++ b/Mesh/meshGRegionMMG.cpp @@ -58,8 +58,8 @@ static void MMG2gmsh(GRegion *gr, MMG5_pMesh mmg, // Store the tets from the Mmg structures into the Gmsh structures for(int k = 1; k <= ne; k++) { int v1mmg, v2mmg, v3mmg, v4mmg; - if(MMG3D_Get_tetrahedron(mmg, &v1mmg, &v2mmg, &v3mmg, &v4mmg, &ref, nullptr) != - 1) + if(MMG3D_Get_tetrahedron(mmg, &v1mmg, &v2mmg, &v3mmg, &v4mmg, &ref, + nullptr) != 1) Msg::Error("Mmg3d: unable to get tetrahedron %d", k); MVertex *v1 = kToMVertex[v1mmg]; @@ -135,8 +135,7 @@ static void gmsh2MMG(GRegion *gr, MMG5_pMesh mmg, MMG5_pSol sol, double L = t->maxEdge(); for(int k = 0; k < 3; k++) { MVertex *v = t->getVertex(k); - auto itv = - LCS.find(v); + auto itv = LCS.find(v); if(itv != LCS.end()) { itv->second.first += L; itv->second.second++; @@ -150,8 +149,7 @@ static void gmsh2MMG(GRegion *gr, MMG5_pMesh mmg, MMG5_pSol sol, int k = 1; std::map<int, int> gmsh2mmg_num; - for(auto it = allVertices.begin(); - it != allVertices.end(); ++it) { + for(auto it = allVertices.begin(); it != allVertices.end(); ++it) { if(MMG3D_Set_vertex(mmg, (*it)->x(), (*it)->y(), (*it)->z(), (*it)->getNum(), k) != 1) Msg::Error("Mmg3d: unable to set vertex %d", k); @@ -227,8 +225,7 @@ static void updateSizes(GRegion *gr, MMG5_pMesh mmg, MMG5_pSol sol, double L = t->maxEdge(); for(int k = 0; k < 3; k++) { MVertex *v = t->getVertex(k); - auto itv = - LCS.find(v); + auto itv = LCS.find(v); if(itv != LCS.end()) { itv->second.first += L; itv->second.second++; @@ -254,8 +251,7 @@ static void updateSizes(GRegion *gr, MMG5_pMesh mmg, MMG5_pSol sol, auto it = mmg2gmsh.find(k); if(it != mmg2gmsh.end() && CTX::instance()->mesh.lcExtendFromBoundary) { - auto itv = - LCS.find(it->second); + auto itv = LCS.find(it->second); if(itv != LCS.end()) { double LL = itv->second.first / itv->second.second; SMetric3 l4(1. / (LL * LL)); diff --git a/Mesh/meshGRegionNetgen.cpp b/Mesh/meshGRegionNetgen.cpp index 2e692bccbafee9a88a00d7408351911829f63c93..931861c6063803b757913492538a9bc68e3f70dc 100644 --- a/Mesh/meshGRegionNetgen.cpp +++ b/Mesh/meshGRegionNetgen.cpp @@ -52,8 +52,7 @@ static Ng_Mesh *buildNetgenStructure(GRegion *gr, bool importVolumeMesh, std::set<MVertex *, MVertexPtrLessThan> allBoundingVertices; getAllBoundingVertices(gr, allBoundingVertices); - auto itv = - allBoundingVertices.begin(); + auto itv = allBoundingVertices.begin(); int I = 1; while(itv != allBoundingVertices.end()) { double tmp[3]; @@ -167,9 +166,7 @@ static int intersectLineTriangle(double X[3], double Y[3], double Z[3], b[1] = P[1] - Y[0]; b[2] = P[2] - Z[0]; - if(!sys3x3_with_tol(mat, b, res, &det)) { - return 0; - } + if(!sys3x3_with_tol(mat, b, res, &det)) { return 0; } // printf("coucou %g %g %g\n",res[0],res[1],res[2]); if(res[0] >= eps_prec && res[0] <= 1.0 - eps_prec && res[1] >= eps_prec && res[1] <= 1.0 - eps_prec && 1 - res[0] - res[1] >= eps_prec && @@ -271,9 +268,7 @@ static void meshNormalsPointOutOfTheRegion(GRegion *gr) break; // negative value means intersection is not "robust" } - if(nb_intersect < 0) { - setRand(rrr); - } + if(nb_intersect < 0) { setRand(rrr); } else { if(nb_intersect % 2 == 1) { // odd nb of intersections: the normal points inside the region @@ -308,7 +303,8 @@ void meshGRegionNetgen(GRegion *gr) std::vector<GFace *> faces = gr->faces(); for(auto it = faces.begin(); it != faces.end(); it++) { if((*it)->quadrangles.size()) { - Msg::Error("Cannot use frontal 3D algorithm with quadrangles on boundary"); + Msg::Error( + "Cannot use frontal 3D algorithm with quadrangles on boundary"); return; } } @@ -338,7 +334,7 @@ void optimizeMeshGRegionNetgen::operator()(GRegion *gr, bool always) ExtrudeParams *ep = gr->meshAttributes.extrude; if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY) return; - if(gr->prisms.size() || gr->hexahedra.size() || gr->pyramids.size()){ + if(gr->prisms.size() || gr->hexahedra.size() || gr->pyramids.size()) { Msg::Info("Skipping Netgen optimizer for hybrid mesh"); return; } diff --git a/Mesh/meshGRegionTransfinite.cpp b/Mesh/meshGRegionTransfinite.cpp index da8f27991f7571911882e6416a938234f142d963..f74c89a5be3e3d365726e0e4bedeecaa11ea9595 100644 --- a/Mesh/meshGRegionTransfinite.cpp +++ b/Mesh/meshGRegionTransfinite.cpp @@ -323,8 +323,7 @@ int MeshTransfiniteVolume(GRegion *gr) // make sure that all bounding edges have begin/end points: everything in here // depends on it const std::vector<GEdge *> &edges = gr->edges(); - for(auto it = edges.begin(); - it != edges.end(); it++) { + for(auto it = edges.begin(); it != edges.end(); it++) { if(!(*it)->getBeginVertex() || !(*it)->getEndVertex()) { Msg::Error("Transfinite algorithm cannot be applied with curve %d which " "has no begin or end point", @@ -342,8 +341,7 @@ int MeshTransfiniteVolume(GRegion *gr) } std::vector<GOrientedTransfiniteFace> orientedFaces(6); - for(auto it = faces.begin(); it != faces.end(); - ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { GOrientedTransfiniteFace f(*it, corners); if(f.index() < 0) { Msg::Error("Incompatible surface %d in transfinite volume %d", diff --git a/Mesh/meshMetric.cpp b/Mesh/meshMetric.cpp index 9b8c7c87bc9f0079452a91c0e174f582c7bb1f3e..4c6570a71df8a62a0995f86dc31e3f335b9ead5f 100644 --- a/Mesh/meshMetric.cpp +++ b/Mesh/meshMetric.cpp @@ -244,8 +244,7 @@ std::vector<MVertex *> getLSBlob(std::size_t minNbPt, v2t_cont::iterator it, for(auto itBV = bvv.begin(); itBV != bvv.end(); itBV++) { // For each boundary vertex... std::vector<MElement *> &adjBV = adj[*itBV]; - for(auto itBVEl = adjBV.begin(); - itBVEl != adjBV.end(); itBVEl++) { + for(auto itBVEl = adjBV.begin(); itBVEl != adjBV.end(); itBVEl++) { for(std::size_t iV = 0; iV < (*itBVEl)->getNumVertices(); iV++) { // ... look for adjacent vertices... MVertex *v = (*itBVEl)->getVertex(iV); @@ -725,9 +724,7 @@ void meshMetric::scaleMetric(int nbElementsTarget, nodalMetricTensor &nmt) } double scale = pow((double)nbElementsTarget / N, 2.0 / _dim); for(auto it = nmt.begin(); it != nmt.end(); ++it) { - if(_dim == 3) { - it->second *= scale; - } + if(_dim == 3) { it->second *= scale; } else { it->second(0, 0) *= scale; it->second(1, 0) *= scale; @@ -817,8 +814,7 @@ double meshMetric::operator()(double x, double y, double z, GEntity *ge) else { Msg::Warning("point %g %g %g not found, looking for nearest node", x, y, z); double minDist = 1.e100; - for(auto it = _nodalSizes.begin(); it != _nodalSizes.end(); - it++) { + for(auto it = _nodalSizes.begin(); it != _nodalSizes.end(); it++) { const double dist = xyz.distance(it->first->point()); if(dist <= minDist) { minDist = dist; @@ -832,9 +828,7 @@ double meshMetric::operator()(double x, double y, double z, GEntity *ge) void meshMetric::operator()(double x, double y, double z, SMetric3 &metr, GEntity *ge) { - if(needMetricUpdate) { - updateMetrics(); - } + if(needMetricUpdate) { updateMetrics(); } if(!setOfMetrics.size()) { Msg::Error("No metric defined"); return; @@ -929,8 +923,7 @@ void meshMetric::operator()(double x, double y, double z, SMetric3 &metr, Msg::Warning("point %g %g %g not found, looking for nearest node", x, y, z); double minDist = 1.e100; - for(auto it = _nodalMetrics.begin(); - it != _nodalMetrics.end(); it++) { + for(auto it = _nodalMetrics.begin(); it != _nodalMetrics.end(); it++) { const double dist = xyz.distance(it->first->point()); if(dist <= minDist) { minDist = dist; diff --git a/Mesh/meshPartition.cpp b/Mesh/meshPartition.cpp index 5b65845f2779b9ae307a5de65e1b8b1aca846594..074dc9f05789832147626d40a21c1f771384640e 100644 --- a/Mesh/meshPartition.cpp +++ b/Mesh/meshPartition.cpp @@ -117,8 +117,8 @@ private: public: Graph(GModel *model) - : _model(model), _nparts(0), _ne(0), _nn(0), _dim(0), _xadj(nullptr), _adjncy(nullptr), - _vwgt(nullptr) + : _model(model), _nparts(0), _ne(0), _nn(0), _dim(0), _xadj(nullptr), + _adjncy(nullptr), _vwgt(nullptr) { } ~Graph() { clear(); } @@ -441,8 +441,7 @@ static std::size_t getSizeOfEind(GModel *model) { std::size_t size = 0; // Loop over volumes - for(auto it = model->firstRegion(); it != model->lastRegion(); - ++it) { + for(auto it = model->firstRegion(); it != model->lastRegion(); ++it) { size += 4 * (*it)->tetrahedra.size(); size += 8 * (*it)->hexahedra.size(); size += 6 * (*it)->prisms.size(); @@ -451,21 +450,18 @@ static std::size_t getSizeOfEind(GModel *model) } // Loop over surfaces - for(auto it = model->firstFace(); it != model->lastFace(); - ++it) { + for(auto it = model->firstFace(); it != model->lastFace(); ++it) { size += 3 * (*it)->triangles.size(); size += 4 * (*it)->quadrangles.size(); } // Loop over curves - for(auto it = model->firstEdge(); it != model->lastEdge(); - ++it) { + for(auto it = model->firstEdge(); it != model->lastEdge(); ++it) { size += 2 * (*it)->lines.size(); } // Loop over points - for(auto it = model->firstVertex(); it != model->lastVertex(); - ++it) { + for(auto it = model->firstVertex(); it != model->lastVertex(); ++it) { size += 1 * (*it)->points.size(); } @@ -541,8 +537,7 @@ static int makeGraph(GModel *model, Graph &graph, int selectDim) // Loop over volumes if(selectDim < 0 || selectDim == 3) { - for(auto it = model->firstRegion(); - it != model->lastRegion(); ++it) { + for(auto it = model->firstRegion(); it != model->lastRegion(); ++it) { GRegion *r = *it; fillElementsToNodesMap(graph, r, eptrIndex, eindIndex, numVertex, r->tetrahedra.begin(), r->tetrahedra.end()); @@ -559,8 +554,7 @@ static int makeGraph(GModel *model, Graph &graph, int selectDim) // Loop over surfaces if(selectDim < 0 || selectDim == 2) { - for(auto it = model->firstFace(); it != model->lastFace(); - ++it) { + for(auto it = model->firstFace(); it != model->lastFace(); ++it) { GFace *f = *it; fillElementsToNodesMap(graph, f, eptrIndex, eindIndex, numVertex, f->triangles.begin(), f->triangles.end()); @@ -571,8 +565,7 @@ static int makeGraph(GModel *model, Graph &graph, int selectDim) // Loop over curves if(selectDim < 0 || selectDim == 1) { - for(auto it = model->firstEdge(); it != model->lastEdge(); - ++it) { + for(auto it = model->firstEdge(); it != model->lastEdge(); ++it) { GEdge *e = *it; fillElementsToNodesMap(graph, e, eptrIndex, eindIndex, numVertex, e->lines.begin(), e->lines.end()); @@ -581,8 +574,7 @@ static int makeGraph(GModel *model, Graph &graph, int selectDim) // Loop over points if(selectDim < 0 || selectDim == 0) { - for(auto it = model->firstVertex(); - it != model->lastVertex(); ++it) { + for(auto it = model->firstVertex(); it != model->lastVertex(); ++it) { GVertex *v = *it; fillElementsToNodesMap(graph, v, eptrIndex, eindIndex, numVertex, v->points.begin(), v->points.end()); @@ -703,14 +695,14 @@ static int partitionGraph(Graph &graph, bool verbose) graph.createDualGraph(false); if(metisOptions[METIS_OPTION_PTYPE] == METIS_PTYPE_KWAY) { - metisError = METIS_PartGraphKway(&ne, &ncon, graph.xadj(), graph.adjncy(), - graph.vwgt(), nullptr, nullptr, &numPart, nullptr, nullptr, - metisOptions, &objval, &epart[0]); + metisError = METIS_PartGraphKway( + &ne, &ncon, graph.xadj(), graph.adjncy(), graph.vwgt(), nullptr, + nullptr, &numPart, nullptr, nullptr, metisOptions, &objval, &epart[0]); } else { metisError = METIS_PartGraphRecursive( - &ne, &ncon, graph.xadj(), graph.adjncy(), graph.vwgt(), nullptr, nullptr, &numPart, - nullptr, nullptr, metisOptions, &objval, &epart[0]); + &ne, &ncon, graph.xadj(), graph.adjncy(), graph.vwgt(), nullptr, + nullptr, &numPart, nullptr, nullptr, metisOptions, &objval, &epart[0]); } switch(metisError) { @@ -806,28 +798,24 @@ static void assignMeshVertices(GModel *model) removeVerticesEntity(model->firstRegion(), model->lastRegion()); // Loop over points - for(auto it = model->firstVertex(); it != model->lastVertex(); - ++it) { + for(auto it = model->firstVertex(); it != model->lastVertex(); ++it) { setVerticesToEntity(*it, (*it)->points.begin(), (*it)->points.end()); } // Loop over curves - for(auto it = model->firstEdge(); it != model->lastEdge(); - ++it) { + for(auto it = model->firstEdge(); it != model->lastEdge(); ++it) { setVerticesToEntity(*it, (*it)->lines.begin(), (*it)->lines.end()); } // Loop over surfaces - for(auto it = model->firstFace(); it != model->lastFace(); - ++it) { + for(auto it = model->firstFace(); it != model->lastFace(); ++it) { setVerticesToEntity(*it, (*it)->triangles.begin(), (*it)->triangles.end()); setVerticesToEntity(*it, (*it)->quadrangles.begin(), (*it)->quadrangles.end()); } // Loop over volumes - for(auto it = model->firstRegion(); it != model->lastRegion(); - ++it) { + for(auto it = model->firstRegion(); it != model->lastRegion(); ++it) { setVerticesToEntity(*it, (*it)->tetrahedra.begin(), (*it)->tetrahedra.end()); setVerticesToEntity(*it, (*it)->hexahedra.begin(), (*it)->hexahedra.end()); @@ -931,8 +919,8 @@ divideNonConnectedEntities(GModel *model, int dim, // Move B-Rep std::vector<GEdge *> BRepEdges = vertex->edges(); if(!BRepEdges.empty()) { - for(auto itBRep = BRepEdges.begin(); - itBRep != BRepEdges.end(); ++itBRep) { + for(auto itBRep = BRepEdges.begin(); itBRep != BRepEdges.end(); + ++itBRep) { if(vertex == (*itBRep)->getBeginVertex()) { (*itBRep)->setVertex(pvertex, 1); pvertex->addEdge(*itBRep); @@ -1008,22 +996,22 @@ divideNonConnectedEntities(GModel *model, int dim, oldOrientations.reserve(BRepFaces.size()); if(!BRepFaces.empty()) { - for(auto itBRep = BRepFaces.begin(); - itBRep != BRepFaces.end(); ++itBRep) { + for(auto itBRep = BRepFaces.begin(); itBRep != BRepFaces.end(); + ++itBRep) { oldOrientations.push_back((*itBRep)->delEdge(edge)); } } for(std::size_t i = 0; i < connectedElements.size(); i++) { // Create the new partitionEdge - partitionEdge *pedge = new partitionEdge( - model, ++elementaryNumber, nullptr, nullptr, edge->getPartitions()); + partitionEdge *pedge = + new partitionEdge(model, ++elementaryNumber, nullptr, nullptr, + edge->getPartitions()); // Assign parent entity pedge->setParentEntity(edge->getParentEntity()); // Add to model model->add(pedge); - for(auto itSet = - connectedElements[i].begin(); + for(auto itSet = connectedElements[i].begin(); itSet != connectedElements[i].end(); ++itSet) { // Add elements pedge->addElement((*itSet)->getType(), (*itSet)); @@ -1031,8 +1019,8 @@ divideNonConnectedEntities(GModel *model, int dim, // Move B-Rep if(BRepFaces.size() > 0) { std::size_t i = 0; - for(auto itBRep = BRepFaces.begin(); - itBRep != BRepFaces.end(); ++itBRep) { + for(auto itBRep = BRepFaces.begin(); itBRep != BRepFaces.end(); + ++itBRep) { (*itBRep)->setEdge(pedge, oldOrientations[i]); pedge->addFace(*itBRep); i++; @@ -1105,8 +1093,8 @@ divideNonConnectedEntities(GModel *model, int dim, std::list<GRegion *> BRepRegions = face->regions(); std::vector<int> oldOrientations; if(BRepRegions.size() > 0) { - for(auto itBRep = BRepRegions.begin(); - itBRep != BRepRegions.end(); ++itBRep) { + for(auto itBRep = BRepRegions.begin(); itBRep != BRepRegions.end(); + ++itBRep) { oldOrientations.push_back((*itBRep)->delFace(face)); } } @@ -1119,8 +1107,7 @@ divideNonConnectedEntities(GModel *model, int dim, pface->setParentEntity(face->getParentEntity()); // Add to model model->add(pface); - for(auto itSet = - connectedElements[i].begin(); + for(auto itSet = connectedElements[i].begin(); itSet != connectedElements[i].end(); ++itSet) { // Add elements pface->addElement((*itSet)->getType(), (*itSet)); @@ -1217,8 +1204,7 @@ divideNonConnectedEntities(GModel *model, int dim, pregion->setParentEntity(region->getParentEntity()); // Add to model model->add(pregion); - for(auto itSet = - connectedElements[i].begin(); + for(auto itSet = connectedElements[i].begin(); itSet != connectedElements[i].end(); ++itSet) { // Add elements pregion->addElement((*itSet)->getType(), (*itSet)); @@ -1253,7 +1239,8 @@ static void createNewEntities(GModel *model, hashmapelementpart &elmToPartition) int elementaryNumber = model->getMaxElementaryNumber(0); for(auto it = vertices.begin(); it != vertices.end(); ++it) { - std::vector<partitionVertex *> newVertices(model->getNumPartitions(), nullptr); + std::vector<partitionVertex *> newVertices(model->getNumPartitions(), + nullptr); assignElementsToEntities(model, elmToPartition, newVertices, (*it)->points.begin(), (*it)->points.end(), @@ -1315,7 +1302,8 @@ static void createNewEntities(GModel *model, hashmapelementpart &elmToPartition) elementaryNumber = model->getMaxElementaryNumber(3); for(auto it = regions.begin(); it != regions.end(); ++it) { - std::vector<partitionRegion *> newRegions(model->getNumPartitions(), nullptr); + std::vector<partitionRegion *> newRegions(model->getNumPartitions(), + nullptr); assignElementsToEntities(model, elmToPartition, newRegions, (*it)->tetrahedra.begin(), (*it)->tetrahedra.end(), @@ -1363,36 +1351,32 @@ static void fillElementToEntity(GModel *model, hashmapelement &elmToEntity, { // Loop over volumes if(dim < 0 || dim == 3) { - for(auto it = model->firstRegion(); - it != model->lastRegion(); ++it) { - for(auto itElm = - (*it)->tetrahedra.begin(); + for(auto it = model->firstRegion(); it != model->lastRegion(); ++it) { + for(auto itElm = (*it)->tetrahedra.begin(); itElm != (*it)->tetrahedra.end(); ++itElm) elmToEntity.insert(std::pair<MElement *, GEntity *>(*itElm, *it)); for(auto itElm = (*it)->hexahedra.begin(); itElm != (*it)->hexahedra.end(); ++itElm) elmToEntity.insert(std::pair<MElement *, GEntity *>(*itElm, *it)); - for(auto itElm = (*it)->prisms.begin(); - itElm != (*it)->prisms.end(); ++itElm) + for(auto itElm = (*it)->prisms.begin(); itElm != (*it)->prisms.end(); + ++itElm) elmToEntity.insert(std::pair<MElement *, GEntity *>(*itElm, *it)); - for(auto itElm = (*it)->pyramids.begin(); - itElm != (*it)->pyramids.end(); ++itElm) + for(auto itElm = (*it)->pyramids.begin(); itElm != (*it)->pyramids.end(); + ++itElm) elmToEntity.insert(std::pair<MElement *, GEntity *>(*itElm, *it)); - for(auto itElm = (*it)->trihedra.begin(); - itElm != (*it)->trihedra.end(); ++itElm) + for(auto itElm = (*it)->trihedra.begin(); itElm != (*it)->trihedra.end(); + ++itElm) elmToEntity.insert(std::pair<MElement *, GEntity *>(*itElm, *it)); } } // Loop over surfaces if(dim < 0 || dim == 2) { - for(auto it = model->firstFace(); it != model->lastFace(); - ++it) { + for(auto it = model->firstFace(); it != model->lastFace(); ++it) { for(auto itElm = (*it)->triangles.begin(); itElm != (*it)->triangles.end(); ++itElm) elmToEntity.insert(std::pair<MElement *, GEntity *>(*itElm, *it)); - for(auto itElm = - (*it)->quadrangles.begin(); + for(auto itElm = (*it)->quadrangles.begin(); itElm != (*it)->quadrangles.end(); ++itElm) elmToEntity.insert(std::pair<MElement *, GEntity *>(*itElm, *it)); } @@ -1400,20 +1384,18 @@ static void fillElementToEntity(GModel *model, hashmapelement &elmToEntity, // Loop over curves if(dim < 0 || dim == 1) { - for(auto it = model->firstEdge(); it != model->lastEdge(); - ++it) { - for(auto itElm = (*it)->lines.begin(); - itElm != (*it)->lines.end(); ++itElm) + for(auto it = model->firstEdge(); it != model->lastEdge(); ++it) { + for(auto itElm = (*it)->lines.begin(); itElm != (*it)->lines.end(); + ++itElm) elmToEntity.insert(std::pair<MElement *, GEntity *>(*itElm, *it)); } } // Loop over points if(dim < 0 || dim == 0) { - for(auto it = model->firstVertex(); - it != model->lastVertex(); ++it) { - for(auto itElm = (*it)->points.begin(); - itElm != (*it)->points.end(); ++itElm) + for(auto it = model->firstVertex(); it != model->lastVertex(); ++it) { + for(auto itElm = (*it)->points.begin(); itElm != (*it)->points.end(); + ++itElm) elmToEntity.insert(std::pair<MElement *, GEntity *>(*itElm, *it)); } } @@ -1514,8 +1496,7 @@ static PART_ENTITY *createPartitionEntity( *newEntity = ppe; } else { - for(auto it = ret.first; - it != ret.second; ++it) { + for(auto it = ret.first; it != ret.second; ++it) { if(referenceEntity == it->second) { ppe = it->first; } } if(!ppe) { @@ -1728,8 +1709,7 @@ static void assignBrep(GModel *model, if(e->dim() == 2) { partitionFace *entity = static_cast<partitionFace *>(e); - for(auto it = - boundaryEntityAndRefElement.begin(); + for(auto it = boundaryEntityAndRefElement.begin(); it != boundaryEntityAndRefElement.end(); ++it) { static_cast<GRegion *>(it->first)->setFace( entity, computeOrientation(it->second, entity->getMeshElement(0))); @@ -1739,8 +1719,7 @@ static void assignBrep(GModel *model, else if(e->dim() == 1) { partitionEdge *entity = static_cast<partitionEdge *>(e); - for(auto it = - boundaryEntityAndRefElement.begin(); + for(auto it = boundaryEntityAndRefElement.begin(); it != boundaryEntityAndRefElement.end(); ++it) { static_cast<GFace *>(it->first)->setEdge( entity, computeOrientation(it->second, entity->getMeshElement(0))); @@ -1750,8 +1729,7 @@ static void assignBrep(GModel *model, else if(e->dim() == 0) { partitionVertex *entity = static_cast<partitionVertex *>(e); - for(auto it = - boundaryEntityAndRefElement.begin(); + for(auto it = boundaryEntityAndRefElement.begin(); it != boundaryEntityAndRefElement.end(); ++it) { static_cast<GEdge *>(it->first)->setVertex( entity, computeOrientation(it->second, entity->getMeshElement(0))); @@ -1784,8 +1762,7 @@ static void assignNewEntityBRep(Graph &graph, hashmapelement &elementToEntity) for(auto it = brep.begin(); it != brep.end(); ++it) { switch(it->first->dim()) { case 3: - for(auto itSet = it->second.begin(); - itSet != it->second.end(); ++itSet) { + for(auto itSet = it->second.begin(); itSet != it->second.end(); ++itSet) { static_cast<GRegion *>(it->first)->setFace( static_cast<GFace *>(itSet->second), itSet->first); static_cast<GFace *>(itSet->second) @@ -1793,8 +1770,7 @@ static void assignNewEntityBRep(Graph &graph, hashmapelement &elementToEntity) } break; case 2: - for(auto itSet = it->second.begin(); - itSet != it->second.end(); ++itSet) { + for(auto itSet = it->second.begin(); itSet != it->second.end(); ++itSet) { static_cast<GFace *>(it->first)->setEdge( static_cast<GEdge *>(itSet->second), itSet->first); static_cast<GEdge *>(itSet->second) @@ -1802,8 +1778,7 @@ static void assignNewEntityBRep(Graph &graph, hashmapelement &elementToEntity) } break; case 1: - for(auto itSet = it->second.begin(); - itSet != it->second.end(); ++itSet) { + for(auto itSet = it->second.begin(); itSet != it->second.end(); ++itSet) { static_cast<GEdge *>(it->first)->setVertex( static_cast<GVertex *>(itSet->second), itSet->first); static_cast<GVertex *>(itSet->second) @@ -1845,8 +1820,7 @@ static void createPartitionTopology( Msg::Info(" - Creating partition surfaces"); for(std::size_t i = 0; i < model->getNumPartitions(); i++) { - for(auto it = - boundaryElements[i].begin(); + for(auto it = boundaryElements[i].begin(); it != boundaryElements[i].end(); ++it) { for(int j = 0; j < (*it)->getNumFaces(); j++) { faceToElement[(*it)->getFace(j)].push_back( @@ -1893,8 +1867,7 @@ static void createPartitionTopology( if(meshDim == 2) { for(std::size_t i = 0; i < model->getNumPartitions(); i++) { - for(auto it = - boundaryElements[i].begin(); + for(auto it = boundaryElements[i].begin(); it != boundaryElements[i].end(); ++it) { for(int j = 0; j < (*it)->getNumEdges(); j++) { edgeToElement[(*it)->getEdge(j)].push_back( @@ -1913,20 +1886,17 @@ static void createPartitionTopology( std::map<idx_t, std::vector<int> > mapOfPartitions; idx_t mapOfPartitionsTag = 0; - for(auto it = model->firstFace(); it != model->lastFace(); - ++it) { + for(auto it = model->firstFace(); it != model->lastFace(); ++it) { if((*it)->geomType() == GEntity::PartitionSurface) { std::vector<int> partitions = static_cast<partitionFace *>(*it)->getPartitions(); mapOfPartitions.insert(std::pair<idx_t, std::vector<int> >( mapOfPartitionsTag, partitions)); // Must absolutely be in the same order as in the makeGraph function - for(auto itElm = - (*it)->triangles.begin(); + for(auto itElm = (*it)->triangles.begin(); itElm != (*it)->triangles.end(); ++itElm) part[partIndex++] = mapOfPartitionsTag; - for(auto itElm = - (*it)->quadrangles.begin(); + for(auto itElm = (*it)->quadrangles.begin(); itElm != (*it)->quadrangles.end(); ++itElm) part[partIndex++] = mapOfPartitionsTag; mapOfPartitionsTag++; @@ -1938,8 +1908,7 @@ static void createPartitionTopology( subBoundaryElements = subGraph.getBoundaryElements(mapOfPartitionsTag); for(idx_t i = 0; i < mapOfPartitionsTag; i++) { - for(auto it = - subBoundaryElements[i].begin(); + for(auto it = subBoundaryElements[i].begin(); it != subBoundaryElements[i].end(); ++it) { for(int j = 0; j < (*it)->getNumEdges(); j++) { edgeToElement[(*it)->getEdge(j)].push_back( @@ -1988,8 +1957,7 @@ static void createPartitionTopology( Msg::Info(" - Creating partition points"); if(meshDim == 1) { for(std::size_t i = 0; i < model->getNumPartitions(); i++) { - for(auto it = - boundaryElements[i].begin(); + for(auto it = boundaryElements[i].begin(); it != boundaryElements[i].end(); ++it) { for(std::size_t j = 0; j < (*it)->getNumPrimaryVertices(); j++) { vertexToElement[(*it)->getVertex(j)].push_back( @@ -2008,16 +1976,15 @@ static void createPartitionTopology( std::map<idx_t, std::vector<int> > mapOfPartitions; idx_t mapOfPartitionsTag = 0; - for(auto it = model->firstEdge(); it != model->lastEdge(); - ++it) { + for(auto it = model->firstEdge(); it != model->lastEdge(); ++it) { if((*it)->geomType() == GEntity::PartitionCurve) { std::vector<int> partitions = static_cast<partitionEdge *>(*it)->getPartitions(); mapOfPartitions.insert(std::pair<idx_t, std::vector<int> >( mapOfPartitionsTag, partitions)); // Must absolutely be in the same order as in the makeGraph function - for(auto itElm = (*it)->lines.begin(); - itElm != (*it)->lines.end(); ++itElm) + for(auto itElm = (*it)->lines.begin(); itElm != (*it)->lines.end(); + ++itElm) part[partIndex++] = mapOfPartitionsTag; mapOfPartitionsTag++; } @@ -2028,8 +1995,7 @@ static void createPartitionTopology( subBoundaryElements = subGraph.getBoundaryElements(mapOfPartitionsTag); for(idx_t i = 0; i < mapOfPartitionsTag; i++) { - for(auto it = - subBoundaryElements[i].begin(); + for(auto it = subBoundaryElements[i].begin(); it != subBoundaryElements[i].end(); ++it) { for(std::size_t j = 0; j < (*it)->getNumPrimaryVertices(); j++) { vertexToElement[(*it)->getVertex(j)].push_back( @@ -2185,32 +2151,28 @@ static void assignPhysicals(GModel *model) model->getInnerPhysicalNamesIterators(iterators); int numPhysical = model->getMaxPhysicalNumber(-1); // Loop over volumes - for(auto it = model->firstRegion(); it != model->lastRegion(); - ++it) { + for(auto it = model->firstRegion(); it != model->lastRegion(); ++it) { if((*it)->geomType() == GEntity::PartitionVolume) { addPhysical(model, *it, nameToNumber, iterators, numPhysical); } } // Loop over surfaces - for(auto it = model->firstFace(); it != model->lastFace(); - ++it) { + for(auto it = model->firstFace(); it != model->lastFace(); ++it) { if((*it)->geomType() == GEntity::PartitionSurface) { addPhysical(model, *it, nameToNumber, iterators, numPhysical); } } // Loop over curves - for(auto it = model->firstEdge(); it != model->lastEdge(); - ++it) { + for(auto it = model->firstEdge(); it != model->lastEdge(); ++it) { if((*it)->geomType() == GEntity::PartitionCurve) { addPhysical(model, *it, nameToNumber, iterators, numPhysical); } } // Loop over points - for(auto it = model->firstVertex(); it != model->lastVertex(); - ++it) { + for(auto it = model->firstVertex(); it != model->lastVertex(); ++it) { if((*it)->geomType() == GEntity::PartitionPoint) { addPhysical(model, *it, nameToNumber, iterators, numPhysical); } @@ -2542,8 +2504,7 @@ int UnpartitionMesh(GModel *model) std::map<std::pair<int, int>, std::string> physicalNames = model->getPhysicalNames(); - for(auto it = physicalNames.begin(); it != physicalNames.end(); - ++it) { + for(auto it = physicalNames.begin(); it != physicalNames.end(); ++it) { std::size_t found = it->second.find("_"); if(found != std::string::npos) { model->removePhysicalGroup(it->first.first, it->first.second); diff --git a/Mesh/meshRefine.cpp b/Mesh/meshRefine.cpp index 575c88ed856c53f1d1d5ef90abdda1ab9c726159..30bdcb00da5e48d7dd11e0a8f4b74fb34a4b7674 100644 --- a/Mesh/meshRefine.cpp +++ b/Mesh/meshRefine.cpp @@ -157,7 +157,7 @@ static void Subdivide(GFace *gf, bool splitIntoQuads, bool splitIntoHexas, SPoint3 ptx; t->pnt(1. / 3., 1. / 3., 0., ptx); bool reparamOK = gf->haveParametrization(); - if(reparamOK && !linear){ + if(reparamOK && !linear) { for(int k = 0; k < 6; k++) { SPoint2 temp; reparamOK &= reparamMeshVertexOnFace(t->getVertex(k), gf, temp); @@ -281,9 +281,7 @@ static void Subdivide(GRegion *gr, bool splitIntoHexas, for(int j = 0; j < t->getNumFaces(); j++) { MFace face = t->getFace(j); auto fIter = faceVertices.find(face); - if(fIter != faceVertices.end()) { - newv.push_back(fIter->second[0]); - } + if(fIter != faceVertices.end()) { newv.push_back(fIter->second[0]); } else { SPoint3 pc = face.barycenter(); newv.push_back(new MVertex(pc.x(), pc.y(), pc.z(), gr)); @@ -325,9 +323,7 @@ static void Subdivide(GRegion *gr, bool splitIntoHexas, for(int j = 0; j < 2; j++) { MFace face = p->getFace(j); auto fIter = faceVertices.find(face); - if(fIter != faceVertices.end()) { - newv.push_back(fIter->second[0]); - } + if(fIter != faceVertices.end()) { newv.push_back(fIter->second[0]); } else { SPoint3 pc = face.barycenter(); newv.push_back(new MVertex(pc.x(), pc.y(), pc.z(), gr)); @@ -500,8 +496,7 @@ void RefineMesh(GModel *m, bool linear, bool splitIntoQuads, // Subdivide the second order elements to create the refined linear // mesh - for(auto it = m->firstEdge(); it != m->lastEdge(); ++it) - Subdivide(*it); + for(auto it = m->firstEdge(); it != m->lastEdge(); ++it) Subdivide(*it); for(auto it = m->firstFace(); it != m->lastFace(); ++it) Subdivide(*it, splitIntoQuads, splitIntoHexas, faceVertices, linear); for(auto it = m->firstRegion(); it != m->lastRegion(); ++it) @@ -511,8 +506,8 @@ void RefineMesh(GModel *m, bool linear, bool splitIntoQuads, m->setAllVolumesPositive(); double t2 = Cpu(), w2 = TimeOfDay(); - Msg::StatusBar(true, "Done refining mesh (Wall %gs, CPU %gs)", - w2 - w1, t2 - t1); + Msg::StatusBar(true, "Done refining mesh (Wall %gs, CPU %gs)", w2 - w1, + t2 - t1); } void BarycentricRefineMesh(GModel *m) @@ -706,9 +701,7 @@ static int schneiders_connect(int i, int j) 69, 67, 73, 71, 73, 96, 97, 3, 100, 101, 29, 103, 100, 4, 5, 100, 103, 86, 86, 30, 35, 0, 94}; - if(i == 0) { - return n0[j]; - } + if(i == 0) { return n0[j]; } else if(i == 1) { return n1[j]; } diff --git a/Mesh/qualityMeasures.cpp b/Mesh/qualityMeasures.cpp index f4c0c3a275a3d7b644c3e8e7e6c2a0ef394eb9d3..a70ccd30e56d1abf1ce48b9e9f216d0c7f90936f 100644 --- a/Mesh/qualityMeasures.cpp +++ b/Mesh/qualityMeasures.cpp @@ -669,9 +669,9 @@ double qmTetrahedron::qm(const double &x1, const double &y1, const double &z1, case QMTET_ONE: return 1.0; case QMTET_ETA: return eta(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, volume); - case QMTET_GAMMA:{ + case QMTET_GAMMA: { double G = gamma(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, volume); - *volume = fabs (*volume); + *volume = fabs(*volume); return G; } case QMTET_COND: @@ -719,27 +719,31 @@ double qmTetrahedron::gamma(const double &x1, const double &y1, *volume = (robustPredicates::orient3d(p0, p1, p2, p3)) / 6.0; - if (fabs(*volume) == 0) return 0; + if(fabs(*volume) == 0) return 0; - double la = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-z1)*(z2-z1); - double lb = (x3-x1)*(x3-x1) + (y3-y1)*(y3-y1) + (z3-z1)*(z3-z1); - double lc = (x4-x1)*(x4-x1) + (y4-y1)*(y4-y1) + (z4-z1)*(z4-z1); - double lA = (x4-x3)*(x4-x3) + (y4-y3)*(y4-y3) + (z4-z3)*(z4-z3); - double lB = (x4-x2)*(x4-x2) + (y4-y2)*(y4-y2) + (z4-z2)*(z4-z2); - double lC = (x3-x2)*(x3-x2) + (y3-y2)*(y3-y2) + (z3-z2)*(z3-z2); + double la = + (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1); + double lb = + (x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1) + (z3 - z1) * (z3 - z1); + double lc = + (x4 - x1) * (x4 - x1) + (y4 - y1) * (y4 - y1) + (z4 - z1) * (z4 - z1); + double lA = + (x4 - x3) * (x4 - x3) + (y4 - y3) * (y4 - y3) + (z4 - z3) * (z4 - z3); + double lB = + (x4 - x2) * (x4 - x2) + (y4 - y2) * (y4 - y2) + (z4 - z2) * (z4 - z2); + double lC = + (x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2) + (z3 - z2) * (z3 - z2); - double lalA = std::sqrt(la*lA); - double lblB = std::sqrt(lb*lB); - double lclC = std::sqrt(lc*lC); + double lalA = std::sqrt(la * lA); + double lblB = std::sqrt(lb * lB); + double lclC = std::sqrt(lc * lC); - double insideSqrt = ( lalA + lblB + lclC) - * ( lalA + lblB - lclC) - * ( lalA - lblB + lclC) - * (-lalA + lblB + lclC); + double insideSqrt = (lalA + lblB + lclC) * (lalA + lblB - lclC) * + (lalA - lblB + lclC) * (-lalA + lblB + lclC); // This happens when the 4 points are (nearly) co-planar // => R is actually undetermined but the quality is (close to) zero - if (insideSqrt <= 0) return 0; + if(insideSqrt <= 0) return 0; double R = std::sqrt(insideSqrt) / 24 / *volume; @@ -747,7 +751,7 @@ double qmTetrahedron::gamma(const double &x1, const double &y1, double s2 = fabs(triangle_area(p0, p2, p3)); double s3 = fabs(triangle_area(p0, p1, p3)); double s4 = fabs(triangle_area(p1, p2, p3)); - double rho = 3 * 3 * *volume / (s1+s2+s3+s4); + double rho = 3 * 3 * *volume / (s1 + s2 + s3 + s4); return rho / R; } diff --git a/Mesh/qualityMeasuresJacobian.cpp b/Mesh/qualityMeasuresJacobian.cpp index 845f068d981f756506812b47ccbb858ca4f37272..c8773c389b371573c7cc53468f88845358f28a72 100644 --- a/Mesh/qualityMeasuresJacobian.cpp +++ b/Mesh/qualityMeasuresJacobian.cpp @@ -110,9 +110,7 @@ static void _computeIGE(const fullVector<double> &det, switch(type) { case TYPE_QUA: - for(int i = 0; i < sz; i++) { - ige(i) = det(i) / v(i, 0) / v(i, 1); - } + for(int i = 0; i < sz; i++) { ige(i) = det(i) / v(i, 0) / v(i, 1); } break; case TYPE_HEX: for(int i = 0; i < sz; i++) { @@ -172,9 +170,7 @@ static void _computeICN(const fullVector<double> &det, for(int i = 0; i < sz; i++) { double p = 0; - for(int k = 0; k < grad.size2(); ++k) { - p += pow_int(grad(i, k), 2); - } + for(int k = 0; k < grad.size2(); ++k) { p += pow_int(grad(i, k), 2); } if(dim == 2) icn(i) = 2 * det(i) / p; else // 3D @@ -212,7 +208,8 @@ static bool _getQualityFunctionSpace(MElement *el, FuncSpaceData &fsGrad, fsDet = FuncSpaceData(el, false, jacOrder, jacOrder - 3, false); break; default: - Msg::Info("Quality measure not implemented for %s", el->getName().c_str()); + Msg::Info("Quality measure not implemented for %s", + el->getName().c_str()); return false; } } @@ -232,7 +229,8 @@ static bool _getQualityFunctionSpace(MElement *el, FuncSpaceData &fsGrad, fsDet = FuncSpaceData(el, true, 1, orderSamplingPoints - 1, false); break; default: - Msg::Info("Quality measure not implemented for %s", el->getName().c_str()); + Msg::Info("Quality measure not implemented for %s", + el->getName().c_str()); return false; } } @@ -603,18 +601,14 @@ namespace jacobianBasedQuality { // J^2/(a^2+b^2), we would get with certainty a negative lower bound. // Returning 0. for(int i = 0; i < det.size(); ++i) { - if(det(i) < 0) { - return 0; - } + if(det(i) < 0) { return 0; } } fullMatrix<double> v; _computeCoeffLengthVectors(mat, v, _type); fullVector<double> prox[6]; - for(int i = 0; i < v.size2(); ++i) { - prox[i].setAsProxy(v, i); - } + for(int i = 0; i < v.size2(); ++i) { prox[i].setAsProxy(v, i); } const bezierBasisRaiser *raiser = _coeffMat->getBezierBasis()->getRaiser(); fullVector<double> coeffDenominator; @@ -793,9 +787,7 @@ namespace jacobianBasedQuality { // Speedup: If one coeff _coeffDet is negative, we would get // a negative lower bound. For now, returning 0. for(int i = 0; i < det.size(); ++i) { - if(det(i) < 0) { - return 0; - } + if(det(i) < 0) { return 0; } } const bezierBasisRaiser *raiser = _coeffMat->getBezierBasis()->getRaiser(); @@ -821,9 +813,7 @@ namespace jacobianBasedQuality { // J (elements of P are automatically set to 0) fullVector<double> P(mat.size1()); for(int i = 0; i < mat.size1(); ++i) { - for(int k = 0; k < mat.size2(); ++k) { - P(i) += mat(i, k) * mat(i, k); - } + for(int k = 0; k < mat.size2(); ++k) { P(i) += mat(i, k) * mat(i, k); } P(i) = std::sqrt(P(i)); } raiser->computeCoeff(P, P, P, coeffDenominator); @@ -860,9 +850,7 @@ namespace jacobianBasedQuality { } ++k; } - if(debug) { - std::cout << "Number of subdivisions: " << k << std::endl; - } + if(debug) { std::cout << "Number of subdivisions: " << k << std::endl; } else if(k == max_subdivision) { Msg::Error("Max subdivision (%d) (size domains %d)", max_subdivision, domains.size()); diff --git a/Numeric/GaussQuadratureHex.cpp b/Numeric/GaussQuadratureHex.cpp index 936ee734c421dfe82a9b8f15d774117d7baccfb1..e91cbc7163f6ae55888b7922906b7577db986f7f 100644 --- a/Numeric/GaussQuadratureHex.cpp +++ b/Numeric/GaussQuadratureHex.cpp @@ -45,47 +45,45 @@ IntPt GQH8[8] = { {{xh8[4], yh8[4], zh8[4]}, ph8[4]}, {{xh8[5], yh8[5], zh8[5]}, ph8[5]}, {{xh8[6], yh8[6], zh8[6]}, ph8[6]}, {{xh8[7], yh8[7], zh8[7]}, ph8[7]}}; - IntPt GQH34[34] = { - {{0.9317380000, 0., 0.}, 0.28465447168}, - {{-0.9317380000, 0., 0.}, 0.28465447168}, - {{0., 0.9317380000, 0.}, 0.28465447168}, - {{0., -0.9317380000, 0.}, 0.28465447168}, - {{0., 0., 0.9317380000}, 0.28465447168}, - {{0., 0., -0.9317380000}, 0.28465447168}, - {{0.9167441779, 0.9167441779, 0.}, 0.09983142160}, - {{-0.9167441779, 0.9167441779, 0.}, 0.09983142160}, - {{0.9167441779, -0.9167441779, 0.}, 0.09983142160}, - {{-0.9167441779, -0.9167441779, 0.}, 0.09983142160}, - {{0., 0.9167441779, 0.9167441779}, 0.09983142160}, - {{0., -0.9167441779, 0.9167441779}, 0.09983142160}, - {{0., 0.9167441779, -0.9167441779}, 0.09983142160}, - {{0., -0.9167441779, -0.9167441779}, 0.09983142160}, - {{0.9167441779, 0., 0.9167441779}, 0.09983142160}, - {{-0.9167441779, 0., 0.9167441779}, 0.09983142160}, - {{0.9167441779, 0., -0.9167441779}, 0.09983142160}, - {{-0.9167441779, 0., -0.9167441779}, 0.09983142160}, - {{0.4086003800, 0.4086003800, 0.4086003800}, 0.42294183928}, - {{0.4086003800, 0.4086003800, -0.4086003800}, 0.42294183928}, - {{0.4086003800, -0.4086003800, 0.4086003800}, 0.42294183928}, - {{0.4086003800, -0.4086003800, -0.4086003800}, 0.42294183928}, - {{-0.4086003800, 0.4086003800, 0.4086003800}, 0.42294183928}, - {{-0.4086003800, 0.4086003800, -0.4086003800}, 0.42294183928}, - {{-0.4086003800, -0.4086003800, 0.4086003800}, 0.42294183928}, - {{-0.4086003800, -0.4086003800, -0.4086003800}, 0.42294183928}, - {{0.7398529500, 0.7398529500, 0.7398529500}, 0.21382017456}, - {{0.7398529500, 0.7398529500, -0.7398529500}, 0.21382017456}, - {{0.7398529500, -0.7398529500, 0.7398529500}, 0.21382017456}, - {{0.7398529500, -0.7398529500, -0.7398529500}, 0.21382017456}, - {{-0.7398529500, 0.7398529500, 0.7398529500}, 0.21382017456}, - {{-0.7398529500, 0.7398529500, -0.7398529500}, 0.21382017456}, - {{-0.7398529500, -0.7398529500, 0.7398529500}, 0.21382017456}, - {{-0.7398529500, -0.7398529500, -0.7398529500}, 0.21382017456} -}; + {{0.9317380000, 0., 0.}, 0.28465447168}, + {{-0.9317380000, 0., 0.}, 0.28465447168}, + {{0., 0.9317380000, 0.}, 0.28465447168}, + {{0., -0.9317380000, 0.}, 0.28465447168}, + {{0., 0., 0.9317380000}, 0.28465447168}, + {{0., 0., -0.9317380000}, 0.28465447168}, + {{0.9167441779, 0.9167441779, 0.}, 0.09983142160}, + {{-0.9167441779, 0.9167441779, 0.}, 0.09983142160}, + {{0.9167441779, -0.9167441779, 0.}, 0.09983142160}, + {{-0.9167441779, -0.9167441779, 0.}, 0.09983142160}, + {{0., 0.9167441779, 0.9167441779}, 0.09983142160}, + {{0., -0.9167441779, 0.9167441779}, 0.09983142160}, + {{0., 0.9167441779, -0.9167441779}, 0.09983142160}, + {{0., -0.9167441779, -0.9167441779}, 0.09983142160}, + {{0.9167441779, 0., 0.9167441779}, 0.09983142160}, + {{-0.9167441779, 0., 0.9167441779}, 0.09983142160}, + {{0.9167441779, 0., -0.9167441779}, 0.09983142160}, + {{-0.9167441779, 0., -0.9167441779}, 0.09983142160}, + {{0.4086003800, 0.4086003800, 0.4086003800}, 0.42294183928}, + {{0.4086003800, 0.4086003800, -0.4086003800}, 0.42294183928}, + {{0.4086003800, -0.4086003800, 0.4086003800}, 0.42294183928}, + {{0.4086003800, -0.4086003800, -0.4086003800}, 0.42294183928}, + {{-0.4086003800, 0.4086003800, 0.4086003800}, 0.42294183928}, + {{-0.4086003800, 0.4086003800, -0.4086003800}, 0.42294183928}, + {{-0.4086003800, -0.4086003800, 0.4086003800}, 0.42294183928}, + {{-0.4086003800, -0.4086003800, -0.4086003800}, 0.42294183928}, + {{0.7398529500, 0.7398529500, 0.7398529500}, 0.21382017456}, + {{0.7398529500, 0.7398529500, -0.7398529500}, 0.21382017456}, + {{0.7398529500, -0.7398529500, 0.7398529500}, 0.21382017456}, + {{0.7398529500, -0.7398529500, -0.7398529500}, 0.21382017456}, + {{-0.7398529500, 0.7398529500, 0.7398529500}, 0.21382017456}, + {{-0.7398529500, 0.7398529500, -0.7398529500}, 0.21382017456}, + {{-0.7398529500, -0.7398529500, 0.7398529500}, 0.21382017456}, + {{-0.7398529500, -0.7398529500, -0.7398529500}, 0.21382017456}}; static IntPt *GQH[3] = {GQH1, GQH6, GQH34}; static int GQHnPt[3] = {1, 6, 34}; -static std::vector<IntPt*> GQHGL(40, nullptr); +static std::vector<IntPt *> GQHGL(40, nullptr); IntPt *getGQHPts(int order) { diff --git a/Numeric/GaussQuadratureLin.cpp b/Numeric/GaussQuadratureLin.cpp index c76e161d1a313b7fa68836d8c0e99c272cf25111..5f8300d506a869c5e9948081be0054e84e1040e0 100644 --- a/Numeric/GaussQuadratureLin.cpp +++ b/Numeric/GaussQuadratureLin.cpp @@ -7,14 +7,13 @@ #include "GaussIntegration.h" #include "GaussLegendre1D.h" -static std::vector<IntPt*> GQL(40, nullptr); +static std::vector<IntPt *> GQL(40, nullptr); IntPt *getGQLPts(int order) { // Number of Gauss Point: (order + 1) / 2 *ROUNDED UP* int n = (order + 1) / (double)2 + 0.5; - if(static_cast<int>(GQL.size()) < order + 1) - GQL.resize(order + 1, nullptr); + if(static_cast<int>(GQL.size()) < order + 1) GQL.resize(order + 1, nullptr); if(!GQL[order]) { double *pt, *wt; gmshGaussLegendre1D(n, &pt, &wt); diff --git a/Numeric/GaussQuadraturePri.cpp b/Numeric/GaussQuadraturePri.cpp index fe6dea40fde0a397f52b0caec5be669140508232..9085b5c90e171bf99a0126a8a6520e50ed78e3f8 100644 --- a/Numeric/GaussQuadraturePri.cpp +++ b/Numeric/GaussQuadraturePri.cpp @@ -7,15 +7,14 @@ #include "GaussIntegration.h" #include "GaussLegendre1D.h" -static std::vector<IntPt*> GQP(40, nullptr); +static std::vector<IntPt *> GQP(40, nullptr); IntPt *getGQPriPts(int order) { int nLin = (order + 3) / 2; int nTri = getNGQTPts(order); int n = nLin * nTri; - if(static_cast<int>(GQP.size()) < order + 1) - GQP.resize(order + 1, nullptr); + if(static_cast<int>(GQP.size()) < order + 1) GQP.resize(order + 1, nullptr); if(!GQP[order]) { double *linPt, *linWt; IntPt *triPts = getGQTPts(order); diff --git a/Numeric/GaussQuadratureQuad.cpp b/Numeric/GaussQuadratureQuad.cpp index 05607202e3c2ba49d3c02d554b1abcf57b76eca1..7894ad3fe692783d03c2d05eabc218dab55d081b 100644 --- a/Numeric/GaussQuadratureQuad.cpp +++ b/Numeric/GaussQuadratureQuad.cpp @@ -29,14 +29,23 @@ IntPt GQQ4[4] = { {{xq4[3], yq4[3], 0}, pq4[3]}, }; -const double xq7[7] = {0., 0., 0., - 0.7745966692414834, 0.7745966692414834,-0.7745966692414834, +const double xq7[7] = {0., + 0., + 0., + 0.7745966692414834, + 0.7745966692414834, + -0.7745966692414834, -0.7745966692414834}; -const double yq7[7] = {0., 0.9660917830792959, -0.9660917830792959, - 0.7745966692414834, -0.7745966692414834, 0.7745966692414834, +const double yq7[7] = {0., + 0.9660917830792959, + -0.9660917830792959, + 0.7745966692414834, + -0.7745966692414834, + 0.7745966692414834, -0.7745966692414834}; -const double pq7[7] = {1.1428571428571428, 0.31746031746031744,0.31746031746031744, - 0.5555555555555556, 0.5555555555555556, 0.5555555555555556, +const double pq7[7] = {1.1428571428571428, 0.31746031746031744, + 0.31746031746031744, 0.5555555555555556, + 0.5555555555555556, 0.5555555555555556, 0.5555555555555556}; IntPt GQQ7[7] = {{{xq7[0], yq7[0], 0}, pq7[0]}, {{xq7[1], yq7[1], 0}, pq7[1]}, {{xq7[2], yq7[2], 0}, pq7[2]}, {{xq7[3], yq7[3], 0}, pq7[3]}, @@ -83,7 +92,7 @@ IntPt GQQ16[16] = { static IntPt *GQQ[3] = {GQQ1, GQQ3, GQQ7}; static int GQQnPt[3] = {1, 3, 7}; -static std::vector<IntPt*> GQQGL(40, nullptr); +static std::vector<IntPt *> GQQGL(40, nullptr); IntPt *getGQQPts(int order) { diff --git a/Numeric/GaussQuadratureTet.cpp b/Numeric/GaussQuadratureTet.cpp index 371f76bf11659c616cff74c2291f9b4942d92d0e..5bc79b4a99f65e69e556ce0be78fbcb7f92c484d 100644 --- a/Numeric/GaussQuadratureTet.cpp +++ b/Numeric/GaussQuadratureTet.cpp @@ -3341,7 +3341,7 @@ static IntPt *GQTetSolin[22] = { static int GQTetnPtSolin[22] = {1, 1, 4, 5, 11, 14, 24, 31, 43, 53, 126, 126, 210, 210, 330, 330, 495, 495, 715, 715, 1001, 1001}; -static std::vector<IntPt*> GQTetGL(40, nullptr); +static std::vector<IntPt *> GQTetGL(40, nullptr); IntPt *getGQTetPts(int order) { diff --git a/Numeric/GaussQuadratureTri.cpp b/Numeric/GaussQuadratureTri.cpp index 5cdab1426f119e3482afea3f6c4e52c80472f85e..d9874204bf4ad512715814fc8236208d07f1d367 100644 --- a/Numeric/GaussQuadratureTri.cpp +++ b/Numeric/GaussQuadratureTri.cpp @@ -884,7 +884,7 @@ static IntPt *GQTSolin[21] = { triP18Solin, triP19Solin, triP20Solin}; static int GQTnPtSolin[21] = {1, 1, 3, 4, 6, 7, 12, 13, 16, 19, 25, 27, 33, 37, 42, 48, 52, 61, 70, 73, 79}; -static std::vector<IntPt*> GQTGL(40, nullptr); +static std::vector<IntPt *> GQTGL(40, nullptr); IntPt *getGQTPts(int order) { diff --git a/Numeric/JacobianBasis.cpp b/Numeric/JacobianBasis.cpp index 6aba6584fdf7c2b52c5b4adbd70b1a14a017a882..1def4384a2386b40d18ec0dc57eb594b7a354666 100644 --- a/Numeric/JacobianBasis.cpp +++ b/Numeric/JacobianBasis.cpp @@ -76,8 +76,8 @@ namespace { { for(int j = 0; j < numMapNodes; j++) { const double &dPhidX = dShapeMat_dX(i, j); - JDJ(i, j) = dPhidX * (dydY * dzdZ - dzdY * dydZ); - JDJ(i, j + numMapNodes) = dPhidX * (dzdY * dxdZ - dxdY * dzdZ); + JDJ(i, j) = dPhidX * (dydY * dzdZ - dzdY * dydZ); + JDJ(i, j + numMapNodes) = dPhidX * (dzdY * dxdZ - dxdY * dzdZ); JDJ(i, j + 2 * numMapNodes) = dPhidX * (dxdY * dydZ - dydY * dxdZ); } JDJ(i, 3 * numMapNodes) = @@ -97,12 +97,12 @@ namespace { for(int j = 0; j < numMapNodes; j++) { const double &dPhidX = dShapeMat_dX(i, j); const double &dPhidY = dShapeMat_dY(i, j); - JDJ(i, j) = dPhidX * (dydY * dzdZ - dzdY * dydZ) - + dPhidY * (dzdX * dydZ - dydX * dzdZ); - JDJ(i, j + numMapNodes) = dPhidX * (dzdY * dxdZ - dxdY * dzdZ) - + dPhidY * (dxdX * dzdZ - dzdX * dxdZ); - JDJ(i, j + 2 * numMapNodes) = dPhidX * (dxdY * dydZ - dydY * dxdZ) - + dPhidY * (dydX * dxdZ - dxdX * dydZ); + JDJ(i, j) = dPhidX * (dydY * dzdZ - dzdY * dydZ) + + dPhidY * (dzdX * dydZ - dydX * dzdZ); + JDJ(i, j + numMapNodes) = dPhidX * (dzdY * dxdZ - dxdY * dzdZ) + + dPhidY * (dxdX * dzdZ - dzdX * dxdZ); + JDJ(i, j + 2 * numMapNodes) = dPhidX * (dxdY * dydZ - dydY * dxdZ) + + dPhidY * (dydX * dxdZ - dxdX * dydZ); } JDJ(i, 3 * numMapNodes) = calcDet3D(dxdX, dxdY, dxdZ, dydX, dydY, dydZ, dzdX, dzdY, dzdZ); @@ -122,15 +122,15 @@ namespace { const double &dPhidX = dShapeMat_dX(i, j); const double &dPhidY = dShapeMat_dY(i, j); const double &dPhidZ = dShapeMat_dZ(i, j); - JDJ(i, j) = dPhidX * (dydY * dzdZ - dzdY * dydZ) - + dPhidY * (dzdX * dydZ - dydX * dzdZ) - + dPhidZ * (dydX * dzdY - dzdX * dydY); - JDJ(i, j + numMapNodes) = dPhidX * (dzdY * dxdZ - dxdY * dzdZ) - + dPhidY * (dxdX * dzdZ - dzdX * dxdZ) - + dPhidZ * (dzdX * dxdY - dxdX * dzdY); - JDJ(i, j + 2 * numMapNodes) = dPhidX * (dxdY * dydZ - dydY * dxdZ) - + dPhidY * (dydX * dxdZ - dxdX * dydZ) - + dPhidZ * (dxdX * dydY - dydX * dxdY); + JDJ(i, j) = dPhidX * (dydY * dzdZ - dzdY * dydZ) + + dPhidY * (dzdX * dydZ - dydX * dzdZ) + + dPhidZ * (dydX * dzdY - dzdX * dydY); + JDJ(i, j + numMapNodes) = dPhidX * (dzdY * dxdZ - dxdY * dzdZ) + + dPhidY * (dxdX * dzdZ - dzdX * dxdZ) + + dPhidZ * (dzdX * dxdY - dxdX * dzdY); + JDJ(i, j + 2 * numMapNodes) = dPhidX * (dxdY * dydZ - dydY * dxdZ) + + dPhidY * (dydX * dxdZ - dxdX * dydZ) + + dPhidZ * (dxdX * dydY - dydX * dxdY); } JDJ(i, 3 * numMapNodes) = calcDet3D(dxdX, dxdY, dxdZ, dydX, dydY, dydZ, dzdX, dzdY, dzdZ); @@ -712,10 +712,9 @@ void JacobianBasis::getSignedJacAndGradientsGeneral( fullMatrix<double> dxyzdX(nSamplingPnts, 3); dSMat_dX.mult(nodesXYZ, dxyzdX); for(int i = 0; i < nSamplingPnts; i++) { - calcJDJ1D(dxyzdX(i, 0), normals(0, 0), normals(1, 0), - dxyzdX(i, 1), normals(0, 1), normals(1, 1), - dxyzdX(i, 2), normals(0, 2), normals(1, 2), - i, numMapNodes, dSMat_dX, JDJ); + calcJDJ1D(dxyzdX(i, 0), normals(0, 0), normals(1, 0), dxyzdX(i, 1), + normals(0, 1), normals(1, 1), dxyzdX(i, 2), normals(0, 2), + normals(1, 2), i, numMapNodes, dSMat_dX, JDJ); } } break; case 2: { @@ -724,10 +723,9 @@ void JacobianBasis::getSignedJacAndGradientsGeneral( dSMat_dX.mult(nodesXYZ, dxyzdX); dSMat_dY.mult(nodesXYZ, dxyzdY); for(int i = 0; i < nSamplingPnts; i++) { - calcJDJ2D(dxyzdX(i, 0), dxyzdY(i, 0), normals(0, 0), - dxyzdX(i, 1), dxyzdY(i, 1), normals(0, 1), - dxyzdX(i, 2), dxyzdY(i, 2), normals(0, 2), - i, numMapNodes, dSMat_dX, dSMat_dY, JDJ); + calcJDJ2D(dxyzdX(i, 0), dxyzdY(i, 0), normals(0, 0), dxyzdX(i, 1), + dxyzdY(i, 1), normals(0, 1), dxyzdX(i, 2), dxyzdY(i, 2), + normals(0, 2), i, numMapNodes, dSMat_dX, dSMat_dY, JDJ); } } break; case 3: { @@ -738,10 +736,10 @@ void JacobianBasis::getSignedJacAndGradientsGeneral( dSMat_dY.mult(nodesXYZ, dxyzdY); dSMat_dZ.mult(nodesXYZ, dxyzdZ); for(int i = 0; i < nSamplingPnts; i++) { - calcJDJ3D(dxyzdX(i, 0), dxyzdY(i, 0), dxyzdZ(i, 0), - dxyzdX(i, 1), dxyzdY(i, 1), dxyzdZ(i, 1), - dxyzdX(i, 2), dxyzdY(i, 2), dxyzdZ(i, 2), - i, numMapNodes, dSMat_dX, dSMat_dY, dSMat_dZ, JDJ); + calcJDJ3D(dxyzdX(i, 0), dxyzdY(i, 0), dxyzdZ(i, 0), dxyzdX(i, 1), + dxyzdY(i, 1), dxyzdZ(i, 1), dxyzdX(i, 2), dxyzdY(i, 2), + dxyzdZ(i, 2), i, numMapNodes, dSMat_dX, dSMat_dY, dSMat_dZ, + JDJ); } } break; } diff --git a/Numeric/fullMatrix.cpp b/Numeric/fullMatrix.cpp index 3c830453282ed44be09e52ad1387aa2e03c8149b..3164da4dae7174a5afa1f94775b2726334a1adfa 100644 --- a/Numeric/fullMatrix.cpp +++ b/Numeric/fullMatrix.cpp @@ -440,8 +440,7 @@ template <> double fullVector<double>::norm() const return sqrt(n); } -template <> -std::complex<double> fullVector<std::complex<double> >::norm() const +template <> std::complex<double> fullVector<std::complex<double> >::norm() const { double n = 0.; for(int i = 0; i < _r; ++i) diff --git a/Numeric/nodalBasis.cpp b/Numeric/nodalBasis.cpp index 09af9d187ec8c02ff72635fde6fcfb59e506f3ba..8dc3699237f0f4aef8ac55cf785e3e641653daef 100644 --- a/Numeric/nodalBasis.cpp +++ b/Numeric/nodalBasis.cpp @@ -643,8 +643,9 @@ namespace ClosureGen { std::vector<int> &cl = closure[i]; if(cl.size() == 0) continue; clFull.resize(6, -1); - int &ref = - cl.size() == 3 ? ref3 : (cl[0] / 3 + cl[1] / 3) % 2 ? ref4b : ref4a; + int &ref = cl.size() == 3 ? ref3 : + (cl[0] / 3 + cl[1] / 3) % 2 ? ref4b : + ref4a; if(ref == -1) ref = i; closureRef[i] = ref; for(std::size_t j = 0; j < cl.size(); j++) @@ -863,62 +864,46 @@ int nodalBasis::getNumBubbleShapeFunctions() const { int numBubble = -1; switch(parentType) { - case TYPE_PNT: - numBubble = 0; - break; - case TYPE_LIN: - numBubble = ElementType::getNumVertices(type) - 2; - break; + case TYPE_PNT: numBubble = 0; break; + case TYPE_LIN: numBubble = ElementType::getNumVertices(type) - 2; break; case TYPE_TRI: - if(serendip) { - numBubble = 0; - } + if(serendip) { numBubble = 0; } else { numBubble = (order - 1) * (order - 2) / 2; } break; case TYPE_QUA: - if(serendip) { - numBubble = 0; - } + if(serendip) { numBubble = 0; } else { numBubble = (order - 1) * (order - 1); } break; case TYPE_TET: - if(serendip) { - numBubble = 0; - } + if(serendip) { numBubble = 0; } else { numBubble = ((order - 1) * (order - 2) * (order - 3)) / 6; } break; case TYPE_PRI: - if(serendip) { - numBubble = 0; - } + if(serendip) { numBubble = 0; } else { numBubble = (order - 1) * (((order - 1) - 1) * (order - 1) / 2); } break; case TYPE_HEX: - if(serendip) { - numBubble = 0; - } + if(serendip) { numBubble = 0; } else { numBubble = (order - 1) * (order - 1) * (order - 1); } break; case TYPE_PYR: - if(serendip) { - numBubble = 0; - } + if(serendip) { numBubble = 0; } else { numBubble = (order - 2) * ((order - 2) + 1) * (2 * (order - 2) + 1) / 6; } break; } - + return numBubble; } diff --git a/Plugin/AnalyseMeshQuality.cpp b/Plugin/AnalyseMeshQuality.cpp index 58e9d7a6c7e6846f24331b20938aa7256846ee08..1a3e1ad655a16356e43678ec1b0a64f7ede200d2 100644 --- a/Plugin/AnalyseMeshQuality.cpp +++ b/Plugin/AnalyseMeshQuality.cpp @@ -64,16 +64,19 @@ std::string GMSH_AnalyseMeshQualityPlugin::getHelp() const "the IGE quality measure (Inverse Gradient Error) and/or the ICN " "quality measure (Condition Number). Statistics are printed and, " "if requested, a model-based post-processing view is created for each " - "quality measure. The plugin can optionally hide elements by comparing " + "quality measure. The plugin can optionally hide elements by " + "comparing " "the measure to a prescribed threshold.\n" "\n" - "J is faster to compute but gives information only on element validity " + "J is faster to compute but gives information only on element " + "validity " "while the other measures also give information on element quality. " "The IGE measure is related to the error on the gradient of the " "finite element solution. It is the scaled Jacobian for quads and " "hexes and a new measure for triangles and tetrahedra. " "The ICN measure is related to the condition number of the stiffness " - "matrix. (See the article \"Efficient computation of the minimum of shape " + "matrix. (See the article \"Efficient computation of the minimum of " + "shape " "quality measures on curvilinear finite elements\" for details.)\n" "\n" "Parameters:\n" @@ -93,7 +96,8 @@ std::string GMSH_AnalyseMeshQualityPlugin::getHelp() const "- `CreateView': create a model-based view of min(J)/max(J), " "min(IGE) and/or min(ICN)?\n" "\n" - "- `Recompute': force recomputation (set to 1 if the mesh has changed).\n" + "- `Recompute': force recomputation (set to 1 if the mesh has " + "changed).\n" "\n" "- `DimensionOfElements': analyse elements of the given dimension if " "equal to 1, 2 or 3; analyse 2D and 3D elements if equal to 4; " @@ -138,24 +142,30 @@ PView *GMSH_AnalyseMeshQualityPlugin::execute(PView *v) double time = Cpu(), w = TimeOfDay(); Msg::StatusBar(true, "Computing Jacobian for %dD elements...", dim); _computeMinMaxJandValidity(dim); - Msg::StatusBar(true, "Done computing Jacobian for %dD elements (Wall %gs, " - "CPU %gs)", dim, TimeOfDay() - w, Cpu() - time); + Msg::StatusBar(true, + "Done computing Jacobian for %dD elements (Wall %gs, " + "CPU %gs)", + dim, TimeOfDay() - w, Cpu() - time); printStatJ = true; } if(computeIGE && !_computedIGE[dim - 1]) { double time = Cpu(), w = TimeOfDay(); Msg::StatusBar(true, "Computing IGE for %dD elements...", dim); _computeMinIGE(dim); - Msg::StatusBar(true, "Done computing IGE for %dD elements (Wall %gs, " - "CPU %gs)", dim, TimeOfDay() - w, Cpu() - time); + Msg::StatusBar(true, + "Done computing IGE for %dD elements (Wall %gs, " + "CPU %gs)", + dim, TimeOfDay() - w, Cpu() - time); printStatS = true; } if(computeICN && !_computedICN[dim - 1]) { double time = Cpu(), w = TimeOfDay(); Msg::StatusBar(true, "Computing ICN for %dD elements...", dim); _computeMinICN(dim); - Msg::StatusBar(true, "Done computing ICN for %dD elements (Wall %gs, " - "CPU %gs)", dim, TimeOfDay() - w, Cpu() - time); + Msg::StatusBar(true, + "Done computing ICN for %dD elements (Wall %gs, " + "CPU %gs)", + dim, TimeOfDay() - w, Cpu() - time); printStatI = true; } } @@ -309,8 +319,8 @@ void GMSH_AnalyseMeshQualityPlugin::_computeMinMaxJandValidity(int dim) if(normals) delete normals; } if(cntInverted) { - Msg::Warning("%d element%s completely inverted", (cntInverted > 1) ? - "s are" : " is"); + Msg::Warning("%d element%s completely inverted", + (cntInverted > 1) ? "s are" : " is"); } _computedJac[dim - 1] = true; bezierCoeff::releasePools(); @@ -325,9 +335,7 @@ void GMSH_AnalyseMeshQualityPlugin::_computeMinIGE(int dim) for(std::size_t i = 0; i < _data.size(); ++i) { MElement *const el = _data[i].element(); if(el->getDim() != dim) continue; - if(_data[i].minJ() <= 0 && _data[i].maxJ() >= 0) { - _data[i].setMinS(0); - } + if(_data[i].minJ() <= 0 && _data[i].maxJ() >= 0) { _data[i].setMinS(0); } else { _data[i].setMinS(jacobianBasedQuality::minIGEMeasure(el, true)); } @@ -346,9 +354,7 @@ void GMSH_AnalyseMeshQualityPlugin::_computeMinICN(int dim) for(std::size_t i = 0; i < _data.size(); ++i) { MElement *const el = _data[i].element(); if(el->getDim() != dim) continue; - if(_data[i].minJ() <= 0 && _data[i].maxJ() >= 0) { - _data[i].setMinI(0); - } + if(_data[i].minJ() <= 0 && _data[i].maxJ() >= 0) { _data[i].setMinI(0); } else { _data[i].setMinI(jacobianBasedQuality::minICNMeasure(el, true)); } diff --git a/Plugin/BoundaryAngles.cpp b/Plugin/BoundaryAngles.cpp index 9060ce119bdf65a13d881a3b8298de38f6aa2193..37e8aaa1eb618dbb134b86916a07f2f394ffca3d 100644 --- a/Plugin/BoundaryAngles.cpp +++ b/Plugin/BoundaryAngles.cpp @@ -43,10 +43,13 @@ std::string GMSH_BoundaryAnglesPlugin::getHelp() const "modulo 2*Pi, are stored in a new post-processing view, one for each " "surface. The plugin currently only works for planar surfaces." "Available options:" - "- Visible (1=True, 0 = False, Default = 1): Visibility of the Views in the GUI " + "- Visible (1=True, 0 = False, Default = 1): Visibility of the Views " + "in the GUI " "- Save (1=True, 0 = False, Default = 0): Save the Views on disk ?" - "- Remove (1=True, 0 = False, Default = 0): Remove the View from the memory after execution?" - "- Filename (Default = 'Angles_Surface'): Root name for the Views (in case of save / Visibility)" + "- Remove (1=True, 0 = False, Default = 0): Remove the View from the " + "memory after execution?" + "- Filename (Default = 'Angles_Surface'): Root name for the Views (in " + "case of save / Visibility)" "- Dir (Default = ''): Output directory (possibly nested)"; } @@ -95,8 +98,7 @@ PView *GMSH_BoundaryAnglesPlugin::execute(PView *v) MElement *e = gf->getMeshElement(i); for(int j = 0; j < e->getNumEdges(); j++) { std::pair<MEdge, MElement *> ed(e->getEdge(j), e); - auto it = - boundaryEdges.find(ed); + auto it = boundaryEdges.find(ed); if(it == boundaryEdges.end()) { boundaryEdges.insert(ed); } else { boundaryEdges.erase(it); @@ -109,9 +111,7 @@ PView *GMSH_BoundaryAnglesPlugin::execute(PView *v) PViewDataList *data = getDataList(view); std::vector<MEdge> edges; SVector3 normal(0, 0, 1.); - for(auto it = - boundaryEdges.begin(); - it != boundaryEdges.end(); ++it) { + for(auto it = boundaryEdges.begin(); it != boundaryEdges.end(); ++it) { edges.push_back(it->first); if(it == boundaryEdges.begin()) normal = it->second->getFace(0).normal(); } @@ -124,8 +124,7 @@ PView *GMSH_BoundaryAnglesPlugin::execute(PView *v) // order; reverse if necessary { // First edge (and element) of the boundary - auto it2 = - boundaryEdges.begin(); + auto it2 = boundaryEdges.begin(); // Loop on every sorted and consecutive nodes for(int j = 0; j < static_cast<int>(nodes[0].size()) - 1; j++) { // Find the vertex that is the starting point of the edge it2->first @@ -153,44 +152,40 @@ PView *GMSH_BoundaryAnglesPlugin::execute(PView *v) data->SP.push_back(p2.y()); data->SP.push_back(p2.z()); // Choose the angle inside the polygon - if(a>0) - a = -(2*M_PI-a); + if(a > 0) a = -(2 * M_PI - a); data->SP.push_back(a); data->NbSP++; } } } - //Filename and path - std::string currentDir = SplitFileName(GetAbsolutePath(GModel::current()->getFileName()))[0]; + // Filename and path + std::string currentDir = + SplitFileName(GetAbsolutePath(GModel::current()->getFileName()))[0]; // Cleaning filename (if needed) std::string rootname = SplitFileName(opt_filename)[1]; - // Output directory - // Add trailing (back)slash if needed - #if defined(WIN32) - char slash = '\\'; - #else - char slash = '/'; - #endif - if(opt_dir[opt_dir.length()-1] != slash) - opt_dir.push_back(slash); +// Output directory +// Add trailing (back)slash if needed +#if defined(WIN32) + char slash = '\\'; +#else + char slash = '/'; +#endif + if(opt_dir[opt_dir.length() - 1] != slash) opt_dir.push_back(slash); std::string outputdir = currentDir + opt_dir; CreatePath(outputdir); - //viewname and filename (=outputdir/viewname.pos) + // viewname and filename (=outputdir/viewname.pos) char viewname[500]; char filename[500]; sprintf(viewname, "%s_%d", rootname.c_str(), gf->tag()); - sprintf(filename, "%s%s_%d.pos", outputdir.c_str(), rootname.c_str(), gf->tag()); + sprintf(filename, "%s%s_%d.pos", outputdir.c_str(), rootname.c_str(), + gf->tag()); data->Time.push_back(0.); data->setName(viewname); data->setFileName(filename); data->finalize(); - if(!viewVisible) - view->getOptions()->visible = 0; - if(saveOnDisk) - view->write(filename, 0, false); - if(removeView) - delete view; - + if(!viewVisible) view->getOptions()->visible = 0; + if(saveOnDisk) view->write(filename, 0, false); + if(removeView) delete view; } return nullptr; diff --git a/Plugin/Bubbles.cpp b/Plugin/Bubbles.cpp index f38ac6f52cce03bcddc34516d2b739cb03aae0f6..a41f4240cc07dd0ebca797e8091b722a965b87b5 100644 --- a/Plugin/Bubbles.cpp +++ b/Plugin/Bubbles.cpp @@ -121,16 +121,14 @@ PView *GMSH_BubblesPlugin::execute(PView *v) (*fit)->triangles[i]->barycenter()); // add boundary vertices in map to get cells "closer" to the boundary - for(auto it = v2t.begin(); - it != v2t.end(); it++) { + for(auto it = v2t.begin(); it != v2t.end(); it++) { MVertex *v = it->first; if(v->onWhat() && v->onWhat()->dim() < 2) it->second.push_back( SPoint3(it->first->x(), it->first->y(), it->first->z())); } - for(auto it = v2t.begin(); - it != v2t.end(); it++) { + for(auto it = v2t.begin(); it != v2t.end(); it++) { if(it->second.size() > 2) { // get barycenter of cell boundary points and order them SPoint3 bc; diff --git a/Plugin/CVTRemesh.cpp b/Plugin/CVTRemesh.cpp index 13662c80c07116ac5802268353f914c968da7503..3d87b2c846ff3f61e79b5240b3bed76390abf17c 100644 --- a/Plugin/CVTRemesh.cpp +++ b/Plugin/CVTRemesh.cpp @@ -140,9 +140,7 @@ PView *GMSH_CVTRemeshPlugin::execute(PView *v) // positions const double *x[3]; - for(int i = 0; i < 3; ++i) { - x[i] = lifted_mesh.vertex(fverts[i]); - } + for(int i = 0; i < 3; ++i) { x[i] = lifted_mesh.vertex(fverts[i]); } // ratio double ratio = 1; @@ -246,9 +244,7 @@ PView *GMSH_CVTRemeshPlugin::execute(PView *v) Revoropt::CVT::DirectMinimizer<Revoropt::ROMesh<3, 6> > cvt; cvt.set_sites(lifted_sites.data(), nsites); cvt.set_mesh(&lifted_mesh); - if(twfactor > 0) { - cvt.set_triangle_weights(triangle_weights.data()); - } + if(twfactor > 0) { cvt.set_triangle_weights(triangle_weights.data()); } // setup the callback SolverCallback callback; diff --git a/Plugin/Crack.cpp b/Plugin/Crack.cpp index 932cba18dc3ddcaa23c41d3aec54ce4b7447a27c..92de413955210947bc19e8e7925bb7aa98351d90 100644 --- a/Plugin/Crack.cpp +++ b/Plugin/Crack.cpp @@ -62,7 +62,8 @@ public: std::vector<MVertex *> data; }; -struct MEdgeDataLessThan : public std::binary_function<EdgeData, EdgeData, bool> { +struct MEdgeDataLessThan + : public std::binary_function<EdgeData, EdgeData, bool> { bool operator()(const EdgeData &e1, const EdgeData &e2) const { if(e1.edge.getMinVertex() < e2.edge.getMinVertex()) return true; @@ -123,7 +124,8 @@ PView *GMSH_CrackPlugin::execute(PView *view) MVertex *v = crackElements[i]->getVertex(j); crackVertices.insert(v); } - for(std::size_t j = 0; j < crackElements[i]->getNumPrimaryVertices(); j++) { + for(std::size_t j = 0; j < crackElements[i]->getNumPrimaryVertices(); + j++) { MVertex *v = crackElements[i]->getVertex(j); if(bndVertices.find(v) == bndVertices.end()) bndVertices.insert(v); @@ -149,8 +151,7 @@ PView *GMSH_CrackPlugin::execute(PView *view) bnd.erase(ed); } } - for(auto it = bnd.begin(); - it != bnd.end(); it++) + for(auto it = bnd.begin(); it != bnd.end(); it++) bndVertices.insert(it->data.begin(), it->data.end()); } @@ -163,7 +164,8 @@ PView *GMSH_CrackPlugin::execute(PView *view) MElement *e = openEntities[i]->getMeshElement(j); for(std::size_t k = 0; k < e->getNumVertices(); k++) { MVertex *v = e->getVertex(k); - if(bndVerticesFromOpenBoundary.find(v) == bndVerticesFromOpenBoundary.end()) + if(bndVerticesFromOpenBoundary.find(v) == + bndVerticesFromOpenBoundary.end()) bndVerticesFromOpenBoundary.insert(v); else bndVerticesFromOpenBoundary.erase(v); @@ -182,13 +184,13 @@ PView *GMSH_CrackPlugin::execute(PView *view) MElement *e = openEntities[i]->getMeshElement(j); for(std::size_t k = 0; k < e->getNumVertices(); k++) { MVertex *v = e->getVertex(k); - if(bndVerticesFromOpenBoundary.find(v) == bndVerticesFromOpenBoundary.end()) + if(bndVerticesFromOpenBoundary.find(v) == + bndVerticesFromOpenBoundary.end()) bndVertices.erase(v); } } } - for(auto it = bndVertices.begin(); - it != bndVertices.end(); it++) + for(auto it = bndVertices.begin(); it != bndVertices.end(); it++) crackVertices.erase(*it); // compute elements on one side of the crack @@ -218,9 +220,7 @@ PView *GMSH_CrackPlugin::execute(PView *view) n = crossprod(normal1d, ce->getEdge(0).tangent()); else n = ce->getFace(0).normal(); - if(dot(n, dv) < 0) { - oneside.insert(e); - } + if(dot(n, dv) < 0) { oneside.insert(e); } } } } @@ -258,7 +258,8 @@ PView *GMSH_CrackPlugin::execute(PView *view) GEdge *crackEdge = nullptr; GFace *crackFace = nullptr; if(dim == 1) { - crackEdge = new discreteEdge(m, m->getMaxElementaryNumber(1) + 1, nullptr, nullptr); + crackEdge = + new discreteEdge(m, m->getMaxElementaryNumber(1) + 1, nullptr, nullptr); m->add(crackEdge); } else { @@ -271,8 +272,7 @@ PView *GMSH_CrackPlugin::execute(PView *view) // duplicate internal crack nodes std::map<MVertex *, MVertex *> vxv; - for(auto it = crackVertices.begin(); - it != crackVertices.end(); it++) { + for(auto it = crackVertices.begin(); it != crackVertices.end(); it++) { MVertex *v = *it; MVertex *newv = new MVertex(v->x(), v->y(), v->z(), crackEntity); crackEntity->mesh_vertices.push_back(newv); @@ -298,8 +298,7 @@ PView *GMSH_CrackPlugin::execute(PView *view) } // replace vertices in elements on one side of the crack - for(auto it = oneside.begin(); it != oneside.end(); - it++) { + for(auto it = oneside.begin(); it != oneside.end(); it++) { MElement *e = *it; for(std::size_t i = 0; i < e->getNumVertices(); i++) { if(vxv.count(e->getVertex(i))) e->setVertex(i, vxv[e->getVertex(i)]); diff --git a/Plugin/CurvedBndDist.cpp b/Plugin/CurvedBndDist.cpp index 96d00cda58977eb3053eb2a816e1bfae56ff1dd3..9ca00f70166ae1ca9142325d173e50a735da6797 100644 --- a/Plugin/CurvedBndDist.cpp +++ b/Plugin/CurvedBndDist.cpp @@ -44,40 +44,40 @@ static void addLine(PViewDataList *data, const SVector3 &p0, const SVector3 &p1, data->SL.push_back(v1); } - /* - static void addQua(PViewDataList *data, const SVector3 &p0, const SVector3 - &p1, const SVector3 &p2, const SVector3 &p3, double v) - { - data->NbSQ ++; - data->SQ.push_back(p0.x()); data->SQ.push_back(p1.x()); - data->SQ.push_back(p2.x()); data->SQ.push_back(p3.x()); - data->SQ.push_back(p0.y()); data->SQ.push_back(p1.y()); - data->SQ.push_back(p2.y()); data->SQ.push_back(p3.y()); - data->SQ.push_back(p0.z()); data->SQ.push_back(p1.z()); - data->SQ.push_back(p2.z()); data->SQ.push_back(p3.z()); data->SQ.push_back(v); - data->SQ.push_back(v); data->SQ.push_back(v); data->SQ.push_back(v); - } +/* +static void addQua(PViewDataList *data, const SVector3 &p0, const SVector3 +&p1, const SVector3 &p2, const SVector3 &p3, double v) +{ + data->NbSQ ++; + data->SQ.push_back(p0.x()); data->SQ.push_back(p1.x()); +data->SQ.push_back(p2.x()); data->SQ.push_back(p3.x()); + data->SQ.push_back(p0.y()); data->SQ.push_back(p1.y()); +data->SQ.push_back(p2.y()); data->SQ.push_back(p3.y()); + data->SQ.push_back(p0.z()); data->SQ.push_back(p1.z()); +data->SQ.push_back(p2.z()); data->SQ.push_back(p3.z()); data->SQ.push_back(v); +data->SQ.push_back(v); data->SQ.push_back(v); data->SQ.push_back(v); +} - static void addPoint(PViewDataList *data, const SVector3 &p0, double v0) - { - data->NbSP ++; - data->SP.push_back(p0.x()); - data->SP.push_back(p0.y()); - data->SP.push_back(p0.z()); - data->SP.push_back(v0); - } +static void addPoint(PViewDataList *data, const SVector3 &p0, double v0) +{ + data->NbSP ++; + data->SP.push_back(p0.x()); + data->SP.push_back(p0.y()); + data->SP.push_back(p0.z()); + data->SP.push_back(v0); +} - static void addVP(PViewDataList *data, const SVector3 p0, SVector3 v) - { - data->NbVP ++; - data->VP.push_back(p0.x()); - data->VP.push_back(p0.y()); - data->VP.push_back(p0.z()); - data->VP.push_back(v.x()); - data->VP.push_back(v.y()); - data->VP.push_back(v.z()); - } - */ +static void addVP(PViewDataList *data, const SVector3 p0, SVector3 v) +{ + data->NbVP ++; + data->VP.push_back(p0.x()); + data->VP.push_back(p0.y()); + data->VP.push_back(p0.z()); + data->VP.push_back(v.x()); + data->VP.push_back(v.y()); + data->VP.push_back(v.z()); +} +*/ #include <limits> static void drawElementDist(PViewDataList *data, GEdge *edge, @@ -103,34 +103,34 @@ static void drawElementDist(PViewDataList *data, GEdge *edge, } } - /* - static void drawElement(PViewDataList *data, GEdge *edge, - const std::vector<MVertex *>&vertices, const - nodalBasis &basis) - { - std::vector<double> gradient; - std::vector<double> param(vertices.size()); - std::vector<bool> onEdge(vertices.size()); - std::vector<SPoint3> xyz(vertices.size()); - for (size_t i = 0; i < vertices.size(); ++i) { - MVertex *v = vertices[i]; - reparamMeshVertexOnEdge(v, edge, param[i]); - onEdge[i] = v->onWhat() == edge; - xyz[i] = v->point(); - } - computeBndDistAndGradient(edge, param, vertices, basis, xyz, onEdge, - gradient,1.e-6); for (size_t i = 0; i < vertices.size(); ++i) { double t0; - reparamMeshVertexOnEdge(vertices[i], edge, t0); - SPoint3 p = vertices[i]->point(); - GPoint gpt = edge->point(t0 + 1e-8); - SPoint3 pt(gpt.x(), gpt.y(), gpt.z()); - SVector3 t = (pt - p); - t.normalize(); - //addPoint(data, p, 0); - addVP(data, p, t * (-gradient[i])); - } +/* +static void drawElement(PViewDataList *data, GEdge *edge, + const std::vector<MVertex *>&vertices, const +nodalBasis &basis) +{ + std::vector<double> gradient; + std::vector<double> param(vertices.size()); + std::vector<bool> onEdge(vertices.size()); + std::vector<SPoint3> xyz(vertices.size()); + for (size_t i = 0; i < vertices.size(); ++i) { + MVertex *v = vertices[i]; + reparamMeshVertexOnEdge(v, edge, param[i]); + onEdge[i] = v->onWhat() == edge; + xyz[i] = v->point(); + } + computeBndDistAndGradient(edge, param, vertices, basis, xyz, onEdge, +gradient,1.e-6); for (size_t i = 0; i < vertices.size(); ++i) { double t0; + reparamMeshVertexOnEdge(vertices[i], edge, t0); + SPoint3 p = vertices[i]->point(); + GPoint gpt = edge->point(t0 + 1e-8); + SPoint3 pt(gpt.x(), gpt.y(), gpt.z()); + SVector3 t = (pt - p); + t.normalize(); + //addPoint(data, p, 0); + addVP(data, p, t * (-gradient[i])); } - */ +} +*/ #endif diff --git a/Plugin/DiscretizationError.cpp b/Plugin/DiscretizationError.cpp index 96c7aa6d0cb22457498f303645ff26904c05d7bc..750434caa422381c3077f239160b6247fbd68809 100644 --- a/Plugin/DiscretizationError.cpp +++ b/Plugin/DiscretizationError.cpp @@ -69,8 +69,7 @@ PView *GMSH_DiscretizationErrorPlugin::execute(PView *v) * 5 6 7 8 * 1 2 3 4 */ - for(auto itQuad = - (*itFace)->quadrangles.begin(); + for(auto itQuad = (*itFace)->quadrangles.begin(); itQuad != (*itFace)->quadrangles.end(); ++itQuad) { for(j = 0; j < nEdgeNodes; j++) { // u for(i = 0; i < nEdgeNodes; i++) { // v diff --git a/Plugin/Distance.cpp b/Plugin/Distance.cpp index 32365e9cd884f6d17b47f5bab63d741c5375dc58..e95f6ec0eaef30f9f7a61e6a18c72f1c4685f069 100644 --- a/Plugin/Distance.cpp +++ b/Plugin/Distance.cpp @@ -28,8 +28,7 @@ StringXNumber DistanceOptions_Number[] = { {GMSH_FULLRC, "PhysicalSurface", nullptr, 0.}, {GMSH_FULLRC, "DistanceType", nullptr, 0}, {GMSH_FULLRC, "MinScale", nullptr, 0}, - {GMSH_FULLRC, "MaxScale", nullptr, 0} -}; + {GMSH_FULLRC, "MaxScale", nullptr, 0}}; extern "C" { GMSH_Plugin *GMSH_RegisterDistancePlugin() { return new GMSH_DistancePlugin(); } @@ -47,7 +46,8 @@ std::string GMSH_DistancePlugin::getHelp() const "If `PhysicalPoint', `PhysicalLine' and `PhysicalSurface' are 0, the " "distance is computed to all the boundaries. Otherwise the distance " "is computed to the given physical group.\n\n" - "If `DistanceType' is 0, the plugin computes the geometrical Euclidean " + "If `DistanceType' is 0, the plugin computes the geometrical " + "Euclidean " "distance using the naive O(N^2) algorithm. If `DistanceType' > 0, " "the plugin computes an approximate distance by solving a PDE with " "a diffusion constant equal to `DistanceType' time the maximum size " @@ -74,8 +74,7 @@ void GMSH_DistancePlugin::printView(std::vector<GEntity *> &entities, double minDist = 1.e22; double maxDist = 0.0; - for(auto itv = distanceMap.begin(); - itv != distanceMap.end(); ++itv) { + for(auto itv = distanceMap.begin(); itv != distanceMap.end(); ++itv) { double dist = itv->second; if(dist > maxDist) maxDist = dist; if(dist < minDist) minDist = dist; @@ -90,11 +89,13 @@ void GMSH_DistancePlugin::printView(std::vector<GEntity *> &entities, if(e->getNumChildren()) numNodes = e->getNumChildren() * e->getChild(0)->getNumVertices(); std::vector<double> x(numNodes), y(numNodes), z(numNodes); - std::vector<double> *out = _data->incrementList(1, e->getType(), numNodes); + std::vector<double> *out = + _data->incrementList(1, e->getType(), numNodes); std::vector<MVertex *> nods; if(!e->getNumChildren()) - for(std::size_t i = 0; i < numNodes; i++) nods.push_back(e->getVertex(i)); + for(std::size_t i = 0; i < numNodes; i++) + nods.push_back(e->getVertex(i)); else for(int i = 0; i < e->getNumChildren(); i++) for(std::size_t j = 0; j < e->getChild(i)->getNumVertices(); j++) @@ -117,7 +118,7 @@ void GMSH_DistancePlugin::printView(std::vector<GEntity *> &entities, for(std::size_t i = 0; i < dist.size(); i++) { if(minScale > 0 && maxScale > 0 && maxDist != minDist) dist[i] = minScale + ((dist[i] - minDist) / (maxDist - minDist)) * - (maxScale - minScale); + (maxScale - minScale); else if(minScale > 0) dist[i] = minScale + dist[i]; out->push_back(dist[i]); @@ -172,15 +173,15 @@ PView *GMSH_DistancePlugin::execute(PView *v) GEntity *g2 = entities[i]; int gDim = g2->dim(); bool computeForEntity = false; - if(!id_point && !id_line && !id_face && gDim == _maxDim - 1){ + if(!id_point && !id_line && !id_face && gDim == _maxDim - 1) { computeForEntity = true; } - else{ + else { std::vector<int> phys = g2->getPhysicalEntities(); for(std::size_t k = 0; k < phys.size(); k++) { if((phys[k] == id_point && gDim == 0) || (phys[k] == id_line && gDim == 1) || - (phys[k] == id_face && gDim == 2)){ + (phys[k] == id_face && gDim == 2)) { computeForEntity = true; break; } @@ -203,7 +204,8 @@ PView *GMSH_DistancePlugin::execute(PView *v) else if(e->getType() == TYPE_TRI) { MVertex *v3 = e->getVertex(2); SPoint3 p3(v3->x(), v3->y(), v3->z()); - signedDistancesPointsTriangle(iDistances, iClosePts, pts, p1, p2, p3); + signedDistancesPointsTriangle(iDistances, iClosePts, pts, p1, p2, + p3); } for(std::size_t kk = 0; kk < pts.size(); kk++) { if(std::abs(iDistances[kk]) < distances[kk]) { @@ -241,15 +243,15 @@ PView *GMSH_DistancePlugin::execute(PView *v) GEntity *ge = entities[i]; int gDim = ge->dim(); bool fixForEntity = false; - if(!id_point && !id_line && !id_face && gDim == _maxDim - 1){ + if(!id_point && !id_line && !id_face && gDim == _maxDim - 1) { fixForEntity = true; } - else{ + else { std::vector<int> phys = ge->getPhysicalEntities(); for(std::size_t k = 0; k < phys.size(); k++) { if((phys[k] == id_point && gDim == 0) || (phys[k] == id_line && gDim == 1) || - (phys[k] == id_face && gDim == 2)){ + (phys[k] == id_face && gDim == 2)) { fixForEntity = true; break; } @@ -289,16 +291,14 @@ PView *GMSH_DistancePlugin::execute(PView *v) double mu = type * L; simpleFunction<double> DIFF(mu * mu), ONE(1.0); distanceTerm distance(GModel::current(), 1, &DIFF, &ONE); - for(auto it = allElems.begin(); - it != allElems.end(); it++) { + for(auto it = allElems.begin(); it != allElems.end(); it++) { SElement se((*it)); distance.addToMatrix(*dofView, &se); } groupOfElements gr(allElems); distance.addToRightHandSide(*dofView, gr); lsys->systemSolve(); - for(auto itv = distanceMap.begin(); - itv != distanceMap.end(); ++itv) { + for(auto itv = distanceMap.begin(); itv != distanceMap.end(); ++itv) { MVertex *v = itv->first; double value; dofView->getDofValue(v, 0, 1, value); diff --git a/Plugin/Divergence.cpp b/Plugin/Divergence.cpp index cad5f5579c53c7edd60c0c4000f4460bd4f91eaa..84dff5949648c4145649ff095fdc65cf5d826aa6 100644 --- a/Plugin/Divergence.cpp +++ b/Plugin/Divergence.cpp @@ -7,7 +7,8 @@ #include "shapeFunctions.h" #include "GmshDefines.h" -StringXNumber DivergenceOptions_Number[] = {{GMSH_FULLRC, "View", nullptr, -1.}}; +StringXNumber DivergenceOptions_Number[] = { + {GMSH_FULLRC, "View", nullptr, -1.}}; extern "C" { GMSH_Plugin *GMSH_RegisterDivergencePlugin() diff --git a/Plugin/Eigenvalues.cpp b/Plugin/Eigenvalues.cpp index a2b92b25f01625f32ebba9fe7abf7c8b85018722..d518b77279bd1933cc2f40646588e2eb08dff208 100644 --- a/Plugin/Eigenvalues.cpp +++ b/Plugin/Eigenvalues.cpp @@ -7,7 +7,8 @@ #include "Numeric.h" #include "GmshDefines.h" -StringXNumber EigenvaluesOptions_Number[] = {{GMSH_FULLRC, "View", nullptr, -1.}}; +StringXNumber EigenvaluesOptions_Number[] = { + {GMSH_FULLRC, "View", nullptr, -1.}}; extern "C" { GMSH_Plugin *GMSH_RegisterEigenvaluesPlugin() diff --git a/Plugin/ExtractElements.cpp b/Plugin/ExtractElements.cpp index 9fb5aa3a1d460421b884bbb9fb3b9c399d04f4c1..7efdcdfc205a5d861491c133ed1ebcc4c97bd583 100644 --- a/Plugin/ExtractElements.cpp +++ b/Plugin/ExtractElements.cpp @@ -7,9 +7,12 @@ #include "Numeric.h" StringXNumber ExtractElementsOptions_Number[] = { - {GMSH_FULLRC, "MinVal", nullptr, 0.}, {GMSH_FULLRC, "MaxVal", nullptr, 0.}, - {GMSH_FULLRC, "TimeStep", nullptr, 0.}, {GMSH_FULLRC, "Visible", nullptr, 1.}, - {GMSH_FULLRC, "Dimension", nullptr, -1.}, {GMSH_FULLRC, "View", nullptr, -1.}}; + {GMSH_FULLRC, "MinVal", nullptr, 0.}, + {GMSH_FULLRC, "MaxVal", nullptr, 0.}, + {GMSH_FULLRC, "TimeStep", nullptr, 0.}, + {GMSH_FULLRC, "Visible", nullptr, 1.}, + {GMSH_FULLRC, "Dimension", nullptr, -1.}, + {GMSH_FULLRC, "View", nullptr, -1.}}; extern "C" { GMSH_Plugin *GMSH_RegisterExtractElementsPlugin() diff --git a/Plugin/HarmonicToTime.cpp b/Plugin/HarmonicToTime.cpp index a1de8a7cb4aec5916dee5616eb05ad68fa1da4de..728a6cbd28318b7ef61ee7c9a54cca962da10018 100644 --- a/Plugin/HarmonicToTime.cpp +++ b/Plugin/HarmonicToTime.cpp @@ -116,7 +116,8 @@ PView *GMSH_HarmonicToTimePlugin::execute(PView *v) } for(int k = 0; k < nSteps; k++) { - double t = frequency ? (2. * M_PI * nPeriods * k / frequency / (double)nSteps) : 0.; + double t = + frequency ? (2. * M_PI * nPeriods * k / frequency / (double)nSteps) : 0.; data2->Time.push_back(t); } data2->setName(data1->getName() + "_HarmonicToTime"); diff --git a/Plugin/Invisible.cpp b/Plugin/Invisible.cpp index 57e813b04a4bb6d2e0c6724d33f07f9963f0e84a..d0629f212d953624e95a7c175aa32f9c7ceccb30 100644 --- a/Plugin/Invisible.cpp +++ b/Plugin/Invisible.cpp @@ -12,10 +12,10 @@ StringXNumber InvisibleOptions_Number[] = { }; extern "C" { - GMSH_Plugin *GMSH_RegisterInvisiblePlugin() - { - return new GMSH_InvisiblePlugin(); - } +GMSH_Plugin *GMSH_RegisterInvisiblePlugin() +{ + return new GMSH_InvisiblePlugin(); +} } std::string GMSH_InvisiblePlugin::getHelp() const diff --git a/Plugin/Lambda2.cpp b/Plugin/Lambda2.cpp index 536e6fa7e230f7b6cdc3efdec523ddf3572d092c..1600a857813972e08a145cc0d489ab516657d0e9 100644 --- a/Plugin/Lambda2.cpp +++ b/Plugin/Lambda2.cpp @@ -6,8 +6,9 @@ #include "Lambda2.h" #include "Numeric.h" -StringXNumber Lambda2Options_Number[] = {{GMSH_FULLRC, "Eigenvalue", nullptr, 2.}, - {GMSH_FULLRC, "View", nullptr, -1.}}; +StringXNumber Lambda2Options_Number[] = { + {GMSH_FULLRC, "Eigenvalue", nullptr, 2.}, + {GMSH_FULLRC, "View", nullptr, -1.}}; extern "C" { GMSH_Plugin *GMSH_RegisterLambda2Plugin() { return new GMSH_Lambda2Plugin(); } @@ -109,9 +110,7 @@ static void eigen(std::vector<double> &inList, int inNb, double val[3][MAX_NOD]; for(int k = 0; k < nbNod; k++) { double *v = &inList[i + 3 * nbNod + nbNod * nbComp * j + nbComp * k]; - for(int l = 0; l < 3; l++) { - val[l][k] = v[l]; - } + for(int l = 0; l < 3; l++) { val[l][k] = v[l]; } } // compute gradient of shape functions double GradPhi_x[MAX_NOD][3]; diff --git a/Plugin/Levelset.cpp b/Plugin/Levelset.cpp index f0d72761e8396509c51b64cf85217ede24ee42bb..e7eae856d74088202753873984be58d05edf728a 100644 --- a/Plugin/Levelset.cpp +++ b/Plugin/Levelset.cpp @@ -543,9 +543,7 @@ PView *GMSH_LevelsetPlugin::execute(PView *v) } PViewData *vdata = getPossiblyAdaptiveData(v), *wdata; - if(_valueView < 0) { - wdata = vdata; - } + if(_valueView < 0) { wdata = vdata; } else if(_valueView > (int)PView::list.size() - 1) { Msg::Error("View[%d] does not exist: reverting to View[%d]", _valueView, v->getIndex()); diff --git a/Plugin/MakeSimplex.cpp b/Plugin/MakeSimplex.cpp index 435523cedbe752c4ac8758cc42565976638fba47..6310d22f803022df7fe90a0a29c2c7469567d31d 100644 --- a/Plugin/MakeSimplex.cpp +++ b/Plugin/MakeSimplex.cpp @@ -5,7 +5,8 @@ #include "MakeSimplex.h" -StringXNumber MakeSimplexOptions_Number[] = {{GMSH_FULLRC, "View", nullptr, -1.}}; +StringXNumber MakeSimplexOptions_Number[] = { + {GMSH_FULLRC, "View", nullptr, -1.}}; extern "C" { GMSH_Plugin *GMSH_RegisterMakeSimplexPlugin() @@ -115,14 +116,10 @@ MakeSimplex::MakeSimplex(int numNodes, int numComponents, int numTimeSteps) int MakeSimplex::numSimplices() { switch(_numNodes) { - case 4: - return 2; // quad -> 2 tris - case 5: - return 2; // pyramid -> 2 tets - case 6: - return 3; // prism -> 3 tets - case 8: - return 6; // hexa -> 6 tets + case 4: return 2; // quad -> 2 tris + case 5: return 2; // pyramid -> 2 tets + case 6: return 3; // prism -> 3 tets + case 8: return 6; // hexa -> 6 tets } return 0; } diff --git a/Plugin/MathEval.cpp b/Plugin/MathEval.cpp index a7583007872fac8c059498f40d6bcee2f63bdce2..4c84475944b889e96f1d2a32c2069083bfb65338 100644 --- a/Plugin/MathEval.cpp +++ b/Plugin/MathEval.cpp @@ -169,9 +169,7 @@ PView *GMSH_MathEvalPlugin::execute(PView *view) PView *v2 = new PView(); PViewDataList *data2 = getDataList(v2); - if(timeStep < 0) { - timeStep = -data1->getNumTimeSteps(); - } + if(timeStep < 0) { timeStep = -data1->getNumTimeSteps(); } else if(timeStep > data1->getNumTimeSteps() - 1) { Msg::Error("Invalid time step (%d) in View[%d]: using all steps instead", timeStep, v1->getIndex()); @@ -218,12 +216,12 @@ PView *GMSH_MathEvalPlugin::execute(PView *view) if(otherData) { if(octree) { int qn = forceInterpolation ? numNodes : 0; - if(!octree->searchScalar(x[nod], y[nod], z[nod], &w[0], step2, nullptr, - qn, &x[0], &y[0], &z[0])) + if(!octree->searchScalar(x[nod], y[nod], z[nod], &w[0], step2, + nullptr, qn, &x[0], &y[0], &z[0])) if(!octree->searchVector(x[nod], y[nod], z[nod], &w[0], step2, nullptr, qn, &x[0], &y[0], &z[0])) - octree->searchTensor(x[nod], y[nod], z[nod], &w[0], step2, nullptr, - qn, &x[0], &y[0], &z[0]); + octree->searchTensor(x[nod], y[nod], z[nod], &w[0], step2, + nullptr, qn, &x[0], &y[0], &z[0]); } else for(int comp = 0; comp < otherNumComp; comp++) diff --git a/Plugin/MeshSizeFieldView.cpp b/Plugin/MeshSizeFieldView.cpp index 2387e9ad79d03d80cc107aa8d1e737d1ef9626f2..7c6d59d018cc0ac1ec5cfe83beab8e5cea885b12 100644 --- a/Plugin/MeshSizeFieldView.cpp +++ b/Plugin/MeshSizeFieldView.cpp @@ -14,8 +14,7 @@ StringXNumber MeshSizeFieldViewOptions_Number[] = { {GMSH_FULLRC, "MeshSizeField", nullptr, 0.}, {GMSH_FULLRC, "View", nullptr, -1.}, - {GMSH_FULLRC, "Component", nullptr, 0.} -}; + {GMSH_FULLRC, "Component", nullptr, 0.}}; extern "C" { GMSH_Plugin *GMSH_RegisterMeshSizeFieldViewPlugin() @@ -26,9 +25,10 @@ GMSH_Plugin *GMSH_RegisterMeshSizeFieldViewPlugin() std::string GMSH_MeshSizeFieldViewPlugin::getHelp() const { - return "Plugin(MeshSizeFieldView) evaluates the mesh size field `MeshSizeField' " - "on specified `Component` (0 for scalar) of the post-processing view " - "`View'."; + return "Plugin(MeshSizeFieldView) evaluates the mesh size field " + "`MeshSizeField' " + "on specified `Component` (0 for scalar) of the post-processing view " + "`View'."; } int GMSH_MeshSizeFieldViewPlugin::getNbOptions() const diff --git a/Plugin/MeshSizeFieldView.h b/Plugin/MeshSizeFieldView.h index c23b945e56636af75d7631e22204237d3c4a0eb5..705421ed455598546325bc599abab1ec69edb034 100644 --- a/Plugin/MeshSizeFieldView.h +++ b/Plugin/MeshSizeFieldView.h @@ -9,7 +9,7 @@ #include "Plugin.h" extern "C" { - GMSH_Plugin *GMSH_RegisterMeshSizeFieldViewPlugin(); +GMSH_Plugin *GMSH_RegisterMeshSizeFieldViewPlugin(); } class GMSH_MeshSizeFieldViewPlugin : public GMSH_PostPlugin { diff --git a/Plugin/MeshSubEntities.cpp b/Plugin/MeshSubEntities.cpp index 51dd2e19d357bc3a270c583ac8c4814928518d33..18e64162535483146d6eab14269f0d7a13437764 100644 --- a/Plugin/MeshSubEntities.cpp +++ b/Plugin/MeshSubEntities.cpp @@ -88,8 +88,7 @@ PView *GMSH_MeshSubEntitiesPlugin::execute(PView *view) vertices.insert(v); } } - for(auto it = vertices.begin(); - it != vertices.end(); ++it) { + for(auto it = vertices.begin(); it != vertices.end(); ++it) { MVertex *v = *it; GVertex *gv = nullptr; if(v->onWhat() && v->onWhat()->dim() == 0) { @@ -113,8 +112,7 @@ PView *GMSH_MeshSubEntitiesPlugin::execute(PView *view) edges.insert(e); } } - for(auto it = edges.begin(); - it != edges.end(); ++it) { + for(auto it = edges.begin(); it != edges.end(); ++it) { const MEdge &e = *it; GEdge *ge = nullptr; MVertex *v0 = e.getVertex(0), *v1 = e.getVertex(1); @@ -129,7 +127,8 @@ PView *GMSH_MeshSubEntitiesPlugin::execute(PView *view) ge = (GEdge *)v1->onWhat(); } if(!ge) { - ge = new discreteEdge(m, m->getMaxElementaryNumber(1) + 1, nullptr, nullptr); + ge = new discreteEdge(m, m->getMaxElementaryNumber(1) + 1, nullptr, + nullptr); v0->setEntity(ge); v1->setEntity(ge); m->add(ge); diff --git a/Plugin/MeshVolume.cpp b/Plugin/MeshVolume.cpp index bfd0ee473c465ac482a4458ff483fac0c1fbb604..b1b4c0a3ea0d18c2692eef29d7f3657a0b0c609e 100644 --- a/Plugin/MeshVolume.cpp +++ b/Plugin/MeshVolume.cpp @@ -9,8 +9,7 @@ StringXNumber MeshVolumeOptions_Number[] = { {GMSH_FULLRC, "PhysicalGroup", nullptr, -1}, - {GMSH_FULLRC, "Dimension", nullptr, 3} -}; + {GMSH_FULLRC, "Dimension", nullptr, 3}}; extern "C" { GMSH_Plugin *GMSH_RegisterMeshVolumePlugin() @@ -52,25 +51,21 @@ PView *GMSH_MeshVolumePlugin::execute(PView *v) } std::vector<GEntity *> entities; - if(physical == -1) { - model->getEntities(entities, dim); - } + if(physical == -1) { model->getEntities(entities, dim); } else { std::map<int, std::vector<GEntity *> > groups; model->getPhysicalGroups(dim, groups); entities = groups[physical]; } - if(entities.empty()) - Msg::Warning("The specified domain is empty"); + if(entities.empty()) Msg::Warning("The specified domain is empty"); double vol = 0; for(std::size_t i = 0; i < entities.size(); i++) for(std::size_t j = 0; j < entities[i]->getNumMeshElements(); j++) vol += entities[i]->getMeshElement(j)->getVolume(); - Msg::Info("Mesh volume (physical %d | dimension %d): %g", - physical, dim, vol); + Msg::Info("Mesh volume (physical %d | dimension %d): %g", physical, dim, vol); PView *v2 = new PView(); PViewDataList *data2 = getDataList(v2); diff --git a/Plugin/ModifyComponents.cpp b/Plugin/ModifyComponents.cpp index 47f21345e87a73583b062c6bf70519cb58813d43..bec3d8e0d9bccde0e57a8d3af1a6d397c1742275 100644 --- a/Plugin/ModifyComponents.cpp +++ b/Plugin/ModifyComponents.cpp @@ -193,12 +193,12 @@ PView *GMSH_ModifyComponentsPlugin::execute(PView *view) std::vector<double> w(std::max(9, numComp2), 0.); if(octree) { int qn = forceInterpolation ? numNodes : 0; - if(!octree->searchScalar(x[nod], y[nod], z[nod], &w[0], step2, nullptr, - qn, &x[0], &y[0], &z[0])) - if(!octree->searchVector(x[nod], y[nod], z[nod], &w[0], step2, nullptr, - qn, &x[0], &y[0], &z[0])) - octree->searchTensor(x[nod], y[nod], z[nod], &w[0], step2, nullptr, - qn, &x[0], &y[0], &z[0]); + if(!octree->searchScalar(x[nod], y[nod], z[nod], &w[0], step2, + nullptr, qn, &x[0], &y[0], &z[0])) + if(!octree->searchVector(x[nod], y[nod], z[nod], &w[0], step2, + nullptr, qn, &x[0], &y[0], &z[0])) + octree->searchTensor(x[nod], y[nod], z[nod], &w[0], step2, + nullptr, qn, &x[0], &y[0], &z[0]); } else { for(int comp = 0; comp < numComp2; comp++) diff --git a/Plugin/NearToFarField.cpp b/Plugin/NearToFarField.cpp index 7fdd786b0778064b1f313ee86eb672612bb861d3..03eb10bd43c358547d2851ae062cacbfe1196954 100644 --- a/Plugin/NearToFarField.cpp +++ b/Plugin/NearToFarField.cpp @@ -401,9 +401,7 @@ PView *GMSH_NearToFarFieldPlugin::execute(PView *v) std::vector<std::vector<double> > farField2i(_nbPhi + 1); std::vector<std::vector<double> > farField3i(_nbPhi + 1); std::vector<std::vector<double> > farFieldVec(3); - for(int comp = 0; comp < 3; comp++) { - farFieldVec[comp].resize(2, 0.); - } + for(int comp = 0; comp < 3; comp++) { farFieldVec[comp].resize(2, 0.); } for(int i = 0; i <= _nbPhi; i++) { phi[i].resize(_nbThe + 1); diff --git a/Plugin/NewView.cpp b/Plugin/NewView.cpp index 58004b616874e96cbfbcf7c49d14d97374821a94..42a38899ddb9de5b5db2446e21d49e1817cae439 100644 --- a/Plugin/NewView.cpp +++ b/Plugin/NewView.cpp @@ -15,12 +15,10 @@ StringXNumber NewViewOptions_Number[] = { {GMSH_FULLRC, "NumComp", nullptr, 1.}, {GMSH_FULLRC, "Value", nullptr, 0.}, {GMSH_FULLRC, "ViewTag", nullptr, -1.}, - {GMSH_FULLRC, "PhysicalGroup", nullptr, -1.} -}; + {GMSH_FULLRC, "PhysicalGroup", nullptr, -1.}}; StringXString NewViewOptions_String[] = { - {GMSH_FULLRC, "Type", nullptr, "NodeData"} -}; + {GMSH_FULLRC, "Type", nullptr, "NodeData"}}; extern "C" { GMSH_Plugin *GMSH_RegisterNewViewPlugin() { return new GMSH_NewViewPlugin(); } @@ -79,18 +77,16 @@ PView *GMSH_NewViewPlugin::execute(PView *v) } std::map<int, std::vector<double> > d; - if(type == "NodeData") - nodeData(numComp, value, d); - if(type == "ElementData") - elementData(numComp, value, d, phys); + if(type == "NodeData") nodeData(numComp, value, d); + if(type == "ElementData") elementData(numComp, value, d, phys); PView *vn = new PView("New view", type, GModel::current(), d, tag); return vn; } -void GMSH_NewViewPlugin::nodeData(int numComp, - double value, - std::map<int, std::vector<double> > &d){ +void GMSH_NewViewPlugin::nodeData(int numComp, double value, + std::map<int, std::vector<double> > &d) +{ std::vector<GEntity *> entities; GModel::current()->getEntities(entities); for(std::size_t i = 0; i < entities.size(); i++) { @@ -101,14 +97,12 @@ void GMSH_NewViewPlugin::nodeData(int numComp, } } -void GMSH_NewViewPlugin::elementData(int numComp, - double value, +void GMSH_NewViewPlugin::elementData(int numComp, double value, std::map<int, std::vector<double> > &d, - int phys){ + int phys) +{ std::vector<GEntity *> entities; - if(phys == -1) { - GModel::current()->getEntities(entities, -1); - } + if(phys == -1) { GModel::current()->getEntities(entities, -1); } else { std::map<int, std::vector<GEntity *> > groups; GModel::current()->getPhysicalGroups(-1, groups); diff --git a/Plugin/NewView.h b/Plugin/NewView.h index e5d65b7907a1a313b599b64471b9f0473aca7e65..3902c2059cdc9e416627304e2e834b1266db90ff 100644 --- a/Plugin/NewView.h +++ b/Plugin/NewView.h @@ -8,9 +8,8 @@ #include "Plugin.h" -extern "C" -{ - GMSH_Plugin *GMSH_RegisterNewViewPlugin(); +extern "C" { +GMSH_Plugin *GMSH_RegisterNewViewPlugin(); } class GMSH_NewViewPlugin : public GMSH_PostPlugin { @@ -29,13 +28,10 @@ public: PView *execute(PView *); private: - void nodeData(int numComp, - double value, + void nodeData(int numComp, double value, std::map<int, std::vector<double> > &d); - void elementData(int numComp, - double value, - std::map<int, std::vector<double> > &d, - int phys); + void elementData(int numComp, double value, + std::map<int, std::vector<double> > &d, int phys); }; #endif diff --git a/Plugin/PluginManager.cpp b/Plugin/PluginManager.cpp index 7ad8847e17437628f7cc7cb214aee933f1bc2c38..ceaa0ad9b81c5fcce4f0c6dc67c22c08bf3ec394 100644 --- a/Plugin/PluginManager.cpp +++ b/Plugin/PluginManager.cpp @@ -90,15 +90,13 @@ PluginManager *PluginManager::_instance = nullptr; PluginManager::~PluginManager() { - for(auto it = allPlugins.begin(); - it != allPlugins.end(); ++it) + for(auto it = allPlugins.begin(); it != allPlugins.end(); ++it) delete it->second; } GMSH_Plugin *PluginManager::find(const std::string &pluginName) { - auto it = - allPlugins.find(pluginName); + auto it = allPlugins.find(pluginName); if(it == allPlugins.end()) return nullptr; return it->second; } diff --git a/Plugin/Remove.cpp b/Plugin/Remove.cpp index 23ea6b68e8774823175656c0cbf61a79705a88b0..691f176c63b77f707a2b8ee873b58152e19baf0e 100644 --- a/Plugin/Remove.cpp +++ b/Plugin/Remove.cpp @@ -6,13 +6,20 @@ #include "Remove.h" StringXNumber RemoveOptions_Number[] = { - {GMSH_FULLRC, "Text2D", nullptr, 1.}, {GMSH_FULLRC, "Text3D", nullptr, 1.}, - {GMSH_FULLRC, "Points", nullptr, 0.}, {GMSH_FULLRC, "Lines", nullptr, 0.}, - {GMSH_FULLRC, "Triangles", nullptr, 0.}, {GMSH_FULLRC, "Quadrangles", nullptr, 0.}, - {GMSH_FULLRC, "Tetrahedra", nullptr, 0.}, {GMSH_FULLRC, "Hexahedra", nullptr, 0.}, - {GMSH_FULLRC, "Prisms", nullptr, 0.}, {GMSH_FULLRC, "Pyramids", nullptr, 0.}, - {GMSH_FULLRC, "Scalar", nullptr, 1.}, {GMSH_FULLRC, "Vector", nullptr, 1.}, - {GMSH_FULLRC, "Tensor", nullptr, 1.}, {GMSH_FULLRC, "View", nullptr, -1.}}; + {GMSH_FULLRC, "Text2D", nullptr, 1.}, + {GMSH_FULLRC, "Text3D", nullptr, 1.}, + {GMSH_FULLRC, "Points", nullptr, 0.}, + {GMSH_FULLRC, "Lines", nullptr, 0.}, + {GMSH_FULLRC, "Triangles", nullptr, 0.}, + {GMSH_FULLRC, "Quadrangles", nullptr, 0.}, + {GMSH_FULLRC, "Tetrahedra", nullptr, 0.}, + {GMSH_FULLRC, "Hexahedra", nullptr, 0.}, + {GMSH_FULLRC, "Prisms", nullptr, 0.}, + {GMSH_FULLRC, "Pyramids", nullptr, 0.}, + {GMSH_FULLRC, "Scalar", nullptr, 1.}, + {GMSH_FULLRC, "Vector", nullptr, 1.}, + {GMSH_FULLRC, "Tensor", nullptr, 1.}, + {GMSH_FULLRC, "View", nullptr, -1.}}; extern "C" { GMSH_Plugin *GMSH_RegisterRemovePlugin() { return new GMSH_RemovePlugin(); } diff --git a/Plugin/ShowNeighborElements.cpp b/Plugin/ShowNeighborElements.cpp index b98f6159e7d4eb58c6276f634d848cbd3fca5e88..79a4539d9fe221fc0d4083dccc19c38fe6a868ca 100644 --- a/Plugin/ShowNeighborElements.cpp +++ b/Plugin/ShowNeighborElements.cpp @@ -21,14 +21,13 @@ StringXNumber ShowNeighborElementsOptions_Number[] = { {GMSH_FULLRC, "Element2", nullptr, 0}, {GMSH_FULLRC, "Element3", nullptr, 0}, {GMSH_FULLRC, "Element4", nullptr, 0}, - {GMSH_FULLRC, "Element5", nullptr, 0} -}; + {GMSH_FULLRC, "Element5", nullptr, 0}}; extern "C" { - GMSH_Plugin *GMSH_RegisterShowNeighborElementsPlugin() - { - return new GMSH_ShowNeighborElementsPlugin(); - } +GMSH_Plugin *GMSH_RegisterShowNeighborElementsPlugin() +{ + return new GMSH_ShowNeighborElementsPlugin(); +} } int GMSH_ShowNeighborElementsPlugin::getNbOptions() const diff --git a/Plugin/Skin.cpp b/Plugin/Skin.cpp index 4d0d9a282d75985a892afe8adef9a13cc7455f9c..dfcfb0cc84db338cdec38d15976f6ebe6dd7f47f 100644 --- a/Plugin/Skin.cpp +++ b/Plugin/Skin.cpp @@ -224,16 +224,14 @@ static void getBoundaryFromMesh(GModel *m, int visible) discreteEdge *e = new discreteEdge(m, m->getMaxElementaryNumber(1) + 1, nullptr, nullptr); m->add(e); - for(auto it = bndEdges.begin(); - it != bndEdges.end(); it++) { + for(auto it = bndEdges.begin(); it != bndEdges.end(); it++) { e->lines.push_back(new MLine(it->getVertex(0), it->getVertex(1))); } } else if(dim == 3) { discreteFace *f = new discreteFace(m, m->getMaxElementaryNumber(2) + 1); m->add(f); - for(auto it = bndFaces.begin(); - it != bndFaces.end(); it++) { + for(auto it = bndFaces.begin(); it != bndFaces.end(); it++) { if(it->getNumVertices() == 3) f->triangles.push_back( new MTriangle(it->getVertex(0), it->getVertex(1), it->getVertex(2))); @@ -320,9 +318,7 @@ PView *GMSH_SkinPlugin::execute(PView *v) } } - for(auto it = skin.begin(); - it != skin.end(); it++) - it->addInView(data2); + for(auto it = skin.begin(); it != skin.end(); it++) it->addInView(data2); for(int i = 0; i < data1->getNumTimeSteps(); i++) if(data1->hasTimeStep(i)) data2->Time.push_back(data1->getTime(i)); diff --git a/Plugin/SpanningTree.cpp b/Plugin/SpanningTree.cpp index 49ae06701dfa46888ae00ae101c0ccfcedd8ee25..afedbcf4e9e60617783b0f2ce64bf4b2edc3f4be 100644 --- a/Plugin/SpanningTree.cpp +++ b/Plugin/SpanningTree.cpp @@ -110,8 +110,7 @@ void GMSH_SpanningTreePlugin::run(void) // Get all elements in physicals for each dimension vector<ElementSet> element(3); for(int i = 0; i < 3; i++) - for(auto j = physical[i].begin(); j != physical[i].end(); - j++) + for(auto j = physical[i].begin(); j != physical[i].end(); j++) getAllMElement(*model, *j, dim[i], element[i]); // Check if we have something @@ -321,7 +320,7 @@ string GMSH_SpanningTreePlugin::DSU::toString(void) // Show (node, parent) [using Gmsh's 1-base index] stringstream str; for(size_t i = 0; i < parent.size(); i++) - str << "(" << i+1 << ", " << parent[i]+1 << ")" << endl; + str << "(" << i + 1 << ", " << parent[i] + 1 << ")" << endl; return str.str(); } diff --git a/Plugin/StreamLines.cpp b/Plugin/StreamLines.cpp index aef4c0264e5c87aa2105f5c176f06ba3338325f2..6d3e7a01699c1a08d986418bdf5acf3b29470676 100644 --- a/Plugin/StreamLines.cpp +++ b/Plugin/StreamLines.cpp @@ -250,9 +250,7 @@ PView *GMSH_StreamLinesPlugin::execute(PView *v) getPoint(i, j, XINIT); getPoint(i, j, X); - if(data2) { - o2->searchScalar(X[0], X[1], X[2], val2, -1); - } + if(data2) { o2->searchScalar(X[0], X[1], X[2], val2, -1); } else { data3->NbVP++; data3->VP.push_back(X[0]); diff --git a/Plugin/Tetrahedralize.cpp b/Plugin/Tetrahedralize.cpp index 87153ddf687a760cd6d0f5390bc9e54d966c847c..b3cf026645ef6aab379c997343cfa28bd3b25866 100644 --- a/Plugin/Tetrahedralize.cpp +++ b/Plugin/Tetrahedralize.cpp @@ -44,15 +44,15 @@ StringXNumber *GMSH_TetrahedralizePlugin::getOption(int iopt) #if defined(HAVE_MESH) namespace { -class PointData : public MVertex { -public: - std::vector<double> val; - PointData(double x, double y, double z, int numVal) : MVertex(x, y, z) - { - val.resize(numVal); - } -}; -} + class PointData : public MVertex { + public: + std::vector<double> val; + PointData(double x, double y, double z, int numVal) : MVertex(x, y, z) + { + val.resize(numVal); + } + }; +} // namespace PView *GMSH_TetrahedralizePlugin::execute(PView *v) { @@ -101,9 +101,9 @@ PView *GMSH_TetrahedralizePlugin::execute(PView *v) for(std::size_t i = 0; i < tets.size(); i++) { bool ok = true; PointData *p[4]; - for(int j = 0; j < 4; j++){ - p[j] = dynamic_cast<PointData*>(tets[i]->getVertex(j)); - if(!p[j]){ // tet connected to enclosing box + for(int j = 0; j < 4; j++) { + p[j] = dynamic_cast<PointData *>(tets[i]->getVertex(j)); + if(!p[j]) { // tet connected to enclosing box ok = false; break; } diff --git a/Plugin/Triangulate.cpp b/Plugin/Triangulate.cpp index 9dd80ba738f2f6d67d481c3277806f67d784e049..c7161af398a22581d2a333caf57af6aec9aa94b0 100644 --- a/Plugin/Triangulate.cpp +++ b/Plugin/Triangulate.cpp @@ -19,9 +19,7 @@ #endif StringXNumber TriangulateOptions_Number[] = { - {GMSH_FULLRC, "Algorithm", nullptr, 1.}, - {GMSH_FULLRC, "View", nullptr, -1.} -}; + {GMSH_FULLRC, "Algorithm", nullptr, 1.}, {GMSH_FULLRC, "View", nullptr, -1.}}; extern "C" { GMSH_Plugin *GMSH_RegisterTriangulatePlugin() @@ -54,18 +52,18 @@ StringXNumber *GMSH_TriangulatePlugin::getOption(int iopt) #if defined(HAVE_MESH) namespace { -class PointData : public MVertex { -public: - std::vector<double> v; - PointData(double x, double y, double z, int numVal) : MVertex(x, y, z) - { - v.resize(3 + numVal); - v[0] = x; - v[1] = y; - v[2] = z; - } -}; -} + class PointData : public MVertex { + public: + std::vector<double> v; + PointData(double x, double y, double z, int numVal) : MVertex(x, y, z) + { + v.resize(3 + numVal); + v[0] = x; + v[1] = y; + v[2] = z; + } + }; +} // namespace PView *GMSH_TriangulatePlugin::execute(PView *v) { diff --git a/Plugin/VoroMetal.cpp b/Plugin/VoroMetal.cpp index 17cac108a15e2f240b02ac805eac278886c98ae6..b4545daca14581d69046598b58aa5570498a6afd 100644 --- a/Plugin/VoroMetal.cpp +++ b/Plugin/VoroMetal.cpp @@ -70,9 +70,7 @@ void voroMetal3D::execute(double h) GModel::riter it; for(it = model->firstRegion(); it != model->lastRegion(); it++) { gr = *it; - if(gr->getNumMeshElements() > 0) { - execute(gr, h); - } + if(gr->getNumMeshElements() > 0) { execute(gr, h); } } } @@ -243,9 +241,7 @@ void voroMetal3D::execute(std::vector<SPoint3> &vertices, areas.clear(); pointers[i]->face_areas(areas); for(j = 0; j < areas.size(); j++) { - if(areas[j] < min_area) { - min_area = areas[j]; - } + if(areas[j] < min_area) { min_area = areas[j]; } } } @@ -311,9 +307,7 @@ void voroMetal3D::execute(std::vector<SPoint3> &vertices, } last = obj.line_loops[face_number].size() - 1; - if(last == 0) { - obj.orientations[face_number].push_back(0); - } + if(last == 0) { obj.orientations[face_number].push_back(0); } else if(obj.lines[obj.line_loops[face_number][last - 1]].second == obj.lines[val].first) { obj.orientations[face_number][last - 1] = 0; @@ -526,9 +520,7 @@ void voroMetal3D::correspondance(double e, double xMax, double yMax, for(it = model->firstFace(); it != model->lastFace(); it++) { gf = *it; - if(gf->numRegions() == 1) { - faces.push_back(gf); - } + if(gf->numRegions() == 1) { faces.push_back(gf); } } centers.clear(); @@ -917,9 +909,7 @@ void voroMetal3D::correspondance(double e, double xMax, double yMax, } } - if(indices1.size() != indices2.size()) { - printf("Error\n\n"); - } + if(indices1.size() != indices2.size()) { printf("Error\n\n"); } file3 << "Periodic Surface {" << gf1->tag() << " }={ " << gf2->tag() << " } Translate { " << -dx.x() << "," << -dx.y() << "," << -dx.z() << "};\n"; @@ -1017,9 +1007,7 @@ void voroMetal3D::correspondance(double delta_x, double delta_y, double delta_z, bool voroMetal3D::equal(double x, double y, double e) { bool flag; - if(x > y - e && x < y + e) { - flag = 1; - } + if(x > y - e && x < y + e) { flag = 1; } else { flag = 0; } @@ -1131,9 +1119,7 @@ static void computeBestSeeds(const char *filename) sqrt((vTmp1->x() - vTmp2->x()) * (vTmp1->x() - vTmp2->x()) + (vTmp1->y() - vTmp2->y()) * (vTmp1->y() - vTmp2->y()) + (vTmp1->z() - vTmp2->z()) * (vTmp1->z() - vTmp2->z())); - if(distTmp < distMinTmp) { - distMinTmp = distTmp; - } + if(distTmp < distMinTmp) { distMinTmp = distTmp; } } if(distMinTmp > distMinGlobal) { distMinGlobal = distMinTmp; @@ -1172,9 +1158,7 @@ static void computeBestSeeds(const char *filename) sqrt((vTmp1->x() - vTmp2->x()) * (vTmp1->x() - vTmp2->x()) + (vTmp1->y() - vTmp2->y()) * (vTmp1->y() - vTmp2->y()) + (vTmp1->z() - vTmp2->z()) * (vTmp1->z() - vTmp2->z())); - if(distTmp < distMinTmp) { - distMinTmp = distTmp; - } + if(distTmp < distMinTmp) { distMinTmp = distTmp; } } if(distMinTmp > distMinGlobal) { distMinGlobal = distMinTmp; @@ -1213,9 +1197,7 @@ static void computeBestSeeds(const char *filename) sqrt((vTmp1->x() - vTmp2->x()) * (vTmp1->x() - vTmp2->x()) + (vTmp1->y() - vTmp2->y()) * (vTmp1->y() - vTmp2->y()) + (vTmp1->z() - vTmp2->z()) * (vTmp1->z() - vTmp2->z())); - if(distTmp < distMinTmp) { - distMinTmp = distTmp; - } + if(distTmp < distMinTmp) { distMinTmp = distTmp; } } if(distMinTmp > distMinGlobal) { distMinGlobal = distMinTmp; @@ -1254,9 +1236,7 @@ static void computeBestSeeds(const char *filename) sqrt((vTmp1->x() - vTmp2->x()) * (vTmp1->x() - vTmp2->x()) + (vTmp1->y() - vTmp2->y()) * (vTmp1->y() - vTmp2->y()) + (vTmp1->z() - vTmp2->z()) * (vTmp1->z() - vTmp2->z())); - if(distTmp < distMinTmp) { - distMinTmp = distTmp; - } + if(distTmp < distMinTmp) { distMinTmp = distTmp; } } if(distMinTmp > distMinGlobal) { distMinGlobal = distMinTmp; @@ -1295,9 +1275,7 @@ static void computeBestSeeds(const char *filename) sqrt((vTmp1->x() - vTmp2->x()) * (vTmp1->x() - vTmp2->x()) + (vTmp1->y() - vTmp2->y()) * (vTmp1->y() - vTmp2->y()) + (vTmp1->z() - vTmp2->z()) * (vTmp1->z() - vTmp2->z())); - if(distTmp < distMinTmp) { - distMinTmp = distTmp; - } + if(distTmp < distMinTmp) { distMinTmp = distTmp; } } if(distMinTmp > distMinGlobal) { distMinGlobal = distMinTmp; @@ -1336,9 +1314,7 @@ static void computeBestSeeds(const char *filename) sqrt((vTmp1->x() - vTmp2->x()) * (vTmp1->x() - vTmp2->x()) + (vTmp1->y() - vTmp2->y()) * (vTmp1->y() - vTmp2->y()) + (vTmp1->z() - vTmp2->z()) * (vTmp1->z() - vTmp2->z())); - if(distTmp < distMinTmp) { - distMinTmp = distTmp; - } + if(distTmp < distMinTmp) { distMinTmp = distTmp; } } if(distMinTmp > distMinGlobal) { distMinGlobal = distMinTmp; @@ -1351,25 +1327,19 @@ static void computeBestSeeds(const char *filename) std::cout << "distance minimale de " << distMinGlobal << std::endl; listDistances[Count] = distMinGlobal; if(xORyORz == 1) { - if(posORneg == 1) { - properties[4 * jMinGlobal] += 0.01; - } + if(posORneg == 1) { properties[4 * jMinGlobal] += 0.01; } else if(posORneg == 2) { properties[4 * jMinGlobal] -= 0.01; } } else if(xORyORz == 2) { - if(posORneg == 1) { - properties[4 * jMinGlobal + 1] += 0.01; - } + if(posORneg == 1) { properties[4 * jMinGlobal + 1] += 0.01; } else if(posORneg == 2) { properties[4 * jMinGlobal + 1] -= 0.01; } } else if(xORyORz == 3) { - if(posORneg == 1) { - properties[4 * jMinGlobal + 2] += 0.01; - } + if(posORneg == 1) { properties[4 * jMinGlobal + 2] += 0.01; } else if(posORneg == 2) { properties[4 * jMinGlobal + 2] -= 0.01; } diff --git a/Post/ColorTable.cpp b/Post/ColorTable.cpp index 49c9d1cd3cca280704c46b59116dd2444e439892..90da1bf65a43b3e708a4bb2d3aafdfa4cb503ca0 100644 --- a/Post/ColorTable.cpp +++ b/Post/ColorTable.cpp @@ -768,17 +768,18 @@ void ColorTable_Recompute(GmshColorTable *ct) double ii = (double)(s - bias) * 128.; if(ii < 0) ii = 0; if(ii > 128) ii = 128; - double rr = ii <= 46 ? 0. : - ii >= 111 ? -0.03125 * (ii - 111) + 1. : - ii >= 78 ? 1. : 0.03125 * (ii - 46); - double gg = ii <= 14 || ii >= 111 ? - 0. : - ii >= 79 ? -0.03125 * (ii - 111) : - ii <= 46 ? 0.03125 * (ii - 14) : 1.; - double bb = ii >= 79 ? - 0. : - ii >= 47 ? -0.03125 * (ii - 79) : - ii <= 14 ? 0.03125 * (ii - 14) + 1. : 1.; + double rr = ii <= 46 ? 0. : + ii >= 111 ? -0.03125 * (ii - 111) + 1. : + ii >= 78 ? 1. : + 0.03125 * (ii - 46); + double gg = ii <= 14 || ii >= 111 ? 0. : + ii >= 79 ? -0.03125 * (ii - 111) : + ii <= 46 ? 0.03125 * (ii - 14) : + 1.; + double bb = ii >= 79 ? 0. : + ii >= 47 ? -0.03125 * (ii - 79) : + ii <= 14 ? 0.03125 * (ii - 14) + 1. : + 1.; r = (int)(rr * 255.); g = (int)(gg * 255.); b = (int)(bb * 255.); @@ -908,9 +909,7 @@ void ColorTable_Recompute(GmshColorTable *ct) b = (int)(255. * sqrt((2. * gray(s - bias) + hot_b(s - bias)) / 3.)); break; case 9: // grayscale - if(s - bias <= 0.) { - r = g = b = 0; - } + if(s - bias <= 0.) { r = g = b = 0; } else if(s - bias <= 1.) { r = g = b = (int)(255 * (1. - curvature) * (s - bias)); } @@ -924,14 +923,17 @@ void ColorTable_Recompute(GmshColorTable *ct) if(ii < 0) ii = 0; if(ii > 1) ii = 1; double rr = ii >= .75 ? 2 * (0.75 - ii) + 1. : - ii >= .5 ? 1. : ii >= .25 ? 4. * (ii - 0.25) : 0.; + ii >= .5 ? 1. : + ii >= .25 ? 4. * (ii - 0.25) : + 0.; double gg = ii <= .25 ? 1.33333 * ii : - ii <= .5 ? 0.33333 + 2.66667 * (ii - 0.25) : - ii <= .75 ? 1 - 2.66667 * (ii - 0.5) : - 1.33333 * (1. - ii); - double bb = ii <= 0.25 ? - 2 * ii + 0.5 : - ii <= 0.5 ? 1. : ii <= 0.75 ? 4 * (0.75 - ii) : 0.; + ii <= .5 ? 0.33333 + 2.66667 * (ii - 0.25) : + ii <= .75 ? 1 - 2.66667 * (ii - 0.5) : + 1.33333 * (1. - ii); + double bb = ii <= 0.25 ? 2 * ii + 0.5 : + ii <= 0.5 ? 1. : + ii <= 0.75 ? 4 * (0.75 - ii) : + 0.; r = (int)(rr * 255.); g = (int)(gg * 255.); b = (int)(bb * 255.); @@ -1121,9 +1123,7 @@ int ColorTable_IsAlpha(GmshColorTable *ct) void HSV_to_RGB(double H, double S, double V, double *R, double *G, double *B) { - if(S < 5.0e-6) { - *R = *G = *B = V; - } + if(S < 5.0e-6) { *R = *G = *B = V; } else { int i = (int)H; double f = H - (float)i; diff --git a/Post/OctreePost.cpp b/Post/OctreePost.cpp index c50eb9d061b7c4939f15f9415e4456149b724d8f..c5b523360948ab0bd3c8d7c1e83d2702c39185d3 100644 --- a/Post/OctreePost.cpp +++ b/Post/OctreePost.cpp @@ -567,55 +567,43 @@ bool OctreePost::searchScalar(double x, double y, double z, double *values, numSteps = _theViewDataList->getNumTimeSteps(); else if(_theViewDataGModel) numSteps = _theViewDataGModel->getNumTimeSteps(); - for(int i = 0; i < numSteps * mult; i++) { - values[i] = 0.; - } + for(int i = 0; i < numSteps * mult; i++) { values[i] = 0.; } } else { for(int i = 0; i < mult; i++) values[i] = 0.; } if(_theViewDataList) { - if((dim < 0 || dim == 3) && - _getValue(getElement(P, _ss, 4, qn, qx, qy, qz), 3, 4, 1, P, step, - values, size, grad)) + if((dim < 0 || dim == 3) && _getValue(getElement(P, _ss, 4, qn, qx, qy, qz), + 3, 4, 1, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 3) && - _getValue(getElement(P, _sh, 8, qn, qx, qy, qz), 3, 8, 1, P, step, - values, size, grad)) + if((dim < 0 || dim == 3) && _getValue(getElement(P, _sh, 8, qn, qx, qy, qz), + 3, 8, 1, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 3) && - _getValue(getElement(P, _si, 6, qn, qx, qy, qz), 3, 6, 1, P, step, - values, size, grad)) + if((dim < 0 || dim == 3) && _getValue(getElement(P, _si, 6, qn, qx, qy, qz), + 3, 6, 1, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 3) && - _getValue(getElement(P, _sy, 5, qn, qx, qy, qz), 3, 5, 1, P, step, - values, size, grad)) + if((dim < 0 || dim == 3) && _getValue(getElement(P, _sy, 5, qn, qx, qy, qz), + 3, 5, 1, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 2) && - _getValue(getElement(P, _st, 3, qn, qx, qy, qz), 2, 3, 1, P, step, - values, size, grad)) + if((dim < 0 || dim == 2) && _getValue(getElement(P, _st, 3, qn, qx, qy, qz), + 2, 3, 1, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 2) && - _getValue(getElement(P, _sq, 4, qn, qx, qy, qz), 2, 4, 1, P, step, - values, size, grad)) + if((dim < 0 || dim == 2) && _getValue(getElement(P, _sq, 4, qn, qx, qy, qz), + 2, 4, 1, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 1) && - _getValue(getElement(P, _sl, 2, qn, qx, qy, qz), 1, 2, 1, P, step, - values, size, grad)) + if((dim < 0 || dim == 1) && _getValue(getElement(P, _sl, 2, qn, qx, qy, qz), + 1, 2, 1, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 0) && - _getValue(getElement(P, _sp, 1, qn, qx, qy, qz), 0, 1, 1, P, step, - values, size, grad)) + if((dim < 0 || dim == 0) && _getValue(getElement(P, _sp, 1, qn, qx, qy, qz), + 0, 1, 1, P, step, values, size, grad)) return true; } else if(_theViewDataGModel) { GModel *m = _theViewDataGModel->getModel((step < 0) ? 0 : step); if(m) { MElement *e = getElement(P, m, qn, qx, qy, qz, dim); - if(_getValue(e, 1, P, step, values, size, grad)) { - return true; - } + if(_getValue(e, 1, P, step, values, size, grad)) { return true; } } } @@ -660,46 +648,36 @@ bool OctreePost::searchVector(double x, double y, double z, double *values, } if(_theViewDataList) { - if((dim < 0 || dim == 3) && - _getValue(getElement(P, _vs, 4, qn, qx, qy, qz), 3, 4, 3, P, step, - values, size, grad)) + if((dim < 0 || dim == 3) && _getValue(getElement(P, _vs, 4, qn, qx, qy, qz), + 3, 4, 3, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 3) && - _getValue(getElement(P, _vh, 8, qn, qx, qy, qz), 3, 8, 3, P, step, - values, size, grad)) + if((dim < 0 || dim == 3) && _getValue(getElement(P, _vh, 8, qn, qx, qy, qz), + 3, 8, 3, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 3) && - _getValue(getElement(P, _vi, 6, qn, qx, qy, qz), 3, 6, 3, P, step, - values, size, grad)) + if((dim < 0 || dim == 3) && _getValue(getElement(P, _vi, 6, qn, qx, qy, qz), + 3, 6, 3, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 3) && - _getValue(getElement(P, _vy, 5, qn, qx, qy, qz), 3, 5, 3, P, step, - values, size, grad)) + if((dim < 0 || dim == 3) && _getValue(getElement(P, _vy, 5, qn, qx, qy, qz), + 3, 5, 3, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 2) && - _getValue(getElement(P, _vt, 3, qn, qx, qy, qz), 2, 3, 3, P, step, - values, size, grad)) + if((dim < 0 || dim == 2) && _getValue(getElement(P, _vt, 3, qn, qx, qy, qz), + 2, 3, 3, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 2) && - _getValue(getElement(P, _vq, 4, qn, qx, qy, qz), 2, 4, 3, P, step, - values, size, grad)) + if((dim < 0 || dim == 2) && _getValue(getElement(P, _vq, 4, qn, qx, qy, qz), + 2, 4, 3, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 1) && - _getValue(getElement(P, _vl, 2, qn, qx, qy, qz), 1, 2, 3, P, step, - values, size, grad)) + if((dim < 0 || dim == 1) && _getValue(getElement(P, _vl, 2, qn, qx, qy, qz), + 1, 2, 3, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 0) && - _getValue(getElement(P, _vp, 1, qn, qx, qy, qz), 0, 1, 3, P, step, - values, size, grad)) + if((dim < 0 || dim == 0) && _getValue(getElement(P, _vp, 1, qn, qx, qy, qz), + 0, 1, 3, P, step, values, size, grad)) return true; } else if(_theViewDataGModel) { GModel *m = _theViewDataGModel->getModel((step < 0) ? 0 : step); if(m) { MElement *e = getElement(P, m, qn, qx, qy, qz, dim); - if(_getValue(e, 3, P, step, values, size, grad)) { - return true; - } + if(_getValue(e, 3, P, step, values, size, grad)) { return true; } } } @@ -744,46 +722,36 @@ bool OctreePost::searchTensor(double x, double y, double z, double *values, } if(_theViewDataList) { - if((dim < 0 || dim == 3) && - _getValue(getElement(P, _ts, 4, qn, qx, qy, qz), 3, 4, 9, P, step, - values, size, grad)) + if((dim < 0 || dim == 3) && _getValue(getElement(P, _ts, 4, qn, qx, qy, qz), + 3, 4, 9, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 3) && - _getValue(getElement(P, _th, 8, qn, qx, qy, qz), 3, 8, 9, P, step, - values, size, grad)) + if((dim < 0 || dim == 3) && _getValue(getElement(P, _th, 8, qn, qx, qy, qz), + 3, 8, 9, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 3) && - _getValue(getElement(P, _ti, 6, qn, qx, qy, qz), 3, 6, 9, P, step, - values, size, grad)) + if((dim < 0 || dim == 3) && _getValue(getElement(P, _ti, 6, qn, qx, qy, qz), + 3, 6, 9, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 3) && - _getValue(getElement(P, _ty, 5, qn, qx, qy, qz), 3, 5, 9, P, step, - values, size, grad)) + if((dim < 0 || dim == 3) && _getValue(getElement(P, _ty, 5, qn, qx, qy, qz), + 3, 5, 9, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 2) && - _getValue(getElement(P, _tt, 3, qn, qx, qy, qz), 2, 3, 9, P, step, - values, size, grad)) + if((dim < 0 || dim == 2) && _getValue(getElement(P, _tt, 3, qn, qx, qy, qz), + 2, 3, 9, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 2) && - _getValue(getElement(P, _tq, 4, qn, qx, qy, qz), 2, 4, 9, P, step, - values, size, grad)) + if((dim < 0 || dim == 2) && _getValue(getElement(P, _tq, 4, qn, qx, qy, qz), + 2, 4, 9, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 1) && - _getValue(getElement(P, _tl, 2, qn, qx, qy, qz), 1, 2, 9, P, step, - values, size, grad)) + if((dim < 0 || dim == 1) && _getValue(getElement(P, _tl, 2, qn, qx, qy, qz), + 1, 2, 9, P, step, values, size, grad)) return true; - if((dim < 0 || dim == 0) && - _getValue(getElement(P, _tp, 1, qn, qx, qy, qz), 0, 1, 9, P, step, - values, size, grad)) + if((dim < 0 || dim == 0) && _getValue(getElement(P, _tp, 1, qn, qx, qy, qz), + 0, 1, 9, P, step, values, size, grad)) return true; } else if(_theViewDataGModel) { GModel *m = _theViewDataGModel->getModel((step < 0) ? 0 : step); if(m) { MElement *e = getElement(P, m, qn, qx, qy, qz, dim); - if(_getValue(e, 9, P, step, values, size, grad)) { - return true; - } + if(_getValue(e, 9, P, step, values, size, grad)) { return true; } } } diff --git a/Post/OctreePost.h b/Post/OctreePost.h index c175df0d3776fe7df5dca87f6c02b217d6226fc6..b4cc82ac4c41465f46494be39eeb988e6ec479f8 100644 --- a/Post/OctreePost.h +++ b/Post/OctreePost.h @@ -46,31 +46,31 @@ public: // prescribed dimension. bool searchScalar(double x, double y, double z, double *values, int step = -1, double *size = nullptr, int qn = 0, double *qx = nullptr, - double *qy = nullptr, double *qz = nullptr, bool grad = false, - int dim = -1); + double *qy = nullptr, double *qz = nullptr, + bool grad = false, int dim = -1); bool searchScalarWithTol(double x, double y, double z, double *values, - int step = -1, double *size = nullptr, double tol = 1.e-2, - int qn = 0, double *qx = nullptr, double *qy = nullptr, - double *qz = nullptr, bool grad = false, - int dim = -1); + int step = -1, double *size = nullptr, + double tol = 1.e-2, int qn = 0, double *qx = nullptr, + double *qy = nullptr, double *qz = nullptr, + bool grad = false, int dim = -1); bool searchVector(double x, double y, double z, double *values, int step = -1, double *size = nullptr, int qn = 0, double *qx = nullptr, - double *qy = nullptr, double *qz = nullptr, bool grad = false, - int dim = -1); + double *qy = nullptr, double *qz = nullptr, + bool grad = false, int dim = -1); bool searchVectorWithTol(double x, double y, double z, double *values, - int step = -1, double *size = nullptr, double tol = 1.e-2, - int qn = 0, double *qx = nullptr, double *qy = nullptr, - double *qz = nullptr, bool grad = false, - int dim = -1); + int step = -1, double *size = nullptr, + double tol = 1.e-2, int qn = 0, double *qx = nullptr, + double *qy = nullptr, double *qz = nullptr, + bool grad = false, int dim = -1); bool searchTensor(double x, double y, double z, double *values, int step = -1, double *size = nullptr, int qn = 0, double *qx = nullptr, - double *qy = nullptr, double *qz = nullptr, bool grad = false, - int dim = -1); + double *qy = nullptr, double *qz = nullptr, + bool grad = false, int dim = -1); bool searchTensorWithTol(double x, double y, double z, double *values, - int step = -1, double *size = nullptr, double tol = 1.e-2, - int qn = 0, double *qx = nullptr, double *qy = nullptr, - double *qz = nullptr, bool grad = false, - int dim = -1); + int step = -1, double *size = nullptr, + double tol = 1.e-2, int qn = 0, double *qx = nullptr, + double *qy = nullptr, double *qz = nullptr, + bool grad = false, int dim = -1); }; #endif diff --git a/Post/PView.cpp b/Post/PView.cpp index 09afcb1483949cb840c8711935413d947e05b570..01661a6c2b845df1b93e8dc5547c0370f3ce7dfb 100644 --- a/Post/PView.cpp +++ b/Post/PView.cpp @@ -295,9 +295,7 @@ void PView::combine(bool time, int how, bool remove, bool copyOptions) if(!d2) allModelBased = false; } PViewData *data = nullptr; - if(allListBased) { - data = new PViewDataList(); - } + if(allListBased) { data = new PViewDataList(); } else if(allModelBased) { PViewDataGModel *d2 = dynamic_cast<PViewDataGModel *>(nds[i].data[0]); data = new PViewDataGModel(d2->getType()); @@ -327,8 +325,7 @@ void PView::combine(bool time, int how, bool remove, bool copyOptions) } } if(remove) - for(auto it = rm.begin(); it != rm.end(); it++) - delete *it; + for(auto it = rm.begin(); it != rm.end(); it++) delete *it; } class PViewLessThanName { diff --git a/Post/PViewData.cpp b/Post/PViewData.cpp index 87f282f0d7de5cedce0f2a385489e19677f69818..823d1ba9aeaca2640c189464dc7939e901e7e538 100644 --- a/Post/PViewData.cpp +++ b/Post/PViewData.cpp @@ -12,15 +12,15 @@ std::map<std::string, interpolationMatrices> PViewData::_interpolationSchemes; -PViewData::PViewData() : _dirty(true), _fileIndex(0), _octree(nullptr), _adaptive(nullptr) +PViewData::PViewData() + : _dirty(true), _fileIndex(0), _octree(nullptr), _adaptive(nullptr) { } PViewData::~PViewData() { if(_adaptive) delete _adaptive; - for(auto it = _interpolation.begin(); - it != _interpolation.end(); it++) + for(auto it = _interpolation.begin(); it != _interpolation.end(); it++) for(std::size_t i = 0; i < it->second.size(); i++) delete it->second[i]; if(_octree) delete _octree; } @@ -196,26 +196,20 @@ void PViewData::deleteInterpolationMatrices(int type) void PViewData::removeInterpolationScheme(const std::string &name) { - auto it = - _interpolationSchemes.find(name); + auto it = _interpolationSchemes.find(name); if(it != _interpolationSchemes.end()) { - for(auto it2 = it->second.begin(); - it2 != it->second.end(); it2++) - for(std::size_t i = 0; i < it2->second.size(); i++) - delete it2->second[i]; + for(auto it2 = it->second.begin(); it2 != it->second.end(); it2++) + for(std::size_t i = 0; i < it2->second.size(); i++) delete it2->second[i]; _interpolationSchemes.erase(it); } } void PViewData::removeAllInterpolationSchemes() { - auto it = - _interpolationSchemes.begin(); + auto it = _interpolationSchemes.begin(); for(; it != _interpolationSchemes.end(); it++) - for(auto it2 = it->second.begin(); - it2 != it->second.end(); it2++) - for(std::size_t i = 0; i < it2->second.size(); i++) - delete it2->second[i]; + for(auto it2 = it->second.begin(); it2 != it->second.end(); it2++) + for(std::size_t i = 0; i < it2->second.size(); i++) delete it2->second[i]; _interpolationSchemes.clear(); std::map<std::string, interpolationMatrices>().swap(_interpolationSchemes); } diff --git a/Post/PViewData.h b/Post/PViewData.h index fdbcad3e88a592ed100787bb9409958b6107682d..314101a11c61dfa237e27fc3c0ce49daaf743552 100644 --- a/Post/PViewData.h +++ b/Post/PViewData.h @@ -90,12 +90,10 @@ public: // get/set min/max for given step (global over all steps if step=-1) virtual double getMin(int step = -1, bool onlyVisible = false, - int tensorRep = 0, - int forceNumComponents = 0, + int tensorRep = 0, int forceNumComponents = 0, int componentMap[9] = nullptr) = 0; virtual double getMax(int step = -1, bool onlyVisible = false, - int tensorRep = 0, - int forceNumComponents = 0, + int tensorRep = 0, int forceNumComponents = 0, int componentMap[9] = nullptr) = 0; virtual void setMin(double min) = 0; virtual void setMax(double max) = 0; @@ -299,31 +297,31 @@ public: // to a different value than -1. bool searchScalar(double x, double y, double z, double *values, int step = -1, double *size = nullptr, int qn = 0, double *qx = nullptr, - double *qy = nullptr, double *qz = nullptr, bool grad = false, - int dim = -1); + double *qy = nullptr, double *qz = nullptr, + bool grad = false, int dim = -1); bool searchScalarWithTol(double x, double y, double z, double *values, - int step = -1, double *size = nullptr, double tol = 1.e-2, - int qn = 0, double *qx = nullptr, double *qy = nullptr, - double *qz = nullptr, bool grad = false, - int dim = -1); + int step = -1, double *size = nullptr, + double tol = 1.e-2, int qn = 0, double *qx = nullptr, + double *qy = nullptr, double *qz = nullptr, + bool grad = false, int dim = -1); bool searchVector(double x, double y, double z, double *values, int step = -1, double *size = nullptr, int qn = 0, double *qx = nullptr, - double *qy = nullptr, double *qz = nullptr, bool grad = false, - int dim = -1); + double *qy = nullptr, double *qz = nullptr, + bool grad = false, int dim = -1); bool searchVectorWithTol(double x, double y, double z, double *values, - int step = -1, double *size = nullptr, double tol = 1.e-2, - int qn = 0, double *qx = nullptr, double *qy = nullptr, - double *qz = nullptr, bool grad = false, - int dim = -1); + int step = -1, double *size = nullptr, + double tol = 1.e-2, int qn = 0, double *qx = nullptr, + double *qy = nullptr, double *qz = nullptr, + bool grad = false, int dim = -1); bool searchTensor(double x, double y, double z, double *values, int step = -1, double *size = nullptr, int qn = 0, double *qx = nullptr, - double *qy = nullptr, double *qz = nullptr, bool grad = false, - int dim = -1); + double *qy = nullptr, double *qz = nullptr, + bool grad = false, int dim = -1); bool searchTensorWithTol(double x, double y, double z, double *values, - int step = -1, double *size = nullptr, double tol = 1.e-2, - int qn = 0, double *qx = nullptr, double *qy = nullptr, - double *qz = nullptr, bool grad = false, - int dim = -1); + int step = -1, double *size = nullptr, + double tol = 1.e-2, int qn = 0, double *qx = nullptr, + double *qy = nullptr, double *qz = nullptr, + bool grad = false, int dim = -1); // I/O routines virtual bool writeSTL(const std::string &fileName); diff --git a/Post/PViewDataGModel.cpp b/Post/PViewDataGModel.cpp index 9f12581f2b23d419137dbc06d920816681292f62..ee8d35c48afbcc94c03104b65d963c04068356e2 100644 --- a/Post/PViewDataGModel.cpp +++ b/Post/PViewDataGModel.cpp @@ -775,8 +775,7 @@ bool PViewDataGModel::combineTime(nameData &nd) } // copy interpolation matrices - for(auto it = - data[0]->_interpolation.begin(); + for(auto it = data[0]->_interpolation.begin(); it != data[0]->_interpolation.end(); it++) if(_interpolation[it->first].empty()) for(std::size_t i = 0; i < it->second.size(); i++) diff --git a/Post/PViewDataGModel.h b/Post/PViewDataGModel.h index 8cd26572cf1ff27c3e954055bcdb8a8be3e60aae..472ea1ad077dad434dcab9b24526c1f5c4363887 100644 --- a/Post/PViewDataGModel.h +++ b/Post/PViewDataGModel.h @@ -263,8 +263,8 @@ public: // Add homogeneous data "on the fly", without a map bool addData(GModel *model, const std::vector<std::size_t> &tags, - const std::vector<double> &data, int step, - double time, int partition, int numComp); + const std::vector<double> &data, int step, double time, + int partition, int numComp); // Allow to destroy the data void destroyData(); diff --git a/Post/PViewDataGModelIO.cpp b/Post/PViewDataGModelIO.cpp index ea9f5836acb03cccb4ac8eeca812a0d3b409e6a5..778cbedb671d3f64a267c45f12dced9b4655ef00 100644 --- a/Post/PViewDataGModelIO.cpp +++ b/Post/PViewDataGModelIO.cpp @@ -25,8 +25,7 @@ bool PViewDataGModel::addData(GModel *model, if(numComp < 0) { numComp = 9; - for(auto it = data.begin(); - it != data.end(); it++) + for(auto it = data.begin(); it != data.end(); it++) numComp = std::min(numComp, (int)it->second.size()); } @@ -40,8 +39,7 @@ bool PViewDataGModel::addData(GModel *model, model->getNumMeshElements(); _steps[step]->resizeData(numEnt); - for(auto it = data.begin(); - it != data.end(); it++) { + for(auto it = data.begin(); it != data.end(); it++) { int mult = it->second.size() / numComp; double *d = _steps[step]->getData(it->first, true, mult); for(int j = 0; j < numComp * mult; j++) d[j] = it->second[j]; @@ -51,7 +49,8 @@ bool PViewDataGModel::addData(GModel *model, return true; } -bool PViewDataGModel::addData(GModel *model, const std::vector<std::size_t> &tags, +bool PViewDataGModel::addData(GModel *model, + const std::vector<std::size_t> &tags, const std::vector<std::vector<double> > &data, int step, double time, int partition, int numComp) { @@ -61,7 +60,7 @@ bool PViewDataGModel::addData(GModel *model, const std::vector<std::size_t> &tag if(_type == ElementNodeData) { numComp = 1; // cannot infer, as we can have different element types } - else{ + else { numComp = 9; for(std::size_t i = 0; i < data.size(); i++) numComp = std::min(numComp, (int)data[i].size()); @@ -88,9 +87,10 @@ bool PViewDataGModel::addData(GModel *model, const std::vector<std::size_t> &tag return true; } -bool PViewDataGModel::addData(GModel *model, const std::vector<std::size_t> &tags, - const std::vector<double> &data, - int step, double time, int partition, int numComp) +bool PViewDataGModel::addData(GModel *model, + const std::vector<std::size_t> &tags, + const std::vector<double> &data, int step, + double time, int partition, int numComp) { if(data.empty() || tags.empty()) return false; @@ -254,8 +254,9 @@ bool PViewDataGModel::writeMSH(const std::string &fileName, double version, model0 = _steps[step]->getModel(); } if(saveMesh) { - if(!_steps[step]->getModel()->writeMSH - (stepFileName, version, binary, false, false, 1.0, 0, 0, multipleView)) + if(!_steps[step]->getModel()->writeMSH(stepFileName, version, binary, + false, false, 1.0, 0, 0, + multipleView)) return false; // append data fp = Fopen(stepFileName.c_str(), binary ? "ab" : "a"); @@ -279,7 +280,8 @@ bool PViewDataGModel::writeMSH(const std::string &fileName, double version, return false; } fprintf(fp, "$MeshFormat\n"); - fprintf(fp, "%g %d %d\n", version, binary ? 1 : 0, (int)sizeof(double)); + fprintf(fp, "%g %d %d\n", version, binary ? 1 : 0, + (int)sizeof(double)); if(binary) { int one = 1; fwrite(&one, sizeof(int), 1, fp); @@ -293,8 +295,8 @@ bool PViewDataGModel::writeMSH(const std::string &fileName, double version, fprintf(fp, "$InterpolationScheme\n"); fprintf(fp, "\"INTERPOLATION_SCHEME\"\n"); fprintf(fp, "%d\n", (int)_interpolation.size()); - for(auto it = _interpolation.begin(); - it != _interpolation.end(); it++) { + for(auto it = _interpolation.begin(); it != _interpolation.end(); + it++) { if(it->second.size() >= 2) { fprintf(fp, "%d\n2\n", it->first); for(int mat = 0; mat < 2; mat++) { @@ -352,8 +354,7 @@ bool PViewDataGModel::writeMSH(const std::string &fileName, double version, else fprintf(fp, "$ElementData\n"); if(saveInterpolationMatrices && haveInterpolationMatrices()) - fprintf(fp, "2\n\"%s\"\n\"INTERPOLATION_SCHEME\"\n", - getName().c_str()); + fprintf(fp, "2\n\"%s\"\n\"INTERPOLATION_SCHEME\"\n", getName().c_str()); else fprintf(fp, "1\n\"%s\"\n", getName().c_str()); @@ -372,8 +373,9 @@ bool PViewDataGModel::writeMSH(const std::string &fileName, double version, return false; } int mult = _steps[step]->getMult(i); - int num = (version >= 3.0) ? e->getNum() : - _steps[step]->getModel()->getMeshElementIndex(e); + int num = (version >= 3.0) ? + e->getNum() : + _steps[step]->getModel()->getMeshElementIndex(e); if(binary) { fwrite(&num, sizeof(int), 1, fp); if(_type == ElementNodeData) fwrite(&mult, sizeof(int), 1, fp); @@ -518,9 +520,7 @@ void PViewDataGModel::importLists(int N[24], std::vector<double> *V[24]) double *tmp = &(*list)[j]; int num = (int)tmp[0]; double *d = _steps[step]->getData(num, true, nn); - for(int k = 0; k < nc * nn; k++) { - d[k] = tmp[1 + nc * nn * step + k]; - } + for(int k = 0; k < nc * nn; k++) { d[k] = tmp[1 + nc * nn * step + k]; } } } } @@ -651,8 +651,10 @@ bool PViewDataGModel::readMED(const std::string &fileName, int fileIndex) setFileName(fileName); setFileIndex(fileIndex); - int numCompMsh = - (numComp <= 1) ? 1 : (numComp <= 3) ? 3 : (numComp <= 9) ? 9 : numComp; + int numCompMsh = (numComp <= 1) ? 1 : + (numComp <= 3) ? 3 : + (numComp <= 9) ? 9 : + numComp; if(numCompMsh > 9) Msg::Info( @@ -764,13 +766,11 @@ bool PViewDataGModel::readMED(const std::string &fileName, int fileIndex) #endif if(numVal <= 0) continue; - _type = (ent == MED_NOEUD) ? - NodeData : - (ent == MED_MAILLE) ? ElementData : ElementNodeData; + _type = (ent == MED_NOEUD) ? NodeData : + (ent == MED_MAILLE) ? ElementData : + ElementNodeData; int mult = 1; - if(ent == MED_NOEUD_MAILLE) { - mult = nodesPerEle[pairs[pair].second]; - } + if(ent == MED_NOEUD_MAILLE) { mult = nodesPerEle[pairs[pair].second]; } else if(ngauss != 1) { mult = ngauss; _type = GaussPointData; @@ -888,9 +888,7 @@ bool PViewDataGModel::readMED(const std::string &fileName, int fileIndex) if(tags.empty()) { std::size_t maxv, maxe; _steps[step]->getModel()->getCheckPointedMaxNumbers(maxv, maxe); - if(nodal) { - startIndex += maxv; - } + if(nodal) { startIndex += maxv; } else { for(int i = 1; i < pairs[pair].second; i++) { #if(MED_MAJOR_NUM >= 3) @@ -905,15 +903,14 @@ bool PViewDataGModel::readMED(const std::string &fileName, int fileIndex) } startIndex += maxe; } - Msg::Debug("MED has no tags -- assuming starting index %lu", startIndex); + Msg::Debug("MED has no tags -- assuming starting index %lu", + startIndex); } // compute entity numbers using profile, then fill step data for(std::size_t i = 0; i < profile.size(); i++) { std::size_t num; - if(tags.empty()) { - num = startIndex + profile[i]; - } + if(tags.empty()) { num = startIndex + profile[i]; } else { if(profile[i] == 0 || profile[i] > (int)tags.size()) { Msg::Error("Wrong index in profile"); @@ -966,8 +963,9 @@ bool PViewDataGModel::writeMED(const std::string &fileName) #if(MED_MAJOR_NUM >= 3) && (MED_MINOR_NUM >= 3) // MEDfileVersionOpen actually appeared in MED 3.2.1 - med_int major = MED_MAJOR_NUM, minor = MED_MINOR_NUM, release = MED_RELEASE_NUM; - if(CTX::instance()->mesh.medFileMinorVersion >= 0){ + med_int major = MED_MAJOR_NUM, minor = MED_MINOR_NUM, + release = MED_RELEASE_NUM; + if(CTX::instance()->mesh.medFileMinorVersion >= 0) { minor = (int)CTX::instance()->mesh.medFileMinorVersion; Msg::Info("Forcing MED file version to %d.%d", major, minor); } @@ -1096,12 +1094,10 @@ bool PViewDataGModel::writeMED(const std::string &fileName) bool PViewDataGModel::readPCH(const std::string &fileName, int fileIndex) { - Msg::Info("Placeholder for reading punch file '%s'", - fileName.c_str()); + Msg::Info("Placeholder for reading punch file '%s'", fileName.c_str()); std::map<int, std::vector<double> > data; - for(int i = 1; i < 200; i++) - data[i].push_back(1.234); + for(int i = 1; i < 200; i++) data[i].push_back(1.234); addData(GModel::current(), data, 0, 0.0, 1, 1); return true; @@ -1122,12 +1118,12 @@ void PViewDataGModel::sendToServer(const std::string &name) int ne = 0; for(std::size_t i = 0; i < _steps[step]->getNumData(); i++) if(_steps[step]->getData(i)) ne++; - if(!step){ + if(!step) { numEnt = ne; numComp = nc; } - else{ - if(ne != numEnt || nc != numComp){ + else { + if(ne != numEnt || nc != numComp) { Msg::Error("Can not send heterogeneous view to server"); return; } @@ -1146,8 +1142,8 @@ void PViewDataGModel::sendToServer(const std::string &name) } int num = v->getNum(); exp.push_back(num); - for(std::size_t step = 0; step < _steps.size(); step++){ - for(int k = 0; k < numComp; k++){ + for(std::size_t step = 0; step < _steps.size(); step++) { + for(int k = 0; k < numComp; k++) { double data = _steps[step]->getData(i)[k]; exp.push_back(data); } diff --git a/Post/PViewDataGModelIO_CGNS.cpp b/Post/PViewDataGModelIO_CGNS.cpp index 39c6ab38533aa70a343b52286691355a1702f46d..dcd9f34e42ff5db3fb842c7201088f1194ab97b3 100644 --- a/Post/PViewDataGModelIO_CGNS.cpp +++ b/Post/PViewDataGModelIO_CGNS.cpp @@ -428,8 +428,9 @@ namespace { // type and total number of entities (either vertices or elements) in zone const bool nodeOrEltData = (dataType == PViewDataGModel::NodeData); - const cgsize_t *zoneEntSize = - nodeOrEltData ? zoneSize : isStructured ? zoneSize + dim : zoneSize + 1; + const cgsize_t *zoneEntSize = nodeOrEltData ? zoneSize : + isStructured ? zoneSize + dim : + zoneSize + 1; // get solution order int order = 1; diff --git a/Post/PViewDataIO.cpp b/Post/PViewDataIO.cpp index ab02e203a91f42fda1bf56b2e35e4f25651019c1..b850dd348b8f715137a0b775251a741cceafc93b 100644 --- a/Post/PViewDataIO.cpp +++ b/Post/PViewDataIO.cpp @@ -291,8 +291,7 @@ void PViewData::sendToServer(const std::string &name) bool ok = toVector(vec); // Success ? - if(!ok) - Msg::Error("sendToServer: cannot vectorize PView"); + if(!ok) Msg::Error("sendToServer: cannot vectorize PView"); // Only one step ? if(vec.size() != 1) diff --git a/Post/PViewDataList.cpp b/Post/PViewDataList.cpp index 8dc1461ef904c7cf7537d080a41ee33b9a25a1a5..6de0bf6fb626ef37578f67de6a549d43e8796763 100644 --- a/Post/PViewDataList.cpp +++ b/Post/PViewDataList.cpp @@ -71,15 +71,13 @@ void PViewDataList::addStep(std::vector<double> &y) std::vector<double> tmp; int stride = SP.size() / NbSP; for(int i = 0; i < NbSP; i++) { - for(int j = 0; j < stride; j++) - tmp.push_back(SP[i * stride + j]); + for(int j = 0; j < stride; j++) tmp.push_back(SP[i * stride + j]); tmp.push_back(y[i]); } SP = tmp; finalize(); } - bool PViewDataList::finalize(bool computeMinMax, const std::string &interpolationScheme) { @@ -717,9 +715,8 @@ bool PViewDataList::combineSpace(nameData &nd) } // copy interpolation matrices - for(auto it = - l->_interpolation.begin(); - it != l->_interpolation.end(); it++) + for(auto it = l->_interpolation.begin(); it != l->_interpolation.end(); + it++) if(_interpolation[it->first].empty()) for(std::size_t i = 0; i < it->second.size(); i++) _interpolation[it->first].push_back( @@ -856,8 +853,7 @@ bool PViewDataList::combineTime(nameData &nd) } NbT2 = data[0]->NbT2; NbT3 = data[0]->NbT3; - for(auto it = - data[0]->_interpolation.begin(); + for(auto it = data[0]->_interpolation.begin(); it != data[0]->_interpolation.end(); it++) if(_interpolation[it->first].empty()) for(std::size_t i = 0; i < it->second.size(); i++) diff --git a/Post/PViewDataListIO.cpp b/Post/PViewDataListIO.cpp index b3ea42d0b2156296414906af988ac32478f9b647..f4a4547deaf64c2da97eb487d718872256da0011 100644 --- a/Post/PViewDataListIO.cpp +++ b/Post/PViewDataListIO.cpp @@ -682,7 +682,8 @@ bool PViewDataList::writeMSH(const std::string &fileName, double version, if(version > 2.2) Msg::Warning("Mesh-based export of list-based datasets not available with " - "MSH %g: using MSH 2.2", version); + "MSH %g: using MSH 2.2", + version); fprintf(fp, "$MeshFormat\n2.2 0 8\n$EndMeshFormat\n"); @@ -709,8 +710,7 @@ bool PViewDataList::writeMSH(const std::string &fileName, double version, fprintf(fp, "$InterpolationScheme\n"); fprintf(fp, "\"INTERPOLATION_SCHEME\"\n"); fprintf(fp, "%d\n", (int)_interpolation.size()); - for(auto it = _interpolation.begin(); - it != _interpolation.end(); it++) { + for(auto it = _interpolation.begin(); it != _interpolation.end(); it++) { if(it->second.size() >= 2) { fprintf(fp, "%d\n2\n", it->first); for(int mat = 0; mat < 2; mat++) { diff --git a/Post/PViewFactory.cpp b/Post/PViewFactory.cpp index fc228c3537004bc4209e515a9b07157247497180..9ae5c2ffc21546f734fc3d50fb1395e318e9a27e 100644 --- a/Post/PViewFactory.cpp +++ b/Post/PViewFactory.cpp @@ -21,9 +21,7 @@ void PViewFactory::setEntry(int id, const fullMatrix<double> &val) vv.resize(val.size1() * val.size2()); int k = 0; for(int i = 0; i < val.size1(); i++) { - for(int j = 0; j < val.size2(); j++) { - vv[k++] = val(i, j); - } + for(int j = 0; j < val.size2(); j++) { vv[k++] = val(i, j); } } } diff --git a/Post/PViewIO.cpp b/Post/PViewIO.cpp index b1dddb1ee24e17af370228c76190916c309c52b3..3b275bc6036dc5db956b43fbbdfc8c1b28b8c0de 100644 --- a/Post/PViewIO.cpp +++ b/Post/PViewIO.cpp @@ -81,7 +81,8 @@ bool PView::readPOS(const std::string &fileName, int fileIndex) return true; } -bool PView::readMSH(const std::string &fileName, int fileIndex, int partitionToRead) +bool PView::readMSH(const std::string &fileName, int fileIndex, + int partitionToRead) { FILE *fp = Fopen(fileName.c_str(), "rb"); if(!fp) { @@ -276,8 +277,9 @@ bool PView::readMSH(const std::string &fileName, int fileIndex, int partitionToR } } if(partitionToRead == -1 || partitionToRead == partition) { - // if default (no particular partition requested from MergeFile -> -1) or - // if current partition corresponds to the requested partition, read the data + // if default (no particular partition requested from MergeFile -> -1) + // or if current partition corresponds to the requested partition, + // read the data if(numEnt > 0) { // either get existing viewData, or create new one PView *p = getViewByName(viewName, timeStep, partition); @@ -302,8 +304,9 @@ bool PView::readMSH(const std::string &fileName, int fileIndex, int partitionToR } } else if(blocksize > 0 && partitionToRead != partition) { - // if current partition does not correspond to the requested partition and - // if its blocksise has been read (5th integer in the header), jump over it + // if current partition does not correspond to the requested partition + // and if its blocksise has been read (5th integer in the header), + // jump over it fseek(fp, blocksize, SEEK_CUR); } } @@ -378,15 +381,9 @@ bool PView::write(const std::string &fileName, int format, bool append) bool ret; switch(format) { - case 0: - ret = _data->writePOS(fileName, false, false, append); - break; // ASCII - case 1: - ret = _data->writePOS(fileName, true, false, append); - break; // binary - case 2: - ret = _data->writePOS(fileName, false, true, append); - break; // parsed + case 0: ret = _data->writePOS(fileName, false, false, append); break; // ASCII + case 1: ret = _data->writePOS(fileName, true, false, append); break; // binary + case 2: ret = _data->writePOS(fileName, false, true, append); break; // parsed case 3: ret = _data->writeSTL(fileName); break; case 4: ret = _data->writeTXT(fileName); break; case 5: @@ -444,6 +441,7 @@ bool PView::writeAdapt(const std::string &guifileName, int useDefaultName, void PView::sendToServer(const std::string &name) { - Msg::Info("Sending View[%d] to ONELAB as parameter '%s'", _index, name.c_str()); + Msg::Info("Sending View[%d] to ONELAB as parameter '%s'", _index, + name.c_str()); _data->sendToServer(name); } diff --git a/Post/PViewVertexArrays.cpp b/Post/PViewVertexArrays.cpp index 96611b6b8e1e90ff451728548f96f65f4c4e7d03..4b885a57c06f9d2f6e2471befbf1a1037794d138 100644 --- a/Post/PViewVertexArrays.cpp +++ b/Post/PViewVertexArrays.cpp @@ -295,8 +295,7 @@ bool isElementVisible(PViewOptions *opt, int dim, int numNodes, double **xyz) bool hidden = false; for(int clip = 0; clip < 6; clip++) { if(opt->clip & (1 << clip)) { - if(dim < 3 && CTX::instance()->clipOnlyVolume) { - } + if(dim < 3 && CTX::instance()->clipOnlyVolume) {} else { double d = intersectClipPlane(clip, numNodes, xyz); if(dim == 3 && CTX::instance()->clipOnlyDrawIntersectingVolume && d) { @@ -318,7 +317,8 @@ static void addOutlinePoint(PView *p, double **xyz, unsigned int color, { if(pre) return; SVector3 n = getPointNormal(p, 1.); - p->va_points->add(&xyz[i0][0], &xyz[i0][1], &xyz[i0][2], &n, &color, nullptr, true); + p->va_points->add(&xyz[i0][0], &xyz[i0][1], &xyz[i0][2], &n, &color, nullptr, + true); } static void addScalarPoint(PView *p, double **xyz, double **val, bool pre, @@ -527,7 +527,8 @@ static void addScalarTriangle(PView *p, double **xyz, double **val, bool pre, } col[i] = opt->getColor(v3[i], vmin, vmax); } - if(!pre) p->va_triangles->add(x3, y3, z3, n, col, nullptr, unique, skin); + if(!pre) + p->va_triangles->add(x3, y3, z3, n, col, nullptr, unique, skin); } } } @@ -556,7 +557,8 @@ static void addScalarTriangle(PView *p, double **xyz, double **val, bool pre, p->normals->get(x3[i], y3[i], z3[i], n[i][0], n[i][1], n[i][2]); } } - if(!pre) p->va_triangles->add(x3, y3, z3, n, col, nullptr, unique, skin); + if(!pre) + p->va_triangles->add(x3, y3, z3, n, col, nullptr, unique, skin); } } if(vmin == vmax) break; @@ -673,8 +675,7 @@ static void addScalarPolygon(PView *p, double **xyz, double **val, bool pre, } opt->boundary--; - for(auto ite = edges.begin(); - ite != edges.end(); ite++) { + for(auto ite = edges.begin(); ite != edges.end(); ite++) { int i = (int)(*ite).second / 100; int j = (*ite).second % 100; if(j < 3) @@ -750,7 +751,8 @@ static void addScalarTetrahedron(PView *p, double **xyz, double **val, bool pre, p->normals->get(x3[i], y3[i], z3[i], n[i][0], n[i][1], n[i][2]); } } - if(!pre) p->va_triangles->add(x3, y3, z3, n, col, nullptr, false, false); + if(!pre) + p->va_triangles->add(x3, y3, z3, n, col, nullptr, false, false); } } if(vmin == vmax) break; @@ -895,8 +897,7 @@ static void addOutlinePolyhedron(PView *p, double **xyz, unsigned int color, triFaces.erase(ite); } } - for(auto ite = triFaces.begin(); - ite != triFaces.end(); ite++) { + for(auto ite = triFaces.begin(); ite != triFaces.end(); ite++) { int i = (int)(*ite).second / 100; int j = (*ite).second % 100; if(j < 4) @@ -911,9 +912,7 @@ static void addScalarPolyhedron(PView *p, double **xyz, double **val, bool pre, { PViewOptions *opt = p->getOptions(); - if(opt->boundary > 0) { - return; - } + if(opt->boundary > 0) { return; } for(int i = 0; i < numNodes / 4; i++) addScalarTetrahedron(p, xyz, val, pre, 4 * i, 4 * i + 1, 4 * i + 2, @@ -1050,7 +1049,8 @@ static void addVectorElement(PView *p, int ient, int iele, int numNodes, dxyz[j][0] = xyz[i][j]; dxyz[j][1] = val[i][j]; } - p->va_vectors->add(dxyz[0], dxyz[1], dxyz[2], nullptr, col, nullptr, false); + p->va_vectors->add(dxyz[0], dxyz[1], dxyz[2], nullptr, col, nullptr, + false); } } } @@ -1087,7 +1087,8 @@ static void addVectorElement(PView *p, int ient, int iele, int numNodes, dxyz[i][0] = pc[i]; dxyz[i][1] = d[i]; } - p->va_vectors->add(dxyz[0], dxyz[1], dxyz[2], nullptr, col, nullptr, false); + p->va_vectors->add(dxyz[0], dxyz[1], dxyz[2], nullptr, col, nullptr, + false); } } for(int i = 0; i < numNodes; i++) delete[] val2[i]; @@ -1202,16 +1203,15 @@ static void addTensorElement(PView *p, int iEnt, int iEle, int numNodes, tensor.eig(S, imS, V, rightV, false); for(int k = 0; k < 3; k++) { vval[k][0] = xyz[i][k]; - for(int j = 0; j < 3; j++) { - vval[k][j + 1] = V(k, j) * S(j); - } + for(int j = 0; j < 3; j++) { vval[k][j + 1] = V(k, j) * S(j); } } double lmax = std::max(S(0), std::max(S(1), S(2))); unsigned int color = opt->getColor( lmax, opt->tmpMin, opt->tmpMax, false, (opt->intervalsType == PViewOptions::Discrete) ? opt->nbIso : -1); unsigned int col[4] = {color, color, color, color}; - p->va_ellipses->add(vval[0], vval[1], vval[2], nullptr, col, nullptr, false); + p->va_ellipses->add(vval[0], vval[1], vval[2], nullptr, col, nullptr, + false); } } else if(opt->glyphLocation == PViewOptions::COG) { @@ -1237,7 +1237,8 @@ static void addTensorElement(PView *p, int iEnt, int iEle, int numNodes, lmax, opt->tmpMin, opt->tmpMax, false, (opt->intervalsType == PViewOptions::Discrete) ? opt->nbIso : -1); unsigned int col[4] = {color, color, color, color}; - p->va_ellipses->add(vval[0], vval[1], vval[2], nullptr, col, nullptr, false); + p->va_ellipses->add(vval[0], vval[1], vval[2], nullptr, col, nullptr, + false); } } else { diff --git a/Post/PViewX3D.cpp b/Post/PViewX3D.cpp index 31f3413c4b932e664d73afb189e65b8ae6bbd06d..8a700b9719817f09c62eef2b7154303bd78ed5b2 100644 --- a/Post/PViewX3D.cpp +++ b/Post/PViewX3D.cpp @@ -240,8 +240,7 @@ bool PView::writeX3D(const std::string &fileName) fprintf(fp, " </head>\n"); // Viewport SBoundingBox3d bb(0., 0., 0., 0., 0., 0.); - for(auto pvit = PView::list.begin(); - pvit < PView::list.end(); pvit++) { + for(auto pvit = PView::list.begin(); pvit < PView::list.end(); pvit++) { PViewData *data = (*pvit)->getData(true); PViewOptions *opt = (*pvit)->getOptions(); if(!data->getDirty() && opt->visible) { diff --git a/Post/adaptiveData.cpp b/Post/adaptiveData.cpp index caa8269386e4f1dcfd3471e661dc7cfd2d7f664a..70cd1725646402b56a329b82ad1dd8d131a989d9 100644 --- a/Post/adaptiveData.cpp +++ b/Post/adaptiveData.cpp @@ -58,9 +58,7 @@ std::vector<PValues> globalVTKData::vtkGlobalValues; template <class T> static void cleanElement() { - for(auto it = T::all.begin(); it != T::all.end(); - ++it) - delete *it; + for(auto it = T::all.begin(); it != T::all.end(); ++it) delete *it; T::all.clear(); T::allVertices.clear(); } @@ -567,9 +565,7 @@ void adaptiveTetrahedron::recurError(adaptiveTetrahedron *t, double AVG, double vri[8]; for(int k = 0; k < 8; k++) { vri[k] = 0.0; - for(int l = 0; l < 8; l++) { - vri[k] += vi[k][l]; - } + for(int l = 0; l < 8; l++) { vri[k] += vi[k][l]; } vri[k] /= 8.0; } if(fabs(t->e[0]->V() - vri[0]) > AVG * tol || @@ -766,9 +762,7 @@ void adaptiveHexahedron::recurError(adaptiveHexahedron *h, double AVG, double vri[8]; for(int k = 0; k < 8; k++) { vri[k] = 0.0; - for(int l = 0; l < 8; l++) { - vri[k] += vii[k][l]; - } + for(int l = 0; l < 8; l++) { vri[k] += vii[k][l]; } vri[k] /= 8.0; } if(fabs(h->e[0]->V() - vri[0]) > AVG * tol || @@ -1086,8 +1080,8 @@ void adaptivePyramid::recurError(adaptivePyramid *p, double AVG, double tol) template <class T> adaptiveElements<T>::adaptiveElements(std::vector<fullMatrix<double> *> &p) - : _coeffsVal(nullptr), _eexpsVal(nullptr), _interpolVal(nullptr), _coeffsGeom(nullptr), _eexpsGeom(nullptr), - _interpolGeom(nullptr) + : _coeffsVal(nullptr), _eexpsVal(nullptr), _interpolVal(nullptr), + _coeffsGeom(nullptr), _eexpsGeom(nullptr), _interpolGeom(nullptr) { if(p.size() >= 2) { _coeffsVal = p[0]; @@ -1128,8 +1122,7 @@ template <class T> void adaptiveElements<T>::init(int level) if(_eexpsGeom) tmpg = new fullVector<double>(_eexpsGeom->size1()); int i = 0; - for(auto it = T::allVertices.begin(); - it != T::allVertices.end(); ++it) { + for(auto it = T::allVertices.begin(); it != T::allVertices.end(); ++it) { if(_coeffsVal && _eexpsVal) computeShapeFunctions(_coeffsVal, _eexpsVal, it->x, it->y, it->z, &sfv, tmpv); @@ -1180,8 +1173,7 @@ template <> void adaptiveElements<adaptivePyramid>::init(int level) if(_eexpsGeom) tmpg = new fullVector<double>(_eexpsGeom->size1()); int i = 0; - for(auto it = - adaptivePyramid::allVertices.begin(); + for(auto it = adaptivePyramid::allVertices.begin(); it != adaptivePyramid::allVertices.end(); ++it) { if(_coeffsVal && _eexpsVal) computeShapeFunctionsPyramid(_coeffsVal, _eexpsVal, it->x, it->y, it->z, @@ -1272,9 +1264,7 @@ bool adaptiveElements<T>::adapt(double tol, int numComp, fullMatrix<double> valxyz(numVals, numComp); resxyz = new fullMatrix<double>(numVertices, numComp); for(int i = 0; i < numVals; i++) { - for(int k = 0; k < numComp; k++) { - valxyz(i, k) = values[i].v[k]; - } + for(int k = 0; k < numComp; k++) { valxyz(i, k) = values[i].v[k]; } } _interpolVal->mult(valxyz, *resxyz); } @@ -1301,8 +1291,7 @@ bool adaptiveElements<T>::adapt(double tol, int numComp, #endif int i = 0; - for(auto it = T::allVertices.begin(); - it != T::allVertices.end(); ++it) { + for(auto it = T::allVertices.begin(); it != T::allVertices.end(); ++it) { // ok because we know this will not change the set ordering adaptiveVertex *p = (adaptiveVertex *)&(*it); p->val = res(i); @@ -1327,8 +1316,7 @@ bool adaptiveElements<T>::adapt(double tol, int numComp, if(resxyz) delete resxyz; - for(auto it = T::all.begin(); it != T::all.end(); - it++) + for(auto it = T::all.begin(); it != T::all.end(); it++) (*it)->visible = false; if(!plug || tol != 0.) { @@ -1341,8 +1329,7 @@ bool adaptiveElements<T>::adapt(double tol, int numComp, coords.clear(); values.clear(); - for(auto it = T::all.begin(); it != T::all.end(); - it++) { + for(auto it = T::all.begin(); it != T::all.end(); it++) { if((*it)->visible) { adaptiveVertex **p = (*it)->p; for(int i = 0; i < T::numNodes; i++) { @@ -1488,7 +1475,7 @@ void adaptiveElements<T>::addInView(double tol, int step, PViewData *in, break; } } - if(adapt(tol, numComp, coords, values, out->Min, out->Max, plug)){ + if(adapt(tol, numComp, coords, values, out->Min, out->Max, plug)) { *outNb += coords.size() / T::numNodes; for(std::size_t i = 0; i < coords.size() / T::numNodes; i++) { for(int k = 0; k < T::numNodes; ++k) @@ -1507,8 +1494,9 @@ void adaptiveElements<T>::addInView(double tol, int step, PViewData *in, } adaptiveData::adaptiveData(PViewData *data, bool outDataInit) - : _step(-1), _level(-1), _tol(-1.), _inData(data), _points(nullptr), _lines(nullptr), - _triangles(nullptr), _quadrangles(nullptr), _tetrahedra(nullptr), _hexahedra(nullptr), _prisms(nullptr), + : _step(-1), _level(-1), _tol(-1.), _inData(data), _points(nullptr), + _lines(nullptr), _triangles(nullptr), _quadrangles(nullptr), + _tetrahedra(nullptr), _hexahedra(nullptr), _prisms(nullptr), _pyramids(nullptr) { if(outDataInit == @@ -1672,11 +1660,8 @@ void VTKData::writeVTKElmData() // Node value counter = 0; darray = new double[vtkNumComp * vtkLocalValues.size()]; - for(auto it = vtkLocalValues.begin(); - it != vtkLocalValues.end(); ++it) { - for(int i = 0; i < vtkNumComp; i++) { - darray[counter + i] = it->v[i]; - } + for(auto it = vtkLocalValues.begin(); it != vtkLocalValues.end(); ++it) { + for(int i = 0; i < vtkNumComp; i++) { darray[counter + i] = it->v[i]; } counter += vtkNumComp; vtkCountTotVal += vtkNumComp; } @@ -1689,11 +1674,8 @@ void VTKData::writeVTKElmData() int sizeArray = (int)vtkLocalCoords.size(); darray = new double[3 * sizeArray]; counter = 0; - for(auto it = vtkLocalCoords.begin(); - it != vtkLocalCoords.end(); ++it) { - for(int i = 0; i < 3; i++) { - darray[counter + i] = (*it).c[i]; - } + for(auto it = vtkLocalCoords.begin(); it != vtkLocalCoords.end(); ++it) { + for(int i = 0; i < 3; i++) { darray[counter + i] = (*it).c[i]; } counter += 3; vtkCountCoord += 3; } @@ -1739,8 +1721,8 @@ void VTKData::writeVTKElmData() // Cell type counter = 0; i8array = new uint8_t[vtkLocalConnectivity.size()]; - for(auto it = vtkLocalCellType.begin(); - it != vtkLocalCellType.end(); it++) { + for(auto it = vtkLocalCellType.begin(); it != vtkLocalCellType.end(); + it++) { i8array[counter] = *it; counter++; } @@ -1751,8 +1733,7 @@ void VTKData::writeVTKElmData() else { // ascii // Node values - for(auto it = vtkLocalValues.begin(); - it != vtkLocalValues.end(); ++it) { + for(auto it = vtkLocalValues.begin(); it != vtkLocalValues.end(); ++it) { for(int i = 0; i < vtkNumComp; i++) { fprintf(vtkFileNodVal, "%23.16e ", (*it).v[i]); vtkCountTotVal++; @@ -1760,8 +1741,7 @@ void VTKData::writeVTKElmData() } } - for(auto it = vtkLocalCoords.begin(); - it != vtkLocalCoords.end(); it++) { + for(auto it = vtkLocalCoords.begin(); it != vtkLocalCoords.end(); it++) { fprintf(vtkFileCoord, "%23.16e %23.16e %23.16e ", (*it).c[0], (*it).c[1], (*it).c[2]); vtkCountCoord += 3; @@ -1792,8 +1772,8 @@ void VTKData::writeVTKElmData() delete[] cellOffset; // Cell type - for(auto it = vtkLocalCellType.begin(); - it != vtkLocalCellType.end(); it++) { + for(auto it = vtkLocalCellType.begin(); it != vtkLocalCellType.end(); + it++) { fprintf(vtkFileCellType, "%d ", *it); vtkCountCellType++; if(vtkCountCellType % 6 == 0) fprintf(vtkFileCellType, "\n"); @@ -1803,9 +1783,7 @@ void VTKData::writeVTKElmData() // finalize and close current vtu file if(vtkCountTotElmLev0 <= numPartMinElm * minElmPerPart) { - if(vtkCountTotElmLev0 % minElmPerPart == 0) { - finalizeVTKFile(); - } + if(vtkCountTotElmLev0 % minElmPerPart == 0) { finalizeVTKFile(); } } else { if((vtkCountTotElmLev0 - numPartMinElm * minElmPerPart) % maxElmPerPart == @@ -2315,9 +2293,7 @@ void adaptiveElements<T>::adaptForVTK(double tol, int numComp, fullMatrix<double> valxyz(numVals, numComp); resxyz = new fullMatrix<double>(numVertices, numComp); for(int i = 0; i < numVals; i++) { - for(int k = 0; k < numComp; k++) { - valxyz(i, k) = values[i].v[k]; - } + for(int k = 0; k < numComp; k++) { valxyz(i, k) = values[i].v[k]; } } _interpolVal->mult(valxyz, *resxyz); } @@ -2344,8 +2320,7 @@ void adaptiveElements<T>::adaptForVTK(double tol, int numComp, #endif int i = 0; - for(auto it = T::allVertices.begin(); - it != T::allVertices.end(); ++it) { + for(auto it = T::allVertices.begin(); it != T::allVertices.end(); ++it) { // ok because we know this will not change the set ordering adaptiveVertex *p = (adaptiveVertex *)&(*it); p->val = res(i); @@ -2370,8 +2345,7 @@ void adaptiveElements<T>::adaptForVTK(double tol, int numComp, if(resxyz) delete resxyz; - for(auto it = T::all.begin(); it != T::all.end(); - it++) + for(auto it = T::all.begin(); it != T::all.end(); it++) (*it)->visible = false; if(tol != 0.) { @@ -2382,8 +2356,7 @@ void adaptiveElements<T>::adaptForVTK(double tol, int numComp, coords.clear(); values.clear(); - for(auto it = T::all.begin(); it != T::all.end(); - it++) { + for(auto it = T::all.begin(); it != T::all.end(); it++) { if((*it)->visible) { adaptiveVertex **p = (*it)->p; for(int i = 0; i < T::numNodes; i++) { @@ -2416,8 +2389,7 @@ void adaptiveElements<T>::buildMapping(nodMap<T> &myNodMap, double tol, myNodMap .cleanMapping(); // Required if tol > 0 (local error based adaptation) - for(auto itleaf = T::all.begin(); - itleaf != T::all.end(); itleaf++) { + for(auto itleaf = T::all.begin(); itleaf != T::all.end(); itleaf++) { // Visit all the leaves of the refined canonical element if((*itleaf)->visible == true) { @@ -2456,8 +2428,8 @@ void adaptiveElements<T>::buildMapping(nodMap<T> &myNodMap, double tol, // Use an ordered set for efficiency // This set is also used in case of partiel refinement std::set<int> uniqueNod; - for(auto it = myNodMap.mapping.begin(); - it != myNodMap.mapping.end(); it++) { + for(auto it = myNodMap.mapping.begin(); it != myNodMap.mapping.end(); + it++) { uniqueNod.insert(*it); } numNodInsert = (int)uniqueNod.size(); @@ -2468,8 +2440,8 @@ void adaptiveElements<T>::buildMapping(nodMap<T> &myNodMap, double tol, // temporary mapping, based on uniqueNod already generated above if(tol > 0.0) { std::set<int>::iterator jt; - for(auto it = myNodMap.mapping.begin(); - it != myNodMap.mapping.end(); ++it) { + for(auto it = myNodMap.mapping.begin(); it != myNodMap.mapping.end(); + ++it) { jt = uniqueNod.find(*it); *it = std::distance(uniqueNod.begin(), jt); } @@ -2627,9 +2599,7 @@ void adaptiveElements<T>::addInViewForVTK(int step, PViewData *in, // Write the VTK data structure of the consider element to vtu file - if(writeVTK == true) { - myVTKData.writeVTKElmData(); - } + if(writeVTK == true) { myVTKData.writeVTKElmData(); } if(buildStaticData == true) { for(int i = 0; i < numNodInsert; i++) { diff --git a/Post/adaptiveData.h b/Post/adaptiveData.h index 5c05418583c480f3657b6b66453777c265e958f8..d925d0eaab60bc49b059e7412c1b7176df4d8357 100644 --- a/Post/adaptiveData.h +++ b/Post/adaptiveData.h @@ -390,17 +390,13 @@ public: { sizev = obj.sizev; v = new double[sizev]; - for(int i = 0; i < sizev; i++) { - v[i] = obj.v[i]; - } + for(int i = 0; i < sizev; i++) { v[i] = obj.v[i]; } } PValues(int size) { sizev = size; v = new double[sizev]; - for(int i = 0; i < sizev; i++) { - v[i] = 0.0; - } + for(int i = 0; i < sizev; i++) { v[i] = 0.0; } } PValues(double vx) { @@ -439,9 +435,7 @@ public: if(sizev != obj.sizev) Msg::Error("In PValues overlodaing operator: size mistmatch %d %d", sizev); - for(int i = 0; i < sizev; i++) { - v[i] = obj.v[i]; - } + for(int i = 0; i < sizev; i++) { v[i] = obj.v[i]; } } }; diff --git a/Post/shapeFunctions.h b/Post/shapeFunctions.h index 1fca5d802c20ec230909c79b3c65bc287cb59a0f..8e6ef073684aa0e9714e74ccfae1ff2d05412e69 100644 --- a/Post/shapeFunctions.h +++ b/Post/shapeFunctions.h @@ -179,9 +179,7 @@ public: dfdu[2] += val[j] * s[2]; j += stride; } - if(invjac) { - matvec(invjac, dfdu, f); - } + if(invjac) { matvec(invjac, dfdu, f); } else { double jac[3][3], inv[3][3]; getJacobian(u, v, w, jac); diff --git a/contrib/HighOrderMeshOptimizer/BoundaryLayerCurver2D.cpp b/contrib/HighOrderMeshOptimizer/BoundaryLayerCurver2D.cpp index c8d2c02dc97b7dc3367c94787e059a871080606f..1db45f474bd525e6c60ac706659bc459d5daff3e 100644 --- a/contrib/HighOrderMeshOptimizer/BoundaryLayerCurver2D.cpp +++ b/contrib/HighOrderMeshOptimizer/BoundaryLayerCurver2D.cpp @@ -91,9 +91,7 @@ namespace { void drawBezierControlPolygon(const std::vector<MVertex *> &vertices, GEdge *gedge = nullptr) { - if(!gedge) { - gedge = *GModel::current()->firstEdge(); - } + if(!gedge) { gedge = *GModel::current()->firstEdge(); } const int nVert = (int)vertices.size(); fullMatrix<double> xyz(nVert, 3); @@ -249,9 +247,7 @@ namespace BoundaryLayerCurver { t = _gedge->firstDer(paramGeoEdge); t.normalize(); } - if(!_gedge || t.norm() == 0) { - t = _edgeOnBoundary->tangent(paramEdge); - } + if(!_gedge || t.norm() == 0) { t = _edgeOnBoundary->tangent(paramEdge); } if(_gface) { SPoint2 paramGFace; @@ -585,9 +581,7 @@ namespace BoundaryLayerCurver { for(int i = 0; i < nbDofh; ++i) { double sf[100]; fs->f(refNodesh(i, 0), refNodesh(i, 1), refNodesh(i, 2), sf); - for(int j = 0; j < nbDof; ++j) { - Mh(i, j) = sf[j]; - } + for(int j = 0; j < nbDof; ++j) { Mh(i, j) = sf[j]; } } // Mh.print("Mh"); @@ -607,9 +601,7 @@ namespace BoundaryLayerCurver { double *val = new double[nbDofh]; for(int i = 0; i < nbDofh; ++i) { LegendrePolynomials::fc(order + 1, refNodesh(i, 0), val); - for(int j = 0; j < nbDofh; ++j) { - vandermonde(i, j) = val[j]; - } + for(int j = 0; j < nbDofh; ++j) { vandermonde(i, j) = val[j]; } } delete val; @@ -626,9 +618,7 @@ namespace BoundaryLayerCurver { double *val = new double[nbDof]; for(int i = 0; i < nbDof; ++i) { LegendrePolynomials::fc(order, refNodes(i, 0), val); - for(int j = 0; j < nbDof; ++j) { - Me(i, j) = val[j]; - } + for(int j = 0; j < nbDof; ++j) { Me(i, j) = val[j]; } } delete val; } @@ -1011,9 +1001,7 @@ namespace BoundaryLayerCurver { const fullMatrix<double> &refNodes = fs->getReferenceNodes(); for(int i = 0; i < szSpace; ++i) { basis.f(refNodes(i, 0), 0, 0, val); - for(int j = 0; j < szSpace; ++j) { - Leg2Lag(i, j) = val[j]; - } + for(int j = 0; j < szSpace; ++j) { Leg2Lag(i, j) = val[j]; } } } @@ -1049,9 +1037,7 @@ namespace BoundaryLayerCurver { M2(i, j) = val[i] * data->intPoints[j].weight; } } - for(int i = 0; i < nConstraint; ++i) { - M2(szSpace + i, nGP + i) = 1; - } + for(int i = 0; i < nConstraint; ++i) { M2(szSpace + i, nGP + i) = 1; } } fullMatrix<double> M1(szSpace + nConstraint, szSpace + nConstraint, true); @@ -1073,9 +1059,7 @@ namespace BoundaryLayerCurver { { for(int i = 0; i < szSpace; ++i) { basis.f(refNodes(i, 0), refNodes(i, 1), 0, val); - for(int j = 0; j < szSpace; ++j) { - Leg2Lag(i, j) = val[j]; - } + for(int j = 0; j < szSpace; ++j) { Leg2Lag(i, j) = val[j]; } } } @@ -1111,9 +1095,7 @@ namespace BoundaryLayerCurver { M2(i, j) = val[i] * data->intPoints[j].weight; } } - for(int i = 0; i < nConstraint; ++i) { - M2(szSpace + i, nGP + i) = 1; - } + for(int i = 0; i < nConstraint; ++i) { M2(szSpace + i, nGP + i) = 1; } } fullMatrix<double> M1(szSpace + nConstraint, szSpace + nConstraint, true); @@ -1135,9 +1117,7 @@ namespace BoundaryLayerCurver { { for(int i = 0; i < szSpace; ++i) { basis.f(refNodes(i, 0), refNodes(i, 1), 0, val); - for(int j = 0; j < szSpace; ++j) { - Leg2Lag(i, j) = val[j]; - } + for(int j = 0; j < szSpace; ++j) { Leg2Lag(i, j) = val[j]; } } } @@ -1222,18 +1202,14 @@ namespace BoundaryLayerCurver { } for(int l = k - numVertexPerLayer; l < k; ++l) { - if(stack[l] == vbot) { - stack[l + numVertexPerLayer] = vtop; - } + if(stack[l] == vbot) { stack[l + numVertexPerLayer] = vtop; } } } // If there remains NULL values, it is because the vertex is the same // on bottom face and top face. for(int l = k; l < k + numVertexPerLayer; ++l) { - if(stack[l] == nullptr) { - stack[l] = stack[l - numVertexPerLayer]; - } + if(stack[l] == nullptr) { stack[l] = stack[l - numVertexPerLayer]; } } k += numVertexPerLayer; diff --git a/contrib/HighOrderMeshOptimizer/BoundaryLayerCurver3D.cpp b/contrib/HighOrderMeshOptimizer/BoundaryLayerCurver3D.cpp index 63af1cc52197f07a8353a0f1831de5fbe74ddb22..a46aaf199ad55c3275fbc40b7c96e3da0cf48016 100644 --- a/contrib/HighOrderMeshOptimizer/BoundaryLayerCurver3D.cpp +++ b/contrib/HighOrderMeshOptimizer/BoundaryLayerCurver3D.cpp @@ -163,38 +163,59 @@ namespace { namespace BoundaryLayerCurver { namespace InnerVertPlacementMatrices { - fullMatrix<double> *_triangle[10] = {nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, nullptr}; - fullMatrix<double> *_quadrangle[10] = {nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, nullptr}; - fullMatrix<double> *_linearTriangle0[10] = {nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, nullptr}; - fullMatrix<double> *_linearTriangle2[10] = {nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, nullptr}; - fullMatrix<double> *_linearQuadrangle[10] = {nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, nullptr}; - fullMatrix<double> *_hexahedron[10] = {nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, nullptr}; + fullMatrix<double> *_triangle[10] = {nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr}; + fullMatrix<double> *_quadrangle[10] = {nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr}; + fullMatrix<double> *_linearTriangle0[10] = { + nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, nullptr}; + fullMatrix<double> *_linearTriangle2[10] = { + nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, nullptr}; + fullMatrix<double> *_linearQuadrangle[10] = { + nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, nullptr}; + fullMatrix<double> *_hexahedron[10] = {nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr}; fullMatrix<double> *_linearHexahedron[3][10] = { - {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, - {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, - {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}}; - fullMatrix<double> *_prism[10] = {nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, nullptr}; + {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr}}; + fullMatrix<double> *_prism[10] = {nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr}; fullMatrix<double> *_linearPrism[4][10] = { - {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, - {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, - {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, - {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}}; - fullMatrix<double> *_tetrahedron[10] = {nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, nullptr}; + {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr}}; + fullMatrix<double> *_tetrahedron[10] = {nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr}; fullMatrix<double> *_linearTet[6][10] = { - {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, - {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, - {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, - {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, - {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, - {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}}; + {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr}}; const fullMatrix<double> *triangle(int order, bool linear, int edge) { diff --git a/contrib/HighOrderMeshOptimizer/HighOrderMeshElasticAnalogy.cpp b/contrib/HighOrderMeshOptimizer/HighOrderMeshElasticAnalogy.cpp index a9703398d564584035ed21a77da1dd63967ea43c..698bdf96a970ebe63208bc0a43c7cd4b46bbb46f 100644 --- a/contrib/HighOrderMeshOptimizer/HighOrderMeshElasticAnalogy.cpp +++ b/contrib/HighOrderMeshOptimizer/HighOrderMeshElasticAnalogy.cpp @@ -92,16 +92,15 @@ void HighOrderMeshElasticAnalogy(GModel *m, bool onlyVisible) checkHighOrderTetrahedron("Final volume mesh", m, bad, worst); double t2 = Cpu(); - Msg::StatusBar(true, "Done applying elastic analogy to high-order mesh (%g s)", - t2 - t1); + Msg::StatusBar( + true, "Done applying elastic analogy to high-order mesh (%g s)", t2 - t1); } void highOrderTools::_moveToStraightSidedLocation(MElement *e) const { for(int i = 0; i < e->getNumVertices(); i++) { MVertex *v = e->getVertex(i); - auto it = - _straightSidedLocation.find(v); + auto it = _straightSidedLocation.find(v); if(it != _straightSidedLocation.end()) { v->x() = it->second.x(); v->y() = it->second.y(); @@ -225,8 +224,7 @@ void highOrderTools::ensureMinimumDistorsion(double threshold) } } else if(_dim == 3) { - for(auto rit = _gm->firstRegion(); rit != _gm->lastRegion(); - ++rit) { + for(auto rit = _gm->firstRegion(); rit != _gm->lastRegion(); ++rit) { v.insert(v.begin(), (*rit)->hexahedra.begin(), (*rit)->hexahedra.end()); v.insert(v.begin(), (*rit)->tetrahedra.begin(), (*rit)->tetrahedra.end()); v.insert(v.begin(), (*rit)->prisms.begin(), (*rit)->prisms.end()); @@ -298,10 +296,9 @@ void highOrderTools::applySmoothingTo(std::vector<MElement *> &all, GFace *gf) if(!v.size()) return; - Msg::Info( - "Smoothing surface %d (%d elements considered in elastic analogy, " - "worst mapping %12.5E, %3d bad elements)", - gf->tag(), v.size(), minD, numBad); + Msg::Info("Smoothing surface %d (%d elements considered in elastic analogy, " + "worst mapping %12.5E, %3d bad elements)", + gf->tag(), v.size(), minD, numBad); addOneLayer(all, v, layer); std::set<MVertex *, MVertexPtrLessThan>::iterator it; @@ -371,10 +368,9 @@ void highOrderTools::applySmoothingTo(std::vector<MElement *> &all, GFace *gf) delete lsys; } -double highOrderTools::_smoothMetric(std::vector<MElement *> &v, GFace *gf, - dofManager<double> &myAssembler, - std::set<MVertex *, MVertexPtrLessThan> &verticesToMove, - elasticityTerm &El) +double highOrderTools::_smoothMetric( + std::vector<MElement *> &v, GFace *gf, dofManager<double> &myAssembler, + std::set<MVertex *, MVertexPtrLessThan> &verticesToMove, elasticityTerm &El) { std::set<MVertex *, MVertexPtrLessThan>::iterator it; double dx = 0.0; @@ -575,10 +571,10 @@ void highOrderTools::_computeStraightSidedPositions() for(std::size_t i = 0; i < (*it)->prisms.size(); i++) { _dim = 3; MPrism *p = (*it)->prisms[i]; - MPrism p_1( - (*it)->prisms[i]->getVertex(0), (*it)->prisms[i]->getVertex(1), - (*it)->prisms[i]->getVertex(2), (*it)->prisms[i]->getVertex(3), - (*it)->prisms[i]->getVertex(4), (*it)->prisms[i]->getVertex(5)); + MPrism p_1((*it)->prisms[i]->getVertex(0), (*it)->prisms[i]->getVertex(1), + (*it)->prisms[i]->getVertex(2), (*it)->prisms[i]->getVertex(3), + (*it)->prisms[i]->getVertex(4), + (*it)->prisms[i]->getVertex(5)); const nodalBasis *fs = p->getFunctionSpace(); for(int j = 0; j < p->getNumVertices(); j++) { if(p->getVertex(j)->onWhat() == *it) { @@ -642,8 +638,7 @@ double highOrderTools::_applyIncrementalDisplacement( } } - for(auto it = _vertices.begin(); - it != _vertices.end(); ++it) { + for(auto it = _vertices.begin(); it != _vertices.end(); ++it) { MVertex *vert = *it; auto itt = _targetLocation.find(vert); // impose displacement @ boundary @@ -684,12 +679,11 @@ double highOrderTools::_applyIncrementalDisplacement( } // Move vertices @ maximum - //FILE *fd = Fopen("d.msh", "w"); - //fprintf(fd, "$MeshFormat\n2 0 8\n$EndMeshFormat\n$NodeData\n1\n" + // FILE *fd = Fopen("d.msh", "w"); + // fprintf(fd, "$MeshFormat\n2 0 8\n$EndMeshFormat\n$NodeData\n1\n" // "\"tr(sigma)\"\n1\n0.0\n3\n1\n3\n%d\n", // (int)_vertices.size()); - for(auto it = _vertices.begin(); - it != _vertices.end(); ++it) { + for(auto it = _vertices.begin(); it != _vertices.end(); ++it) { double ax, ay, az; myAssembler.getDofValue(*it, 0, _tag, ax); myAssembler.getDofValue(*it, 1, _tag, ay); @@ -697,10 +691,10 @@ double highOrderTools::_applyIncrementalDisplacement( (*it)->x() += max_incr * ax; (*it)->y() += max_incr * ay; (*it)->z() += max_incr * az; - //fprintf(fd, "%d %g %g %g\n", (*it)->getIndex(), ax, ay, az); + // fprintf(fd, "%d %g %g %g\n", (*it)->getIndex(), ax, ay, az); } - //fprintf(fd, "$EndNodeData\n"); - //fclose(fd); + // fprintf(fd, "$EndNodeData\n"); + // fclose(fd); // Check now if elements are ok @@ -713,8 +707,7 @@ double highOrderTools::_applyIncrementalDisplacement( getDistordedElements(v, 0.5, disto, minD); if(minD < thres) { percentage -= 10.; - for(auto it = _vertices.begin(); - it != _vertices.end(); ++it) { + for(auto it = _vertices.begin(); it != _vertices.end(); ++it) { double ax, ay, az; myAssembler.getDofValue(*it, 0, _tag, ax); myAssembler.getDofValue(*it, 1, _tag, ay); @@ -765,8 +758,8 @@ double highOrderTools::applySmoothingTo(std::vector<MElement *> &all, // _gm->writeMSH("straightSided.msh"); char sm[] = "sm.msh"; - double percentage_of_what_is_left = _applyIncrementalDisplacement - (1., all, mixed, -100000000, sm, all); + double percentage_of_what_is_left = + _applyIncrementalDisplacement(1., all, mixed, -100000000, sm, all); // ensureMinimumDistorsion (all, threshold); @@ -788,8 +781,8 @@ double highOrderTools::applySmoothingTo(std::vector<MElement *> &all, } getDistordedElements(all, 0.3, disto, minD); - Msg::Info(" - Iter %d: %d elements / %d distorted, min Disto = %g", - ITER, all.size(), disto.size(), minD); + Msg::Info(" - Iter %d: %d elements / %d distorted, min Disto = %g", ITER, + all.size(), disto.size(), minD); return percentage; } diff --git a/contrib/HighOrderMeshOptimizer/HighOrderMeshElasticAnalogy.h b/contrib/HighOrderMeshOptimizer/HighOrderMeshElasticAnalogy.h index 461a7ff0d2113723311418b905901219e694e610..9e5ad04b5e78b0b3ffbba01aba4498826f16088f 100644 --- a/contrib/HighOrderMeshOptimizer/HighOrderMeshElasticAnalogy.h +++ b/contrib/HighOrderMeshOptimizer/HighOrderMeshElasticAnalogy.h @@ -83,8 +83,7 @@ public: bool mixed); inline SVector3 getSSL(MVertex *v) const { - auto it = - _straightSidedLocation.find(v); + auto it = _straightSidedLocation.find(v); if(it != _straightSidedLocation.end()) return it->second; else diff --git a/contrib/HighOrderMeshOptimizer/HighOrderMeshFastCurving.cpp b/contrib/HighOrderMeshOptimizer/HighOrderMeshFastCurving.cpp index cd06ca8a8395a138c491e4d49eb6769167d5157e..776bb31d4d8eabd1f266e915bd3cbdec1cf9802e 100644 --- a/contrib/HighOrderMeshOptimizer/HighOrderMeshFastCurving.cpp +++ b/contrib/HighOrderMeshOptimizer/HighOrderMeshFastCurving.cpp @@ -465,9 +465,9 @@ namespace { maxVert[iMaxV] = nullptr; } // Set last vertex of elTopFace as remaining vertex in elMaxFace - MVertex *thirdMaxVert = (maxVert[0] != nullptr) ? - maxVert[0] : - (maxVert[1] != nullptr) ? maxVert[1] : maxVert[2]; + MVertex *thirdMaxVert = (maxVert[0] != nullptr) ? maxVert[0] : + (maxVert[1] != nullptr) ? maxVert[1] : + maxVert[2]; if(topVert[0] == nullptr) topVert[0] = thirdMaxVert; else if(topVert[1] == nullptr) @@ -690,8 +690,7 @@ namespace { fprintf(fp, "$MeshFormat\n2.2 0 8\n$EndMeshFormat\n"); fprintf(fp, "$Nodes\n"); fprintf(fp, "%d\n", vert_.size()); - for(auto itV = vert_.begin(); itV != vert_.end(); - ++itV) { + for(auto itV = vert_.begin(); itV != vert_.end(); ++itV) { SPoint3 p = (*itV)->point(); fprintf(fp, "%i %g %g %g\n", (*itV)->getNum(), p.x(), p.y(), p.z()); } @@ -1216,8 +1215,8 @@ namespace { // Loop over boundary elements to curve them by columns DbgOutputMeta dbgOut; std::set<MVertex *> movedVert; - for(auto itBE = bndEl.begin(); - itBE != bndEl.end(); itBE++) // Loop over bnd. elements + for(auto itBE = bndEl.begin(); itBE != bndEl.end(); + itBE++) // Loop over bnd. elements curveMeshFromBndElt(ed2el, face2el, ent, bndEnt, *itBE, movedVert, p, dbgOut); // dbgOut.write("meta-elements", bndEnt->tag()); diff --git a/contrib/HighOrderMeshOptimizer/HighOrderMeshFastCurving.h b/contrib/HighOrderMeshOptimizer/HighOrderMeshFastCurving.h index b505a3fab570d03fee2d1a4ff9c4c1ad21e90015..fa867150076d63c7050dd0d83edc7bd416de7720 100644 --- a/contrib/HighOrderMeshOptimizer/HighOrderMeshFastCurving.h +++ b/contrib/HighOrderMeshOptimizer/HighOrderMeshFastCurving.h @@ -36,7 +36,7 @@ struct FastCurvingParameters { bool onlyVisible; // Apply curving to visible entities ONLY? bool optimizeGeometry; // Optimize boundary edges/faces to fit geometry? OUTERBLCURVE - curveOuterBL; // Curve also the outer surface of the boundary layer? + curveOuterBL; // Curve also the outer surface of the boundary layer? int maxNumLayers; // Maximum number of layers of elements to curve in BL double maxRho; // Maximum ratio min/max edge/face size for elements to curve in BL diff --git a/contrib/HighOrderMeshOptimizer/HighOrderMeshOptimizer.cpp b/contrib/HighOrderMeshOptimizer/HighOrderMeshOptimizer.cpp index be193f9a67b7cf1c6aed1dcc7f75f4e563fee4b7..4b4489fc99799b855a731420252a65b9ec3e6a32 100644 --- a/contrib/HighOrderMeshOptimizer/HighOrderMeshOptimizer.cpp +++ b/contrib/HighOrderMeshOptimizer/HighOrderMeshOptimizer.cpp @@ -63,8 +63,8 @@ void exportMeshToDassault(GModel *gm, const std::string &fn, int dim) if(dim == 2) fprintf(f, "%ld %22.15E %22.15E\n", v->getIndex(), v->x(), v->y()); else if(dim == 3) - fprintf(f, "%ld %22.15E %22.15E %22.5E\n", v->getIndex(), v->x(), v->y(), - v->z()); + fprintf(f, "%ld %22.15E %22.15E %22.5E\n", v->getIndex(), v->x(), + v->y(), v->z()); } if(dim == 2) { @@ -207,9 +207,7 @@ static bool testElInDist(const SPoint3 &p, double limDist, MElement *el) const SPoint3 B = faceVert[1]->point(); const SPoint3 C = faceVert[2]->point(); if(faceVert.size() == 3) { - if(testTriSphereIntersect(A, B, C, p, limDistSq)){ - return true; - } + if(testTriSphereIntersect(A, B, C, p, limDistSq)) { return true; } else { const SPoint3 D = faceVert[3]->point(); if(testTriSphereIntersect(A, B, C, p, limDistSq) || diff --git a/contrib/HighOrderMeshOptimizer/HighOrderMeshPeriodicity.cpp b/contrib/HighOrderMeshOptimizer/HighOrderMeshPeriodicity.cpp index 27e90345d25ddbb66d8e1ecbb490f39526453a40..152ce83d453f47c6974aaba50c9587c9c74a24bf 100644 --- a/contrib/HighOrderMeshOptimizer/HighOrderMeshPeriodicity.cpp +++ b/contrib/HighOrderMeshOptimizer/HighOrderMeshPeriodicity.cpp @@ -31,7 +31,8 @@ #include "MVertex.h" #include "fullMatrix.h" -HighOrderMeshPeriodicity::HighOrderMeshPeriodicity(std::vector<GEntity *> &entities) +HighOrderMeshPeriodicity::HighOrderMeshPeriodicity( + std::vector<GEntity *> &entities) { for(std::size_t i = 0; i < entities.size(); ++i) { // MVertex on GVertex cannot move @@ -84,7 +85,8 @@ void HighOrderMeshPeriodicity::_relocateMasterVertices() } } - std::map<MVertex *, MVertex *> &pointS2M = slave->correspondingHighOrderVertices; + std::map<MVertex *, MVertex *> &pointS2M = + slave->correspondingHighOrderVertices; for(vit = pointS2M.begin(); vit != pointS2M.end(); ++vit) { MFaceVertex *v = dynamic_cast<MFaceVertex *>(vit->second); if(v && v->onWhat() == master) { @@ -114,17 +116,16 @@ void HighOrderMeshPeriodicity::_relocateMasterVertices() std::vector<double> tfo = _inverse(slave->affineTransform); - Msg::Info( - "Relocating %d main and %d high order nodes for %d nodes " - "of master edge %i (%i-%i) using slave %i (%i-%i)", - slave->correspondingVertices.size(), - slave->correspondingHighOrderVertices.size(), master->getNumMeshVertices(), - me->tag(), - me->getBeginVertex() ? me->getBeginVertex()->tag() : -1, - me->getEndVertex() ? me->getEndVertex()->tag() : -1, - se->tag(), - se->getBeginVertex() ? se->getBeginVertex()->tag() : -1, - se->getEndVertex() ? se->getEndVertex()->tag() : -1); + Msg::Info("Relocating %d main and %d high order nodes for %d nodes " + "of master edge %i (%i-%i) using slave %i (%i-%i)", + slave->correspondingVertices.size(), + slave->correspondingHighOrderVertices.size(), + master->getNumMeshVertices(), me->tag(), + me->getBeginVertex() ? me->getBeginVertex()->tag() : -1, + me->getEndVertex() ? me->getEndVertex()->tag() : -1, + se->tag(), + se->getBeginVertex() ? se->getBeginVertex()->tag() : -1, + se->getEndVertex() ? se->getEndVertex()->tag() : -1); std::map<MVertex *, MVertex *>::iterator vit; @@ -136,7 +137,8 @@ void HighOrderMeshPeriodicity::_relocateMasterVertices() v->setXYZ(v->x() + gp.x(), v->y() + gp.y(), v->z() + gp.z()); } } - std::map<MVertex *, MVertex *> &pointS2M = slave->correspondingHighOrderVertices; + std::map<MVertex *, MVertex *> &pointS2M = + slave->correspondingHighOrderVertices; for(vit = pointS2M.begin(); vit != pointS2M.end(); ++vit) { MEdgeVertex *v = dynamic_cast<MEdgeVertex *>(vit->second); if(v && v->onWhat() == master) { @@ -207,7 +209,8 @@ void HighOrderMeshPeriodicity::_copyBackMasterVertices() int idx = 0; - std::map<MVertex *, MVertex *> &pointS2M = slave->correspondingHighOrderVertices; + std::map<MVertex *, MVertex *> &pointS2M = + slave->correspondingHighOrderVertices; for(vit = pointS2M.begin(); vit != pointS2M.end(); ++vit) { MFaceVertex *sv = dynamic_cast<MFaceVertex *>(vit->first); MFaceVertex *mv = dynamic_cast<MFaceVertex *>(vit->second); @@ -252,7 +255,8 @@ void HighOrderMeshPeriodicity::_copyBackMasterVertices() } } - std::map<MVertex *, MVertex *> &pointS2M = slave->correspondingHighOrderVertices; + std::map<MVertex *, MVertex *> &pointS2M = + slave->correspondingHighOrderVertices; for(vit = pointS2M.begin(); vit != pointS2M.end(); ++vit) { MEdgeVertex *sv = dynamic_cast<MEdgeVertex *>(vit->first); MEdgeVertex *mv = dynamic_cast<MEdgeVertex *>(vit->second); @@ -286,7 +290,8 @@ SPoint3 HighOrderMeshPeriodicity::_transform(MVertex *vsource, return SPoint3(res[0], res[1], res[2]); } -std::vector<double> HighOrderMeshPeriodicity::_inverse(const std::vector<double> &tfo) +std::vector<double> +HighOrderMeshPeriodicity::_inverse(const std::vector<double> &tfo) { std::vector<double> result(16, 0.); if(tfo.size() < 16) { diff --git a/contrib/HighOrderMeshOptimizer/MetaEl.cpp b/contrib/HighOrderMeshOptimizer/MetaEl.cpp index e4b70ea16c821dd17afe784917ac39126c278880..e7f8d8b878c2f17999dee5a40365d711dc9f54c0 100644 --- a/contrib/HighOrderMeshOptimizer/MetaEl.cpp +++ b/contrib/HighOrderMeshOptimizer/MetaEl.cpp @@ -183,8 +183,7 @@ MetaEl::metaInfoType::metaInfoType(int type, int order) const MetaEl::metaInfoType &MetaEl::getMetaInfo(int elType, int order) { - auto itMInfo = - _metaInfo.find(elType); + auto itMInfo = _metaInfo.find(elType); if(itMInfo == _metaInfo.end()) { const metaInfoType mInfo(elType, order); itMInfo = diff --git a/contrib/HighOrderMeshOptimizer/ObjContribMetricMin.h b/contrib/HighOrderMeshOptimizer/ObjContribMetricMin.h index 5e28ee3e79dde078713f3392e75a284c3e4b9f21..dfef8128e2f3cfb70f0a98cf464bca5785162f58 100644 --- a/contrib/HighOrderMeshOptimizer/ObjContribMetricMin.h +++ b/contrib/HighOrderMeshOptimizer/ObjContribMetricMin.h @@ -53,8 +53,8 @@ protected: template <class FuncType> ObjContribMetricMin<FuncType>::ObjContribMetricMin(double weight) - : ObjContrib("MetricMin", FuncType::getNamePrefix() + "MetricMin"), _mesh(nullptr), - _weight(weight) + : ObjContrib("MetricMin", FuncType::getNamePrefix() + "MetricMin"), + _mesh(nullptr), _weight(weight) { } diff --git a/contrib/HighOrderMeshOptimizer/ObjContribScaledJac.h b/contrib/HighOrderMeshOptimizer/ObjContribScaledJac.h index c62a3273e2031957345019d0cb1cfa6a8901a2c3..1a30384e83f1507791b542db2e322aecb9cbe304 100644 --- a/contrib/HighOrderMeshOptimizer/ObjContribScaledJac.h +++ b/contrib/HighOrderMeshOptimizer/ObjContribScaledJac.h @@ -53,8 +53,8 @@ protected: template <class FuncType> ObjContribScaledJac<FuncType>::ObjContribScaledJac(double weight) - : ObjContrib("ScaledJac", FuncType::getNamePrefix() + "ScaledJac"), _mesh(nullptr), - _weight(weight) + : ObjContrib("ScaledJac", FuncType::getNamePrefix() + "ScaledJac"), + _mesh(nullptr), _weight(weight) { } diff --git a/contrib/MeshOptimizer/CADDistances.cpp b/contrib/MeshOptimizer/CADDistances.cpp index 577f1d57f172d3090cfcd4770ea673369f6f9e8c..2d4da82a3d80f2c58d4a7f119b2f3180754e673a 100644 --- a/contrib/MeshOptimizer/CADDistances.cpp +++ b/contrib/MeshOptimizer/CADDistances.cpp @@ -224,9 +224,7 @@ namespace { const std::vector<SPoint3> &Q) { double CAij; - if(CA(i, j) > -1.) { - CAij = CA(i, j); - } + if(CA(i, j) > -1.) { CAij = CA(i, j); } else if(i == 0 && j == 0) { CA(i, j) = P[0].distance(Q[0]); // update the CA permanent CAij = CA(i, j); // set the current relevant value diff --git a/contrib/MeshOptimizer/MeshOpt.cpp b/contrib/MeshOptimizer/MeshOpt.cpp index c7e808e0dd54344656dd55596bcb1a0789499d9e..dcb1d82cb551179b91bc4fb4e58170aaf1e63e66 100644 --- a/contrib/MeshOptimizer/MeshOpt.cpp +++ b/contrib/MeshOptimizer/MeshOpt.cpp @@ -143,9 +143,10 @@ void MeshOpt::printProgress(const std::vector<double> &x, double Obj) mvprintList(22, 5, _iterHistory, 1); } if((_verbose > 2) && (_iter % _intervDisplay == 0 || _nCurses)) - Msg::Info(("Iteration %3d " + _objFunc->minMaxStr() + - " (obj %5E, rel decr %5E)").c_str(), - _iter, Obj, Obj / _initObj); + Msg::Info( + ("Iteration %3d " + _objFunc->minMaxStr() + " (obj %5E, rel decr %5E)") + .c_str(), + _iter, Obj, Obj / _initObj); } void MeshOpt::calcScale(std::vector<double> &scale) @@ -282,12 +283,13 @@ void MeshOpt::runOptim(std::vector<double> &x, sstream << "Optimization finalized after " << iterationscount << " iterations (" << nfev << " function evaluations)"; switch(int(terminationtype)) { - case 1: sstream << - ", because relative function improvement is no more than EpsF"; break; + case 1: + sstream << ", because relative function improvement is no more than EpsF"; + break; case 2: sstream << ", because relative step is no more than EpsX"; break; case 4: sstream << ", because gradient norm is no more than EpsG"; break; case 5: sstream << ", because the maximum number of steps was taken"; break; - default: sstream << ", with code "<< int(terminationtype); break; + default: sstream << ", with code " << int(terminationtype); break; } Msg::Info("%s", sstream.str().c_str()); } diff --git a/contrib/MeshOptimizer/MeshOpt.h b/contrib/MeshOptimizer/MeshOpt.h index 5d03d01a5c43d54cc059e7ead88c9b34cd3ca3a7..7c1a6b94e2a866767765f66f1dde21c9d5782b30 100644 --- a/contrib/MeshOptimizer/MeshOpt.h +++ b/contrib/MeshOptimizer/MeshOpt.h @@ -68,8 +68,8 @@ private: // Values for reporting double _initObj; void calcScale(std::vector<double> &scale); - void runOptim(std::vector<double> &x, - const std::vector<double> &initGradObj, int itMax, int iBar); + void runOptim(std::vector<double> &x, const std::vector<double> &initGradObj, + int itMax, int iBar); }; #endif diff --git a/contrib/MeshOptimizer/MeshOptimizer.cpp b/contrib/MeshOptimizer/MeshOptimizer.cpp index cccac18e97cda0f4ad7d286e7701c16d1fc67caf..5637c32b1ca13318165048936d3ea5143512bc6b 100644 --- a/contrib/MeshOptimizer/MeshOptimizer.cpp +++ b/contrib/MeshOptimizer/MeshOptimizer.cpp @@ -150,8 +150,7 @@ namespace { todoPB[iB] = false; group.insert(iB); const std::set<int> &connect = groupConnect[iB]; - for(auto itBC = connect.begin(); - itBC != connect.end(); ++itBC) + for(auto itBC = connect.begin(); itBC != connect.end(); ++itBC) addPatchChaintoGroup(group, groupConnect, todoPB, *itBC); } } @@ -178,8 +177,7 @@ namespace { MElement *getFaceInBndElements(const MFace &f, std::vector<GFace *> const &gFaces) { - for(auto itGF = gFaces.begin(); - itGF != gFaces.end(); itGF++) { + for(auto itGF = gFaces.begin(); itGF != gFaces.end(); itGF++) { if(f.getNumVertices() == 3) { std::vector<MTriangle *> &tris = (*itGF)->triangles; for(int iEl = 0; iEl < tris.size(); iEl++) @@ -197,8 +195,7 @@ namespace { MElement *getEdgeInBndElements(const MEdge &e, std::vector<GEdge *> const &gEdges) { - for(auto itGE = gEdges.begin(); - itGE != gEdges.end(); itGE++) { + for(auto itGE = gEdges.begin(); itGE != gEdges.end(); itGE++) { std::vector<MLine *> &lines = (*itGE)->lines; for(int iEl = 0; iEl < lines.size(); iEl++) if(lines[iEl]->getEdge(0) == e) return lines[iEl]; @@ -215,8 +212,7 @@ namespace { // Fill boundary element -> GEntity connectivity GFaceList gFaces = entity->faces(); - for(auto itGF = gFaces.begin(); itGF != gFaces.end(); - itGF++) { + for(auto itGF = gFaces.begin(); itGF != gFaces.end(); itGF++) { std::vector<MTriangle *> &tris = (*itGF)->triangles; for(int i = 0; i < tris.size(); i++) bndEl2Ent.insert(std::pair<MElement *, GEntity *>(tris[i], *itGF)); @@ -244,8 +240,7 @@ namespace { // Fill boundary element -> GEntity connectivity GEdgeList gEdges = entity->edges(); - for(auto itGE = gEdges.begin(); itGE != gEdges.end(); - itGE++) { + for(auto itGE = gEdges.begin(); itGE != gEdges.end(); itGE++) { std::vector<MLine *> &lines = (*itGE)->lines; for(int i = 0; i < lines.size(); i++) bndEl2Ent.insert(std::pair<MElement *, GEntity *>(lines[i], *itGE)); @@ -287,8 +282,7 @@ namespace { Msg::Info("Constructing %i primary patches", badElements.size()); std::vector<elSet> primPatches; primPatches.reserve(badElements.size()); - for(auto it = badElements.begin(); it != badElements.end(); - ++it) { + for(auto it = badElements.begin(); it != badElements.end(); ++it) { const double limDist = par.patchDef->maxDistance(*it); primPatches.push_back( getSurroundingPatch(*it, par.patchDef, limDist, par.patchDef->maxLayers, @@ -305,8 +299,7 @@ namespace { std::set<int> &patchInd = tags[*itEl]; if(!patchInd.empty() && (badElements.find(*itEl) != badElements.end() || !par.patchDef->weakMerge)) { - for(auto itBS = patchInd.begin(); - itBS != patchInd.end(); ++itBS) + for(auto itBS = patchInd.begin(); itBS != patchInd.end(); ++itBS) patchConnect[*itBS].insert(iB); patchConnect[iB].insert(patchInd.begin(), patchInd.end()); } @@ -328,11 +321,9 @@ namespace { // Merge primary patches according to groups Msg::Info("Merging primary patches into %i patches...", groups.size()); std::list<elSet> patches; - for(auto itG = groups.begin(); - itG != groups.end(); ++itG) { + for(auto itG = groups.begin(); itG != groups.end(); ++itG) { patches.push_back(elSet()); - for(auto itB = itG->begin(); itB != itG->end(); - ++itB) { + for(auto itB = itG->begin(); itB != itG->end(); ++itB) { elSet primPatch = primPatches[*itB]; patches.back().insert(primPatch.begin(), primPatch.end()); } @@ -341,8 +332,7 @@ namespace { // Store and compute patch boundaries Msg::Info("Computing boundaries for %i patches...", patches.size()); std::vector<elSetVertSetPair> result; - for(auto itB = patches.begin(); itB != patches.end(); - ++itB) + for(auto itB = patches.begin(); itB != patches.end(); ++itB) result.push_back( elSetVertSetPair(*itB, getAllBndVertices(*itB, vertex2elements))); diff --git a/contrib/MeshOptimizer/ObjContribScaledNodeDispSq.h b/contrib/MeshOptimizer/ObjContribScaledNodeDispSq.h index 8533bb7363e18ab93b43b50beefd09b7f0d208c7..b0bd1a5b9e0caffbb0981f88f75244c553f30652 100644 --- a/contrib/MeshOptimizer/ObjContribScaledNodeDispSq.h +++ b/contrib/MeshOptimizer/ObjContribScaledNodeDispSq.h @@ -75,8 +75,8 @@ void ObjContribScaledNodeDispSq<FuncType>::initialize(Patch *mesh) } template <class FuncType> -bool ObjContribScaledNodeDispSq<FuncType>::addContrib(double &Obj, - std::vector<double> &gradObj) +bool ObjContribScaledNodeDispSq<FuncType>::addContrib( + double &Obj, std::vector<double> &gradObj) { _min = BIGVAL; _max = -BIGVAL; diff --git a/contrib/MeshOptimizer/ObjectiveFunction.cpp b/contrib/MeshOptimizer/ObjectiveFunction.cpp index da286b5eca2dcbbbd1f6c75ffb1f612f17c7ff81..341849a1b3b56f68ca07c83d5f1c4e9bc99c0718 100644 --- a/contrib/MeshOptimizer/ObjectiveFunction.cpp +++ b/contrib/MeshOptimizer/ObjectiveFunction.cpp @@ -30,8 +30,7 @@ void ObjectiveFunction::initialize(Patch *mesh) { - for(auto it = begin(); it != end(); it++) - (*it)->initialize(mesh); + for(auto it = begin(); it != end(); it++) (*it)->initialize(mesh); } std::string ObjectiveFunction::contribNames() @@ -79,27 +78,23 @@ std::vector<std::string> ObjectiveFunction::names() void ObjectiveFunction::updateMinMax() { - for(auto it = begin(); it != end(); it++) - (*it)->updateMinMax(); + for(auto it = begin(); it != end(); it++) (*it)->updateMinMax(); } void ObjectiveFunction::updateParameters() { - for(auto it = begin(); it != end(); it++) - (*it)->updateParameters(); + for(auto it = begin(); it != end(); it++) (*it)->updateParameters(); } void ObjectiveFunction::updateResults() { - for(auto it = begin(); it != end(); it++) - (*it)->updateResults(); + for(auto it = begin(); it != end(); it++) (*it)->updateResults(); } bool ObjectiveFunction::stagnated() { bool stagnated = true; - for(auto it = begin(); it != end(); it++) - stagnated &= (*it)->stagnated(); + for(auto it = begin(); it != end(); it++) stagnated &= (*it)->stagnated(); return stagnated; } diff --git a/contrib/MeshOptimizer/Patch.cpp b/contrib/MeshOptimizer/Patch.cpp index c58d08cf4f24198876b2112b784173a75bbf4be8..e8a761df5373936407542639b14ca6ad66d5e3bb 100644 --- a/contrib/MeshOptimizer/Patch.cpp +++ b/contrib/MeshOptimizer/Patch.cpp @@ -55,12 +55,10 @@ Patch::Patch(const std::map<MElement *, GEntity *> &element2entity, if(!element2entity.empty()) _gEnt.resize(nElements); int iEl = 0; bool nonGeoMove = false; - for(auto it = els.begin(); it != els.end(); - ++it, ++iEl) { + for(auto it = els.begin(); it != els.end(); ++it, ++iEl) { _el[iEl] = *it; if(!element2entity.empty()) { - auto itEl2Ent = - element2entity.find(*it); + auto itEl2Ent = element2entity.find(*it); _gEnt[iEl] = (itEl2Ent == element2entity.end()) ? 0 : itEl2Ent->second; } _nNodEl[iEl] = _el[iEl]->getNumVertices(); @@ -108,12 +106,10 @@ Patch::Patch(const std::map<MElement *, GEntity *> &element2entity, _bndEl2FV.resize(nBndElts); int iBndEl = 0; bool unknownVert = false; - for(auto it = bndEls.begin(); it != bndEls.end(); - ++it, ++iBndEl) { + for(auto it = bndEls.begin(); it != bndEls.end(); ++it, ++iBndEl) { MElement *bndEl = *it; _bndEl[iBndEl] = bndEl; - auto itBndEl2Ent = - bndEl2Ent.find(bndEl); + auto itBndEl2Ent = bndEl2Ent.find(bndEl); _bndEl2Ent[iBndEl] = (itBndEl2Ent == bndEl2Ent.end()) ? 0 : itBndEl2Ent->second; int nBndElVerts = bndEl->getNumVertices(); @@ -121,14 +117,12 @@ Patch::Patch(const std::map<MElement *, GEntity *> &element2entity, _bndEl2FV[iBndEl].resize(nBndElVerts); for(int iVBndEl = 0; iVBndEl < nBndElVerts; iVBndEl++) { MVertex *vert = bndEl->getVertex(iVBndEl); - auto itV = - std::find(_vert.begin(), _vert.end(), vert); + auto itV = std::find(_vert.begin(), _vert.end(), vert); if(itV == _vert.end()) unknownVert = true; else _bndEl2V[iBndEl][iVBndEl] = std::distance(_vert.begin(), itV); - auto itFV = - std::find(_freeVert.begin(), _freeVert.end(), vert); + auto itFV = std::find(_freeVert.begin(), _freeVert.end(), vert); if(itFV == _freeVert.end()) _bndEl2FV[iBndEl][iVBndEl] = -1; else @@ -153,8 +147,7 @@ Patch::Patch(const std::map<MElement *, GEntity *> &element2entity, int Patch::addVert(MVertex *vert) { - auto itVert = - find(_vert.begin(), _vert.end(), vert); + auto itVert = find(_vert.begin(), _vert.end(), vert); if(itVert == _vert.end()) { _vert.push_back(vert); return _vert.size() - 1; @@ -166,8 +159,7 @@ int Patch::addVert(MVertex *vert) int Patch::addFreeVert(MVertex *vert, const int iV, const int nPCV, VertexCoord *param, std::set<MVertex *> &toFix) { - auto itVert = - find(_freeVert.begin(), _freeVert.end(), vert); + auto itVert = find(_freeVert.begin(), _freeVert.end(), vert); if(itVert == _freeVert.end()) { const int iStart = (_startPCFV.size() == 0) ? 0 : _startPCFV.back() + _nPCFV.back(); @@ -496,9 +488,7 @@ void Patch::metricMinAndGradients(int iEl, std::vector<double> &lambda, int iPC = 0; std::vector<SPoint3> gXyzV(numSamplingPnts); std::vector<SPoint3> gUvwV(numSamplingPnts); - for(int l = 0; l < numSamplingPnts; l++) { - lambda[l] = lambdaB(l); - } + for(int l = 0; l < numSamplingPnts; l++) { lambda[l] = lambdaB(l); } for(int i = 0; i < numMapNodes; i++) { int &iFVi = _el2FV[iEl][i]; if(iFVi >= 0) { @@ -564,9 +554,7 @@ bool Patch::bndDistAndGradients(int iEl, double &f, std::vector<double> &gradF, nodes[i] = _xyz[_el2V[iEl][closure[i]]]; onedge[i] = element->getVertex(closure[i])->onWhat() == edge && _el2FV[iEl][closure[i]] >= 0; - if(onedge[i]) { - params[i] = _uvw[_el2FV[iEl][closure[i]]].x(); - } + if(onedge[i]) { params[i] = _uvw[_el2FV[iEl][closure[i]]].x(); } else reparamMeshVertexOnEdge(element->getVertex(closure[i]), edge, params[i]); diff --git a/contrib/MeshOptimizer/VertexCoord.cpp b/contrib/MeshOptimizer/VertexCoord.cpp index 2f436ba168f49a1f9fd1b5e448e2d22a3abe1087..31256ce0720a9e9e93f0f7f97c1bdc3b8ccb15b2 100644 --- a/contrib/MeshOptimizer/VertexCoord.cpp +++ b/contrib/MeshOptimizer/VertexCoord.cpp @@ -94,8 +94,7 @@ void VertexCoordParent::gXyz2gUvw(const SPoint3 &uvw, if(ge->dim() == 1) { SVector3 der = static_cast<GEdge *>(ge)->firstDer(uvw[0]); auto itUvw = gUvw.begin(); - for(auto itXyz = gXyz.begin(); - itXyz != gXyz.end(); itXyz++) { + for(auto itXyz = gXyz.begin(); itXyz != gXyz.end(); itXyz++) { (*itUvw)[0] = itXyz->x() * der.x() + itXyz->y() * der.y() + itXyz->z() * der.z(); itUvw++; @@ -105,8 +104,7 @@ void VertexCoordParent::gXyz2gUvw(const SPoint3 &uvw, Pair<SVector3, SVector3> der = static_cast<GFace *>(ge)->firstDer(SPoint2(uvw[0], uvw[1])); auto itUvw = gUvw.begin(); - for(auto itXyz = gXyz.begin(); - itXyz != gXyz.end(); itXyz++) { + for(auto itXyz = gXyz.begin(); itXyz != gXyz.end(); itXyz++) { (*itUvw)[0] = itXyz->x() * der.first().x() + itXyz->y() * der.first().y() + itXyz->z() * der.first().z(); (*itUvw)[1] = itXyz->x() * der.second().x() + @@ -177,8 +175,7 @@ VertexCoordLocalLine::VertexCoordLocalLine(MVertex *v) MElement *el = ge->getMeshElement(iEl); std::vector<MVertex *> lVerts; el->getVertices(lVerts); - auto itV = - std::find(lVerts.begin(), lVerts.end(), v); + auto itV = std::find(lVerts.begin(), lVerts.end(), v); if(itV != lVerts.end()) { const int iNode = std::distance(lVerts.begin(), itV); dir += getLineElTangent(el, iNode); @@ -198,8 +195,7 @@ VertexCoordLocalSurf::VertexCoordLocalSurf(MVertex *v) MElement *el = ge->getMeshElement(iEl); std::vector<MVertex *> lVerts; el->getVertices(lVerts); - auto itV = - std::find(lVerts.begin(), lVerts.end(), v); + auto itV = std::find(lVerts.begin(), lVerts.end(), v); if(itV != lVerts.end()) { const int iNode = std::distance(lVerts.begin(), itV); n += getSurfElNormal(el, iNode); diff --git a/contrib/MeshOptimizer/VertexCoord.h b/contrib/MeshOptimizer/VertexCoord.h index 0762ea0bae5afe2257c81fad19709fffa7dac8d9..bde9fe0de38683f13806bcb0c5fe7e5a108c5425 100644 --- a/contrib/MeshOptimizer/VertexCoord.h +++ b/contrib/MeshOptimizer/VertexCoord.h @@ -60,8 +60,7 @@ public: std::vector<SPoint3> &gUvw) const { auto itUvw = gUvw.begin(); - for(auto itXyz = gXyz.begin(); - itXyz != gXyz.end(); itXyz++) { + for(auto itXyz = gXyz.begin(); itXyz != gXyz.end(); itXyz++) { *itUvw = *itXyz; itUvw++; } @@ -103,8 +102,7 @@ public: std::vector<SPoint3> &gUvw) const { auto itUvw = gUvw.begin(); - for(auto itXyz = gXyz.begin(); - itXyz != gXyz.end(); itXyz++) { + for(auto itXyz = gXyz.begin(); itXyz != gXyz.end(); itXyz++) { (*itUvw)[0] = itXyz->x() * dir[0] + itXyz->y() * dir[1] + itXyz->z() * dir[2]; itUvw++; @@ -135,8 +133,7 @@ public: std::vector<SPoint3> &gUvw) const { auto itUvw = gUvw.begin(); - for(auto itXyz = gXyz.begin(); - itXyz != gXyz.end(); itXyz++) { + for(auto itXyz = gXyz.begin(); itXyz != gXyz.end(); itXyz++) { (*itUvw)[0] = itXyz->x() * dir0[0] + itXyz->y() * dir0[1] + itXyz->z() * dir0[2]; (*itUvw)[1] = diff --git a/contrib/MeshQualityOptimizer/MeshQualityOptimizer.cpp b/contrib/MeshQualityOptimizer/MeshQualityOptimizer.cpp index 908e88b81ccba4fbfbde2e9b93bdde25c4dfb93f..e4010e61d9902a613f85a810447c1be5f69249dd 100644 --- a/contrib/MeshQualityOptimizer/MeshQualityOptimizer.cpp +++ b/contrib/MeshQualityOptimizer/MeshQualityOptimizer.cpp @@ -91,8 +91,7 @@ double QualPatchDefParameters::elBadness(MElement *el, GEntity *gEnt) const else if(gEnt->dim() == 3) blc = static_cast<GRegion *>(gEnt)->getColumns(); if(blc) { - auto itBLEl = - blc->_toFirst.find(el); + auto itBLEl = blc->_toFirst.find(el); if(itBLEl != blc->_toFirst.end()) return 1.; } } @@ -127,8 +126,7 @@ int QualPatchDefParameters::inPatch(const SPoint3 &badBary, double limDist, else if(gEnt->dim() == 3) blc = static_cast<GRegion *>(gEnt)->getColumns(); if(blc) { - auto itBLEl = - blc->_toFirst.find(el); + auto itBLEl = blc->_toFirst.find(el); if(itBLEl != blc->_toFirst.end()) return -1; } } diff --git a/contrib/MeshQualityOptimizer/ObjContribIdealJac.h b/contrib/MeshQualityOptimizer/ObjContribIdealJac.h index efa45cf8fe04a19881797621bdbf59e47905dfcb..34125aa0952170fc8d87005779ae6637fec9d6c3 100644 --- a/contrib/MeshQualityOptimizer/ObjContribIdealJac.h +++ b/contrib/MeshQualityOptimizer/ObjContribIdealJac.h @@ -53,8 +53,8 @@ protected: template <class FuncType> ObjContribIdealJac<FuncType>::ObjContribIdealJac(double weight) - : ObjContrib("IdealJac", FuncType::getNamePrefix() + "IdealJac"), _mesh(nullptr), - _weight(weight) + : ObjContrib("IdealJac", FuncType::getNamePrefix() + "IdealJac"), + _mesh(nullptr), _weight(weight) { }