80 chk(cg_open(argv[1], CG_MODE_MODIFY, &fn),
"open");
81 chk(cg_zone_read(fn, 1, 1, zname, sz),
"zone read");
82 chk(cg_nsections(fn, 1, 1, &ns),
"nsections");
87 chk(cg_nbocos(fn, 1, 1, &nbc),
"nbocos");
89 std::vector<cgsize_t> side[2];
90 cgsize_t count[2] = {0, 0};
91 for (
int I = 1; I <= nbc; ++I)
94 CGNS_ENUMT(BCType_t) bt;
95 CGNS_ENUMT(PointSetType_t) ps;
98 CGNS_ENUMT(DataType_t) ndt;
99 chk(cg_boco_info(fn, 1, 1, I, bn, &bt, &ps, &np, ni, &nls, &ndt, &nd),
101 int w = strstr(bn,
"Inlet") ? 0 : (strstr(bn,
"Outlet") ? 1 : -1);
108 chk(cg_boco_read(fn, 1, 1, I, side[w].data(),
nullptr),
"boco read");
109 printf(
"side %d from '%s': %ld faces\n", w, bn, (
long)np);
111 if (side[0].empty() || side[1].empty())
113 printf(
"inlet/outlet not found\n");
118 cgsize_t *a = side[0].data(), *b = side[1].data();
119 cgsize_t n = count[0] < count[1] ? count[0] : count[1];
120 printf(
"zone '%s': periodic pair declared over %ld + %ld faces, leaving "
121 "%ld of the inlet and %ld of the outlet to their conditions\n",
122 zname, (
long)n, (
long)n, (
long)(count[0] - n), (
long)(count[1] - n));
124 float centre[3] = {0, 0, 0}, angle[3] = {0, 0, 0};
125 float fwd[3] = {0, 0, 1}, rev[3] = {0, 0, -1};
128 chk(cg_conn_write(fn, 1, 1,
"periodic_a", CGNS_ENUMV(FaceCenter),
129 CGNS_ENUMV(Abutting1to1), CGNS_ENUMV(PointList), n, a,
130 zname, CGNS_ENUMV(Unstructured),
131 CGNS_ENUMV(PointListDonor), CGNS_ENUMV(LongInteger), n, b,
134 chk(cg_conn_periodic_write(fn, 1, 1, J, centre, angle, fwd),
"periodic a");
136 chk(cg_conn_write(fn, 1, 1,
"periodic_b", CGNS_ENUMV(FaceCenter),
137 CGNS_ENUMV(Abutting1to1), CGNS_ENUMV(PointList), n, b,
138 zname, CGNS_ENUMV(Unstructured),
139 CGNS_ENUMV(PointListDonor), CGNS_ENUMV(LongInteger), n, a,
142 chk(cg_conn_periodic_write(fn, 1, 1, J, centre, angle, rev),
"periodic b");
144 chk(cg_close(fn),
"close");