39#include <unordered_set>
41namespace berrc = boost::system::errc;
52 return PredefinedDataType::Native<int>();
148 bool sharedFilesystem)
149 :
FieldIO(pComm, sharedFilesystem)
176 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
177 std::vector<std::vector<NekDouble>> &fielddata,
181 std::stringstream prfx;
182 prfx <<
m_comm->GetRank() <<
": FieldIOHdf5::v_Write(): ";
183 double tm0 = 0.0, tm1 = 0.0;
185 if (
m_comm->GetRank() == 0)
199 ASSERTL1(fielddefs.size() == fielddata.size(),
200 prfx.str() +
"fielddefs and fielddata have incompatible lengths.");
202 size_t nFields = fielddefs.size();
203 size_t nMaxFields = nFields;
210 if (
m_comm->GetSpaceComm()->GetSize() > 1)
212 max_fields_comm =
m_comm->GetSpaceComm()->CommCreateIf(
213 (nFields == nMaxFields) ? 1 : 0);
217 max_fields_comm =
m_comm->GetSpaceComm();
222 int rank =
m_comm->GetSpaceComm()->GetRank();
225 amRoot = (rank == root_rank);
233 ASSERTL1(root_rank >= 0 && root_rank < m_comm->GetSpaceComm()->GetSize(),
234 prfx.str() +
"invalid root rank.");
236 std::vector<uint64_t> decomps(nMaxFields *
MAX_DCMPS, 0);
237 std::vector<uint64_t> all_hashes(
238 nMaxFields *
m_comm->GetSpaceComm()->GetSize(), 0);
239 std::vector<uint64_t> cnts(
MAX_CNTS, 0);
240 std::vector<std::string> fieldNames(nFields);
241 std::vector<std::string> shapeStrings(nFields);
242 std::vector<std::vector<NekDouble>> homoLengths(nFields);
243 std::vector<std::vector<unsigned int>> homoSIDs(nFields), homoYIDs(nFields),
245 std::vector<std::vector<unsigned int>> numModesPerDirVar(nFields);
246 std::vector<std::string> numModesPerDirUni(nFields);
251 for (
int f = 0; f < nFields; ++f)
253 if (!fielddefs[f]->m_uniOrder)
265 for (
int f = 0; f < nFields; ++f)
269 "fielddata vector must contain at least one value.");
270 ASSERTL1(fielddata[f].size() == fielddefs[f]->m_fields.size() *
272 prfx.str() +
"fielddata vector has invalid size.");
274 std::size_t nFieldElems = fielddefs[f]->m_elementIDs.size();
275 std::size_t nElemVals = fielddata[f].size();
284 std::stringstream hashStream;
285 std::size_t nSubFields = fielddefs[f]->m_fields.size();
286 for (
int sf = 0; sf < nSubFields; ++sf)
288 hashStream << fielddefs[f]->m_fields[sf];
291 nSubFields = fielddefs[f]->m_basis.size();
292 for (
int sf = 0; sf < nSubFields; ++sf)
294 hashStream << fielddefs[f]->m_basis[sf];
298 std::stringstream shapeStringStream;
299 shapeStringStream <<
ShapeTypeMap[fielddefs[f]->m_shapeType];
301 if (fielddefs[f]->m_numHomogeneousDir > 0)
305 homDim = fielddefs[f]->m_numHomogeneousDir;
308 ASSERTL1(homDim == fielddefs[f]->m_numHomogeneousDir,
309 "HDF5 does not support variable homogeneous directions in "
312 shapeStringStream <<
"-HomogenousExp"
313 << fielddefs[f]->m_numHomogeneousDir <<
"D";
316 if (fielddefs[f]->m_homoStrips)
318 shapeStringStream <<
"-Strips";
321 shapeStrings[f] = shapeStringStream.str();
322 hashStream << shapeStringStream.str();
325 if (fielddefs[f]->m_numHomogeneousDir)
327 nSubFields = fielddefs[f]->m_homogeneousLengths.size();
328 homoLengths[f].resize(nSubFields);
329 for (
int sf = 0; sf < nSubFields; ++sf)
331 NekDouble len = fielddefs[f]->m_homogeneousLengths[sf];
333 homoLengths[f][sf] = len;
336 nSubFields = fielddefs[f]->m_homogeneousYIDs.size();
339 homoYIDs[f].resize(nSubFields);
342 for (
int sf = 0; sf < nSubFields; ++sf)
344 homoYIDs[f][sf] = fielddefs[f]->m_homogeneousYIDs[sf];
348 nSubFields = fielddefs[f]->m_homogeneousZIDs.size();
351 homoZIDs[f].resize(nSubFields);
354 for (
int sf = 0; sf < nSubFields; ++sf)
356 homoZIDs[f][sf] = fielddefs[f]->m_homogeneousZIDs[sf];
360 nSubFields = fielddefs[f]->m_homogeneousSIDs.size();
363 homoSIDs[f].resize(nSubFields);
366 for (
int sf = 0; sf < nSubFields; ++sf)
368 homoSIDs[f][sf] = fielddefs[f]->m_homogeneousSIDs[sf];
373 if (fielddefs[f]->m_uniOrder)
375 std::vector<unsigned int> elemModes(fielddefs[f]->m_basis.size());
377 for (std::vector<int>::size_type i = 0;
378 i < fielddefs[f]->m_basis.size(); ++i)
380 elemModes[i] = fielddefs[f]->m_numModes[i];
385 for (std::vector<int>::size_type i = 0; i < nFieldElems; ++i)
387 std::copy(elemModes.begin(), elemModes.end(),
388 std::back_inserter(numModesPerDirVar[f]));
391 nFieldElems * elemModes.size();
396 std::stringstream numModesStringStream;
397 numModesStringStream <<
"UNIORDER:";
398 for (std::vector<int>::size_type i = 0; i < elemModes.size();
403 numModesStringStream <<
",";
405 numModesStringStream << elemModes[i];
408 numModesPerDirUni[f] = numModesStringStream.str();
409 hashStream << numModesPerDirUni[f];
414 numModesPerDirVar[f] = fielddefs[f]->m_numModes;
416 fielddefs[f]->m_numModes.size();
420 std::hash<std::string> string_hasher;
421 std::stringstream fieldNameStream;
422 uint64_t fieldDefHash = string_hasher(hashStream.str());
425 all_hashes[
m_comm->GetSpaceComm()->GetRank() * nMaxFields + f] =
428 fieldNameStream << fieldDefHash;
429 fieldNames[f] = fieldNameStream.str();
433 std::vector<uint64_t> all_cnts =
434 m_comm->GetSpaceComm()->Gather(root_rank, cnts);
435 std::vector<uint64_t> all_idxs(
m_comm->GetSpaceComm()->GetSize() *
MAX_IDXS,
437 std::vector<uint64_t> all_decomps =
438 m_comm->GetSpaceComm()->Gather(root_rank, decomps);
439 std::vector<uint64_t> all_dsetsize(
MAX_CNTS, 0);
445 ASSERTL1(outfile, prfx.str() +
"cannot create HDF5 file.");
447 ASSERTL1(root, prfx.str() +
"cannot create root group.");
456 std::size_t nTotElems = 0, nTotVals = 0, nTotOrder = 0;
457 std::size_t nTotHomY = 0, nTotHomZ = 0, nTotHomS = 0;
458 int nRanks =
m_comm->GetSpaceComm()->GetSize();
459 for (
int r = 0; r < nRanks; ++r)
489 root->CreateDataSet(
"DECOMPOSITION", decomps_type, decomps_space);
491 prfx.str() +
"cannot create DECOMPOSITION dataset.");
498 root->CreateDataSet(
"ELEMENTIDS", ids_type, ids_space);
499 ASSERTL1(ids_dset, prfx.str() +
"cannot create ELEMENTIDS dataset.");
506 root->CreateDataSet(
"DATA", data_type, data_space);
507 ASSERTL1(data_dset, prfx.str() +
"cannot create DATA dataset.");
516 root->CreateDataSet(
"HOMOGENEOUSYIDS", homy_type, homy_space);
518 prfx.str() +
"cannot create HOMOGENEOUSYIDS dataset.");
528 root->CreateDataSet(
"HOMOGENEOUSZIDS", homz_type, homz_space);
530 prfx.str() +
"cannot create HOMOGENEOUSZIDS dataset.");
540 root->CreateDataSet(
"HOMOGENEOUSSIDS", homs_type, homs_space);
542 prfx.str() +
"cannot create HOMOGENEOUSSIDS dataset.");
552 root->CreateDataSet(
"POLYORDERS", order_type, order_space);
554 prfx.str() +
"cannot create POLYORDERS dataset.");
558 m_comm->GetSpaceComm()->Bcast(all_dsetsize, root_rank);
569 std::set<uint64_t> hashToProc;
572 std::map<int, std::vector<uint64_t>> writingProcs;
577 for (
int n = 0; n <
m_comm->GetSpaceComm()->GetSize(); ++n)
579 for (
int i = 0; i < nMaxFields; ++i)
581 uint64_t hash = all_hashes[n * nMaxFields + i];
584 if (hashToProc.find(hash) != hashToProc.end() || hash == 0)
588 hashToProc.insert(hash);
589 writingProcs[n].push_back(hash);
594 for (
auto &sIt : writingProcs)
596 int rank = sIt.first;
599 if (
m_comm->GetSpaceComm()->GetRank() == rank)
607 ASSERTL1(outfile, prfx.str() +
"cannot open HDF5 file.");
609 ASSERTL1(root, prfx.str() +
"cannot open root group.");
613 for (
int i = 0; i < sIt.second.size(); ++i)
615 for (
int f = 0; f < nFields; ++f)
618 all_hashes[
m_comm->GetSpaceComm()->GetRank() *
621 hashToProc.find(sIt.second[i]) != hashToProc.end())
626 hashToProc.insert(sIt.second[i]);
630 root->CreateGroup(fieldNames[f]);
632 prfx.str() +
"cannot create field group.");
633 field_group->SetAttribute(
"FIELDS", fielddefs[f]->m_fields);
634 field_group->SetAttribute(
"BASIS", fielddefs[f]->m_basis);
635 field_group->SetAttribute(
"SHAPE", shapeStrings[f]);
637 if (homoLengths[f].size() > 0)
639 field_group->SetAttribute(
"HOMOGENEOUSLENGTHS",
649 field_group->SetAttribute(
"NUMMODESPERDIR",
650 numModesPerDirUni[f]);
654 std::string numModesPerDir =
"MIXORDER";
655 field_group->SetAttribute(
"NUMMODESPERDIR",
663 m_comm->GetSpaceComm()->Block();
675 ASSERTL1(outfile, prfx.str() +
"cannot open HDF5 file.");
677 ASSERTL1(root, prfx.str() +
"cannot open root group.");
682 prfx.str() +
"cannot open DECOMPOSITION dataset.");
686 prfx.str() +
"cannot open DECOMPOSITION filespace.");
688 decomps_fspace->SelectRange(0, all_decomps.size());
689 decomps_dset->Write(all_decomps, decomps_fspace, writeSR);
693 std::vector<uint64_t> idx =
694 m_comm->GetSpaceComm()->Scatter(root_rank, all_idxs);
705 if (
m_comm->GetSpaceComm()->GetSize() > 1)
709 parallelProps->SetMpio(
m_comm->GetSpaceComm());
712 writePL->SetDxMpioCollective();
718 ASSERTL1(outfile, prfx.str() +
"cannot open HDF5 file.");
720 ASSERTL1(root, prfx.str() +
"cannot open root group.");
722 m_comm->GetSpaceComm()->Block();
727 ASSERTL1(ids_dset, prfx.str() +
"cannot open ELEMENTIDS dataset.");
729 ASSERTL1(ids_fspace, prfx.str() +
"cannot open ELEMENTIDS filespace.");
733 ASSERTL1(data_dset, prfx.str() +
"cannot open DATA dataset.");
735 ASSERTL1(data_fspace, prfx.str() +
"cannot open DATA filespace.");
743 order_dset = root->OpenDataSet(
"POLYORDERS");
744 ASSERTL1(order_dset, prfx.str() +
"cannot open POLYORDERS dataset.");
745 order_fspace = order_dset->GetSpace();
747 prfx.str() +
"cannot open POLYORDERS filespace.");
752 homy_dset = root->OpenDataSet(
"HOMOGENEOUSYIDS");
754 prfx.str() +
"cannot open HOMOGENEOUSYIDS dataset.");
755 homy_fspace = homy_dset->GetSpace();
757 prfx.str() +
"cannot open HOMOGENEOUSYIDS filespace.");
762 homz_dset = root->OpenDataSet(
"HOMOGENEOUSZIDS");
764 prfx.str() +
"cannot open HOMOGENEOUSZIDS dataset.");
765 homz_fspace = homz_dset->GetSpace();
767 prfx.str() +
"cannot open HOMOGENEOUSZIDS filespace.");
772 homs_dset = root->OpenDataSet(
"HOMOGENEOUSSIDS");
774 prfx.str() +
"cannot open HOMOGENEOUSSIDS dataset.");
775 homs_fspace = homs_dset->GetSpace();
777 prfx.str() +
"cannot open HOMOGENEOUSSIDS filespace.");
781 for (
int f = 0; f < nFields; ++f)
784 std::size_t nFieldElems = fielddefs[f]->m_elementIDs.size();
785 ids_fspace->SelectRange(ids_i, nFieldElems);
786 ids_dset->Write(fielddefs[f]->m_elementIDs, ids_fspace, writePL);
787 ids_i += nFieldElems;
790 std::size_t nFieldVals = fielddata[f].size();
791 data_fspace->SelectRange(data_i, nFieldVals);
792 data_dset->Write(fielddata[f], data_fspace, writePL);
793 data_i += nFieldVals;
798 for (
int f = 0; f < nFields; ++f)
800 std::size_t nOrders = numModesPerDirVar[f].size();
801 order_fspace->SelectRange(order_i, nOrders);
802 order_dset->Write(numModesPerDirVar[f], order_fspace, writePL);
809 for (
int f = 0; f < nFields; ++f)
811 std::size_t nYIDs = homoYIDs[f].size();
812 homy_fspace->SelectRange(homy_i, nYIDs);
813 homy_dset->Write(homoYIDs[f], homy_fspace, writePL);
820 for (
int f = 0; f < nFields; ++f)
822 std::size_t nZIDs = homoZIDs[f].size();
823 homz_fspace->SelectRange(homz_i, nZIDs);
824 homz_dset->Write(homoZIDs[f], homz_fspace, writePL);
831 for (
int f = 0; f < nFields; ++f)
833 std::size_t nSIDs = homoSIDs[f].size();
834 homs_fspace->SelectRange(homs_i, nSIDs);
835 homs_dset->Write(homoSIDs[f], homs_fspace, writePL);
840 for (
int f = nFields; f < nMaxFields; ++f)
845 ids_dset->Write(fielddefs[nFields - 1]->m_elementIDs, ids_fspace,
847 data_dset->Write(fielddata[nFields - 1], data_fspace, writePL);
851 order_dset->Write(numModesPerDirVar[nFields - 1], order_fspace,
857 homy_dset->Write(homoYIDs[nFields - 1], homy_fspace, writePL);
862 homz_dset->Write(homoZIDs[nFields - 1], homz_fspace, writePL);
867 homs_dset->Write(homoSIDs[nFields - 1], homs_fspace, writePL);
871 m_comm->GetSpaceComm()->Block();
874 if (
m_comm->GetRank() == 0)
877 std::cout <<
" (" << tm1 - tm0 <<
"s, HDF5)" << std::endl;
894 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
895 std::vector<std::vector<NekDouble>> &fielddata,
899 std::stringstream prfx;
900 int nRanks =
m_comm->GetSpaceComm()->GetSize();
911 parallelProps->SetMpio(
m_comm->GetSpaceComm());
914 readPL->SetDxMpioCollective();
916 readPLInd->SetDxMpioIndependent();
924 std::static_pointer_cast<H5DataSource>(dataSource);
925 ASSERTL1(h5, prfx.str() +
"cannot open HDF5 file.");
927 ASSERTL1(root, prfx.str() +
"cannot open root group.");
930 unsigned int formatVersion;
933 for (; attrIt != attrEnd; ++attrIt)
935 if (*attrIt ==
"FORMAT_VERSION")
942 "Unable to determine Nektar++ HDF5 file version");
943 root->GetAttribute(
"FORMAT_VERSION", formatVersion);
946 "File format if " + infilename +
947 " is higher than supported in "
948 "this version of Nektar++");
952 ASSERTL1(decomps_dset, prfx.str() +
"cannot open DECOMPOSITION dataset.");
955 ASSERTL1(ids_dset, prfx.str() +
"cannot open ELEMENTIDS dataset.");
958 ASSERTL1(data_dset, prfx.str() +
"cannot open DATA dataset.");
963 prfx.str() +
"cannot open DECOMPOSITION filespace.");
966 ASSERTL1(ids_fspace, prfx.str() +
"cannot open ELEMENTIDS filespace.");
969 ASSERTL1(data_fspace, prfx.str() +
"cannot open DATA filespace.");
972 std::vector<uint64_t> ids;
974 ids_dset->Read(ids, ids_fspace, readPL);
976 std::unordered_set<uint64_t> toread;
979 for (uint64_t i = 0; i < ElementIDs.size(); ++i)
981 toread.insert(ElementIDs[i]);
985 std::vector<uint64_t> decomps;
986 decomps_dset->Read(decomps, decomps_fspace, readPL);
988 size_t nDecomps = decomps.size() /
MAX_DCMPS;
989 size_t cnt = 0, cnt2 = 0;
992 std::vector<OffsetHelper> decompsToOffsets(nDecomps);
996 std::map<uint64_t, std::vector<unsigned int>> groupsToElmts;
999 std::map<uint64_t, std::set<uint64_t>> groupsToDecomps;
1002 bool selective = toread.size() > 0;
1007 for (
size_t i = 0; i < nDecomps; ++i, cnt +=
MAX_DCMPS)
1012 std::vector<uint64_t> tmp;
1016 for (
size_t j = 0; j < nElmt; ++j)
1018 uint64_t elmtId = ids[cnt2 + j];
1019 if (toread.find(elmtId) != toread.end())
1021 tmp.push_back(elmtId);
1027 tmp.insert(tmp.begin(), ids.begin() + cnt2,
1028 ids.begin() + cnt2 + nElmt);
1031 std::vector<unsigned int> tmp2(nElmt);
1032 for (
size_t j = 0; j < nElmt; ++j)
1034 tmp2[j] = ids[cnt2 + j];
1041 groupsToDecomps[groupHash].insert(i);
1044 groupsToElmts[i] = tmp2;
1045 decompsToOffsets[i] = running;
1054 for (
auto &gIt : groupsToDecomps)
1057 for (
auto &sIt : gIt.second)
1059 std::stringstream fieldNameStream;
1060 fieldNameStream << gIt.first;
1064 ImportFieldDef(readPLInd, root, decomps, sIt, decompsToOffsets[sIt],
1065 fieldNameStream.str(), fielddef);
1067 fielddef->m_elementIDs = groupsToElmts[sIt];
1068 fielddefs.push_back(fielddef);
1072 std::vector<NekDouble> decompFieldData;
1074 decompsToOffsets[sIt].data, decomps, sIt,
1075 fielddef, decompFieldData);
1076 fielddata.push_back(decompFieldData);
1082 m_comm->GetSpaceComm()->Block();
1095 std::vector<uint64_t> &decomps,
1100 std::stringstream prfx;
1101 prfx <<
m_comm->GetRank() <<
": FieldIOHdf5::ImportFieldDefsHdf5(): ";
1104 ASSERTL1(field, prfx.str() +
"cannot open field group, " + group +
'.');
1106 def->m_uniOrder =
false;
1110 for (; attrIt != attrEnd; ++attrIt)
1112 const std::string &attrName = *attrIt;
1113 if (attrName ==
"FIELDS")
1115 field->GetAttribute(attrName, def->m_fields);
1117 else if (attrName ==
"SHAPE")
1119 std::string shapeString;
1120 field->GetAttribute(attrName, shapeString);
1126 if (shapeString.find(
"Strips") != std::string::npos)
1128 def->m_homoStrips =
true;
1131 if ((
loc = shapeString.find_first_of(
"-")) != std::string::npos)
1133 if (shapeString.find(
"Exp1D") != std::string::npos)
1135 def->m_numHomogeneousDir = 1;
1139 def->m_numHomogeneousDir = 2;
1142 shapeString.erase(
loc, shapeString.length());
1160 std::string(
"unable to correctly parse the shape type: ")
1161 .append(shapeString)
1164 else if (attrName ==
"BASIS")
1166 field->GetAttribute(attrName, def->m_basis);
1168 for (
auto &bIt : def->m_basis)
1173 "unable to correctly parse the basis types.");
1176 else if (attrName ==
"HOMOGENEOUSLENGTHS")
1178 field->GetAttribute(attrName, def->m_homogeneousLengths);
1180 else if (attrName ==
"NUMMODESPERDIR")
1182 std::string numModesPerDir;
1183 field->GetAttribute(attrName, numModesPerDir);
1185 if (strstr(numModesPerDir.c_str(),
"UNIORDER:"))
1187 def->m_uniOrder =
true;
1189 numModesPerDir.substr(9), def->m_numModes);
1192 "unable to correctly parse the number of modes.");
1195 else if (attrName ==
"POINTSTYPE")
1197 std::string pointsString;
1198 field->GetAttribute(attrName, pointsString);
1199 def->m_pointsDef =
true;
1201 std::vector<std::string> pointsStrings;
1205 "unable to correctly parse the points types.");
1206 for (std::vector<std::string>::size_type i = 0;
1207 i < pointsStrings.size(); i++)
1223 "unable to correctly parse the points type: ")
1224 .append(pointsStrings[i])
1228 else if (attrName ==
"NUMPOINTSPERDIR")
1230 std::string numPointsPerDir;
1231 field->GetAttribute(attrName, numPointsPerDir);
1232 def->m_numPointsDef =
true;
1238 "unable to correctly parse the number of points.");
1242 std::string errstr(
"unknown attribute: ");
1244 ASSERTL1(
false, prfx.str() + errstr.c_str());
1248 if (def->m_numHomogeneousDir >= 1)
1253 homz_fspace->SelectRange(offset.
homz, dsize);
1254 homz_dset->Read(def->m_homogeneousZIDs, homz_fspace, readPL);
1257 if (def->m_numHomogeneousDir >= 2)
1262 homy_fspace->SelectRange(offset.
homy, dsize);
1263 homy_dset->Read(def->m_homogeneousYIDs, homy_fspace, readPL);
1266 if (def->m_homoStrips)
1271 homs_fspace->SelectRange(offset.
homs, dsize);
1272 homs_dset->Read(def->m_homogeneousSIDs, homs_fspace, readPL);
1275 if (!def->m_uniOrder)
1280 order_fspace->SelectRange(offset.
order, dsize);
1281 order_dset->Read(def->m_numModes, order_fspace, readPL);
1300 std::vector<uint64_t> &decomps, uint64_t decomp,
1303 std::stringstream prfx;
1304 prfx <<
m_comm->GetRank() <<
": FieldIOHdf5::ImportFieldData(): ";
1307 uint64_t nFieldVals = nElemVals;
1309 data_fspace->SelectRange(data_i, nFieldVals);
1310 data_dset->Read(fielddata, data_fspace, readPL);
1312 ASSERTL0(fielddata.size() == datasize * fielddef->m_fields.size(),
1314 "input data is not the same length as header information.");
1349 std::static_pointer_cast<H5DataSource>(dataSource);
1358 pEnd = metadata->attr_end();
1359 for (; param != pEnd; ++param)
1361 std::string paramString = *param;
1362 if (paramString !=
"Provenance")
1364 std::string paramBodyStr;
1365 metadata->GetAttribute(paramString, paramBodyStr);
1366 fieldmetadatamap[paramString] = paramBodyStr;
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
void ImportFieldData(H5::PListSharedPtr readPL, H5::DataSetSharedPtr data_dset, H5::DataSpaceSharedPtr data_fspace, uint64_t data_i, std::vector< uint64_t > &decomps, uint64_t decomp, const FieldDefinitionsSharedPtr fielddef, std::vector< NekDouble > &fielddata)
Import the field data from the HDF5 document.
static const unsigned int ELEM_CNT_IDX
A helper for FieldIOHdf5::v_Write. Describes the position of the number of elements in the cnt array.
static FieldIOSharedPtr create(LibUtilities::CommSharedPtr pComm, bool sharedFilesystem)
Creates an instance of this class.
static const unsigned int MAX_CNTS
A helper for FieldIOHdf5::v_Write. Describes the maximum number of items in the cnt array per field d...
virtual DataSourceSharedPtr v_ImportFieldMetaData(const std::string &filename, FieldMetaDataMap &fieldmetadatamap) override
Import field metadata from filename and return the data source which wraps filename.
virtual const std::string & v_GetClassName() const override
Get class name.
virtual void v_Write(const std::string &outFile, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, const FieldMetaDataMap &fieldinfomap=NullFieldMetaDataMap, const bool backup=false) override
Write a HDF5 file to outFile given the field definitions fielddefs, field data fielddata and metadata...
static const unsigned int HOMY_CNT_IDX
A helper for FieldIOHdf5::v_Write. Describes the position of the number of homogeneous y-planes in th...
static std::string className
Name of class.
static const unsigned int ORDER_DCMP_IDX
A helper for FieldIOHdf5::v_Write and FieldIOHdf5::v_Import. Describes the position of the number of ...
static const unsigned int HOMZ_CNT_IDX
A helper for FieldIOHdf5::v_Write. Describes the position of the number of homogeneous z-planes in th...
static const unsigned int FORMAT_VERSION
Version of the Nektar++ HDF5 format, which is embedded into the main NEKTAR group as an attribute.
static const unsigned int HASH_DCMP_IDX
The hash of the field definition information, which defines the name of the attribute containing the ...
static const unsigned int HOMS_CNT_IDX
A helper for FieldIOHdf5::v_Write. Describes the position of the number of homogeneous strips in the ...
static const unsigned int VAL_CNT_IDX
A helper for FieldIOHdf5::v_Write. Describes the position of the number of data points in the cnt arr...
static const unsigned int IDS_IDX_IDX
A helper for FieldIOHdf5::v_Write. Describes the position of the element IDs within the indexing set.
static const unsigned int HOMS_DCMP_IDX
A helper for FieldIOHdf5::v_Write and FieldIOHdf5::v_Import. Describes the position of the number of ...
static const unsigned int ELEM_DCMP_IDX
A helper for FieldIOHdf5::v_Write and FieldIOHdf5::v_Import. Describes the position of the number of ...
static const unsigned int ORDER_CNT_IDX
A helper for FieldIOHdf5::v_Write. Describes the position of the number of order points in the cnt ar...
void ImportFieldDef(H5::PListSharedPtr readPL, H5::GroupSharedPtr root, std::vector< uint64_t > &decomps, uint64_t decomp, OffsetHelper offset, std::string group, FieldDefinitionsSharedPtr def)
Import field definitions from a HDF5 document.
static const unsigned int ORDER_IDX_IDX
A helper for FieldIOHdf5::v_Write. Describes the position of the element order within the indexing se...
static const unsigned int HOMZ_DCMP_IDX
A helper for FieldIOHdf5::v_Write and FieldIOHdf5::v_Import. Describes the position of the number of ...
static const unsigned int MAX_DCMPS
A helper for FieldIOHdf5::v_Write. Describes the maximum number of items in the decomposition per fie...
FieldIOHdf5(LibUtilities::CommSharedPtr pComm, bool sharedFilesystem)
Construct the FieldIO object for HDF5 output.
static const unsigned int MAX_IDXS
A helper for FieldIOHdf5::v_Write. Describes the maximum number of items in the indexing set.
virtual void v_Import(const std::string &infilename, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata=NullVectorNekDoubleVector, FieldMetaDataMap &fieldinfomap=NullFieldMetaDataMap, const Array< OneD, int > &ElementIDs=NullInt1DArray) override
Import a HDF5 format file.
static const unsigned int VAL_DCMP_IDX
A helper for FieldIOHdf5::v_Write and FieldIOHdf5::v_Import. Describes the position of the number of ...
static const unsigned int DATA_IDX_IDX
A helper for FieldIOHdf5::v_Write. Describes the position of the data size within the indexing set.
void ImportHDF5FieldMetaData(DataSourceSharedPtr dataSource, FieldMetaDataMap &fieldmetadatamap)
Import field metadata from dataSource.
static const unsigned int HOMS_IDX_IDX
A helper for FieldIOHdf5::v_Write. Describes the position of the number of homogeneous strips within ...
static const unsigned int HOMY_DCMP_IDX
A helper for FieldIOHdf5::v_Write and FieldIOHdf5::v_Import. Describes the position of the number of ...
static const unsigned int HOMZ_IDX_IDX
A helper for FieldIOHdf5::v_Write. Describes the position of the number of z-planes within the indexi...
static const unsigned int HOMY_IDX_IDX
A helper for FieldIOHdf5::v_Write. Describes the position of the number of y-planes within the indexi...
Class for operating on Nektar++ input/output files.
int CheckFieldDefinition(const FieldDefinitionsSharedPtr &fielddefs)
Check field definitions for correctness and return storage size.
std::string SetUpOutput(const std::string outname, bool perRank, bool backup=false)
Set up the filesystem ready for output.
LibUtilities::CommSharedPtr m_comm
Communicator to use when writing parallel format.
static void AddInfoTag(TagWriterSharedPtr root, const FieldMetaDataMap &fieldmetadatamap)
Add provenance information to the field metadata map.
static DataSpaceSharedPtr OneD(hsize_t size)
static DataTypeSharedPtr OfObject(const T &obj)
static FileSharedPtr Open(const std::string &filename, unsigned mode, PListSharedPtr accessPL=PList::Default())
static FileSharedPtr Create(const std::string &filename, unsigned mode, PListSharedPtr createPL=PList::Default(), PListSharedPtr accessPL=PList::Default())
static PListSharedPtr DatasetXfer()
Properties for raw data transfer.
static PListSharedPtr FileAccess()
Properties for file access.
static PListSharedPtr Default()
Default options.
static DataSourceSharedPtr create(const std::string &fn, H5::PListSharedPtr parallelProps)
Static constructor for this data source.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
std::shared_ptr< DataSpace > DataSpaceSharedPtr
std::shared_ptr< PList > PListSharedPtr
std::shared_ptr< File > FileSharedPtr
std::shared_ptr< DataType > DataTypeSharedPtr
std::shared_ptr< Group > GroupSharedPtr
std::shared_ptr< DataSet > DataSetSharedPtr
const char *const ShapeTypeMap[SIZE_ShapeType]
std::shared_ptr< TagWriter > TagWriterSharedPtr
std::shared_ptr< H5DataSource > H5DataSourceSharedPtr
std::shared_ptr< DataSource > DataSourceSharedPtr
std::map< std::string, std::string > FieldMetaDataMap
const std::string kPointsTypeStr[]
static std::vector< std::vector< NekDouble > > NullVectorNekDoubleVector
std::shared_ptr< FieldDefinitions > FieldDefinitionsSharedPtr
FieldIOFactory & GetFieldIOFactory()
Returns the FieldIO factory.
@ SIZE_PointsType
Length of enum list.
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
@ SIZE_BasisType
Length of enum list.
The above copyright notice and this permission notice shall be included.
static Array< OneD, int > NullInt1DArray
static DataTypeSharedPtr GetType()