128 int arraySiz,
int arraySizPoint,
135 auto mpi =
mesh->getMPI();
137 if (mpi.rank !=
mRank && flag == 0)
143 std::filesystem::path outFile{fname};
144 std::filesystem::create_directories(outFile.parent_path() /
".");
150 std::filesystem::path outPath{fname +
".dir"};
151 std::filesystem::create_directories(outPath);
153 std::sprintf(BUF,
"%06d", mpi.rank);
157 std::ofstream fout(fname, std::ios::binary);
160 DNDS::log() <<
"Error: WriteMeshDebugTecASCII open \"" << fname <<
"\" failure" << std::endl;
163 const char magic_word[] =
"#!TDV112";
164 const int b_magic_word =
sizeof(magic_word) - 1;
169 auto writeInt = [&](
int d) ->
void
172 fout.write((
char *)(&intBuf),
sizeof(intBuf));
174 auto writeFloat = [&](float_t d) ->
void
177 fout.write((
char *)(&floatBuf),
sizeof(floatBuf));
179 auto writeDouble = [&](double_t d) ->
void
182 fout.write((
char *)(&doubleBuf),
sizeof(doubleBuf));
184 auto writeString = [&](
const std::string &title) ->
void
189 fout.write((
char *)(&intBuf),
sizeof(intBuf));
192 fout.write((
char *)(&intBuf),
sizeof(intBuf));
194 fout.write(magic_word, b_magic_word);
197 writeString(
"Title Here");
198 writeInt(arraySiz + 3 + 1 + arraySizPoint);
202 for (
int idata = 0; idata < arraySizPoint; idata++)
203 writeString(namesPoint(idata));
204 for (
int idata = 0; idata < arraySiz; idata++)
205 writeString(names(idata));
206 writeString(
"iPart");
212 writeString(
"zone_0");
219 else if (
mesh->dim == 3)
221 else if (
mesh->dim == 1)
225 for (
int idim = 0; idim < 3; idim++)
227 for (
int idata = 0; idata < arraySizPoint; idata++)
229 for (
int idata = 0; idata < arraySiz; idata++)
242 index nCell{-1}, nNode{-1};
246 std::vector<Geom::tPoint>
248 std::vector<index> nodesExtraAtOriginal;
249 if (
mesh->isPeriodic)
251 for (
index iCell = 0; iCell < nCell; iCell++)
252 for (
rowsize ic2n = 0; ic2n < cell2nodePbiOut.
RowSize(iCell); ic2n++)
253 if (cell2nodePbiOut[iCell][ic2n])
254 nodesExtra.push_back(
mesh->periodicInfo.GetCoordByBits(coordOut[cell2nodeOut[iCell][ic2n]], cell2nodePbiOut[iCell][ic2n])),
255 nodesExtraAtOriginal.push_back(cell2nodeOut(iCell, ic2n));
266 std::vector<index> nodeDedu2Old;
267 std::vector<index> nodeOld2Dedu;
268 GetViolentNodeDeduplication(nNode, nodesExtra, coordOut, nodeDedu2Old, nodeOld2Dedu);
271 writeInt(nodeDedu2Old.size());
287 for (
int idim = 0; idim < 3; idim++)
289 for (
int idata = 0; idata < arraySizPoint; idata++)
291 for (
int idata = 0; idata < arraySiz; idata++)
303 for (
int idim = 0; idim < 3; idim++)
304 for (
DNDS::index i = 0; i < nodeDedu2Old.size(); i++)
306 index iN = nodeDedu2Old.at(i);
309 minVal[idim] = std::min(coordOut[iN](idim), minVal[idim]);
310 maxVal[idim] = std::max(coordOut[iN](idim), maxVal[idim]);
314 minVal[idim] = std::min(nodesExtra.at(iN - nNode)(idim), minVal[idim]);
315 maxVal[idim] = std::max(nodesExtra.at(iN - nNode)(idim), maxVal[idim]);
319 for (
int idata = 0; idata < arraySiz; idata++)
322 minVal[3 + idata] = std::min(data(idata, iv), minVal[3 + idata]);
323 maxVal[3 + idata] = std::max(data(idata, iv), maxVal[3 + idata]);
326 for (
int idata = 0; idata < arraySizPoint; idata++)
329 minValPoint[idata] = std::min(dataPoint(idata, iv), minValPoint[idata]);
330 maxValPoint[idata] = std::max(dataPoint(idata, iv), maxValPoint[idata]);
333 for (
int idim = 0; idim < 3; idim++)
335 writeDouble(minVal[idim]);
336 writeDouble(maxVal[idim]);
338 for (
int idata = 0; idata < arraySizPoint; idata++)
340 writeDouble(minValPoint[idata]);
341 writeDouble(maxValPoint[idata]);
343 for (
int idata = 0; idata < arraySiz; idata++)
345 writeDouble(minVal[3 + idata]);
346 writeDouble(maxVal[3 + idata]);
349 writeDouble(mpi.size);
351 for (
int idim = 0; idim < 3; idim++)
353 for (
DNDS::index i = 0; i < nodeDedu2Old.size(); i++)
357 writeDouble(coordOut[iN](idim));
359 writeDouble(nodesExtra.at(iN - nNode)(idim));
363 for (
int idata = 0; idata < arraySizPoint; idata++)
365 for (
DNDS::index i = 0; i < nodeDedu2Old.size(); i++)
369 writeDouble(dataPoint(idata, iN));
371 writeDouble(dataPoint(idata, nodesExtraAtOriginal.at(iN - nNode)));
375 for (
int idata = 0; idata < arraySiz; idata++)
378 writeDouble(data(idata, iv));
392 r =
mesh->getMPI().rank;
407 auto elem =
Elem::Element{cellElemInfoOut[iv]->getElemType()};
408 std::vector<index> c2n = cell2nodeOut[iv];
409 if (
mesh->isPeriodic)
410 for (
rowsize ic2n = 0; ic2n < c2n.size(); ic2n++)
412 if (cell2nodePbiOut[iv][ic2n])
413 c2n[ic2n] = (nExtra++) + nNode;
417 v = nodeOld2Dedu.at(
v);
418 switch (elem.GetParamSpace())
421 writeInt(c2n[0] + 0LL);
422 writeInt(c2n[1] + 0LL);
425 writeInt(c2n[0] + 0LL);
426 writeInt(c2n[1] + 0LL);
427 writeInt(c2n[2] + 0LL);
428 writeInt(c2n[2] + 0LL);
431 writeInt(c2n[0] + 0LL);
432 writeInt(c2n[1] + 0LL);
433 writeInt(c2n[2] + 0LL);
434 writeInt(c2n[3] + 0LL);
437 writeInt(c2n[0] + 0LL);
438 writeInt(c2n[1] + 0LL);
439 writeInt(c2n[2] + 0LL);
440 writeInt(c2n[2] + 0LL);
441 writeInt(c2n[3] + 0LL);
442 writeInt(c2n[3] + 0LL);
443 writeInt(c2n[3] + 0LL);
444 writeInt(c2n[3] + 0LL);
447 writeInt(c2n[0] + 0LL);
448 writeInt(c2n[1] + 0LL);
449 writeInt(c2n[2] + 0LL);
450 writeInt(c2n[3] + 0LL);
451 writeInt(c2n[4] + 0LL);
452 writeInt(c2n[5] + 0LL);
453 writeInt(c2n[6] + 0LL);
454 writeInt(c2n[7] + 0LL);
457 writeInt(c2n[0] + 0LL);
458 writeInt(c2n[1] + 0LL);
459 writeInt(c2n[2] + 0LL);
460 writeInt(c2n[2] + 0LL);
461 writeInt(c2n[3] + 0LL);
462 writeInt(c2n[4] + 0LL);
463 writeInt(c2n[5] + 0LL);
464 writeInt(c2n[5] + 0LL);
467 writeInt(c2n[0] + 0LL);
468 writeInt(c2n[1] + 0LL);
469 writeInt(c2n[2] + 0LL);
470 writeInt(c2n[3] + 0LL);
471 writeInt(c2n[4] + 0LL);
472 writeInt(c2n[4] + 0LL);
473 writeInt(c2n[4] + 0LL);
474 writeInt(c2n[4] + 0LL);
754 std::string fname, std::string seriesName,
755 int arraySiz,
int vecArraySiz,
int arraySizPoint,
int vecArraySizPoint,
766 auto mpi =
mesh->getMPI();
767 std::string fnameIN = fname;
769 if (mpi.rank !=
mRank && flag == 0)
775 std::filesystem::path outFile{fname};
776 std::filesystem::create_directories(outFile.parent_path() /
".");
778 if (seriesName.size())
779 updateVTKSeries(seriesName +
".vtu.series",
getStringForcePath(outFile.filename()), t);
781 std::filesystem::path outPath;
784 outPath = {fname +
".vtu.dir"};
785 std::filesystem::create_directories(outPath);
787 std::sprintf(BUF,
"%04d", mpi.rank);
791 std::ofstream fout(fname);
794 DNDS::log() <<
"Error: PrintSerialPartVTKDataArray open \"" << fname <<
"\" failure" << std::endl;
804 index nCell{-1}, nNode{-1};
808 std::vector<Geom::tPoint>
810 std::vector<index> nodesExtraAtOriginal;
811 if (
mesh->isPeriodic)
813 for (
index iCell = 0; iCell < nCell; iCell++)
814 for (
rowsize ic2n = 0; ic2n < cell2nodePbiOut.
RowSize(iCell); ic2n++)
815 if (cell2nodePbiOut[iCell][ic2n])
816 nodesExtra.push_back(
mesh->periodicInfo.GetCoordByBits(coordOut[cell2nodeOut[iCell][ic2n]], cell2nodePbiOut[iCell][ic2n])),
817 nodesExtraAtOriginal.push_back(cell2nodeOut(iCell, ic2n));
828 std::vector<index> nodeDedu2Old;
829 std::vector<index> nodeOld2Dedu;
830 GetViolentNodeDeduplication(nNode, nodesExtra, coordOut, nodeDedu2Old, nodeOld2Dedu);
833 std::string indentV =
" ";
834 std::string newlineV =
"\n";
836 auto writeXMLEntity = [&](std::ostream &out,
int level,
const auto &name,
const std::vector<std::pair<std::string, std::string>> &attr,
auto &&writeContent) ->
void
838 for (
int i = 0; i < level; i++)
840 out <<
"<" << name <<
" ";
841 for (
const auto &a : attr)
842 out << a.first <<
"=\"" << a.second <<
"\" ";
843 out <<
">" << newlineV;
845 writeContent(out, level + 1);
847 for (
int i = 0; i < level; i++)
849 out <<
"</" << name <<
">" << newlineV;
852 auto writeCoords = [&](
auto &out,
int level)
855 out, level,
"Points",
857 [&](
auto &out,
int level)
860 out, level,
"DataArray",
861 {{
"type",
"Float64"},
862 {
"NumberOfComponents",
"3"},
863 {
"format", vtuFloatEncodeMode}},
864 [&](
auto &out,
int level)
866 if (vtuFloatEncodeMode ==
"binary")
870 uint64_t binSize = (nodeDedu2Old.size() * 3) *
sizeof(
double);
871 std::vector<uint8_t> dataOutBytes;
872 dataOutBytes.resize(binSize +
sizeof(binSize), 0);
874 *(uint64_t *)(dataOutBytes.data() + top) = binSize, top +=
sizeof(uint64_t);
875 for (
index i = 0; i < nodeDedu2Old.size(); i++)
877 index iN = nodeDedu2Old.at(i);
880 *(
double *)(dataOutBytes.data() + top) =
double(coordOut[iN](0)), top +=
sizeof(
double);
881 *(
double *)(dataOutBytes.data() + top) =
double(coordOut[iN](1)), top +=
sizeof(
double);
882 *(
double *)(dataOutBytes.data() + top) =
double(coordOut[iN](2)), top +=
sizeof(
double);
886 *(
double *)(dataOutBytes.data() + top) =
double(nodesExtra.at(iN - nNode)(0)), top +=
sizeof(double);
887 *(
double *)(dataOutBytes.data() + top) =
double(nodesExtra.at(iN - nNode)(1)), top +=
sizeof(double);
888 *(
double *)(dataOutBytes.data() + top) =
double(nodesExtra.at(iN - nNode)(2)), top +=
sizeof(double);
891 out << cppcodec::base64_rfc4648::encode(dataOutBytes);
893 else if (vtuFloatEncodeMode ==
"ascii")
895 std::vector<double> coordsOutData(nodeDedu2Old.size() * 3);
896 for (
index i = 0; i < nodeDedu2Old.size(); i++)
898 index iN = nodeDedu2Old.at(i);
901 coordsOutData[i * 3 + 0LL] = coordOut[iN](0);
902 coordsOutData[i * 3 + 1LL] = coordOut[iN](1);
903 coordsOutData[i * 3 + 2LL] = coordOut[iN](2);
907 coordsOutData[i * 3 + 0LL] = nodesExtra.at(iN - nNode)(0);
908 coordsOutData[i * 3 + 1LL] = nodesExtra.at(iN - nNode)(1);
909 coordsOutData[i * 3 + 2LL] = nodesExtra.at(iN - nNode)(2);
915 for (
auto v : coordsOutData)
916 out << std::setprecision(ascii_precision) <<
v <<
" ";
925 auto vtkTopo = BuildVTKCellTopology(
926 nCell, nNode, cell2nodeOut, cell2nodePbiOut,
927 cellElemInfoOut, nodeOld2Dedu,
mesh->isPeriodic);
928 auto &cell2nodeOutData = vtkTopo.connectivity;
929 auto &cell2nodeOffsetData = vtkTopo.offsets;
930 auto &cellTypeData = vtkTopo.cellTypes;
932 auto writeCells = [&](
auto &out,
int level)
937 [&](
auto &out,
int level)
940 out, level,
"DataArray",
942 {
"Name",
"connectivity"},
943 {
"format",
"ascii"}},
944 [&](
auto &out,
int level)
949 for (
auto v : cell2nodeOutData)
954 out, level,
"DataArray",
957 {
"format",
"ascii"}},
958 [&](
auto &out,
int level)
963 for (
auto v : cell2nodeOffsetData)
968 out, level,
"DataArray",
971 {
"format",
"ascii"}},
972 [&](
auto &out,
int level)
977 for (
int v : cellTypeData)
984 auto writeCellData = [&](
auto &out,
int level)
986 std::string namesAll;
987 for (
int i = 0; i < arraySiz; i++)
988 namesAll.append(names(i) +
" ");
989 std::string vectorsNameAll;
990 for (
int i = 0; i < vecArraySiz; i++)
991 vectorsNameAll.append(vectorNames(i) +
" ");
994 out, level,
"CellData",
995 {{
"Scalars", namesAll},
996 {
"Vectors", vectorsNameAll}},
997 [&](
auto &out,
int level)
999 for (
int i = 0; i < arraySiz; i++)
1002 out, level,
"DataArray",
1003 {{
"type",
"Float64"},
1005 {
"format", vtuFloatEncodeMode}},
1006 [&](
auto &out,
int level)
1008 if (vtuFloatEncodeMode ==
"binary")
1012 uint64_t binSize = nCell *
sizeof(double);
1013 std::vector<uint8_t> dataOutBytes;
1014 dataOutBytes.resize(binSize +
sizeof(binSize), 0);
1016 *(uint64_t *)(dataOutBytes.data() + top) = binSize, top +=
sizeof(uint64_t);
1017 for (
index iCell = 0; iCell < nCell; iCell++)
1018 *(
double *)(dataOutBytes.data() + top) =
double(data(i, iCell)), top +=
sizeof(
double);
1019 out << cppcodec::base64_rfc4648::encode(dataOutBytes);
1021 else if (vtuFloatEncodeMode ==
"ascii")
1025 std::vector<double> dataOutC(nCell);
1026 for (
index iCell = 0; iCell < nCell; iCell++)
1027 dataOutC[iCell] = data(i, iCell);
1030 out << std::setprecision(ascii_precision);
1031 for (
auto v : dataOutC)
1040 out, level,
"DataArray",
1043 {
"format",
"ascii"}},
1044 [&](
auto &out,
int level)
1046 std::vector<double> dataOutC(nCell);
1047 for (
index iCell = 0; iCell < nCell; iCell++)
1057 r =
mesh->getMPI().rank;
1058 dataOutC[iCell] =
r;
1060 out << std::setprecision(ascii_precision);
1061 for (
auto v : dataOutC)
1065 for (
int i = 0; i < vecArraySiz; i++)
1068 out, level,
"DataArray",
1069 {{
"type",
"Float64"},
1070 {
"Name", vectorNames(i)},
1071 {
"NumberOfComponents",
"3"},
1072 {
"format", vtuFloatEncodeMode}},
1073 [&](
auto &out,
int level)
1075 if (vtuFloatEncodeMode ==
"binary")
1079 uint64_t binSize = (nCell * 3) *
sizeof(
double);
1080 std::vector<uint8_t> dataOutBytes;
1081 dataOutBytes.resize(binSize +
sizeof(binSize), 0);
1083 *(uint64_t *)(dataOutBytes.data() + top) = binSize, top +=
sizeof(uint64_t);
1084 for (
index iCell = 0; iCell < nCell; iCell++)
1086 *(
double *)(dataOutBytes.data() + top) = vectorData(i, iCell, 0), top +=
sizeof(double);
1087 *(
double *)(dataOutBytes.data() + top) = vectorData(i, iCell, 1), top +=
sizeof(double);
1088 *(
double *)(dataOutBytes.data() + top) = vectorData(i, iCell, 2), top +=
sizeof(double);
1090 out << cppcodec::base64_rfc4648::encode(dataOutBytes);
1092 else if (vtuFloatEncodeMode ==
"ascii")
1096 std::vector<double> dataOutC(nCell * 3);
1097 for (
index iCell = 0; iCell < nCell; iCell++)
1099 dataOutC[iCell * 3 + 0LL] = vectorData(i, iCell, 0);
1100 dataOutC[iCell * 3 + 1] = vectorData(i, iCell, 1);
1101 dataOutC[iCell * 3 + 2] = vectorData(i, iCell, 2);
1106 for (
auto v : dataOutC)
1107 out << std::setprecision(ascii_precision) <<
v <<
" ";
1117 auto writePointData = [&](
auto &out,
int level)
1119 std::string namesAll;
1120 for (
int i = 0; i < arraySizPoint; i++)
1121 namesAll.append(namesPoint(i) +
" ");
1122 std::string vectorsNameAll;
1123 for (
int i = 0; i < vecArraySizPoint; i++)
1124 vectorsNameAll.append(vectorNamesPoint(i) +
" ");
1127 out, level,
"PointData",
1128 {{
"Scalars", namesAll},
1129 {
"Vectors", vectorsNameAll}},
1130 [&](
auto &out,
int level)
1132 for (
int i = 0; i < arraySizPoint; i++)
1135 out, level,
"DataArray",
1136 {{
"type",
"Float64"},
1137 {
"Name", namesPoint(i)},
1138 {
"format", vtuFloatEncodeMode}},
1139 [&](
auto &out,
int level)
1141 if (vtuFloatEncodeMode ==
"binary")
1145 uint64_t binSize = (nodeDedu2Old.size()) *
sizeof(
double);
1146 std::vector<uint8_t> dataOutBytes;
1147 dataOutBytes.resize(binSize +
sizeof(binSize), 0);
1149 *(uint64_t *)(dataOutBytes.data() + top) = binSize, top +=
sizeof(uint64_t);
1150 for (
index ii = 0; ii < nodeDedu2Old.size(); ii++)
1152 index iN = nodeDedu2Old.at(ii);
1154 *(
double *)(dataOutBytes.data() + top) = dataPoint(i, iN), top +=
sizeof(double);
1156 *(
double *)(dataOutBytes.data() + top) = dataPoint(i, nodesExtraAtOriginal.at(iN - nNode)), top +=
sizeof(
double);
1158 out << cppcodec::base64_rfc4648::encode(dataOutBytes);
1160 else if (vtuFloatEncodeMode ==
"ascii")
1164 out << std::setprecision(ascii_precision);
1165 for (
index ii = 0; ii < nodeDedu2Old.size(); ii++)
1167 index iN = nodeDedu2Old.at(ii);
1169 out << dataPoint(i, iN) <<
" ";
1171 out << dataPoint(i, nodesExtraAtOriginal.at(iN - nNode)) <<
" ";
1179 for (
int i = 0; i < vecArraySizPoint; i++)
1182 out, level,
"DataArray",
1183 {{
"type",
"Float64"},
1184 {
"Name", vectorNamesPoint(i)},
1185 {
"NumberOfComponents",
"3"},
1186 {
"format", vtuFloatEncodeMode}},
1187 [&](
auto &out,
int level)
1189 if (vtuFloatEncodeMode ==
"binary")
1193 uint64_t binSize = (nodeDedu2Old.size()) * 3 *
sizeof(
double);
1194 std::vector<uint8_t> dataOutBytes;
1195 dataOutBytes.resize(binSize +
sizeof(binSize), 0);
1197 *(uint64_t *)(dataOutBytes.data() + top) = binSize, top +=
sizeof(uint64_t);
1198 for (
index ii = 0; ii < nodeDedu2Old.size(); ii++)
1200 index iN = nodeDedu2Old.at(ii);
1203 *(
double *)(dataOutBytes.data() + top) = vectorDataPoint(i, iN, 0), top +=
sizeof(double);
1204 *(
double *)(dataOutBytes.data() + top) = vectorDataPoint(i, iN, 1), top +=
sizeof(double);
1205 *(
double *)(dataOutBytes.data() + top) = vectorDataPoint(i, iN, 2), top +=
sizeof(double);
1209 *(
double *)(dataOutBytes.data() + top) = vectorDataPoint(i, nodesExtraAtOriginal.at(iN - nNode), 0), top +=
sizeof(
double);
1210 *(
double *)(dataOutBytes.data() + top) = vectorDataPoint(i, nodesExtraAtOriginal.at(iN - nNode), 1), top +=
sizeof(
double);
1211 *(
double *)(dataOutBytes.data() + top) = vectorDataPoint(i, nodesExtraAtOriginal.at(iN - nNode), 2), top +=
sizeof(
double);
1214 out << cppcodec::base64_rfc4648::encode(dataOutBytes);
1216 else if (vtuFloatEncodeMode ==
"ascii")
1220 out << std::setprecision(ascii_precision);
1221 for (
index ii = 0; ii < nodeDedu2Old.size(); ii++)
1223 index iN = nodeDedu2Old.at(ii);
1226 out << vectorDataPoint(i, iN, 0) <<
" ";
1227 out << vectorDataPoint(i, iN, 1) <<
" ";
1228 out << vectorDataPoint(i, iN, 2) <<
" ";
1232 out << vectorDataPoint(i, nodesExtraAtOriginal.at(iN - nNode), 0) <<
" ";
1233 out << vectorDataPoint(i, nodesExtraAtOriginal.at(iN - nNode), 1) <<
" ";
1234 out << vectorDataPoint(i, nodesExtraAtOriginal.at(iN - nNode), 2) <<
" ";
1246 std::string endianName{
"BigEndian"};
1247 uint32_t beTest = 1;
1248 uint8_t beTestS = *(uint8_t *)(&beTest);
1250 endianName =
"LittleEndian";
1255 {
"type",
"UnstructuredGrid"},
1256 {
"byte_order", endianName},
1257 {
"header_type",
"UInt64"},
1260 [&](
auto &out,
int level)
1263 out, level,
"UnstructuredGrid",
1265 [&](
auto &out,
int level)
1268 out, level,
"FieldData",
1270 [&](
auto &out,
int level)
1273 out, level,
"DataArray",
1274 {{
"type",
"Float64"},
1276 {
"NumberOfTuples",
"1"},
1277 {
"format",
"ascii"}},
1278 [&](
auto &out,
int level)
1280 out << std::setprecision(16);
1285 out, level,
"Piece",
1286 {{
"NumberOfPoints", std::to_string(nodeDedu2Old.size())},
1287 {
"NumberOfCells", std::to_string(nCell)}},
1288 [&](
auto &out,
int level)
1292 writeCoords(out, level);
1294 writeCells(out, level);
1296 writeCellData(out, level);
1298 writePointData(out, level);
1304 if (mpi.rank ==
mRank && flag == 1)
1306 WritePVTUMasterFile(
1307 fnameIN, outPath, endianName, seriesName, t, mpi.size,
1308 arraySiz, vecArraySiz, arraySizPoint, vecArraySizPoint,
1309 names, vectorNames, namesPoint, vectorNamesPoint,
1617 std::map<std::string, std::vector<cgsize_t>>
bocoLists;
1619 bocoLists.insert({name, std::vector<cgsize_t>()});
1620 for (
index iBnd = 0; iBnd < nBnd; iBnd++)
1623 std::string bcName = fbcid2name(this->bndElemInfo(iBnd, 0).zone);
1624 bocoLists[bcName].push_back(iBnd + nBndCellProcOffset + 1);
1626 std::vector<index> bocoListLengths(allNames.size());
1627 for (
size_t i = 0; i < allNames.size(); i++)
1628 bocoListLengths[i] = bocoLists[allNames[i]].size();
1629 std::vector<index> bocoListLengthsGlobal{bocoListLengths};
1632 this->AdjGlobal2LocalPrimary();
1637 std::filesystem::path outFile{fname};
1638 std::filesystem::create_directories(outFile.parent_path() /
".");
1646 std::array<cgsize_t, 3> zone_sizes{nNodeGlobal, nCellGlobal, 0};
1647 DNDS_CGNS_CALL_EXIT(cg_zone_write(cgns_file, iBase,
"Zone_0", zone_sizes.data(), Unstructured, &iZone));
1648 std::array<int, 3> iCoords;
1649 DNDS_CGNS_CALL_EXIT(cgp_coord_write(cgns_file, iBase, iZone, RealDouble,
"CoordinateX", &iCoords[0]));
1650 DNDS_CGNS_CALL_EXIT(cgp_coord_write(cgns_file, iBase, iZone, RealDouble,
"CoordinateY", &iCoords[1]));
1651 DNDS_CGNS_CALL_EXIT(cgp_coord_write(cgns_file, iBase, iZone, RealDouble,
"CoordinateZ", &iCoords[2]));
1652 std::array<cgsize_t, 1> rmin{nNodeProcOffset + 1};
1653 std::array<cgsize_t, 1> rmax{nNodeProcOffset + nNode};
1655 DNDS_CGNS_CALL_EXIT(cgp_coord_write_data(cgns_file, iBase, iZone, iCoords[0], rmin.data(), rmax.data(), coordsX.data()));
1656 DNDS_CGNS_CALL_EXIT(cgp_coord_write_data(cgns_file, iBase, iZone, iCoords[1], rmin.data(), rmax.data(), coordsY.data()));
1657 DNDS_CGNS_CALL_EXIT(cgp_coord_write_data(cgns_file, iBase, iZone, iCoords[2], rmin.data(), rmax.data(), coordsZ.data()));
1660 DNDS_CGNS_CALL_EXIT(cgp_poly_section_write(cgns_file, iBase, iZone,
"all_elements", ElementType_t::MIXED, 1, nCellGlobal + nBndGlobal,
1661 bndCellOffsetsGlobalMax, 0, &iSec));
1664 nBndCellProcOffset + 1, nBndCellProcOffset + nBndCell,
1665 elementPolyData.data(), bndCellOffsets.data()));
1667 static_assert(CGNS_VERSION >= 4500,
"Need at least CGNS 4.5.0");
1668 for (
size_t i = 0; i < allNames.size(); i++)
1669 if (bocoListLengthsGlobal[i] > 0)
1672 DNDS_CGNS_CALL_EXIT(cg_boco_write(cgns_file, iBase, iZone, allNames[i].data(), BCType_t::BCTypeNull, PointList,
1673 bocoListLengthsGlobal[i], NULL, &iBC));
1674 DNDS_CGNS_CALL_EXIT(cg_boco_gridlocation_write(cgns_file, iBase, iZone, iBC, this->dim == 3 ? GridLocation_t::FaceCenter : GridLocation_t::EdgeCenter));
1675 DNDS_CGNS_CALL_EXIT(cg_goto(cgns_file, iBase,
"Zone_t", iZone,
"ZoneBC_t", 1,
"BC_t", iBC,
"PointList", 0,
""));
1676 index nBCLocal = bocoListLengths[i];
1677 index nBCLocalProcOffSet{0};
1679 nBCLocalProcOffSet -= nBCLocal;
1680 DNDS_CGNS_CALL_EXIT(cgp_ptlist_write_data(cgns_file, nBCLocalProcOffSet + 1, nBCLocalProcOffSet + nBCLocal, bocoLists.at(allNames[i]).data()));
1683 if (cgp_close(cgns_file))