From 4d68446dd2be0b31d3bf4764a20e073971abd146 Mon Sep 17 00:00:00 2001 From: Scott Charlton Date: Thu, 24 Oct 2019 20:06:49 -0600 Subject: [PATCH 1/2] Added methods to read/write solutions at IFaceCenter and JFaceCenter of 2D structured grids --- iriclib.cpp | 51 +++- iriclib.h | 28 ++- iriclib_cgnsfile.h | 8 + iriclib_cgnsfile_base.cpp | 82 ++++++- iriclib_cgnsfile_sol.cpp | 72 +++++- iriclib_single.c | 20 ++ private/iriclib_cgnsfile_impl.h | 16 +- private/iriclib_cgnsfile_solutionwriter.h | 4 + ...cgnsfile_solutionwriterdividesolutions.cpp | 109 ++++++++- ...b_cgnsfile_solutionwriterdividesolutions.h | 5 +- ...riclib_cgnsfile_solutionwriterstandard.cpp | 59 ++++- .../iriclib_cgnsfile_solutionwriterstandard.h | 5 +- unittests_cgnsfile/case_sol_readwrite.cpp | 221 +++++++++++++++++- 13 files changed, 633 insertions(+), 47 deletions(-) diff --git a/iriclib.cpp b/iriclib.cpp index 1e93a42..d9b9a49 100644 --- a/iriclib.cpp +++ b/iriclib.cpp @@ -15,7 +15,9 @@ #include #include -#if !defined(_MSC_VER) +#if defined(_MSC_VER) +#define unlink _unlink // warning C4996 +#else #define _stat stat #include // unlink #endif @@ -763,6 +765,18 @@ int cg_iRIC_Read_Sol_Cell_Integer_Mul(int fid, int step, const char *name, int* return f->Sol_Read_Cell_Integer(step, name, data); } +int cg_iRIC_Read_Sol_IFace_Integer_Mul(int fid, int step, const char *name, int* data) +{ + GET_F(fid); + return f->Sol_Read_IFace_Integer(step, name, data); +} + +int cg_iRIC_Read_Sol_JFace_Integer_Mul(int fid, int step, const char *name, int* data) +{ + GET_F(fid); + return f->Sol_Read_JFace_Integer(step, name, data); +} + int cg_iRIC_Read_Sol_Real_Mul(int fid, int step, const char *name, double* data) { GET_F(fid); @@ -775,6 +789,18 @@ int cg_iRIC_Read_Sol_Cell_Real_Mul(int fid, int step, const char *name, double* return f->Sol_Read_Cell_Real(step, name, data); } +int cg_iRIC_Read_Sol_IFace_Real_Mul(int fid, int step, const char *name, double* data) +{ + GET_F(fid); + return f->Sol_Read_IFace_Real(step, name, data); +} + +int cg_iRIC_Read_Sol_JFace_Real_Mul(int fid, int step, const char *name, double* data) +{ + GET_F(fid); + return f->Sol_Read_JFace_Real(step, name, data); +} + int cg_iRIC_Write_Sol_Time_Mul(int fid, double time){ GET_F(fid); return f->Sol_Write_Time(time); @@ -819,6 +845,18 @@ int cg_iRIC_Write_Sol_Cell_Integer_Mul(int fid, const char *name, int* data) return f->Sol_Write_Cell_Integer(name, data); } +int cg_iRIC_Write_Sol_IFace_Integer_Mul(int fid, const char *name, int* data) +{ + GET_F(fid); + return f->Sol_Write_IFace_Integer(name, data); +} + +int cg_iRIC_Write_Sol_JFace_Integer_Mul(int fid, const char *name, int* data) +{ + GET_F(fid); + return f->Sol_Write_JFace_Integer(name, data); +} + int cg_iRIC_Write_Sol_Real_Mul(int fid, const char *name, double* data) { GET_F(fid); @@ -831,6 +869,17 @@ int cg_iRIC_Write_Sol_Cell_Real_Mul(int fid, const char *name, double* data) return f->Sol_Write_Cell_Real(name, data); } +int cg_iRIC_Write_Sol_IFace_Real_Mul(int fid, const char *name, double* data) +{ + GET_F(fid); + return f->Sol_Write_IFace_Real(name, data); +} + +int cg_iRIC_Write_Sol_JFace_Real_Mul(int fid, const char *name, double* data) +{ + GET_F(fid); + return f->Sol_Write_JFace_Real(name, data); +} int cg_iRIC_Write_ErrorCode_Mul(int fid, int errorcode) { diff --git a/iriclib.h b/iriclib.h index e046a09..5da43ce 100644 --- a/iriclib.h +++ b/iriclib.h @@ -237,12 +237,20 @@ int IRICLIBDLL cg_iRIC_Read_Sol_GridCoord3d_Mul(int fid, int step, double* x, do int IRICLIBDLL cg_iRIC_Read_Sol_Integer_Mul(int fid, int step, const char *name, int* data); -int IRICLIBDLL cg_iRIC_Read_Sol_Real_Mul(int fid, int step, const char *name, double* data); - int IRICLIBDLL cg_iRIC_Read_Sol_Cell_Integer_Mul(int fid, int step, const char *name, int* data); +int IRICLIBDLL cg_iRIC_Read_Sol_IFace_Integer_Mul(int fid, int step, const char *name, int* data); + +int IRICLIBDLL cg_iRIC_Read_Sol_JFace_Integer_Mul(int fid, int step, const char *name, int* data); + +int IRICLIBDLL cg_iRIC_Read_Sol_Real_Mul(int fid, int step, const char *name, double* data); + int IRICLIBDLL cg_iRIC_Read_Sol_Cell_Real_Mul(int fid, int step, const char *name, double* data); +int IRICLIBDLL cg_iRIC_Read_Sol_IFace_Real_Mul(int fid, int step, const char *name, double* data); + +int IRICLIBDLL cg_iRIC_Read_Sol_JFace_Real_Mul(int fid, int step, const char *name, double* data); + /**********************************************/ /* Writing Solutions */ /**********************************************/ @@ -263,10 +271,18 @@ int IRICLIBDLL cg_iRIC_Write_Sol_Integer_Mul(int fid, const char *name, int* dat int IRICLIBDLL cg_iRIC_Write_Sol_Cell_Integer_Mul(int fid, const char *name, int* data); +int IRICLIBDLL cg_iRIC_Write_Sol_IFace_Integer_Mul(int fid, const char *name, int* data); + +int IRICLIBDLL cg_iRIC_Write_Sol_JFace_Integer_Mul(int fid, const char *name, int* data); + int IRICLIBDLL cg_iRIC_Write_Sol_Real_Mul(int fid, const char *name, double* data); int IRICLIBDLL cg_iRIC_Write_Sol_Cell_Real_Mul(int fid, const char *name, double* data); +int IRICLIBDLL cg_iRIC_Write_Sol_IFace_Real_Mul(int fid, const char *name, double* data); + +int IRICLIBDLL cg_iRIC_Write_Sol_JFace_Real_Mul(int fid, const char *name, double* data); + int IRICLIBDLL cg_iRIC_Write_ErrorCode_Mul(int fid, int errorcode); /**********************************************/ @@ -586,10 +602,18 @@ int IRICLIBDLL cg_iRIC_Write_Sol_Integer(const char *name, int* data); int IRICLIBDLL cg_iRIC_Write_Sol_Cell_Integer(const char *name, int* data); +int IRICLIBDLL cg_iRIC_Write_Sol_IFace_Integer(const char *name, int* data); + +int IRICLIBDLL cg_iRIC_Write_Sol_JFace_Integer(const char *name, int* data); + int IRICLIBDLL cg_iRIC_Write_Sol_Real(const char *name, double* data); int IRICLIBDLL cg_iRIC_Write_Sol_Cell_Real(const char *name, double* data); +int IRICLIBDLL cg_iRIC_Write_Sol_IFace_Real(const char *name, double* data); + +int IRICLIBDLL cg_iRIC_Write_Sol_JFace_Real(const char *name, double* data); + int IRICLIBDLL cg_iRIC_Write_ErrorCode(int errorcode); void IRICLIBDLL cg_iRIC_Init_BC_Names(); diff --git a/iriclib_cgnsfile.h b/iriclib_cgnsfile.h index 6bb4bfe..9b13616 100644 --- a/iriclib_cgnsfile.h +++ b/iriclib_cgnsfile.h @@ -160,8 +160,12 @@ class CgnsFile int Sol_Read_GridCoord3d(int step, double* x, double* y, double* z); int Sol_Read_Integer(int step, const char *name, int* data); int Sol_Read_Cell_Integer(int step, const char *name, int* data); + int Sol_Read_IFace_Integer(int step, const char *name, int* data); + int Sol_Read_JFace_Integer(int step, const char *name, int* data); int Sol_Read_Real(int step, const char *name, double* data); int Sol_Read_Cell_Real(int step, const char *name, double* data); + int Sol_Read_IFace_Real(int step, const char *name, double* data); + int Sol_Read_JFace_Real(int step, const char *name, double* data); int Sol_Write_Time(double time); int Sol_Write_Iteration(int index); @@ -171,8 +175,12 @@ class CgnsFile int Sol_Write_GridCoord3d(double *x, double *y, double *z); int Sol_Write_Integer(const char *name, int* data); int Sol_Write_Cell_Integer(const char *name, int* data); + int Sol_Write_IFace_Integer(const char *name, int* data); + int Sol_Write_JFace_Integer(const char *name, int* data); int Sol_Write_Real(const char *name, double* data); int Sol_Write_Cell_Real(const char *name, double* data); + int Sol_Write_IFace_Real(const char *name, double* data); + int Sol_Write_JFace_Real(const char *name, double* data); // -------------- // ErrorCode I/O diff --git a/iriclib_cgnsfile_base.cpp b/iriclib_cgnsfile_base.cpp index ff32504..a45cb81 100644 --- a/iriclib_cgnsfile_base.cpp +++ b/iriclib_cgnsfile_base.cpp @@ -215,6 +215,9 @@ int CgnsFile::Impl::loadResultData() int ier = cg_gopath(m_fileId, "/iRIC/iRICZone/ZoneIterativeData/FlowCellSolutionPointers"); m_hasCellSols = (ier == 0); + ier = cg_gopath(m_fileId, "/iRIC/iRICZone/ZoneIterativeData/FlowIFaceSolutionPointers"); + m_hasFaceSols = (ier == 0); + ier = gotoBase(); RETURN_IF_ERR; @@ -686,6 +689,16 @@ void CgnsFile::Impl::getCellSolName(int num, char* name) sprintf(name, "FlowCellSolution%d", num); } +void CgnsFile::Impl::getIFaceSolName(int num, char* name) +{ + sprintf(name, "FlowIFaceSolution%d", num); +} + +void CgnsFile::Impl::getJFaceSolName(int num, char* name) +{ + sprintf(name, "FlowJFaceSolution%d", num); +} + void CgnsFile::Impl::getSolGridCoordName(int num, char* name) { sprintf(name, "GridCoordinatesForSolution%d", num); @@ -701,7 +714,7 @@ void CgnsFile::Impl::getPolydataSolName(int num, char* name) sprintf(name, "PolydataSolution%d", num); } -int CgnsFile::Impl::addSolutionNode(int fid, int bid, int zid, int sid, std::vector* sols, std::vector* cellsols) +int CgnsFile::Impl::addSolutionNode(int fid, int bid, int zid, int sid, std::vector* sols, std::vector* cellsols, std::vector* ifacesols, std::vector* jfacesols) { char solname[NAME_MAXLENGTH]; getSolName(sid, solname); @@ -711,6 +724,14 @@ int CgnsFile::Impl::addSolutionNode(int fid, int bid, int zid, int sid, std::vec getCellSolName(sid, cellsolname); cellsols->push_back(cellsolname); + char ifacesolname[NAME_MAXLENGTH]; + getIFaceSolName(sid, ifacesolname); + ifacesols->push_back(ifacesolname); + + char jfacesolname[NAME_MAXLENGTH]; + getJFaceSolName(sid, jfacesolname); + jfacesols->push_back(jfacesolname); + int S, ier; ier = cg_sol_write(fid, bid, zid, solname, Vertex, &S); @@ -719,12 +740,24 @@ int CgnsFile::Impl::addSolutionNode(int fid, int bid, int zid, int sid, std::vec ier = cg_sol_write(fid, bid, zid, cellsolname, CellCenter, &S); RETURN_IF_ERR; + ier = cg_sol_write(fid, bid, zid, ifacesolname, IFaceCenter, &S); + RETURN_IF_ERR; + + ier = cg_sol_write(fid, bid, zid, jfacesolname, JFaceCenter, &S); + RETURN_IF_ERR; + ier = writeFlowSolutionPointers(fid, bid, zid, *sols); RETURN_IF_ERR; ier = writeFlowCellSolutionPointers(fid, bid, zid, *cellsols); RETURN_IF_ERR; + ier = writeFlowIFaceSolutionPointers(fid, bid, zid, *ifacesols); + RETURN_IF_ERR; + + ier = writeFlowJFaceSolutionPointers(fid, bid, zid, *jfacesols); + RETURN_IF_ERR; + ier = addPolydataSolutionNode(fid, bid, zid, sid); RETURN_IF_ERR; @@ -770,15 +803,34 @@ int CgnsFile::Impl::solIndex(CGNS_ENUMT(GridLocation_t) location, int step) { int index = step; if (this->m_hasCellSols) { - switch (location) { - case CGNS_ENUMV(Vertex): - index = 2 * (step - 1) + 1; - break; - case CGNS_ENUMV(CellCenter): - index = 2 * (step - 1) + 2; - break; - default: - assert(false); + if (this->m_hasFaceSols) { + switch (location) { + case CGNS_ENUMV(Vertex): + index = 4 * (step - 1) + 1; + break; + case CGNS_ENUMV(CellCenter): + index = 4 * (step - 1) + 2; + break; + case CGNS_ENUMV(IFaceCenter): + index = 4 * (step - 1) + 3; + break; + case CGNS_ENUMV(JFaceCenter): + index = 4 * (step - 1) + 4; + break; + default: + assert(false); + } + } else { + switch (location) { + case CGNS_ENUMV(Vertex): + index = 2 * (step - 1) + 1; + break; + case CGNS_ENUMV(CellCenter): + index = 2 * (step - 1) + 2; + break; + default: + assert(false); + } } } return index; @@ -812,6 +864,16 @@ int CgnsFile::Impl::writeFlowCellSolutionPointers(int fid, int bid, int zid, con return writePointers(fid, bid, zid, "FlowCellSolutionPointers", sols); } +int CgnsFile::Impl::writeFlowIFaceSolutionPointers(int fid, int bid, int zid, const std::vector& sols) +{ + return writePointers(fid, bid, zid, "FlowIFaceSolutionPointers", sols); +} + +int CgnsFile::Impl::writeFlowJFaceSolutionPointers(int fid, int bid, int zid, const std::vector& sols) +{ + return writePointers(fid, bid, zid, "FlowJFaceSolutionPointers", sols); +} + int CgnsFile::Impl::writeGridCoordinatesPointers(int fid, int bid, int zid, const std::vector& coords) { return writePointers(fid, bid, zid, "GridCoordinatesPointers", coords); diff --git a/iriclib_cgnsfile_sol.cpp b/iriclib_cgnsfile_sol.cpp index ba78d96..c19b1ee 100644 --- a/iriclib_cgnsfile_sol.cpp +++ b/iriclib_cgnsfile_sol.cpp @@ -17,8 +17,14 @@ static const std::string ECNODE = "ErrorCode"; int CgnsFile::Sol_Read_Count(int* count) { if (impl->m_hasCellSols) { - assert((impl->m_solId % 2) == 0); - *count = impl->m_solId / 2; + if (impl->m_hasFaceSols) { + assert((impl->m_solId % 4) == 0); + *count = impl->m_solId / 4; + } + else { + assert((impl->m_solId % 2) == 0); + *count = impl->m_solId / 2; + } } else { *count = impl->m_solId; @@ -120,11 +126,31 @@ int CgnsFile::Sol_Read_Cell_Integer(int step, const char *name, int* data) return Impl::readArray(name, Integer, -1, data); } +int CgnsFile::Sol_Read_IFace_Integer(int step, const char *name, int* data) +{ + int idx = impl->solIndex(IFaceCenter, step); + int ier = cg_goto(impl->m_fileId, impl->m_baseId, "Zone_t", impl->m_zoneId, + "FlowSolution_t", idx, NULL); + RETURN_IF_ERR; + + return Impl::readArray(name, Integer, -1, data); +} + +int CgnsFile::Sol_Read_JFace_Integer(int step, const char *name, int* data) +{ + int idx = impl->solIndex(JFaceCenter, step); + int ier = cg_goto(impl->m_fileId, impl->m_baseId, "Zone_t", impl->m_zoneId, + "FlowSolution_t", idx, NULL); + RETURN_IF_ERR; + + return Impl::readArray(name, Integer, -1, data); +} + int CgnsFile::Sol_Read_Real(int step, const char *name, double* data) { int idx = impl->solIndex(Vertex, step); int ier = cg_goto(impl->m_fileId, impl->m_baseId, "Zone_t", impl->m_zoneId, - "FlowSolution_t", idx, NULL); + "FlowSolution_t", idx, NULL); RETURN_IF_ERR; return Impl::readArray(name, RealDouble, -1, data); @@ -140,6 +166,26 @@ int CgnsFile::Sol_Read_Cell_Real(int step, const char *name, double* data) return Impl::readArray(name, RealDouble, -1, data); } +int CgnsFile::Sol_Read_IFace_Real(int step, const char *name, double* data) +{ + int idx = impl->solIndex(IFaceCenter, step); + int ier = cg_goto(impl->m_fileId, impl->m_baseId, "Zone_t", impl->m_zoneId, + "FlowSolution_t", idx, NULL); + RETURN_IF_ERR; + + return Impl::readArray(name, RealDouble, -1, data); +} + +int CgnsFile::Sol_Read_JFace_Real(int step, const char *name, double* data) +{ + int idx = impl->solIndex(JFaceCenter, step); + int ier = cg_goto(impl->m_fileId, impl->m_baseId, "Zone_t", impl->m_zoneId, + "FlowSolution_t", idx, NULL); + RETURN_IF_ERR; + + return Impl::readArray(name, RealDouble, -1, data); +} + int CgnsFile::Sol_Write_Time(double time) { return impl->m_solutionWriter->Sol_Write_Time(time); @@ -216,6 +262,16 @@ int CgnsFile::Sol_Write_Cell_Integer(const char *name, int* data) return impl->m_solutionWriter->Sol_Write_Cell_Integer(name, data); } +int CgnsFile::Sol_Write_IFace_Integer(const char *name, int* data) +{ + return impl->m_solutionWriter->Sol_Write_IFace_Integer(name, data); +} + +int CgnsFile::Sol_Write_JFace_Integer(const char *name, int* data) +{ + return impl->m_solutionWriter->Sol_Write_JFace_Integer(name, data); +} + int CgnsFile::Sol_Write_Real(const char *name, double* data) { return impl->m_solutionWriter->Sol_Write_Real(name, data); @@ -226,6 +282,16 @@ int CgnsFile::Sol_Write_Cell_Real(const char *name, double* data) return impl->m_solutionWriter->Sol_Write_Cell_Real(name, data); } +int CgnsFile::Sol_Write_IFace_Real(const char *name, double* data) +{ + return impl->m_solutionWriter->Sol_Write_IFace_Real(name, data); +} + +int CgnsFile::Sol_Write_JFace_Real(const char *name, double* data) +{ + return impl->m_solutionWriter->Sol_Write_JFace_Real(name, data); +} + int CgnsFile::ErrorCode_Write(int errorcode) { int ier = impl->gotoBase(); diff --git a/iriclib_single.c b/iriclib_single.c index cdbcd1b..e1521c2 100644 --- a/iriclib_single.c +++ b/iriclib_single.c @@ -442,6 +442,16 @@ int cg_iRIC_Write_Sol_Cell_Integer(const char* name, int* data) return cg_iRIC_Write_Sol_Cell_Integer_Mul(lastfileid, name, data); } +int cg_iRIC_Write_Sol_IFace_Integer(const char* name, int* data) +{ + return cg_iRIC_Write_Sol_IFace_Integer_Mul(lastfileid, name, data); +} + +int cg_iRIC_Write_Sol_JFace_Integer(const char* name, int* data) +{ + return cg_iRIC_Write_Sol_JFace_Integer_Mul(lastfileid, name, data); +} + int cg_iRIC_Write_Sol_Real(const char* name, double* data) { return cg_iRIC_Write_Sol_Real_Mul(lastfileid, name, data); @@ -452,6 +462,16 @@ int cg_iRIC_Write_Sol_Cell_Real(const char* name, double* data) return cg_iRIC_Write_Sol_Cell_Real_Mul(lastfileid, name, data); } +int cg_iRIC_Write_Sol_IFace_Real(const char* name, double* data) +{ + return cg_iRIC_Write_Sol_IFace_Real_Mul(lastfileid, name, data); +} + +int cg_iRIC_Write_Sol_JFace_Real(const char* name, double* data) +{ + return cg_iRIC_Write_Sol_JFace_Real_Mul(lastfileid, name, data); +} + int cg_iRIC_Write_ErrorCode(int errorcode) { return cg_iRIC_Write_ErrorCode_Mul(lastfileid, errorcode); diff --git a/private/iriclib_cgnsfile_impl.h b/private/iriclib_cgnsfile_impl.h index bdd8eee..6c0f772 100644 --- a/private/iriclib_cgnsfile_impl.h +++ b/private/iriclib_cgnsfile_impl.h @@ -13,6 +13,12 @@ class CgnsFile::Impl { public: static const int NAME_MAXLENGTH = 200; + + static const int VERTEX_SOLUTION_ID = 1; + static const int CELL_SOLUTION_ID = 2; + static const int IFACE_2D_SOLUTION_ID = 3; + static const int JFACE_2D_SOLUTION_ID = 4; + static const std::string IRICZONE; static const std::string BINAME; static const std::string RDNODE; @@ -87,12 +93,14 @@ class CgnsFile::Impl static void getBcName(const char* typeName, int num, char* name); // local_get_bc_name static void getSolName(int num, char* name); static void getCellSolName(int num, char* name); + static void getIFaceSolName(int num, char* name); + static void getJFaceSolName(int num, char* name); static void getSolGridCoordName(int num, char* name); static void getParticleSolName(int num, char* name); static void getPolydataSolName(int num, char* name); - static int addSolutionNode(int fid, int bid, int zid, int sid, std::vector* sols, std::vector* cellsols); + static int addSolutionNode(int fid, int bid, int zid, int sid, std::vector* sols, std::vector* cellsols, std::vector* ifacesols, std::vector* jfacesols); static int addSolutionGridCoordNode(int fid, int bid, int zid, int sid, std::vector* coords); static int addParticleSolutionNode(int fid, int bid, int zid, int sid); static int addPolydataSolutionNode(int fid, int bid, int zid, int sid); @@ -100,6 +108,9 @@ class CgnsFile::Impl static int writePointers(int fid, int bid, int zid, const char* name, const std::vector& strs); static int writeFlowSolutionPointers(int fid, int bid, int zid, const std::vector& sols); static int writeFlowCellSolutionPointers(int fid, int bid, int zid, const std::vector& sols); + static int writeFlowIFaceSolutionPointers(int fid, int bid, int zid, const std::vector& sols); + static int writeFlowJFaceSolutionPointers(int fid, int bid, int zid, const std::vector& sols); + static int writeGridCoordinatesPointers(int fid, int bid, int zid, const std::vector& coords); int solIndex(CGNS_ENUMT(GridLocation_t) location, int step); @@ -119,11 +130,14 @@ class CgnsFile::Impl int m_solId = 0; bool m_hasCellSols = true; + bool m_hasFaceSols = true; std::vector m_solTimes; std::vector m_solIndices; std::vector m_solGridCoordPointers; std::vector m_solPointers; std::vector m_cellSolPointers; + std::vector m_ifaceSolPointers; + std::vector m_jfaceSolPointers; std::vector m_solParticlePointers; std::vector > m_solBaseIterInts; diff --git a/private/iriclib_cgnsfile_solutionwriter.h b/private/iriclib_cgnsfile_solutionwriter.h index 61b8d4b..aebdbf8 100644 --- a/private/iriclib_cgnsfile_solutionwriter.h +++ b/private/iriclib_cgnsfile_solutionwriter.h @@ -23,6 +23,10 @@ class CgnsFile::SolutionWriter virtual int Sol_Write_Real(const char *name, double* data) = 0; virtual int Sol_Write_Cell_Integer(const char *name, int* data) = 0; virtual int Sol_Write_Cell_Real(const char *name, double* data) = 0; + virtual int Sol_Write_IFace_Integer(const char *name, int* data) = 0; + virtual int Sol_Write_IFace_Real(const char *name, double* data) = 0; + virtual int Sol_Write_JFace_Integer(const char *name, int* data) = 0; + virtual int Sol_Write_JFace_Real(const char *name, double* data) = 0; virtual int Sol_Particle_Write_Pos2d(cgsize_t count, double* x, double* y) = 0; virtual int Sol_Particle_Write_Pos3d(cgsize_t count, double* x, double* y, double* z) = 0; virtual int Sol_Particle_Write_Real(const char* name, double* value) = 0; diff --git a/private/iriclib_cgnsfile_solutionwriterdividesolutions.cpp b/private/iriclib_cgnsfile_solutionwriterdividesolutions.cpp index 1c315b8..f35a50f 100644 --- a/private/iriclib_cgnsfile_solutionwriterdividesolutions.cpp +++ b/private/iriclib_cgnsfile_solutionwriterdividesolutions.cpp @@ -153,9 +153,13 @@ int CgnsFile::SolutionWriterDivideSolutions::Sol_Write_Time(double time) std::vector sols; std::vector cellsols; - ier = Impl::addSolutionNode(m_fileId, m_baseId, m_zoneId, 1, &sols, &cellsols); + std::vector ifacesols; + std::vector jfacesols; + ier = Impl::addSolutionNode(m_fileId, m_baseId, m_zoneId, 1, &sols, &cellsols, &ifacesols, &jfacesols); RETURN_IF_ERR; + // Vertex + char solname[CgnsFile::Impl::NAME_MAXLENGTH]; CgnsFile::Impl::getSolName(i->m_solId, solname); @@ -166,6 +170,8 @@ int CgnsFile::SolutionWriterDivideSolutions::Sol_Write_Time(double time) ier = CgnsFile::Impl::writeFlowSolutionPointers(i->m_fileId, i->m_baseId, i->m_zoneId, i->m_solPointers); RETURN_IF_ERR; + // CellCenter + char cellsolname[CgnsFile::Impl::NAME_MAXLENGTH]; CgnsFile::Impl::getCellSolName(i->m_solId, cellsolname); @@ -173,7 +179,34 @@ int CgnsFile::SolutionWriterDivideSolutions::Sol_Write_Time(double time) RETURN_IF_ERR; i->m_cellSolPointers.push_back(cellsolname); - return CgnsFile::Impl::writeFlowCellSolutionPointers(i->m_fileId, i->m_baseId, i->m_zoneId, i->m_cellSolPointers); + ier = CgnsFile::Impl::writeFlowCellSolutionPointers(i->m_fileId, i->m_baseId, i->m_zoneId, i->m_cellSolPointers); + RETURN_IF_ERR; + + // IFaceCenter + + char ifacesolname[CgnsFile::Impl::NAME_MAXLENGTH]; + CgnsFile::Impl::getIFaceSolName(i->m_solId, ifacesolname); + + ier = linkSolution(m_fileName.c_str(), m_fileId, m_baseId, m_zoneId, 3, i->m_fileId, i->m_baseId, i->m_zoneId, ifacesolname); + RETURN_IF_ERR; + + i->m_ifaceSolPointers.push_back(ifacesolname); + ier = CgnsFile::Impl::writeFlowIFaceSolutionPointers(i->m_fileId, i->m_baseId, i->m_zoneId, i->m_ifaceSolPointers); + RETURN_IF_ERR; + + // JFaceCenter + + char jfacesolname[CgnsFile::Impl::NAME_MAXLENGTH]; + CgnsFile::Impl::getJFaceSolName(i->m_solId, jfacesolname); + + ier = linkSolution(m_fileName.c_str(), m_fileId, m_baseId, m_zoneId, 4, i->m_fileId, i->m_baseId, i->m_zoneId, jfacesolname); + RETURN_IF_ERR; + + i->m_jfaceSolPointers.push_back(jfacesolname); + ier = CgnsFile::Impl::writeFlowJFaceSolutionPointers(i->m_fileId, i->m_baseId, i->m_zoneId, i->m_jfaceSolPointers); + RETURN_IF_ERR; + + return 0; } int CgnsFile::SolutionWriterDivideSolutions::Sol_Write_Iteration(int index) @@ -194,11 +227,18 @@ int CgnsFile::SolutionWriterDivideSolutions::Sol_Write_Iteration(int index) ier = cg_array_write("IterationValues", Integer, 1, &dimVec, &index); RETURN_IF_ERR; + ier = cg_ziter_write(m_fileId, m_baseId, m_zoneId, ZINAME.c_str()); + RETURN_IF_ERR; + std::vector sols; std::vector cellsols; - ier = Impl::addSolutionNode(m_fileId, m_baseId, m_zoneId, 1, &sols, &cellsols); + std::vector ifacesols; + std::vector jfacesols; + ier = Impl::addSolutionNode(m_fileId, m_baseId, m_zoneId, 1, &sols, &cellsols, &ifacesols, &jfacesols); RETURN_IF_ERR; + // Vertex + char solname[CgnsFile::Impl::NAME_MAXLENGTH]; CgnsFile::Impl::getSolName(i->m_solId, solname); @@ -209,6 +249,8 @@ int CgnsFile::SolutionWriterDivideSolutions::Sol_Write_Iteration(int index) ier = CgnsFile::Impl::writeFlowSolutionPointers(i->m_fileId, i->m_baseId, i->m_zoneId, i->m_solPointers); RETURN_IF_ERR; + // CellCenter + char cellsolname[CgnsFile::Impl::NAME_MAXLENGTH]; CgnsFile::Impl::getCellSolName(i->m_solId, cellsolname); @@ -216,7 +258,35 @@ int CgnsFile::SolutionWriterDivideSolutions::Sol_Write_Iteration(int index) RETURN_IF_ERR; i->m_cellSolPointers.push_back(cellsolname); - return CgnsFile::Impl::writeFlowCellSolutionPointers(i->m_fileId, i->m_baseId, i->m_zoneId, i->m_cellSolPointers); + ier = CgnsFile::Impl::writeFlowCellSolutionPointers(i->m_fileId, i->m_baseId, i->m_zoneId, i->m_cellSolPointers); + RETURN_IF_ERR; + + // IFaceCenter + + char ifacesolname[CgnsFile::Impl::NAME_MAXLENGTH]; + CgnsFile::Impl::getIFaceSolName(i->m_solId, ifacesolname); + + ier = linkSolution(m_fileName.c_str(), m_fileId, m_baseId, m_zoneId, 3, i->m_fileId, i->m_baseId, i->m_zoneId, ifacesolname); + RETURN_IF_ERR; + + i->m_ifaceSolPointers.push_back(ifacesolname); + ier = CgnsFile::Impl::writeFlowIFaceSolutionPointers(i->m_fileId, i->m_baseId, i->m_zoneId, i->m_ifaceSolPointers); + RETURN_IF_ERR; + + + // JFaceCenter + + char jfacesolname[CgnsFile::Impl::NAME_MAXLENGTH]; + CgnsFile::Impl::getJFaceSolName(i->m_solId, jfacesolname); + + ier = linkSolution(m_fileName.c_str(), m_fileId, m_baseId, m_zoneId, 4, i->m_fileId, i->m_baseId, i->m_zoneId, jfacesolname); + RETURN_IF_ERR; + + i->m_jfaceSolPointers.push_back(jfacesolname); + ier = CgnsFile::Impl::writeFlowJFaceSolutionPointers(i->m_fileId, i->m_baseId, i->m_zoneId, i->m_jfaceSolPointers); + RETURN_IF_ERR; + + return 0; } int CgnsFile::SolutionWriterDivideSolutions::Sol_Write_GridCoord2d(double *x, double *y) @@ -260,26 +330,49 @@ int CgnsFile::SolutionWriterDivideSolutions::Sol_Write_GridCoord3d(double *x, do int CgnsFile::SolutionWriterDivideSolutions::Sol_Write_Integer(const char *name, int* data) { int F; - return cg_field_write(m_fileId, m_baseId, m_zoneId, 1, Integer, name, data, &F); + return cg_field_write(m_fileId, m_baseId, m_zoneId, CgnsFile::Impl::VERTEX_SOLUTION_ID, Integer, name, data, &F); } int CgnsFile::SolutionWriterDivideSolutions::Sol_Write_Cell_Integer(const char *name, int* data) { int F; - return cg_field_write(m_fileId, m_baseId, m_zoneId, 2, Integer, name, data, &F); + return cg_field_write(m_fileId, m_baseId, m_zoneId, CgnsFile::Impl::CELL_SOLUTION_ID, Integer, name, data, &F); +} + +int CgnsFile::SolutionWriterDivideSolutions::Sol_Write_IFace_Integer(const char *name, int* data) +{ + int F; + return cg_field_write(m_fileId, m_baseId, m_zoneId, CgnsFile::Impl::IFACE_2D_SOLUTION_ID, Integer, name, data, &F); } +int CgnsFile::SolutionWriterDivideSolutions::Sol_Write_JFace_Integer(const char *name, int* data) +{ + int F; + return cg_field_write(m_fileId, m_baseId, m_zoneId, CgnsFile::Impl::JFACE_2D_SOLUTION_ID, Integer, name, data, &F); +} int CgnsFile::SolutionWriterDivideSolutions::Sol_Write_Real(const char *name, double* data) { int F; - return cg_field_write(m_fileId, m_baseId, m_zoneId, 1, RealDouble, name, data, &F); + return cg_field_write(m_fileId, m_baseId, m_zoneId, CgnsFile::Impl::VERTEX_SOLUTION_ID, RealDouble, name, data, &F); } int CgnsFile::SolutionWriterDivideSolutions::Sol_Write_Cell_Real(const char *name, double* data) { int F; - return cg_field_write(m_fileId, m_baseId, m_zoneId, 2, RealDouble, name, data, &F); + return cg_field_write(m_fileId, m_baseId, m_zoneId, CgnsFile::Impl::CELL_SOLUTION_ID, RealDouble, name, data, &F); +} + +int CgnsFile::SolutionWriterDivideSolutions::Sol_Write_IFace_Real(const char *name, double* data) +{ + int F; + return cg_field_write(m_fileId, m_baseId, m_zoneId, CgnsFile::Impl::IFACE_2D_SOLUTION_ID, RealDouble, name, data, &F); +} + +int CgnsFile::SolutionWriterDivideSolutions::Sol_Write_JFace_Real(const char *name, double* data) +{ + int F; + return cg_field_write(m_fileId, m_baseId, m_zoneId, CgnsFile::Impl::JFACE_2D_SOLUTION_ID, RealDouble, name, data, &F); } int CgnsFile::SolutionWriterDivideSolutions::Sol_Particle_Write_Pos2d(cgsize_t count, double* x, double* y) diff --git a/private/iriclib_cgnsfile_solutionwriterdividesolutions.h b/private/iriclib_cgnsfile_solutionwriterdividesolutions.h index 4fbebc2..0c0d291 100644 --- a/private/iriclib_cgnsfile_solutionwriterdividesolutions.h +++ b/private/iriclib_cgnsfile_solutionwriterdividesolutions.h @@ -20,7 +20,10 @@ class CgnsFile::SolutionWriterDivideSolutions : public CgnsFile::SolutionWriter int Sol_Write_Real(const char *name, double* data) override; int Sol_Write_Cell_Integer(const char *name, int* data) override; int Sol_Write_Cell_Real(const char *name, double* data) override; - + int Sol_Write_IFace_Integer(const char *name, int* data) override; + int Sol_Write_IFace_Real(const char *name, double* data) override; + int Sol_Write_JFace_Integer(const char *name, int* data) override; + int Sol_Write_JFace_Real(const char *name, double* data) override; int Sol_Particle_Write_Pos2d(cgsize_t count, double* x, double* y) override; int Sol_Particle_Write_Pos3d(cgsize_t count, double* x, double* y, double* z) override; int Sol_Particle_Write_Real(const char* name, double* value) override; diff --git a/private/iriclib_cgnsfile_solutionwriterstandard.cpp b/private/iriclib_cgnsfile_solutionwriterstandard.cpp index 25e0603..a24462b 100644 --- a/private/iriclib_cgnsfile_solutionwriterstandard.cpp +++ b/private/iriclib_cgnsfile_solutionwriterstandard.cpp @@ -3,6 +3,7 @@ #include "../error_macros.h" #include +#include using namespace iRICLib; @@ -16,12 +17,16 @@ int CgnsFile::SolutionWriterStandard::Sol_Write_Time(double time) int ier = stdSolWriteTime(time, i); RETURN_IF_ERR; - return Impl::addSolutionNode(i->m_fileId, i->m_baseId, i->m_zoneId, i->m_solId, &(i->m_solPointers), &(i->m_cellSolPointers)); + return Impl::addSolutionNode(i->m_fileId, i->m_baseId, i->m_zoneId, i->m_solId, &(i->m_solPointers), &(i->m_cellSolPointers), &(i->m_ifaceSolPointers), &(i->m_jfaceSolPointers)); } int CgnsFile::SolutionWriterStandard::Sol_Write_Iteration(int index) { - return stdSolWriteIteration(index, impl()); + Impl* i = impl(); + int ier = stdSolWriteIteration(index, i); + RETURN_IF_ERR; + + return Impl::addSolutionNode(i->m_fileId, i->m_baseId, i->m_zoneId, i->m_solId, &(i->m_solPointers), &(i->m_cellSolPointers), &(i->m_ifaceSolPointers), &(i->m_jfaceSolPointers)); } int CgnsFile::SolutionWriterStandard::Sol_Write_GridCoord2d(double *x, double *y) @@ -58,6 +63,22 @@ int CgnsFile::SolutionWriterStandard::Sol_Write_Cell_Integer(const char *name, i return cg_field_write(i->m_fileId, i->m_baseId, i->m_zoneId, solId, Integer, name, data, &F); } +int CgnsFile::SolutionWriterStandard::Sol_Write_IFace_Integer(const char *name, int* data) +{ + int F; + Impl* i = impl(); + int solId = i->solIndex(IFaceCenter, i->m_solId); + return cg_field_write(i->m_fileId, i->m_baseId, i->m_zoneId, solId, Integer, name, data, &F); +} + +int CgnsFile::SolutionWriterStandard::Sol_Write_JFace_Integer(const char *name, int* data) +{ + int F; + Impl* i = impl(); + int solId = i->solIndex(JFaceCenter, i->m_solId); + return cg_field_write(i->m_fileId, i->m_baseId, i->m_zoneId, solId, Integer, name, data, &F); +} + int CgnsFile::SolutionWriterStandard::Sol_Write_Real(const char *name, double* data) { int F; @@ -74,6 +95,22 @@ int CgnsFile::SolutionWriterStandard::Sol_Write_Cell_Real(const char *name, doub return cg_field_write(i->m_fileId, i->m_baseId, i->m_zoneId, solId, RealDouble, name, data, &F); } +int CgnsFile::SolutionWriterStandard::Sol_Write_IFace_Real(const char *name, double* data) +{ + int F; + Impl* i = impl(); + int solId = i->solIndex(IFaceCenter, i->m_solId); + return cg_field_write(i->m_fileId, i->m_baseId, i->m_zoneId, solId, RealDouble, name, data, &F); +} + +int CgnsFile::SolutionWriterStandard::Sol_Write_JFace_Real(const char *name, double* data) +{ + int F; + Impl* i = impl(); + int solId = i->solIndex(JFaceCenter, i->m_solId); + return cg_field_write(i->m_fileId, i->m_baseId, i->m_zoneId, solId, RealDouble, name, data, &F); +} + int CgnsFile::SolutionWriterStandard::Sol_Particle_Write_Pos2d(cgsize_t count, double* x, double* y) { Impl* i = impl(); @@ -113,12 +150,13 @@ int CgnsFile::SolutionWriterStandard::stdSolWriteTime(double time, CgnsFile::Imp { impl->m_solTimes.push_back(time); ++ impl->m_solId; + assert(impl->m_solTimes.size() == impl->m_solId); // write to default base (with calculation condition) int ier = cg_biter_write(impl->m_fileId, impl->m_ccBaseId, Impl::BINAME.c_str(), impl->m_solId); RETURN_IF_ERR; ier = impl->gotoCCBaseIter(); - RETURN_IF_ERR + RETURN_IF_ERR; cgsize_t dimVec = impl->m_solId; ier = cg_array_write("TimeValues", RealDouble, 1, &dimVec, impl->m_solTimes.data()); RETURN_IF_ERR; @@ -127,20 +165,24 @@ int CgnsFile::SolutionWriterStandard::stdSolWriteTime(double time, CgnsFile::Imp ier = cg_biter_write(impl->m_fileId, impl->m_baseId, Impl::BINAME.c_str(), impl->m_solId); RETURN_IF_ERR; ier = impl->gotoBaseIter(); - RETURN_IF_ERR - return cg_array_write("TimeValues", RealDouble, 1, &dimVec, impl->m_solTimes.data()); + RETURN_IF_ERR; + ier = cg_array_write("TimeValues", RealDouble, 1, &dimVec, impl->m_solTimes.data()); + RETURN_IF_ERR; + + return 0; } int CgnsFile::SolutionWriterStandard::stdSolWriteIteration(int index, CgnsFile::Impl* impl) { impl->m_solIndices.push_back(index); ++ impl->m_solId; + assert(impl->m_solIndices.size() == impl->m_solId); // write to default base (with calculation condition) int ier = cg_biter_write(impl->m_fileId, impl->m_ccBaseId, Impl::BINAME.c_str(), impl->m_solId); RETURN_IF_ERR; ier = impl->gotoCCBaseIter(); - RETURN_IF_ERR + RETURN_IF_ERR; cgsize_t dimVec = impl->m_solId; ier = cg_array_write("IterationValues", Integer, 1, &dimVec, impl->m_solIndices.data()); RETURN_IF_ERR; @@ -149,12 +191,11 @@ int CgnsFile::SolutionWriterStandard::stdSolWriteIteration(int index, CgnsFile:: ier = cg_biter_write(impl->m_fileId, impl->m_baseId, Impl::BINAME.c_str(), impl->m_solId); RETURN_IF_ERR; ier = impl->gotoBaseIter(); - RETURN_IF_ERR + RETURN_IF_ERR; ier = cg_array_write("IterationValues", Integer, 1, &dimVec, impl->m_solIndices.data()); RETURN_IF_ERR; - // add solution node - return Impl::addSolutionNode(impl->m_fileId, impl->m_baseId, impl->m_zoneId, impl->m_solId, &(impl->m_solPointers), &(impl->m_cellSolPointers)); + return 0; } int CgnsFile::SolutionWriterStandard::stdSolWriteGridCoord2d(double* x, double* y, int fid, int bid, int zid, int gcid, CgnsFile::Impl* impl) diff --git a/private/iriclib_cgnsfile_solutionwriterstandard.h b/private/iriclib_cgnsfile_solutionwriterstandard.h index 2cab936..d9cf828 100644 --- a/private/iriclib_cgnsfile_solutionwriterstandard.h +++ b/private/iriclib_cgnsfile_solutionwriterstandard.h @@ -18,7 +18,10 @@ class CgnsFile::SolutionWriterStandard : public CgnsFile::SolutionWriter int Sol_Write_Real(const char* name, double* data) override; int Sol_Write_Cell_Integer(const char *name, int* data) override; int Sol_Write_Cell_Real(const char *name, double* data) override; - + int Sol_Write_IFace_Integer(const char *name, int* data) override; + int Sol_Write_IFace_Real(const char *name, double* data) override; + int Sol_Write_JFace_Integer(const char *name, int* data) override; + int Sol_Write_JFace_Real(const char *name, double* data) override; int Sol_Particle_Write_Pos2d(cgsize_t count, double* x, double* y) override; int Sol_Particle_Write_Pos3d(cgsize_t count, double* x, double* y, double* z) override; int Sol_Particle_Write_Real(const char* name, double* value) override; diff --git a/unittests_cgnsfile/case_sol_readwrite.cpp b/unittests_cgnsfile/case_sol_readwrite.cpp index d605658..09b0fc6 100644 --- a/unittests_cgnsfile/case_sol_readwrite.cpp +++ b/unittests_cgnsfile/case_sol_readwrite.cpp @@ -31,6 +31,34 @@ void writeSolution(const char* filename, int* fid, bool iterMode) std::vector ccdepth; std::vector ccwet; + // fill iface + std::vector iface_is_edge; + std::vector iface_is_edge_reals; + iface_is_edge.assign(isize*(jsize - 1), 0); + iface_is_edge_reals.assign(isize*(jsize - 1), 0.); + for (int j = 0; j < jsize - 1; ++j) { + for (int i = 0; i < isize; ++i) { + if (j == 0 || j == (jsize - 2) || i == 0 || i == (isize - 1)) { + iface_is_edge[j * isize + i] = 1; + iface_is_edge_reals[j * isize + i] = .1; + } + } + } + + // fill jface + std::vector jface_is_edge; + std::vector jface_is_edge_reals; + jface_is_edge.assign((isize - 1)*jsize, 0); + jface_is_edge_reals.assign((isize - 1)*jsize, 0.); + for (int j = 0; j < jsize; ++j) { + for (int i = 0; i < isize - 1; ++i) { + if (j == 0 || j == (jsize - 1) || i == 0 || i == (isize - 2)) { + jface_is_edge[j * (isize - 1) + i] = 2; + jface_is_edge_reals[j * (isize - 1) + i] = .2; + } + } + } + std::vector particle_x, particle_y; std::vector particle_vx, particle_vy; std::vector particle_active; @@ -66,22 +94,23 @@ void writeSolution(const char* filename, int* fid, bool iterMode) VERIFY_LOG("cg_iRIC_Write_Sol_Time_Mul() ier == 0", ier == 0); } - cg_iRIC_Write_Sol_GridCoord2d_Mul(*fid, x.data(), y.data()); + ier = cg_iRIC_Write_Sol_GridCoord2d_Mul(*fid, x.data(), y.data()); + VERIFY_LOG("cg_iRIC_Write_Sol_GridCoord2d_Mul() ier == 0", ier == 0); // Vertex solutions depth.assign(isize * jsize, (double)i); - cg_iRIC_Write_Sol_Real_Mul(*fid, "Depth", depth.data()); + ier = cg_iRIC_Write_Sol_Real_Mul(*fid, "Depth", depth.data()); VERIFY_LOG("cg_iRIC_Write_Sol_Real_Mul() for Depth ier == 0", ier == 0); - cg_iRIC_Write_Sol_Real_Mul(*fid, "VelocityX", vx.data()); + ier = cg_iRIC_Write_Sol_Real_Mul(*fid, "VelocityX", vx.data()); VERIFY_LOG("cg_iRIC_Write_Sol_Real_Mul() for VelocityX ier == 0", ier == 0); - cg_iRIC_Write_Sol_Real_Mul(*fid, "VelocityY", vy.data()); + ier = cg_iRIC_Write_Sol_Real_Mul(*fid, "VelocityY", vy.data()); VERIFY_LOG("cg_iRIC_Write_Sol_Real_Mul() for VelocityY ier == 0", ier == 0); wet.assign(isize * jsize, i); - cg_iRIC_Write_Sol_Integer_Mul(*fid, "IBC", wet.data()); + ier = cg_iRIC_Write_Sol_Integer_Mul(*fid, "IBC", wet.data()); VERIFY_LOG("cg_iRIC_Write_Sol_Integer_Mul() for IBC ier == 0", ier == 0); // CellCenter solutions @@ -94,13 +123,29 @@ void writeSolution(const char* filename, int* fid, bool iterMode) ier = cg_iRIC_Write_Sol_Cell_Integer("CCWet", ccwet.data()); VERIFY_LOG("cg_iRIC_Write_Sol_Cell_Integer() ier == 0", ier == 0); + // IFaceCenter solutions + + ier = cg_iRIC_Write_Sol_IFace_Integer_Mul(*fid, "IFaceIsEdge", iface_is_edge.data()); + VERIFY_LOG("cg_iRIC_Write_Sol_IFace_Integer() ier == 0", ier == 0); + + ier = cg_iRIC_Write_Sol_IFace_Real_Mul(*fid, "IFaceIsEdgeReals", iface_is_edge_reals.data()); + VERIFY_LOG("cg_iRIC_Write_Sol_IFace_Real() ier == 0", ier == 0); + + // JFaceCenter solutions + + ier = cg_iRIC_Write_Sol_JFace_Integer_Mul(*fid, "JFaceIsEdge", jface_is_edge.data()); + VERIFY_LOG("cg_iRIC_Write_Sol_JFace_Integer() ier == 0", ier == 0); + + ier = cg_iRIC_Write_Sol_JFace_Real_Mul(*fid, "JFaceIsEdgeReals", jface_is_edge_reals.data()); + VERIFY_LOG("cg_iRIC_Write_Sol_JFace_Real() ier == 0", ier == 0); + // BaseIterativeData double Dist = i * - 0.2 + 20; - cg_iRIC_Write_Sol_BaseIterative_Real_Mul(*fid, "Discharge", Dist); + ier = cg_iRIC_Write_Sol_BaseIterative_Real_Mul(*fid, "Discharge", Dist); VERIFY_LOG("cg_iRIC_Write_Sol_BaseIterative_Real_Mul() for Discharge ier == 0", ier == 0); int DamOpen = i; - cg_iRIC_Write_Sol_BaseIterative_Integer_Mul(*fid, "DamOpen", DamOpen); + ier = cg_iRIC_Write_Sol_BaseIterative_Integer_Mul(*fid, "DamOpen", DamOpen); VERIFY_LOG("cg_iRIC_Write_Sol_BaseIterative_Integer_Mul() for DamOpen ier == 0", ier == 0); // Particle solutions @@ -226,6 +271,10 @@ void readSolution(int fid) std::vector int_sol; std::vector real_ccsol; std::vector int_ccsol; + std::vector iface_is_edge; + std::vector iface_is_edge_reals; + std::vector jface_is_edge; + std::vector jface_is_edge_reals; ier = cg_iRIC_GotoGridCoord2d_Mul(fid, &isize, &jsize); VERIFY_LOG("cg_iRIC_GotoGridCoord2d_Mul() ier == 0", ier == 0); @@ -236,6 +285,10 @@ void readSolution(int fid) int_sol.assign(isize * jsize, 0); real_ccsol.assign((isize - 1) * (jsize - 1), 0); int_ccsol.assign((isize - 1) * (jsize - 1), 0); + iface_is_edge.assign(isize * (jsize - 1), 0); + iface_is_edge_reals.assign(isize * (jsize - 1), 0); + jface_is_edge.assign((isize - 1) * jsize, 0); + jface_is_edge_reals.assign((isize - 1) * jsize, 0); for (int S = 1; S <= sol_count; ++S) { @@ -276,6 +329,46 @@ void readSolution(int fid) sprintf(buffer, "cg_iRIC_Read_Sol_Cell_Integer_Mul() int_ccsol[%lu] == %d", int_ccsol.size() - 1, S); VERIFY_LOG(buffer, int_ccsol[int_ccsol.size() - 1] == S); + // IFaceCenter solutions + + ier = cg_iRIC_Read_Sol_IFace_Integer_Mul(fid, S, "IFaceIsEdge", iface_is_edge.data()); + VERIFY_LOG("cg_iRIC_Read_Sol_IFace_Integer() ier == 0", ier == 0); + + ier = cg_iRIC_Read_Sol_IFace_Real_Mul(fid, S, "IFaceIsEdgeReals", iface_is_edge_reals.data()); + VERIFY_LOG("cg_iRIC_Read_Sol_IFace_Real() ier == 0", ier == 0); + + // verify iface + for (int j = 0; j < jsize - 1; ++j) { + for (int i = 0; i < isize; ++i) { + if (j == 0 || j == (jsize - 2) || i == 0 || i == (isize - 1)) { + sprintf(buffer, "cg_iRIC_Read_Sol_IFace_Integer_Mul() iface_is_edge[%d] == %d", j * isize + i, 1); + VERIFY_LOG(buffer, iface_is_edge[j * isize + i] == 1); + sprintf(buffer, "cg_iRIC_Read_Sol_IFace_Integer_Mul() iface_is_edge[%d] == %g", j * isize + i, .1); + VERIFY_LOG(buffer, iface_is_edge_reals[j * isize + i] == .1); + } + } + } + + // JFaceCenter solutions + + ier = cg_iRIC_Read_Sol_JFace_Integer_Mul(fid, S, "JFaceIsEdge", jface_is_edge.data()); + VERIFY_LOG("cg_iRIC_Read_Sol_JFace_Integer() ier == 0", ier == 0); + + ier = cg_iRIC_Read_Sol_JFace_Real_Mul(fid, S, "JFaceIsEdgeReals", jface_is_edge_reals.data()); + VERIFY_LOG("cg_iRIC_Read_Sol_JFace_Real() ier == 0", ier == 0); + + // verify jface + for (int j = 0; j < jsize; ++j) { + for (int i = 0; i < isize - 1; ++i) { + if (j == 0 || j == (jsize - 1) || i == 0 || i == (isize - 2)) { + sprintf(buffer, "cg_iRIC_Read_Sol_JFace_Integer_Mul() jface_is_edge[%d] == %d", j * (isize - 1) + i, 2); + VERIFY_LOG(buffer, jface_is_edge[j * (isize - 1) + i] == 2); + sprintf(buffer, "cg_iRIC_Read_Sol_IFace_Integer_Mul() jface_is_edge_reals[%d] == %g", j * (isize - 1) + i, .2); + VERIFY_LOG(buffer, jface_is_edge_reals[j * (isize - 1) + i] == .2); + } + } + } + // BaseIterativeData double d; @@ -310,6 +403,13 @@ void case_SolWriteStd(const std::string& origCgnsName) iRIC_InitOption(IRIC_OPTION_STDSOLUTION); bool hdf = is_hdf(origCgnsName); + + remove("case_solstd.cgn"); + + // + // Test Writing Standard (IRIC_OPTION_STDSOLUTION) with times + // + fs::copy(origCgnsName, "case_solstd.cgn"); int fid; @@ -327,7 +427,11 @@ void case_SolWriteStd(const std::string& origCgnsName) ier = cg_close(fid); VERIFY_LOG("cg_close() ier == 0", ier == 0); - ier = cg_open("case_solstd.cgn", CG_MODE_MODIFY, &fid); + // + // Test Reading Standard (IRIC_OPTION_STDSOLUTION) with times + // + + ier = cg_open("case_solstd.cgn", CG_MODE_READ, &fid); VERIFY_LOG("cg_open() ier == 0", ier == 0); VERIFY_LOG("cg_open() fid != 0", fid != 0); @@ -343,7 +447,9 @@ void case_SolWriteStd(const std::string& origCgnsName) VERIFY_REMOVE("case_solstd.cgn", hdf); - // @todo add codes to test + // + // Test Writing 3D Standard (IRIC_OPTION_STDSOLUTION) with times + // fs::copy(origCgnsName, "case_solstd3d.cgn"); @@ -365,6 +471,10 @@ void case_SolWriteStd(const std::string& origCgnsName) // @todo add codes to test + // + // Test Writing Standard (IRIC_OPTION_STDSOLUTION) with iterations + // + fs::copy(origCgnsName, "case_solstditer.cgn"); ier = cg_open("case_solstditer.cgn", CG_MODE_MODIFY, &fid); @@ -381,6 +491,23 @@ void case_SolWriteStd(const std::string& origCgnsName) ier = cg_close(fid); VERIFY_LOG("cg_close() ier == 0", ier == 0); + // + // Test Reading Standard (IRIC_OPTION_STDSOLUTION) with iterations + // + + ier = cg_open("case_solstditer.cgn", CG_MODE_READ, &fid); + VERIFY_LOG("cg_open() ier == 0", ier == 0); + VERIFY_LOG("cg_open() fid != 0", fid != 0); + + ier = cg_iRIC_InitRead(fid); + VERIFY_LOG("cg_iRIC_InitRead() ier == 0", ier == 0); + + cg_iRIC_SetFilename(fid, "case_solstditer.cgn"); + + readSolution(fid); + ier = cg_close(fid); + VERIFY_LOG("cg_close() ier == 0", ier == 0); + VERIFY_REMOVE("case_solstditer.cgn", hdf); // @todo add codes to test @@ -390,6 +517,8 @@ void case_SolWriteDivide(const std::string& origCgnsName) { iRIC_InitOption(IRIC_OPTION_DIVIDESOLUTIONS); + bool hdf = is_hdf(origCgnsName); + remove("case_soldivide.cgn"); remove("case_soldivide_Solution1.cgn"); remove("case_soldivide_Solution2.cgn"); @@ -397,7 +526,10 @@ void case_SolWriteDivide(const std::string& origCgnsName) remove("case_soldivide_Solution4.cgn"); remove("case_soldivide_Solution5.cgn"); - bool hdf = is_hdf(origCgnsName); + // + // Test Writing Divided Solutions (IRIC_OPTION_DIVIDESOLUTIONS) with times + // + fs::copy(origCgnsName, "case_soldivide.cgn"); int fid; @@ -415,7 +547,11 @@ void case_SolWriteDivide(const std::string& origCgnsName) ier = cg_close(fid); VERIFY_LOG("cg_close() ier == 0", ier == 0); - ier = cg_open("case_soldivide.cgn", CG_MODE_MODIFY, &fid); + // + // Test Reading Divided Solutions (IRIC_OPTION_DIVIDESOLUTIONS) with times + // + + ier = cg_open("case_soldivide.cgn", CG_MODE_READ, &fid); VERIFY_LOG("cg_open() ier == 0", ier == 0); VERIFY_LOG("cg_open() fid != 0", fid != 0); @@ -444,6 +580,10 @@ void case_SolWriteDivide(const std::string& origCgnsName) VERIFY_REMOVE("case_soldivide_Solution4.cgn", hdf); VERIFY_REMOVE("case_soldivide_Solution5.cgn", hdf); + // + // Test Writing 3D Divided Solutions (IRIC_OPTION_DIVIDESOLUTIONS) with times + // + remove("case_soldivide3d.cgn"); remove("case_soldivide3d_Solution1.cgn"); remove("case_soldivide3d_Solution2.cgn"); @@ -486,6 +626,65 @@ void case_SolWriteDivide(const std::string& origCgnsName) // @todo add codes to test + // + // Test Writing Divided Solutions (IRIC_OPTION_DIVIDESOLUTIONS) with iterations + // + + remove("case_soldivideiter.cgn"); + remove("case_soldivideiter_Solution1.cgn"); + remove("case_soldivideiter_Solution2.cgn"); + remove("case_soldivideiter_Solution3.cgn"); + remove("case_soldivideiter_Solution4.cgn"); + remove("case_soldivideiter_Solution5.cgn"); + + fs::copy(origCgnsName, "case_soldivideiter.cgn"); + + ier = cg_open("case_soldivideiter.cgn", CG_MODE_MODIFY, &fid); + VERIFY_LOG("cg_open() ier == 0", ier == 0); + VERIFY_LOG("cg_open() fid != 0", fid != 0); + + ier = cg_iRIC_Init(fid); + cg_iRIC_SetFilename(fid, "case_soldivideiter.cgn"); + + VERIFY_LOG("cg_iRIC_Init() ier == 0", ier == 0); + + writeSolution("case_soldivideiter.cgn", &fid, true); + + ier = cg_close(fid); + VERIFY_LOG("cg_close() ier == 0", ier == 0); + + // + // Test Reading Divided Solutions (IRIC_OPTION_DIVIDESOLUTIONS) with iterations + // + + ier = cg_open("case_soldivideiter.cgn", CG_MODE_READ, &fid); + VERIFY_LOG("cg_open() ier == 0", ier == 0); + VERIFY_LOG("cg_open() fid != 0", fid != 0); + + ier = cg_iRIC_InitRead(fid); + VERIFY_LOG("cg_iRIC_InitRead() ier == 0", ier == 0); + + cg_iRIC_SetFilename(fid, "case_soldivideiter.cgn"); + + readSolution(fid); + ier = cg_close(fid); + VERIFY_LOG("cg_close() ier == 0", ier == 0); + +#ifdef _MSC_VER + if (hdf) { + // this seems necessary when IRIC_OPTION_DIVIDESOLUTIONS is set on windows + herr_t err = H5close(); + VERIFY_LOG("H5close() ier == 0", err >= 0); + } +#endif + + VERIFY_REMOVE("case_soldivideiter.cgn", hdf); + VERIFY_REMOVE("case_soldivideiter_Solution1.cgn", hdf); + VERIFY_REMOVE("case_soldivideiter_Solution2.cgn", hdf); + VERIFY_REMOVE("case_soldivideiter_Solution3.cgn", hdf); + VERIFY_REMOVE("case_soldivideiter_Solution4.cgn", hdf); + VERIFY_REMOVE("case_soldivideiter_Solution5.cgn", hdf); + // restore mode. iRIC_InitOption(IRIC_OPTION_STDSOLUTION); } From 31e2df5206085fab339d6e4f0d1d7bb776b0eae9 Mon Sep 17 00:00:00 2001 From: Scott Charlton Date: Mon, 28 Oct 2019 11:25:17 -0600 Subject: [PATCH 2/2] updated for fortran --- iric_ftoc.c | 160 ++++++++++++++++++++++++++++++++++++++++++++--- iriclib.h | 12 +++- iriclib_single.c | 28 +++++++-- 3 files changed, 186 insertions(+), 14 deletions(-) diff --git a/iric_ftoc.c b/iric_ftoc.c index 651412d..182d8ca 100644 --- a/iric_ftoc.c +++ b/iric_ftoc.c @@ -791,22 +791,40 @@ void IRICLIBDLL FMNAME(cg_iric_read_sol_integer_mul_f, CG_IRIC_READ_SOL_INTEGER_ *ier = cg_iRIC_Read_Sol_Integer_Mul(*fid, *step, c_name, data); } -void IRICLIBDLL FMNAME(cg_iric_read_sol_real_mul_f, CG_IRIC_READ_SOL_REAL_MUL_F) (int *fid, int *step, STR_PSTR(name), double *data, int *ier STR_PLEN(name)) { +void IRICLIBDLL FMNAME(cg_iric_read_sol_cell_integer_mul_f, CG_IRIC_READ_SOL_CELL_INTEGER_MUL_F) (int *fid, int *step, STR_PSTR(name), int *data, int *ier STR_PLEN(name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; string_2_C_string(STR_PTR(name), STR_LEN(name), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; - *ier = cg_iRIC_Read_Sol_Real_Mul(*fid, *step, c_name, data); + *ier = cg_iRIC_Read_Sol_Cell_Integer_Mul(*fid, *step, c_name, data); } -void IRICLIBDLL FMNAME(cg_iric_read_sol_cell_integer_mul_f, CG_IRIC_READ_SOL_CELL_INTEGER_MUL_F) (int *fid, int *step, STR_PSTR(name), int *data, int *ier STR_PLEN(name)) { +void IRICLIBDLL FMNAME(cg_iric_read_sol_iface_integer_mul_f, CG_IRIC_READ_SOL_IFACE_INTEGER_MUL_F) (int *fid, int *step, STR_PSTR(name), int *data, int *ier STR_PLEN(name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; string_2_C_string(STR_PTR(name), STR_LEN(name), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; - *ier = cg_iRIC_Read_Sol_Cell_Integer_Mul(*fid, *step, c_name, data); + *ier = cg_iRIC_Read_Sol_IFace_Integer_Mul(*fid, *step, c_name, data); +} + +void IRICLIBDLL FMNAME(cg_iric_read_sol_jface_integer_mul_f, CG_IRIC_READ_SOL_JFACE_INTEGER_MUL_F) (int *fid, int *step, STR_PSTR(name), int *data, int *ier STR_PLEN(name)) { + char c_name[CGIO_MAX_NAME_LENGTH+1]; + string_2_C_string(STR_PTR(name), STR_LEN(name), + c_name, CGIO_MAX_NAME_LENGTH, ier); + if (*ier) return; + + *ier = cg_iRIC_Read_Sol_JFace_Integer_Mul(*fid, *step, c_name, data); +} + +void IRICLIBDLL FMNAME(cg_iric_read_sol_real_mul_f, CG_IRIC_READ_SOL_REAL_MUL_F) (int *fid, int *step, STR_PSTR(name), double *data, int *ier STR_PLEN(name)) { + char c_name[CGIO_MAX_NAME_LENGTH+1]; + string_2_C_string(STR_PTR(name), STR_LEN(name), + c_name, CGIO_MAX_NAME_LENGTH, ier); + if (*ier) return; + + *ier = cg_iRIC_Read_Sol_Real_Mul(*fid, *step, c_name, data); } void IRICLIBDLL FMNAME(cg_iric_read_sol_cell_real_mul_f, CG_IRIC_READ_SOL_CELL_REAL_MUL_F) (int *fid, int *step, STR_PSTR(name), double *data, int *ier STR_PLEN(name)) { @@ -818,6 +836,24 @@ void IRICLIBDLL FMNAME(cg_iric_read_sol_cell_real_mul_f, CG_IRIC_READ_SOL_CELL_R *ier = cg_iRIC_Read_Sol_Cell_Real_Mul(*fid, *step, c_name, data); } +void IRICLIBDLL FMNAME(cg_iric_read_sol_iface_real_mul_f, CG_IRIC_READ_SOL_IFACE_REAL_MUL_F) (int *fid, int *step, STR_PSTR(name), double *data, int *ier STR_PLEN(name)) { + char c_name[CGIO_MAX_NAME_LENGTH+1]; + string_2_C_string(STR_PTR(name), STR_LEN(name), + c_name, CGIO_MAX_NAME_LENGTH, ier); + if (*ier) return; + + *ier = cg_iRIC_Read_Sol_IFace_Real_Mul(*fid, *step, c_name, data); +} + +void IRICLIBDLL FMNAME(cg_iric_read_sol_jface_real_mul_f, CG_IRIC_READ_SOL_JFACE_REAL_MUL_F) (int *fid, int *step, STR_PSTR(name), double *data, int *ier STR_PLEN(name)) { + char c_name[CGIO_MAX_NAME_LENGTH+1]; + string_2_C_string(STR_PTR(name), STR_LEN(name), + c_name, CGIO_MAX_NAME_LENGTH, ier); + if (*ier) return; + + *ier = cg_iRIC_Read_Sol_JFace_Real_Mul(*fid, *step, c_name, data); +} + void IRICLIBDLL FMNAME(cg_iric_write_sol_time_mul_f, CG_IRIC_WRITE_SOL_TIME_MUL_F) (int *fid, double *time, int *ier) { *ier = cg_iRIC_Write_Sol_Time_Mul(*fid, *time); } @@ -870,6 +906,24 @@ void IRICLIBDLL FMNAME(cg_iric_write_sol_cell_integer_mul_f, CG_IRIC_WRITE_SOL_C *ier = cg_iRIC_Write_Sol_Cell_Integer_Mul(*fid, c_name, data); } +void IRICLIBDLL FMNAME(cg_iric_write_sol_iface_integer_mul_f, CG_IRIC_WRITE_SOL_IFACE_INTEGER_MUL_F) (int *fid, STR_PSTR(name), int *data, int *ier STR_PLEN(name)) { + char c_name[CGIO_MAX_NAME_LENGTH+1]; + string_2_C_string(STR_PTR(name), STR_LEN(name), + c_name, CGIO_MAX_NAME_LENGTH, ier); + if (*ier) return; + + *ier = cg_iRIC_Write_Sol_IFace_Integer_Mul(*fid, c_name, data); +} + +void IRICLIBDLL FMNAME(cg_iric_write_sol_jface_integer_mul_f, CG_IRIC_WRITE_SOL_JFACE_INTEGER_MUL_F) (int *fid, STR_PSTR(name), int *data, int *ier STR_PLEN(name)) { + char c_name[CGIO_MAX_NAME_LENGTH+1]; + string_2_C_string(STR_PTR(name), STR_LEN(name), + c_name, CGIO_MAX_NAME_LENGTH, ier); + if (*ier) return; + + *ier = cg_iRIC_Write_Sol_JFace_Integer_Mul(*fid, c_name, data); +} + void IRICLIBDLL FMNAME(cg_iric_write_sol_real_mul_f, CG_IRIC_WRITE_SOL_REAL_MUL_F) (int *fid, STR_PSTR(name), double *data, int *ier STR_PLEN(name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; string_2_C_string(STR_PTR(name), STR_LEN(name), @@ -888,6 +942,24 @@ void IRICLIBDLL FMNAME(cg_iric_write_sol_cell_real_mul_f, CG_IRIC_WRITE_SOL_CELL *ier = cg_iRIC_Write_Sol_Cell_Real_Mul(*fid, c_name, data); } +void IRICLIBDLL FMNAME(cg_iric_write_sol_iface_real_mul_f, CG_IRIC_WRITE_SOL_IFACE_REAL_MUL_F) (int *fid, STR_PSTR(name), double *data, int *ier STR_PLEN(name)) { + char c_name[CGIO_MAX_NAME_LENGTH+1]; + string_2_C_string(STR_PTR(name), STR_LEN(name), + c_name, CGIO_MAX_NAME_LENGTH, ier); + if (*ier) return; + + *ier = cg_iRIC_Write_Sol_IFace_Real_Mul(*fid, c_name, data); +} + +void IRICLIBDLL FMNAME(cg_iric_write_sol_jface_real_mul_f, CG_IRIC_WRITE_SOL_JFACE_REAL_MUL_F) (int *fid, STR_PSTR(name), double *data, int *ier STR_PLEN(name)) { + char c_name[CGIO_MAX_NAME_LENGTH+1]; + string_2_C_string(STR_PTR(name), STR_LEN(name), + c_name, CGIO_MAX_NAME_LENGTH, ier); + if (*ier) return; + + *ier = cg_iRIC_Write_Sol_JFace_Real_Mul(*fid, c_name, data); +} + void IRICLIBDLL FMNAME(cg_iric_write_errorcode_mul_f, CG_IRIC_WRITE_ERRORCODE_MUL_F) (int *fid, int *errorcode, int *ier) { *ier = cg_iRIC_Write_ErrorCode_Mul(*fid, *errorcode); } @@ -1979,22 +2051,40 @@ void IRICLIBDLL FMNAME(cg_iric_read_sol_integer_f, CG_IRIC_READ_SOL_INTEGER_F) ( *ier = cg_iRIC_Read_Sol_Integer(*step, c_name, data); } -void IRICLIBDLL FMNAME(cg_iric_read_sol_real_f, CG_IRIC_READ_SOL_REAL_F) (int *step, STR_PSTR(name), double *data, int *ier STR_PLEN(name)) { +void IRICLIBDLL FMNAME(cg_iric_read_sol_cell_integer_f, CG_IRIC_READ_SOL_CELL_INTEGER_F) (int *step, STR_PSTR(name), int *data, int *ier STR_PLEN(name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; string_2_C_string(STR_PTR(name), STR_LEN(name), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; - *ier = cg_iRIC_Read_Sol_Real(*step, c_name, data); + *ier = cg_iRIC_Read_Sol_Cell_Integer(*step, c_name, data); } -void IRICLIBDLL FMNAME(cg_iric_read_sol_cell_integer_f, CG_IRIC_READ_SOL_CELL_INTEGER_F) (int *step, STR_PSTR(name), int *data, int *ier STR_PLEN(name)) { +void IRICLIBDLL FMNAME(cg_iric_read_sol_iface_integer_f, CG_IRIC_READ_SOL_IFACE_INTEGER_F) (int *step, STR_PSTR(name), int *data, int *ier STR_PLEN(name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; string_2_C_string(STR_PTR(name), STR_LEN(name), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; - *ier = cg_iRIC_Read_Sol_Cell_Integer(*step, c_name, data); + *ier = cg_iRIC_Read_Sol_IFace_Integer(*step, c_name, data); +} + +void IRICLIBDLL FMNAME(cg_iric_read_sol_jface_integer_f, CG_IRIC_READ_SOL_JFACE_INTEGER_F) (int *step, STR_PSTR(name), int *data, int *ier STR_PLEN(name)) { + char c_name[CGIO_MAX_NAME_LENGTH+1]; + string_2_C_string(STR_PTR(name), STR_LEN(name), + c_name, CGIO_MAX_NAME_LENGTH, ier); + if (*ier) return; + + *ier = cg_iRIC_Read_Sol_JFace_Integer(*step, c_name, data); +} + +void IRICLIBDLL FMNAME(cg_iric_read_sol_real_f, CG_IRIC_READ_SOL_REAL_F) (int *step, STR_PSTR(name), double *data, int *ier STR_PLEN(name)) { + char c_name[CGIO_MAX_NAME_LENGTH+1]; + string_2_C_string(STR_PTR(name), STR_LEN(name), + c_name, CGIO_MAX_NAME_LENGTH, ier); + if (*ier) return; + + *ier = cg_iRIC_Read_Sol_Real(*step, c_name, data); } void IRICLIBDLL FMNAME(cg_iric_read_sol_cell_real_f, CG_IRIC_READ_SOL_CELL_REAL_F) (int *step, STR_PSTR(name), double *data, int *ier STR_PLEN(name)) { @@ -2006,6 +2096,24 @@ void IRICLIBDLL FMNAME(cg_iric_read_sol_cell_real_f, CG_IRIC_READ_SOL_CELL_REAL_ *ier = cg_iRIC_Read_Sol_Cell_Real(*step, c_name, data); } +void IRICLIBDLL FMNAME(cg_iric_read_sol_iface_real_f, CG_IRIC_READ_SOL_IFACE_REAL_F) (int *step, STR_PSTR(name), double *data, int *ier STR_PLEN(name)) { + char c_name[CGIO_MAX_NAME_LENGTH+1]; + string_2_C_string(STR_PTR(name), STR_LEN(name), + c_name, CGIO_MAX_NAME_LENGTH, ier); + if (*ier) return; + + *ier = cg_iRIC_Read_Sol_IFace_Real(*step, c_name, data); +} + +void IRICLIBDLL FMNAME(cg_iric_read_sol_jface_real_f, CG_IRIC_READ_SOL_JFACE_REAL_F) (int *step, STR_PSTR(name), double *data, int *ier STR_PLEN(name)) { + char c_name[CGIO_MAX_NAME_LENGTH+1]; + string_2_C_string(STR_PTR(name), STR_LEN(name), + c_name, CGIO_MAX_NAME_LENGTH, ier); + if (*ier) return; + + *ier = cg_iRIC_Read_Sol_JFace_Real(*step, c_name, data); +} + void IRICLIBDLL FMNAME(cg_iric_write_sol_time_f, CG_IRIC_WRITE_SOL_TIME_F) (double *time, int *ier) { *ier = cg_iRIC_Write_Sol_Time(*time); } @@ -2058,6 +2166,24 @@ void IRICLIBDLL FMNAME(cg_iric_write_sol_cell_integer_f, CG_IRIC_WRITE_SOL_CELL_ *ier = cg_iRIC_Write_Sol_Cell_Integer(c_name, data); } +void IRICLIBDLL FMNAME(cg_iric_write_sol_iface_integer_f, CG_IRIC_WRITE_SOL_IFACE_INTEGER_F) (STR_PSTR(name), int *data, int *ier STR_PLEN(name)) { + char c_name[CGIO_MAX_NAME_LENGTH+1]; + string_2_C_string(STR_PTR(name), STR_LEN(name), + c_name, CGIO_MAX_NAME_LENGTH, ier); + if (*ier) return; + + *ier = cg_iRIC_Write_Sol_IFace_Integer(c_name, data); +} + +void IRICLIBDLL FMNAME(cg_iric_write_sol_jface_integer_f, CG_IRIC_WRITE_SOL_JFACE_INTEGER_F) (STR_PSTR(name), int *data, int *ier STR_PLEN(name)) { + char c_name[CGIO_MAX_NAME_LENGTH+1]; + string_2_C_string(STR_PTR(name), STR_LEN(name), + c_name, CGIO_MAX_NAME_LENGTH, ier); + if (*ier) return; + + *ier = cg_iRIC_Write_Sol_JFace_Integer(c_name, data); +} + void IRICLIBDLL FMNAME(cg_iric_write_sol_real_f, CG_IRIC_WRITE_SOL_REAL_F) (STR_PSTR(name), double *data, int *ier STR_PLEN(name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; string_2_C_string(STR_PTR(name), STR_LEN(name), @@ -2076,6 +2202,24 @@ void IRICLIBDLL FMNAME(cg_iric_write_sol_cell_real_f, CG_IRIC_WRITE_SOL_CELL_REA *ier = cg_iRIC_Write_Sol_Cell_Real(c_name, data); } +void IRICLIBDLL FMNAME(cg_iric_write_sol_iface_real_f, CG_IRIC_WRITE_SOL_IFACE_REAL_F) (STR_PSTR(name), double *data, int *ier STR_PLEN(name)) { + char c_name[CGIO_MAX_NAME_LENGTH+1]; + string_2_C_string(STR_PTR(name), STR_LEN(name), + c_name, CGIO_MAX_NAME_LENGTH, ier); + if (*ier) return; + + *ier = cg_iRIC_Write_Sol_IFace_Real(c_name, data); +} + +void IRICLIBDLL FMNAME(cg_iric_write_sol_jface_real_f, CG_IRIC_WRITE_SOL_JFACE_REAL_F) (STR_PSTR(name), double *data, int *ier STR_PLEN(name)) { + char c_name[CGIO_MAX_NAME_LENGTH+1]; + string_2_C_string(STR_PTR(name), STR_LEN(name), + c_name, CGIO_MAX_NAME_LENGTH, ier); + if (*ier) return; + + *ier = cg_iRIC_Write_Sol_JFace_Real(c_name, data); +} + void IRICLIBDLL FMNAME(cg_iric_write_errorcode_f, CG_IRIC_WRITE_ERRORCODE_F) (int *errorcode, int *ier) { *ier = cg_iRIC_Write_ErrorCode(*errorcode); } diff --git a/iriclib.h b/iriclib.h index 5da43ce..025d175 100644 --- a/iriclib.h +++ b/iriclib.h @@ -580,12 +580,20 @@ int IRICLIBDLL cg_iRIC_Read_Sol_GridCoord3d(int step, double* x, double* y, doub int IRICLIBDLL cg_iRIC_Read_Sol_Integer(int step, const char *name, int* data); -int IRICLIBDLL cg_iRIC_Read_Sol_Real(int step, const char *name, double* data); - int IRICLIBDLL cg_iRIC_Read_Sol_Cell_Integer(int step, const char *name, int* data); +int IRICLIBDLL cg_iRIC_Read_Sol_IFace_Integer(int step, const char *name, int* data); + +int IRICLIBDLL cg_iRIC_Read_Sol_JFace_Integer(int step, const char *name, int* data); + +int IRICLIBDLL cg_iRIC_Read_Sol_Real(int step, const char *name, double* data); + int IRICLIBDLL cg_iRIC_Read_Sol_Cell_Real(int step, const char *name, double* data); +int IRICLIBDLL cg_iRIC_Read_Sol_IFace_Real(int step, const char *name, double* data); + +int IRICLIBDLL cg_iRIC_Read_Sol_JFace_Real(int step, const char *name, double* data); + int IRICLIBDLL cg_iRIC_Write_Sol_Time(double time); int IRICLIBDLL cg_iRIC_Write_Sol_Iteration(int index); diff --git a/iriclib_single.c b/iriclib_single.c index e1521c2..88b3e56 100644 --- a/iriclib_single.c +++ b/iriclib_single.c @@ -387,14 +387,24 @@ int cg_iRIC_Read_Sol_Integer(int step, const char* name, int* data) return cg_iRIC_Read_Sol_Integer_Mul(lastfileid, step, name, data); } -int cg_iRIC_Read_Sol_Real(int step, const char* name, double* data) +int cg_iRIC_Read_Sol_Cell_Integer(int step, const char* name, int* data) { - return cg_iRIC_Read_Sol_Real_Mul(lastfileid, step, name, data); + return cg_iRIC_Read_Sol_Cell_Integer_Mul(lastfileid, step, name, data); } -int cg_iRIC_Read_Sol_Cell_Integer(int step, const char* name, int* data) +int cg_iRIC_Read_Sol_IFace_Integer(int step, const char* name, int* data) { - return cg_iRIC_Read_Sol_Cell_Integer_Mul(lastfileid, step, name, data); + return cg_iRIC_Read_Sol_IFace_Integer_Mul(lastfileid, step, name, data); +} + +int cg_iRIC_Read_Sol_JFace_Integer(int step, const char* name, int* data) +{ + return cg_iRIC_Read_Sol_JFace_Integer_Mul(lastfileid, step, name, data); +} + +int cg_iRIC_Read_Sol_Real(int step, const char* name, double* data) +{ + return cg_iRIC_Read_Sol_Real_Mul(lastfileid, step, name, data); } int cg_iRIC_Read_Sol_Cell_Real(int step, const char* name, double* data) @@ -402,6 +412,16 @@ int cg_iRIC_Read_Sol_Cell_Real(int step, const char* name, double* data) return cg_iRIC_Read_Sol_Cell_Real_Mul(lastfileid, step, name, data); } +int cg_iRIC_Read_Sol_IFace_Real(int step, const char* name, double* data) +{ + return cg_iRIC_Read_Sol_IFace_Real_Mul(lastfileid, step, name, data); +} + +int cg_iRIC_Read_Sol_JFace_Real(int step, const char* name, double* data) +{ + return cg_iRIC_Read_Sol_JFace_Real_Mul(lastfileid, step, name, data); +} + int cg_iRIC_Write_Sol_Time(double time) { return cg_iRIC_Write_Sol_Time_Mul(lastfileid, time);