Skip to content

Commit

Permalink
Merge pull request i-RIC#57 from kskinoue0612/issue-56
Browse files Browse the repository at this point in the history
Closes i-RIC#56
  • Loading branch information
scharlton2 authored Mar 22, 2019
2 parents a6a110f + fbefd63 commit 7cc7034
Show file tree
Hide file tree
Showing 15 changed files with 399 additions and 2 deletions.
78 changes: 78 additions & 0 deletions iric_ftoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,45 @@ void IRICLIBDLL FMNAME(cg_iric_write_sol_particle_integer_mul_f, CG_IRIC_WRITE_S
*ier = cg_iRIC_Write_Sol_Particle_Integer_Mul(*fid, c_name, value);
}

void IRICLIBDLL FMNAME(cg_iric_write_sol_polydata_groupbegin_mul_f, CG_IRIC_WRITE_SOL_POLYDATA_GROUPBEGIN_MUL_F) (int *fid, STR_PSTR(name), 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_PolyData_GroupBegin_Mul(*fid, c_name);
}

void IRICLIBDLL FMNAME(cg_iric_write_sol_polydata_groupend_mul_f, CG_IRIC_WRITE_SOL_POLYDATA_GROUPEND_MUL_F) (int *fid, int *ier) {
*ier = cg_iRIC_Write_Sol_PolyData_GroupEnd_Mul(*fid);
}

void IRICLIBDLL FMNAME(cg_iric_write_sol_polydata_polygon_mul_f, CG_IRIC_WRITE_SOL_POLYDATA_POLYGON_MUL_F) (int *fid, int *numPoints, double *x, double *y, int *ier) {
*ier = cg_iRIC_Write_Sol_PolyData_Polygon_Mul(*fid, *numPoints, x, y);
}

void IRICLIBDLL FMNAME(cg_iric_write_sol_polydata_polyline_mul_f, CG_IRIC_WRITE_SOL_POLYDATA_POLYLINE_MUL_F) (int *fid, int *numPoints, double *x, double *y, int *ier) {
*ier = cg_iRIC_Write_Sol_PolyData_Polyline_Mul(*fid, *numPoints, x, y);
}

void IRICLIBDLL FMNAME(cg_iric_write_sol_polydata_integer_mul_f, CG_IRIC_WRITE_SOL_POLYDATA_INTEGER_MUL_F) (int *fid, STR_PSTR(name), int *value, 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_PolyData_Integer_Mul(*fid, c_name, *value);
}

void IRICLIBDLL FMNAME(cg_iric_write_sol_polydata_real_mul_f, CG_IRIC_WRITE_SOL_POLYDATA_REAL_MUL_F) (int *fid, STR_PSTR(name), double *value, 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_PolyData_Real_Mul(*fid, c_name, *value);
}

