diff --git a/Common/gmsh.cpp b/Common/gmsh.cpp index fbe5cac9fe7b2ec7f53a1ce2c591c5fdfa41886c..2b3a7007d1163b56c4bad4f855dd45a68658af6f 100644 --- a/Common/gmsh.cpp +++ b/Common/gmsh.cpp @@ -469,9 +469,9 @@ int gmshModelAddEmbedded(int dim, const std::vector<int> &tags, int toDim, int t // gmshModelGeo -int gmshModelGeoAddVertex(int &tag, double x, double y, double z, double lc) +int gmshModelGeoAddVertex(int &tag, double x, double y, double z, double meshSize) { - return !GModel::current()->getGEOInternals()->addVertex(tag, x, y, z, lc); + return !GModel::current()->getGEOInternals()->addVertex(tag, x, y, z, meshSize); } int gmshModelGeoAddLine(int &tag, int startTag, int endTag) @@ -642,4 +642,13 @@ int gmshModelGeoSynchronize() // gmshModelOCC +static void createOcc() +{ + if(!GModel::current()->getOCCInternals()) GModel::current()->createOCCInternals(); +} +int gmshModelOccAddVertex(int &tag, double x, double y, double z, double meshSize) +{ + createOcc(); + return !GModel::current()->getOCCInternals()->addVertex(tag, x, y, z, meshSize); +} diff --git a/Common/gmsh.h b/Common/gmsh.h index 8fcf171215152a65967f08b0393b744186e492b0..0e7eb98edb4d5735319eb8ae97e3c76f2deda0c5 100644 --- a/Common/gmsh.h +++ b/Common/gmsh.h @@ -82,7 +82,7 @@ GMSH_API gmshModelAddEmbedded(int dim, const std::vector<int> &tags, int toDim, int toTag); // gmshModelGeo -GMSH_API gmshModelGeoAddVertex(int &tag, double x, double y, double z, double lc); +GMSH_API gmshModelGeoAddVertex(int &tag, double x, double y, double z, double meshSize); GMSH_API gmshModelGeoAddLine(int &tag, int startTag, int endTag); GMSH_API gmshModelGeoAddCircleArc(int &tag, int startTag, int centerTag, int endTag, double nx=0., double ny=0., double nz=0.); @@ -135,7 +135,8 @@ GMSH_API gmshModelGeoRemove(const std::vector<std::pair<int, int> > &dimTags, GMSH_API gmshModelGeoRemoveAllDuplicates(); GMSH_API gmshModelGeoSynchronize(); -// gmshModelOCC +// gmshModelOcc +GMSH_API gmshModelOccAddVertex(int &tag, double x, double y, double z, double meshSize); // gmshSolver diff --git a/Mesh/HighOrder.cpp b/Mesh/HighOrder.cpp index c00db77e13ab6ed8686bb500a5b0c87c01d2fca8..fca6ece17873fb75e84510e983efa2ee92316128 100644 --- a/Mesh/HighOrder.cpp +++ b/Mesh/HighOrder.cpp @@ -1328,41 +1328,36 @@ static void updateHighOrderVertices(GEntity *e, static void updatePeriodicEdgesAndFaces(GModel *m) { - // Edges for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); ++it) { - GEdge *tgt = *it; GEdge *src = dynamic_cast<GEdge*>(tgt->meshMaster()); if (src != NULL && src != tgt) { - std::map<MVertex*,MVertex*> &v2v = tgt->correspondingVertices; std::map<MVertex*,MVertex*> &p2p = tgt->correspondingHOPoints; p2p.clear(); Msg::Info("Constructing high order periodicity for edge connection %d - %d", - tgt->tag(),src->tag()); + tgt->tag(), src->tag()); std::map<MEdge,MLine*,Less_Edge> srcEdges; - for (unsigned int i=0;i<src->getNumMeshElements();i++) { + for (unsigned int i = 0; i < src->getNumMeshElements(); i++) { MLine* srcLine = dynamic_cast<MLine*>(src->getMeshElement(i)); - if (!srcLine) Msg::Error("Master element %d is not an edge ", + if (!srcLine) Msg::Error("Master element %d is not an edge", src->getMeshElement(i)->getNum()); srcEdges[MEdge(srcLine->getVertex(0), srcLine->getVertex(1))] = srcLine; } for (unsigned int i = 0; i < tgt->getNumMeshElements(); ++i) { - MLine* tgtLine = dynamic_cast<MLine*> (tgt->getMeshElement(i)); MVertex* vtcs[2]; - if (!tgtLine) Msg::Error("Slave element %d is not an edge ", tgt->getMeshElement(i)->getNum()); - for (int iVtx=0;iVtx<2;iVtx++) { + for (int iVtx = 0; iVtx < 2; iVtx++) { MVertex* vtx = tgtLine->getVertex(iVtx); std::map<MVertex*,MVertex*>::iterator tIter = v2v.find(vtx); if (tIter == v2v.end()) { @@ -1373,8 +1368,9 @@ static void updatePeriodicEdgesAndFaces(GModel *m) else vtcs[iVtx] = tIter->second; } - std::map<MEdge,MLine*,Less_Edge>::iterator srcIter = srcEdges.find(MEdge(vtcs[0],vtcs[1])); - if (srcIter==srcEdges.end()) { + std::map<MEdge,MLine*,Less_Edge>::iterator srcIter = + srcEdges.find(MEdge(vtcs[0],vtcs[1])); + if (srcIter == srcEdges.end()) { Msg::Error("Can't find periodic counterpart of edge %d-%d on edge %d" ", connected to edge %d-%d on %d", tgtLine->getVertex(0)->getNum(), @@ -1387,7 +1383,8 @@ static void updatePeriodicEdgesAndFaces(GModel *m) else { MLine* srcLine = srcIter->second; if (tgtLine->getNumVertices() != srcLine->getNumVertices()) throw; - for (int i=2;i<tgtLine->getNumVertices();i++) p2p[tgtLine->getVertex(i)] = srcLine->getVertex(i); + for (int i = 2; i < tgtLine->getNumVertices(); i++) + p2p[tgtLine->getVertex(i)] = srcLine->getVertex(i); } } } @@ -1397,7 +1394,6 @@ static void updatePeriodicEdgesAndFaces(GModel *m) GFace *tgt = *it; GFace *src = dynamic_cast<GFace*>(tgt->meshMaster()); if (src != NULL && src != tgt) { - Msg::Info("Constructing high order periodicity for face connection %d - %d", tgt->tag(),src->tag()); @@ -1407,20 +1403,19 @@ static void updatePeriodicEdgesAndFaces(GModel *m) std::map<MFace,MElement*,Less_Face> srcFaces; - for (unsigned int i=0;i<src->getNumMeshElements();++i) { + for (unsigned int i = 0; i < src->getNumMeshElements(); ++i) { MElement* srcElmt = src->getMeshElement(i); int nbVtcs = 0; if (dynamic_cast<MTriangle*> (srcElmt)) nbVtcs = 3; if (dynamic_cast<MQuadrangle*> (srcElmt)) nbVtcs = 4; std::vector<MVertex*> vtcs; - for (int iVtx=0;iVtx<nbVtcs;iVtx++) { + for (int iVtx = 0; iVtx < nbVtcs; iVtx++) { vtcs.push_back(srcElmt->getVertex(iVtx)); } srcFaces[MFace(vtcs)] = srcElmt; } - for (unsigned int i=0;i<tgt->getNumMeshElements();++i) { - + for (unsigned int i = 0; i < tgt->getNumMeshElements(); ++i) { MElement* tgtElmt = tgt->getMeshElement(i); Msg::Info("Checking element %d in face %d",i,tgt->tag()); @@ -1428,7 +1423,7 @@ static void updatePeriodicEdgesAndFaces(GModel *m) if (dynamic_cast<MTriangle*> (tgtElmt)) nbVtcs = 3; if (dynamic_cast<MQuadrangle*> (tgtElmt)) nbVtcs = 4; std::vector<MVertex*> vtcs; - for (int iVtx=0;iVtx<nbVtcs;iVtx++) { + for (int iVtx = 0; iVtx < nbVtcs; iVtx++) { MVertex* vtx = tgtElmt->getVertex(iVtx); std::map<MVertex*,MVertex*>::iterator tIter = v2v.find(vtx); @@ -1447,7 +1442,8 @@ static void updatePeriodicEdgesAndFaces(GModel *m) std::map<MFace,MElement*>::iterator srcIter = srcFaces.find(MFace(vtcs)); if (srcIter == srcFaces.end()) { std::ostringstream faceDef; - for (int iVtx=0;iVtx<nbVtcs;iVtx++) faceDef << vtcs[iVtx]->getNum() << " "; + for (int iVtx = 0; iVtx < nbVtcs; iVtx++) + faceDef << vtcs[iVtx]->getNum() << " "; Msg::Error("Cannot find periodic counterpart of face %s in face %d " "connected to %d",faceDef.str().c_str(), tgt->tag(),src->tag()); @@ -1461,7 +1457,7 @@ static void updatePeriodicEdgesAndFaces(GModel *m) } } } - Msg::Info("Finalized high order topology of periodic connections"); + Msg::Debug("Finalized high order topology of periodic connections"); } void SetOrder1(GModel *m, bool onlyVisible) diff --git a/utils/api_demos/CMakeLists.txt b/demos/api/CMakeLists.txt similarity index 100% rename from utils/api_demos/CMakeLists.txt rename to demos/api/CMakeLists.txt diff --git a/utils/api_demos/basic.cpp b/demos/api/basic.cpp similarity index 100% rename from utils/api_demos/basic.cpp rename to demos/api/basic.cpp diff --git a/utils/api_demos/basic2.cpp b/demos/api/basic2.cpp similarity index 100% rename from utils/api_demos/basic2.cpp rename to demos/api/basic2.cpp diff --git a/utils/api_demos/t1.cpp b/demos/api/t1.cpp similarity index 99% rename from utils/api_demos/t1.cpp rename to demos/api/t1.cpp index 94f602673dfc07cbfcebb4e1ab251c07e746993e..3d107e12a2fadc06aaf0968dad4241f77f749e4e 100644 --- a/utils/api_demos/t1.cpp +++ b/demos/api/t1.cpp @@ -7,6 +7,7 @@ int main(int argc, char **argv) { gmshInitialize(argc, argv); gmshOptionSetNumber("General.Terminal", 1); + gmshModelCreate("t1"); double lc = 1e-2; @@ -39,9 +40,11 @@ int main(int argc, char **argv) gmshModelSetPhysicalName(2, 6, "My surface"); gmshModelGeoSynchronize(); + gmshModelMesh(2); gmshExport("t1.msh"); + gmshFinalize(); return 0; }