Skip to content

Commit

Permalink
cgns fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
flagdanger committed Oct 10, 2024
1 parent 7e4cd5a commit 6e47c85
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 23 deletions.
2 changes: 1 addition & 1 deletion apf/apfMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ class Mesh
GlobalNumbering* findGlobalNumbering(const char* name);

GlobalNumbering* getGlobalNumbering(int i);
/** \brief get the global pcu */
/** \brief get the mesh pcu */
pcu::PCU* getPCU() const {return pcu_;}
void switchPCU(pcu::PCU *newPCU);
/** \brief true if any associated fields use array storage */
Expand Down
10 changes: 4 additions & 6 deletions mds/apfMDS.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
// AJP: alternative is to allow common cgns base header
// but trying to avoid that since it's not core functionality
#include <apf.h>
#include <PCU_C.h>

//
namespace pcu{
class PCU;
Expand All @@ -54,8 +56,6 @@ class Field;

/** \brief a map from global ids to vertex objects */
typedef std::map<long, MeshEntity*> GlobalToVert;
typedef struct PCU_t PCU_t;


/** \brief create an empty MDS part
\param model the geometric model interface
Expand Down Expand Up @@ -204,12 +204,10 @@ int getMdsIndex(Mesh2* in, MeshEntity* e);
so call apf::reorderMdsMesh after any mesh modification. */
MeshEntity* getMdsEntity(Mesh2* in, int dimension, int index);

Mesh2* loadMdsFromCGNS(gmi_model* g, const char* filename, CGNSBCMap& cgnsBCMap);
Mesh2* loadMdsFromCGNS2(PCU_t h, gmi_model* g, const char* filename, CGNSBCMap& cgnsBCMap);
Mesh2* loadMdsFromCGNS(PCU_t h, gmi_model* g, const char* filename, CGNSBCMap& cgnsBCMap);

// names of mesh data to read from file: (VERTEX, VelocityX; CellCentre, Pressure)
Mesh2* loadMdsFromCGNS(gmi_model* g, const char* filename, CGNSBCMap& cgnsBCMap, const std::vector<std::pair<std::string, std::string>>& meshData);
Mesh2* loadMdsFromCGNS2(PCU_t h, gmi_model* g, const char* filename, CGNSBCMap& cgnsBCMap, const std::vector<std::pair<std::string, std::string>>& meshData);
Mesh2* loadMdsFromCGNS(PCU_t h, gmi_model* g, const char* filename, CGNSBCMap& cgnsBCMap, const std::vector<std::pair<std::string, std::string>>& meshData);


int gmshMajorVersion(const char* filename);
Expand Down
18 changes: 3 additions & 15 deletions mds/mdsCGNS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void Kill(PCU_t h, const int fid, Args &&... args)
{
cgp_close(fid);
// Finalize the MPI environment.
PCU_Comm_Free(h);
PCU_Comm_Free(&h);
MPI_Finalize();
cgp_error_exit();
exit(EXIT_FAILURE);
Expand All @@ -252,7 +252,7 @@ void Kill(PCU_t h, const int fid)
{
cgp_close(fid);
// Finalize the MPI environment.
PCU_Comm_Free(h);
PCU_Comm_Free(&h);
MPI_Finalize();
cgp_error_exit();
exit(EXIT_FAILURE);
Expand Down Expand Up @@ -1286,7 +1286,7 @@ apf::Mesh2 *DoIt(PCU_t h, gmi_model *g, const std::string &fname, apf::CGNSBCMap
};

// process meshData and find vectors (and matrices)
const auto findMatch = [&meshData, &index, &cgid](MeshData &other, std::vector<MeshDataGroup> &meshDataGroups) {
const auto findMatch = [&meshData, &index, &cgid, &h](MeshData &other, std::vector<MeshDataGroup> &meshDataGroups) {
MeshDataGroup group;
for (auto &md : meshData)
{
Expand Down Expand Up @@ -1723,12 +1723,6 @@ namespace apf
{

// caller needs to bring up and pull down mpi/pcu: mpi/pcu is required and assumed.
Mesh2 *loadMdsFromCGNS(gmi_model *g, const char *fname, apf::CGNSBCMap &cgnsBCMap, const std::vector<std::pair<std::string, std::string>> &meshData)
{
PCU_t h = PCU_Get_Global_Handle();
return loadMdsFromCGNS(h, g, fname, cgnsBCMap, meshData);
}

Mesh2 *loadMdsFromCGNS(PCU_t h, gmi_model *g, const char *fname, apf::CGNSBCMap &cgnsBCMap, const std::vector<std::pair<std::string, std::string>> &meshData)
{
#ifdef HAVE_CGNS
Expand All @@ -1744,12 +1738,6 @@ Mesh2 *loadMdsFromCGNS(PCU_t h, gmi_model *g, const char *fname, apf::CGNSBCMap
}

// caller needs to bring up and pull down mpi/pcu: mpi/pcu is required and assumed.
Mesh2 *loadMdsFromCGNS(gmi_model *g, const char *fname, apf::CGNSBCMap &cgnsBCMap)
{
PCU_t h = PCU_Get_Global_Handle();
return loadMdsFromCGNS(h, g, fname, cgnsBCMap);
}

Mesh2 *loadMdsFromCGNS(PCU_t h, gmi_model *g, const char *fname, apf::CGNSBCMap &cgnsBCMap)
{
#ifdef HAVE_CGNS
Expand Down
1 change: 1 addition & 0 deletions pcu/pkg_tribits.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ set(HEADERS
pcu_util.h
reel/reel.h
pcu_defines.h
PCU.h
)
tribits_add_library(
pcu
Expand Down
2 changes: 1 addition & 1 deletion test/cgns.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ std::string doit(apf::CGNSBCMap &cgnsBCMap, const std::string &argv1, const std:
gmi_model *g = gmi_load(".null");
PCU_t h;
h.ptr = static_cast<void*>(PCUObj);
apf::Mesh2 *m = apf::loadMdsFromCGNS2(h, g, argv1.c_str(), cgnsBCMap, meshData);
apf::Mesh2 *m = apf::loadMdsFromCGNS(h, g, argv1.c_str(), cgnsBCMap, meshData);
m->verify();
//
m->writeNative(argv2.c_str());
Expand Down

0 comments on commit 6e47c85

Please sign in to comment.