void IRICLIBDLL FMNAME(cg_iric_read_geo_count_mul_f, CG_IRIC_READ_GEO_COUNT_MUL_F) (int *fid, STR_PSTR(name), int *count, int *ier STR_PLEN(name)) {
char c_name[CGIO_MAX_NAME_LENGTH+1];
string_2_C_string(STR_PTR(name), STR_LEN(name),
Expand Down Expand Up @@ -2306,6 +2345,45 @@ void IRICLIBDLL FMNAME(cg_iric_write_sol_particle_integer_f, CG_IRIC_WRITE_SOL_P
*ier = cg_iRIC_Write_Sol_Particle_Integer(c_name, value);
}

void IRICLIBDLL FMNAME(cg_iric_write_sol_polydata_groupbegin_f, CG_IRIC_WRITE_SOL_POLYDATA_GROUPBEGIN_F) (STR_PSTR(name), 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_PolyData_GroupBegin(c_name);
}

void IRICLIBDLL FMNAME(cg_iric_write_sol_polydata_groupend_f, CG_IRIC_WRITE_SOL_POLYDATA_GROUPEND_F) (int *ier) {
*ier = cg_iRIC_Write_Sol_PolyData_GroupEnd();
}

void IRICLIBDLL FMNAME(cg_iric_write_sol_polydata_polygon_f, CG_IRIC_WRITE_SOL_POLYDATA_POLYGON_F) (int *numPoints, double *x, double *y, int *ier) {
*ier = cg_iRIC_Write_Sol_PolyData_Polygon(*numPoints, x, y);
}

void IRICLIBDLL FMNAME(cg_iric_write_sol_polydata_polyline_f, CG_IRIC_WRITE_SOL_POLYDATA_POLYLINE_F) (int *numPoints, double *x, double *y, int *ier) {
*ier = cg_iRIC_Write_Sol_PolyData_Polyline(*numPoints, x, y);
}

void IRICLIBDLL FMNAME(cg_iric_write_sol_polydata_integer_f, CG_IRIC_WRITE_SOL_POLYDATA_INTEGER_F) (STR_PSTR(name), int *value, 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_PolyData_Integer(c_name, *value);
}

void IRICLIBDLL FMNAME(cg_iric_write_sol_polydata_real_f, CG_IRIC_WRITE_SOL_POLYDATA_REAL_F) (STR_PSTR(name), double *value, 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_PolyData_Real(c_name, *value);
}

void IRICLIBDLL FMNAME(cg_iric_read_geo_count_f, CG_IRIC_READ_GEO_COUNT_F) (STR_PSTR(name), int *count, int *ier STR_PLEN(name)) {
char c_name[CGIO_MAX_NAME_LENGTH+1];
string_2_C_string(STR_PTR(name), STR_LEN(name),
Expand Down
36 changes: 36 additions & 0 deletions iriclib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1001,4 +1001,40 @@ int cg_iRIC_Write_Sol_Particle_Integer_Mul(int fid, const char* name, int* value
return f->Sol_Particle_Write_Integer(name, value);
}

int cg_iRIC_Write_Sol_PolyData_GroupBegin_Mul(int fid, const char* name)
{
GET_F(fid);
return f->Sol_PolyData_Write_GroupBegin(name);
}

int cg_iRIC_Write_Sol_PolyData_GroupEnd_Mul(int fid)
{
GET_F(fid);
return f->Sol_PolyData_Write_GroupEnd();
}

int cg_iRIC_Write_Sol_PolyData_Polygon_Mul(int fid, int numPoints, double* x, double* y)
{
GET_F(fid);
return f->Sol_PolyData_Write_Polygon(numPoints, x, y);
}

int cg_iRIC_Write_Sol_PolyData_Polyline_Mul(int fid, int numPoints, double* x, double* y)
{
GET_F(fid);
return f->Sol_PolyData_Write_Polyline(numPoints, x, y);
}

int cg_iRIC_Write_Sol_PolyData_Integer_Mul(int fid, const char* name, int value)
{
GET_F(fid);
return f->Sol_PolyData_Write_Integer(name, value);
}

int cg_iRIC_Write_Sol_PolyData_Real_Mul(int fid, const char* name, double value)
{
GET_F(fid);
return f->Sol_PolyData_Write_Real(name, value);
}

} // extern "C"
26 changes: 26 additions & 0 deletions iriclib.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

#define IRIC_CANCELED 1

#define IRIC_POLYDATA_POLYGON 1
#define IRIC_POLYDATA_POLYLINE 2

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -331,6 +334,17 @@ int IRICLIBDLL cg_iRIC_Write_Sol_Particle_Pos3d_Mul(int fid, cgsize_t count, dou
int IRICLIBDLL cg_iRIC_Write_Sol_Particle_Real_Mul(int fid, const char* name, double* value);
int IRICLIBDLL cg_iRIC_Write_Sol_Particle_Integer_Mul(int fid, const char* name, int* value);

/**********************************************/
/* Writing Polydata */
/**********************************************/

int IRICLIBDLL cg_iRIC_Write_Sol_PolyData_GroupBegin_Mul(int fid, const char* name);
int IRICLIBDLL cg_iRIC_Write_Sol_PolyData_GroupEnd_Mul(int fid);
int IRICLIBDLL cg_iRIC_Write_Sol_PolyData_Polygon_Mul(int fid, int numPoints, double* x, double* y);
int IRICLIBDLL cg_iRIC_Write_Sol_PolyData_Polyline_Mul(int fid, int numPoints, double* x, double* y);
int IRICLIBDLL cg_iRIC_Write_Sol_PolyData_Integer_Mul(int fid, const char* name, int value);
int IRICLIBDLL cg_iRIC_Write_Sol_PolyData_Real_Mul(int fid, const char* name, double value);

/**********************************************/
/* Reading Geographic Data */
/**********************************************/
Expand Down Expand Up @@ -634,6 +648,18 @@ int IRICLIBDLL cg_iRIC_Write_Sol_Particle_Real(const char* name, double* value);

int IRICLIBDLL cg_iRIC_Write_Sol_Particle_Integer(const char* name, int* value);

int IRICLIBDLL cg_iRIC_Write_Sol_PolyData_GroupBegin(const char* name);

int IRICLIBDLL cg_iRIC_Write_Sol_PolyData_GroupEnd();

int IRICLIBDLL cg_iRIC_Write_Sol_PolyData_Polygon(int numPoints, double* x, double* y);

int IRICLIBDLL cg_iRIC_Write_Sol_PolyData_Polyline(int numPoints, double* x, double* y);

int IRICLIBDLL cg_iRIC_Write_Sol_PolyData_Integer(const char* name, int value);

int IRICLIBDLL cg_iRIC_Write_Sol_PolyData_Real(const char* name, double value);

int IRICLIBDLL cg_iRIC_Read_Geo_Count(const char* name, int* count);

int IRICLIBDLL cg_iRIC_Read_Geo_Filename(const char* name, int geoid, char* filename, int* type);
Expand Down
11 changes: 11 additions & 0 deletions iriclib_cgnsfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,17 @@ class CgnsFile
int Sol_Particle_Write_Real(const char* name, double* value);
int Sol_Particle_Write_Integer(const char* name, int* value);

// ----------------------
// Solution Polydata I/O
// ----------------------

int Sol_PolyData_Write_GroupBegin(const char* name);
int Sol_PolyData_Write_GroupEnd();
int Sol_PolyData_Write_Polygon(int numPoints, double* x, double* y);
int Sol_PolyData_Write_Polyline(int numPoints, double* x, double* y);
int Sol_PolyData_Write_Integer(const char* name, int value);
int Sol_PolyData_Write_Real(const char* name, double value);

// --------------------
// Geographic data I/O
// --------------------
Expand Down
23 changes: 22 additions & 1 deletion iriclib_cgnsfile_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,11 @@ void CgnsFile::Impl::getParticleSolName(int num, char* name)
sprintf(name, "ParticleSolution%d", num);
}

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<std::string>* sols, std::vector<std::string>* cellsols)
{
char solname[NAME_MAXLENGTH];
Expand All @@ -717,7 +722,13 @@ int CgnsFile::Impl::addSolutionNode(int fid, int bid, int zid, int sid, std::vec
ier = writeFlowSolutionPointers(fid, bid, zid, *sols);
RETURN_IF_ERR;

return writeFlowCellSolutionPointers(fid, bid, zid, *cellsols);
ier = writeFlowCellSolutionPointers(fid, bid, zid, *cellsols);
RETURN_IF_ERR;

ier = addPolydataSolutionNode(fid, bid, zid, sid);
RETURN_IF_ERR;

return 0;
}

int CgnsFile::Impl::addSolutionGridCoordNode(int fid, int bid, int zid, int sid, std::vector<std::string>* coords)
Expand Down Expand Up @@ -745,6 +756,16 @@ int CgnsFile::Impl::addParticleSolutionNode(int fid, int bid, int zid, int sid)
return cg_user_data_write(solname);
}

int CgnsFile::Impl::addPolydataSolutionNode(int fid, int bid, int zid, int sid)
{
char solname[NAME_MAXLENGTH];
getPolydataSolName(sid, solname);

int ier = cg_goto(fid, bid, "Zone_t", zid, NULL);
RETURN_IF_ERR;
return cg_user_data_write(solname);
}

int CgnsFile::Impl::solIndex(CGNS_ENUMT(GridLocation_t) location, int step)
{
int index = step;
Expand Down
30 changes: 30 additions & 0 deletions iriclib_cgnsfile_sol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,33 @@ int CgnsFile::Sol_Particle_Write_Integer(const char* name, int* value)
{
return impl->m_solutionWriter->Sol_Particle_Write_Integer(name, value);
}

int CgnsFile::Sol_PolyData_Write_GroupBegin(const char* name)
{
return impl->m_solutionWriter->Sol_PolyData_Write_GroupBegin(name);
}

int CgnsFile::Sol_PolyData_Write_GroupEnd()
{
return impl->m_solutionWriter->Sol_PolyData_Write_GroupEnd();
}

int CgnsFile::Sol_PolyData_Write_Polygon(int numPoints, double* x, double* y)
{
return impl->m_solutionWriter->Sol_PolyData_Write_Polygon(numPoints, x, y);
}

int CgnsFile::Sol_PolyData_Write_Polyline(int numPoints, double* x, double* y)
{
return impl->m_solutionWriter->Sol_PolyData_Write_Polyline(numPoints, x, y);
}

int CgnsFile::Sol_PolyData_Write_Integer(const char* name, int value)
{
return impl->m_solutionWriter->Sol_PolyData_Write_Integer(name, value);
}

int CgnsFile::Sol_PolyData_Write_Real(const char* name, double value)
{
return impl->m_solutionWriter->Sol_PolyData_Write_Real(name, value);
}
4 changes: 4 additions & 0 deletions iriclib_f.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@

integer IRIC_CANCELED
parameter(IRIC_CANCELED = 1)

integer IRIC_POLYDATA_POLYGON, IRIC_POLYDATA_POLYLINE
parameter(IRIC_POLYDATA_POLYGON = 1)
parameter(IRIC_POLYDATA_POLYLINE = 2)
30 changes: 30 additions & 0 deletions iriclib_single.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,36 @@ int cg_iRIC_Write_Sol_Particle_Integer(const char* name, int* value)
return cg_iRIC_Write_Sol_Particle_Integer_Mul(lastfileid, name, value);
}

int cg_iRIC_Write_Sol_PolyData_GroupBegin(const char* name)
{
return cg_iRIC_Write_Sol_PolyData_GroupBegin_Mul(lastfileid, name);
}

int cg_iRIC_Write_Sol_PolyData_GroupEnd()
{
return cg_iRIC_Write_Sol_PolyData_GroupEnd_Mul(lastfileid);
}

int cg_iRIC_Write_Sol_PolyData_Polygon(int numPoints, double* x, double* y)
{
return cg_iRIC_Write_Sol_PolyData_Polygon_Mul(lastfileid, numPoints, x, y);
}

int cg_iRIC_Write_Sol_PolyData_Polyline(int numPoints, double* x, double* y)
{
return cg_iRIC_Write_Sol_PolyData_Polyline_Mul(lastfileid, numPoints, x, y);
}

int cg_iRIC_Write_Sol_PolyData_Integer(const char* name, int value)
{
return cg_iRIC_Write_Sol_PolyData_Integer_Mul(lastfileid, name, value);
}

int cg_iRIC_Write_Sol_PolyData_Real(const char* name, double value)
{
return cg_iRIC_Write_Sol_PolyData_Real_Mul(lastfileid, name, value);
}

int cg_iRIC_Read_Geo_Count(const char* name, int* count)
{
return cg_iRIC_Read_Geo_Count_Mul(lastfileid, name, count);
Expand Down
3 changes: 2 additions & 1 deletion private/iriclib_cgnsfile_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ class CgnsFile::Impl

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<std::string>* sols, std::vector<std::string>* cellsols);
static int addSolutionGridCoordNode(int fid, int bid, int zid, int sid, std::vector<std::string>* coords);
static int addParticleSolutionNode(int fid, int bid, int zid, int sid);
static int addPolydataSolutionNode(int fid, int bid, int zid, int sid);

static int writePointers(int fid, int bid, int zid, const char* name, const std::vector<std::string>& strs);
static int writeFlowSolutionPointers(int fid, int bid, int zid, const std::vector<std::string>& sols);
Expand Down Expand Up @@ -124,7 +126,6 @@ class CgnsFile::Impl
std::vector<std::string> m_cellSolPointers;
std::vector<std::string> m_solParticlePointers;


std::vector<BaseIterativeT<int> > m_solBaseIterInts;
std::vector<BaseIterativeT<double> > m_solBaseIterReals;

Expand Down
Loading

0 comments on commit 7cc7034

Please sign in to comment.