From 4c8840e4243b3730bfd5b7f86f579e458e6ebebe Mon Sep 17 00:00:00 2001 From: "Kenneth E. Jansen" Date: Wed, 5 Oct 2022 11:31:09 -0600 Subject: [PATCH 1/8] support gmsh v4 (breaks gmsh v2 at this time) --- mds/apfMDS.h | 2 + mds/mdsGmsh.cc | 180 ++++++++++++++++++++++++++++++++++++++++--------- test/gmsh.cc | 12 ++-- 3 files changed, 157 insertions(+), 37 deletions(-) diff --git a/mds/apfMDS.h b/mds/apfMDS.h index ef745e576..f32c5c6ca 100644 --- a/mds/apfMDS.h +++ b/mds/apfMDS.h @@ -194,6 +194,8 @@ MeshEntity* getMdsEntity(Mesh2* in, int dimension, int index); Mesh2* loadMdsFromGmsh(gmi_model* g, const char* filename); +Mesh2* loadMdsDmgFromGmsh(const char* fnameDmg, const char* filename); + Mesh2* loadMdsFromUgrid(gmi_model* g, const char* filename); void printUgridPtnStats(gmi_model* g, const char* ugridfile, const char* ptnfile, diff --git a/mds/mdsGmsh.cc b/mds/mdsGmsh.cc index 63e5ce463..cac98c6ce 100644 --- a/mds/mdsGmsh.cc +++ b/mds/mdsGmsh.cc @@ -97,6 +97,16 @@ long getLong(Reader* r) return x; } +double getDouble(Reader* r) +{ + double x; + int nchars; + int ret = sscanf(r->word, "%lf%n", &x, &nchars); + PCU_ALWAYS_ASSERT(ret == 1); + r->word += nchars; + return x; +} + bool startsWith(char const* prefix, char const* s) { int ls = strlen(s); @@ -118,23 +128,102 @@ void checkMarker(Reader* r, char const* marker) PCU_ALWAYS_ASSERT(startsWith(marker, r->line)); } -void readNode(Reader* r) +void readNode(Reader* r, int bm) { - long id; Node n; apf::Vector3& p = n.point; - sscanf(r->line, "%ld %lf %lf %lf", &id, &p[0], &p[1], &p[2]); - r->nodeMap[id] = n; + sscanf(r->line, "%lf %lf %lf", &p[0], &p[1], &p[2]); + r->nodeMap[bm] = n; getLine(r); } +void readEntities(Reader* r,const char* fnameDmg) +{ + seekMarker(r, "$Entities"); + long nlde,ilde,iud,tag,isign,nMV,nME,nMF,nMR; + double x,y,z; + FILE* f = fopen(fnameDmg, "w"); + sscanf(r->line, "%ld %ld %ld %ld", &nMV, &nME, &nMF, &nMR); + fprintf(f, "%ld %ld %ld %ld \n", nMR, nMF, nME, nMV); // just reverse order + fprintf(f, "%f %f %f \n ", 0.0, 0.0, 0.0); // Probaby model bounding box? + fprintf(f, "%f %f %f \n", 0.0, 0.0, 0.0); // + + getLine(r); // because readNode gets the next line we need this outside for Nodes_Block + for (long i = 0; i < nMV; ++i){ + sscanf(r->line, "%ld %lf %lf %lf %ld ", &tag, &x, &y, &z, &iud); + fprintf(f, "%ld %lf %lf %lf \n",tag,x,y,z); + getLine(r); + } + for (long i = 0; i < nME; ++i){ + tag = getLong(r); + fprintf(f, "%ld", tag); + for (int i=0; i< 6; ++i) x=getDouble(r); // read past min maxes + iud = getLong(r); + for(long j =0; j < iud; ++j) isign=getLong(r); // read past iud user tags + nlde=getLong(r); // 2 in straight edged models but... + for(long j =0; j < nlde; ++j) { + ilde=getLong(r); + fprintf(f, " %d", abs(ilde)); // modVerts started from 1 + } + fprintf(f, "\n"); + getLine(r); + } + for (long i = 0; i < nMF; ++i){ + tag = getLong(r); + fprintf(f, "%ld %d\n", tag, 1); + for (int i=0; i< 6; ++i) x=getDouble(r); // read past min maxes + iud = getLong(r); + for(long j =0; j < iud; ++j) isign=getLong(r); // read past iud user tags + nlde=getLong(r); + fprintf(f, " %ld \n", nlde); + for(long j =0; j < nlde; ++j) { + ilde=getLong(r); + if(ilde > 0 ) + isign=1; + else + isign=0; + fprintf(f, " %d %ld \n", abs(ilde),isign); + } + getLine(r); + } + for (long i = 0; i < nMR; ++i){ + tag = getLong(r); + fprintf(f, "%ld %d \n", tag, 1); + for (int i=0; i< 6; ++i) x=getDouble(r); // read past min maxes + iud = getLong(r); + for(long j =0; j < iud; ++j) getLong(r); // read past iud user tags + nlde=getLong(r); + fprintf(f, "%ld \n", nlde); + for(long j =0; j < nlde; ++j) { + ilde=getLong(r); + if(ilde > 0 ) + isign=1; + else + isign=0; + fprintf(f, "%d %ld \n", abs(ilde),isign); + } + getLine(r); + } + checkMarker(r, "$EndEntities"); + fclose(f); +} void readNodes(Reader* r) { seekMarker(r, "$Nodes"); - long n = getLong(r); - getLine(r); - for (long i = 0; i < n; ++i) - readNode(r); + long Num_EntityBlocks,Num_Nodes,Nodes_Block,edim,etag,junk1,junk2,junk3; + sscanf(r->line, "%ld %ld %ld %ld", &Num_EntityBlocks, &Num_Nodes, &junk1, &junk2); + getLine(r); // because readNode gets the next line we need this outside for Nodes_Block + for (long i = 0; i < Num_EntityBlocks; ++i){ + sscanf(r->line, "%ld %ld %ld %ld", &edim, &etag, &junk3, &Nodes_Block); + long blockMap[Nodes_Block]; + for (long j = 0; j < Nodes_Block; ++j){ + getLine(r); + sscanf(r->line, "%ld", &blockMap[j]); + } + getLine(r); + for (long j = 0; j < Nodes_Block; ++j) + readNode(r,blockMap[j]); // has a genLine at end + } checkMarker(r, "$EndNodes"); } @@ -149,34 +238,35 @@ apf::MeshEntity* lookupVert(Reader* r, long nodeId, apf::ModelEntity* g) return n.entity; } -void readElement(Reader* r) +void readElement(Reader* r, long gmshType,long gtag) { long id = getLong(r); - long gmshType = getLong(r); if (isQuadratic(gmshType)) r->isQuadratic = true; int apfType = apfFromGmsh(gmshType); PCU_ALWAYS_ASSERT(0 <= apfType); int nverts = apf::Mesh::adjacentCount[apfType][0]; int dim = apf::Mesh::typeDimension[apfType]; - long ntags = getLong(r); - /* The Gmsh 4.9 documentation on the legacy 2.* format states: - * "By default, the first tag is the tag of the physical entity to which the - * element belongs; the second is the tag of the elementary model entity to - * which the element belongs; the third is the number of mesh partitions to - * which the element belongs, followed by the partition ids (negative - * partition ids indicate ghost cells). A zero tag is equivalent to no tag. - * Gmsh and most codes using the MSH 2 format require at least the first two - * tags (physical and elementary tags)." - * A physical entity is a user defined grouping of elementary model entities. - * An elementary model entity is a geometric model entity. */ - PCU_ALWAYS_ASSERT(ntags >= 2); - const int physType = static_cast(getLong(r)); - PCU_ALWAYS_ASSERT(dim>=0 && dim<4); - r->physicalType[dim].push_back(physType); - long gtag = getLong(r); - for (long i = 2; i < ntags; ++i) - getLong(r); /* discard all other element tags */ + if(false) { // FIXME + long ntags = getLong(r); + /* The Gmsh 4.9 documentation on the legacy 2.* format states: + * "By default, the first tag is the tag of the physical entity to which the + * element belongs; the second is the tag of the elementary model entity to + * which the element belongs; the third is the number of mesh partitions to + * which the element belongs, followed by the partition ids (negative + * partition ids indicate ghost cells). A zero tag is equivalent to no tag. + * Gmsh and most codes using the MSH 2 format require at least the first two + * tags (physical and elementary tags)." + * A physical entity is a user defined grouping of elementary model entities. + * An elementary model entity is a geometric model entity. */ + PCU_ALWAYS_ASSERT(ntags >= 2); + const int physType = static_cast(getLong(r)); + PCU_ALWAYS_ASSERT(dim>=0 && dim<4); + r->physicalType[dim].push_back(physType); +//FIXME blocks compilation long gtag = getLong(r); + for (long i = 2; i < ntags; ++i) + getLong(r); /* discard all other element tags */ + } apf::ModelEntity* g = r->mesh->findModelEntity(dim, gtag); apf::Downward verts; for (int i = 0; i < nverts; ++i) { @@ -196,10 +286,16 @@ void readElement(Reader* r) void readElements(Reader* r) { seekMarker(r, "$Elements"); - long n = getLong(r); + long Num_EntityBlocks,Num_Elements,Elements_Block,Edim,gtag,gmshType,junk1,junk2; + sscanf(r->line, "%ld %ld %ld %ld", &Num_EntityBlocks, &Num_Elements, &junk1, &junk2); getLine(r); - for (long i = 0; i < n; ++i) - readElement(r); + for (long i = 0; i < Num_EntityBlocks; ++i){ + sscanf(r->line, "%ld %ld %ld %ld", &Edim, >ag, &gmshType, &Elements_Block); + getLine(r); + for (long j = 0; j < Elements_Block; ++j) { + readElement(r,gmshType,gtag); + } + } checkMarker(r, "$EndElements"); } @@ -284,15 +380,25 @@ void readGmsh(apf::Mesh2* m, const char* filename) readNodes(&r); readElements(&r); m->acceptChanges(); - setElmPhysicalType(&r,m); + if(false) // FIXME + setElmPhysicalType(&r,m); freeReader(&r); if (r.isQuadratic) readQuadratic(&r, m, filename); } +} // closes original namespace +namespace apf { +void gmshFindDmg(const char* fnameDmg, const char* filename) +{ + Reader r; + + Mesh2* m=NULL; + initReader(&r, m, filename); + readEntities(&r, fnameDmg); + freeReader(&r); } -namespace apf { Mesh2* loadMdsFromGmsh(gmi_model* g, const char* filename) { @@ -301,4 +407,12 @@ Mesh2* loadMdsFromGmsh(gmi_model* g, const char* filename) return m; } +Mesh2* loadMdsDmgFromGmsh(const char*fnameDmg, const char* filename) +{ + gmshFindDmg(fnameDmg, filename); // new function that scans $Entities and writes a dmg + Mesh2* m = makeEmptyMdsMesh(gmi_load(fnameDmg), 0, false); + readGmsh(m, filename); + return m; +} + } diff --git a/test/gmsh.cc b/test/gmsh.cc index 307fab07e..7db3788f5 100644 --- a/test/gmsh.cc +++ b/test/gmsh.cc @@ -21,10 +21,14 @@ int main(int argc, char** argv) } gmi_register_null(); gmi_register_mesh(); - apf::Mesh2* m = apf::loadMdsFromGmsh(gmi_load(argv[1]), argv[2]); - // if input model is null derive a basic model for verify to pass. - if (std::string(argv[1]).compare(".null") == 0) - apf::deriveMdsModel(m); + if(false) { + apf::Mesh2* m = apf::loadMdsFromGmsh(gmi_load(argv[1]), argv[2]); + // if input model is null derive a basic model for verify to pass. + if (std::string(argv[1]).compare(".null") == 0) + apf::deriveMdsModel(m); + } + apf::Mesh2* m = apf::loadMdsDmgFromGmsh(argv[1], argv[2]); + m->verify(); m->writeNative(argv[3]); m->destroyNative(); From 1fa5ab1036d5966f2cba8409bea8853a70f1255e Mon Sep 17 00:00:00 2001 From: "Kenneth E. Jansen" Date: Wed, 5 Oct 2022 08:23:19 -0600 Subject: [PATCH 2/8] Parmetis from github needed some help from Ben M --- cmake/FindParmetis.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/FindParmetis.cmake b/cmake/FindParmetis.cmake index b00a11d41..e9a544418 100644 --- a/cmake/FindParmetis.cmake +++ b/cmake/FindParmetis.cmake @@ -28,7 +28,13 @@ if(NOT EXISTS "${METIS_LIBRARY}") message(FATAL_ERROR "metis library not found") endif() -set(PARMETIS_LIBRARIES ${PARMETIS_LIBRARY} ${METIS_LIBRARY}) +find_library(GK_LIBRARY GKlib PATHS "${PARMETIS_PREFIX}/lib") +if(EXISTS "${GK_LIBRARY}") + set(PARMETIS_LIBRARIES ${PARMETIS_LIBRARY} ${METIS_LIBRARY} ${GK_LIBRARY}) +else() + set(PARMETIS_LIBRARIES ${PARMETIS_LIBRARY} ${METIS_LIBRARY}) +endif() + set(PARMETIS_INCLUDE_DIRS ${PARMETIS_INCLUDE_DIR} ${METIS_INCLUDE_DIR}) include(FindPackageHandleStandardArgs) From 4e8b8e4065b7ab84ffec3c6a8edc4499e4922ac2 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 5 Oct 2022 13:46:38 -0400 Subject: [PATCH 3/8] latest pumi-meshes --- pumi-meshes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pumi-meshes b/pumi-meshes index 98f48ca2c..457c28125 160000 --- a/pumi-meshes +++ b/pumi-meshes @@ -1 +1 @@ -Subproject commit 98f48ca2cb8f1f3ad3db0c5fe4ad1c8df1f20811 +Subproject commit 457c28125284b015cb226883f5628a0b3a7af9c8 From ba87fb3ad748d393f8298a348d7b1da0a815bfc4 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 5 Oct 2022 14:02:53 -0400 Subject: [PATCH 4/8] gmsh v4 test --- test/testing.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/testing.cmake b/test/testing.cmake index de1120f82..afe76acc6 100644 --- a/test/testing.cmake +++ b/test/testing.cmake @@ -191,12 +191,19 @@ mpi_test(create_misSquare 1 mis_test) set(MDIR ${MESHES}/gmsh) -mpi_test(twoQuads 1 +mpi_test(gmshv2TwoQuads 1 ./from_gmsh ".null" "${MDIR}/twoQuads.msh" "${MDIR}/twoQuads.smb") +set(MDIR ${MESHES}/gmsh/v4) +mpi_test(gmshV4AirFoil 1 + ./from_gmsh + "${MDIR}/AirfoilDemo.dmg" + "${MDIR}/AirfoilDemo.msh" + "${MDIR}/AirfoilDemo.smb") + set(MDIR ${MESHES}/ugrid) mpi_test(naca_ugrid 2 ./from_ugrid From b27c9b2b93d01e018bfbec92d3a215a67192d19b Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 5 Oct 2022 14:38:14 -0400 Subject: [PATCH 5/8] gmsh: restore v2 support --- mds/apfMDS.h | 2 + mds/mdsGmsh.cc | 110 ++++++++++++++++++++++++++++++++++----------- test/gmsh.cc | 39 ++++++++++++---- test/testing.cmake | 10 +++-- 4 files changed, 122 insertions(+), 39 deletions(-) diff --git a/mds/apfMDS.h b/mds/apfMDS.h index f32c5c6ca..fbc8749d8 100644 --- a/mds/apfMDS.h +++ b/mds/apfMDS.h @@ -192,6 +192,8 @@ int getMdsIndex(Mesh2* in, MeshEntity* e); so call apf::reorderMdsMesh after any mesh modification. */ MeshEntity* getMdsEntity(Mesh2* in, int dimension, int index); +int gmshMajorVersion(const char* filename); + Mesh2* loadMdsFromGmsh(gmi_model* g, const char* filename); Mesh2* loadMdsDmgFromGmsh(const char* fnameDmg, const char* filename); diff --git a/mds/mdsGmsh.cc b/mds/mdsGmsh.cc index cac98c6ce..5271198c0 100644 --- a/mds/mdsGmsh.cc +++ b/mds/mdsGmsh.cc @@ -52,6 +52,8 @@ struct Reader { char* line; char* word; size_t linecap; + int major_version; + int minor_version; bool isQuadratic; std::map nodeMap; std::map entMap[4]; @@ -60,19 +62,6 @@ struct Reader { std::vector physicalType[4]; }; -void initReader(Reader* r, apf::Mesh2* m, const char* filename) -{ - r->mesh = m; - r->file = fopen(filename, "r"); - if (!r->file) { - lion_eprint(1,"couldn't open Gmsh file \"%s\"\n",filename); - abort(); - } - r->line = static_cast(malloc(1)); - r->line[0] = '\0'; - r->linecap = 1; - r->isQuadratic = false; -} void freeReader(Reader* r) { @@ -128,12 +117,37 @@ void checkMarker(Reader* r, char const* marker) PCU_ALWAYS_ASSERT(startsWith(marker, r->line)); } -void readNode(Reader* r, int bm) +void initReader(Reader* r, apf::Mesh2* m, const char* filename) +{ + r->mesh = m; + r->file = fopen(filename, "r"); + if (!r->file) { + lion_eprint(1,"couldn't open Gmsh file \"%s\"\n",filename); + abort(); + } + r->line = static_cast(malloc(1)); + r->line[0] = '\0'; + r->linecap = 1; + r->isQuadratic = false; + seekMarker(r, "$MeshFormat"); + int fileType, dataSize; + int ret = sscanf(r->line, "%d.%d %d %d\n", + &r->major_version, &r->minor_version, &fileType, &dataSize); + PCU_ALWAYS_ASSERT(ret==4); +} + +void readNode(Reader* r, int bm=-1) { Node n; apf::Vector3& p = n.point; - sscanf(r->line, "%lf %lf %lf", &p[0], &p[1], &p[2]); - r->nodeMap[bm] = n; + if(r->major_version == 4) { + sscanf(r->line, "%lf %lf %lf", &p[0], &p[1], &p[2]); + r->nodeMap[bm] = n; + } else if(r->major_version == 2) { + long id; + sscanf(r->line, "%ld %lf %lf %lf", &id, &p[0], &p[1], &p[2]); + r->nodeMap[id] = n; + } getLine(r); } @@ -207,8 +221,21 @@ void readEntities(Reader* r,const char* fnameDmg) checkMarker(r, "$EndEntities"); fclose(f); } -void readNodes(Reader* r) + +void readNodesV2(Reader* r) +{ + PCU_ALWAYS_ASSERT(r->major_version == 2); + seekMarker(r, "$Nodes"); + long n = getLong(r); + getLine(r); + for (long i = 0; i < n; ++i) + readNode(r); + checkMarker(r, "$EndNodes"); +} + +void readNodesV4(Reader* r) { + PCU_ALWAYS_ASSERT(r->major_version == 4); seekMarker(r, "$Nodes"); long Num_EntityBlocks,Num_Nodes,Nodes_Block,edim,etag,junk1,junk2,junk3; sscanf(r->line, "%ld %ld %ld %ld", &Num_EntityBlocks, &Num_Nodes, &junk1, &junk2); @@ -238,16 +265,19 @@ apf::MeshEntity* lookupVert(Reader* r, long nodeId, apf::ModelEntity* g) return n.entity; } -void readElement(Reader* r, long gmshType,long gtag) +void readElement(Reader* r, long gmshType=-1, long gtag=-1) { long id = getLong(r); + if(r->major_version == 2) { + gmshType = getLong(r); + } if (isQuadratic(gmshType)) r->isQuadratic = true; int apfType = apfFromGmsh(gmshType); PCU_ALWAYS_ASSERT(0 <= apfType); int nverts = apf::Mesh::adjacentCount[apfType][0]; int dim = apf::Mesh::typeDimension[apfType]; - if(false) { // FIXME + if(r->major_version == 2) { long ntags = getLong(r); /* The Gmsh 4.9 documentation on the legacy 2.* format states: * "By default, the first tag is the tag of the physical entity to which the @@ -263,7 +293,7 @@ void readElement(Reader* r, long gmshType,long gtag) const int physType = static_cast(getLong(r)); PCU_ALWAYS_ASSERT(dim>=0 && dim<4); r->physicalType[dim].push_back(physType); -//FIXME blocks compilation long gtag = getLong(r); + long gtag = getLong(r); for (long i = 2; i < ntags; ++i) getLong(r); /* discard all other element tags */ } @@ -283,8 +313,20 @@ void readElement(Reader* r, long gmshType,long gtag) getLine(r); } -void readElements(Reader* r) +void readElementsV2(Reader* r) { + PCU_ALWAYS_ASSERT(r->major_version == 2); + seekMarker(r, "$Elements"); + long n = getLong(r); + getLine(r); + for (long i = 0; i < n; ++i) + readElement(r); + checkMarker(r, "$EndElements"); +} + +void readElementsV4(Reader* r) +{ + PCU_ALWAYS_ASSERT(r->major_version == 4); seekMarker(r, "$Elements"); long Num_EntityBlocks,Num_Elements,Elements_Block,Edim,gtag,gmshType,junk1,junk2; sscanf(r->line, "%ld %ld %ld %ld", &Num_EntityBlocks, &Num_Elements, &junk1, &junk2); @@ -377,24 +419,40 @@ void readGmsh(apf::Mesh2* m, const char* filename) { Reader r; initReader(&r, m, filename); - readNodes(&r); - readElements(&r); - m->acceptChanges(); - if(false) // FIXME + if(r.major_version == 4) { + readNodesV4(&r); + readElementsV4(&r); + m->acceptChanges(); + } else if(r.major_version == 2) { + readNodesV2(&r); + readElementsV2(&r); + m->acceptChanges(); setElmPhysicalType(&r,m); - freeReader(&r); + } if (r.isQuadratic) readQuadratic(&r, m, filename); + freeReader(&r); } } // closes original namespace namespace apf { + +int gmshMajorVersion(const char* filename) { + Reader r; + Mesh2* m=NULL; + initReader(&r, m, filename); + int version = r.major_version; + freeReader(&r); + return version; +} + void gmshFindDmg(const char* fnameDmg, const char* filename) { Reader r; Mesh2* m=NULL; initReader(&r, m, filename); + PCU_ALWAYS_ASSERT(r.major_version==4); readEntities(&r, fnameDmg); freeReader(&r); } diff --git a/test/gmsh.cc b/test/gmsh.cc index 7db3788f5..77adab9fc 100644 --- a/test/gmsh.cc +++ b/test/gmsh.cc @@ -13,24 +13,45 @@ int main(int argc, char** argv) MPI_Init(&argc,&argv); PCU_Comm_Init(); lion_set_verbosity(1); - if ( argc != 4 ) { + if ( argc != 5 ) { if ( !PCU_Comm_Self() ) - printf("Usage: %s \n", argv[0]); + printf("Usage: %s \n" + "The input .msh and output .smb file names are required. \n" + "If 'none' is specified as the input model file name then \n" + "a output model (.dmg) will be written to the specified filename. \n" + "When a **gmsh v2** .msh is passed in, a minimal model will be created from " + "the mesh.\n" + "When a **gmsh v4** .msh is passed in, a topological model will be created " + "from the geometric model entities defined in the gmsh input file.\n", argv[0]); MPI_Finalize(); exit(EXIT_FAILURE); } gmi_register_null(); gmi_register_mesh(); - if(false) { - apf::Mesh2* m = apf::loadMdsFromGmsh(gmi_load(argv[1]), argv[2]); - // if input model is null derive a basic model for verify to pass. - if (std::string(argv[1]).compare(".null") == 0) + + std::string model(argv[1]); + std::string gmsh(argv[2]); + std::string outMesh(argv[3]); + std::string outModel(argv[4]); + + const int gmshVersion = apf::gmshMajorVersion(gmsh.c_str()); + fprintf(stderr, "version %d\n", gmshVersion); + apf::Mesh2* m; + if (gmshVersion == 2) { + if (model.compare("none") == 0) { + m = apf::loadMdsFromGmsh(gmi_load(".null"), gmsh.c_str()); apf::deriveMdsModel(m); + gmi_write_dmg(m->getModel(),outModel.c_str()); + } else { + m = apf::loadMdsFromGmsh(gmi_load(model.c_str()), gmsh.c_str()); + } + } else if (gmshVersion == 4) { + if (model.compare("none") == 0) { + m = apf::loadMdsDmgFromGmsh(outModel.c_str(), gmsh.c_str()); + } } - apf::Mesh2* m = apf::loadMdsDmgFromGmsh(argv[1], argv[2]); - m->verify(); - m->writeNative(argv[3]); + m->writeNative(outMesh.c_str()); m->destroyNative(); apf::destroyMesh(m); PCU_Comm_Free(); diff --git a/test/testing.cmake b/test/testing.cmake index afe76acc6..180ac9776 100644 --- a/test/testing.cmake +++ b/test/testing.cmake @@ -193,16 +193,18 @@ mpi_test(create_misSquare 1 set(MDIR ${MESHES}/gmsh) mpi_test(gmshv2TwoQuads 1 ./from_gmsh - ".null" + "none" "${MDIR}/twoQuads.msh" - "${MDIR}/twoQuads.smb") + "${MDIR}/twoQuads.smb" + "${MDIR}/twoQuads.dmg") set(MDIR ${MESHES}/gmsh/v4) mpi_test(gmshV4AirFoil 1 ./from_gmsh - "${MDIR}/AirfoilDemo.dmg" + "none" "${MDIR}/AirfoilDemo.msh" - "${MDIR}/AirfoilDemo.smb") + "${MDIR}/AirfoilDemo.smb" + "${MDIR}/AirfoilDemo.dmg") set(MDIR ${MESHES}/ugrid) mpi_test(naca_ugrid 2 From e72c47391555a66debaf4e0f4d49b826724ee4ca Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 5 Oct 2022 15:57:45 -0400 Subject: [PATCH 6/8] gmsh: fix warning this was a bug... thanks github actions --- mds/mdsGmsh.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mds/mdsGmsh.cc b/mds/mdsGmsh.cc index 5271198c0..eab936442 100644 --- a/mds/mdsGmsh.cc +++ b/mds/mdsGmsh.cc @@ -293,7 +293,7 @@ void readElement(Reader* r, long gmshType=-1, long gtag=-1) const int physType = static_cast(getLong(r)); PCU_ALWAYS_ASSERT(dim>=0 && dim<4); r->physicalType[dim].push_back(physType); - long gtag = getLong(r); + gtag = getLong(r); for (long i = 2; i < ntags; ++i) getLong(r); /* discard all other element tags */ } From 7b523eb0345c130147c5609f95232af3cb7405b0 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 5 Oct 2022 16:11:35 -0400 Subject: [PATCH 7/8] gmsh: silence more warnings --- mds/mdsGmsh.cc | 6 +++--- test/gmsh.cc | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mds/mdsGmsh.cc b/mds/mdsGmsh.cc index eab936442..7d4a26567 100644 --- a/mds/mdsGmsh.cc +++ b/mds/mdsGmsh.cc @@ -177,7 +177,7 @@ void readEntities(Reader* r,const char* fnameDmg) nlde=getLong(r); // 2 in straight edged models but... for(long j =0; j < nlde; ++j) { ilde=getLong(r); - fprintf(f, " %d", abs(ilde)); // modVerts started from 1 + fprintf(f, " %ld", std::abs(ilde)); // modVerts started from 1 } fprintf(f, "\n"); getLine(r); @@ -196,7 +196,7 @@ void readEntities(Reader* r,const char* fnameDmg) isign=1; else isign=0; - fprintf(f, " %d %ld \n", abs(ilde),isign); + fprintf(f, " %ld %ld \n", std::abs(ilde),isign); } getLine(r); } @@ -214,7 +214,7 @@ void readEntities(Reader* r,const char* fnameDmg) isign=1; else isign=0; - fprintf(f, "%d %ld \n", abs(ilde),isign); + fprintf(f, "%ld %ld \n", std::abs(ilde),isign); } getLine(r); } diff --git a/test/gmsh.cc b/test/gmsh.cc index 77adab9fc..b2f3911ec 100644 --- a/test/gmsh.cc +++ b/test/gmsh.cc @@ -36,7 +36,7 @@ int main(int argc, char** argv) const int gmshVersion = apf::gmshMajorVersion(gmsh.c_str()); fprintf(stderr, "version %d\n", gmshVersion); - apf::Mesh2* m; + apf::Mesh2* m = NULL; if (gmshVersion == 2) { if (model.compare("none") == 0) { m = apf::loadMdsFromGmsh(gmi_load(".null"), gmsh.c_str()); From 7e306ce55ebf97663008fdd76ba0170b3adf4862 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Thu, 6 Oct 2022 12:40:17 -0400 Subject: [PATCH 8/8] gmsh: compare dmg --- pumi-meshes | 2 +- test/testing.cmake | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pumi-meshes b/pumi-meshes index 457c28125..d03989485 160000 --- a/pumi-meshes +++ b/pumi-meshes @@ -1 +1 @@ -Subproject commit 457c28125284b015cb226883f5628a0b3a7af9c8 +Subproject commit d0398948585a3a0487f0e6cc61fe591573531fc4 diff --git a/test/testing.cmake b/test/testing.cmake index 180ac9776..b9d7011e7 100644 --- a/test/testing.cmake +++ b/test/testing.cmake @@ -205,6 +205,9 @@ mpi_test(gmshV4AirFoil 1 "${MDIR}/AirfoilDemo.msh" "${MDIR}/AirfoilDemo.smb" "${MDIR}/AirfoilDemo.dmg") +add_test(NAME gmshV4AirFoil_dmgDiff + COMMAND diff -r ${MDIR}/AirfoilDemo.dmg AirfoilDemo_gold.dmg + WORKING_DIRECTORY ${MDIR}) set(MDIR ${MESHES}/ugrid) mpi_test(naca_ugrid 2