40 #include <lifev/fsi_blocks/filter/DOFInterfaceIO.hpp> 48 DOFInterfaceIO::DOFInterfaceIO (
const std::string& fileName,
49 const commPtr_Type& comm) :
53 M_myRank = M_comm->MyPID();
56 void DOFInterfaceIO::write (
const interfaceVectorPtr_Type& interfaces)
58 M_HDF5IO.openFile (M_fileName, M_comm,
false);
60 const UInt numParts = interfaces->size();
61 std::vector<UInt> sizes (numParts, 0);
64 for (UInt i = 0; i < numParts; ++i)
66 interface_Type& curIf = * (interfaces->at (i) );
67 UInt curSize = curIf.localDofMap().size();
69 if (maxPoints < curSize)
75 hsize_t sizeSpaceDims[2] = {numParts, 1};
76 hsize_t sizeCount[2] = {1, 1};
78 hsize_t currentSpaceDims[2];
79 hsize_t currentCount[2];
80 currentSpaceDims[0] = numParts;
81 currentSpaceDims[1] = maxPoints;
83 currentCount[1] = currentSpaceDims[1];
86 M_HDF5IO.createTable (
"Sizes", H5T_STD_U32BE, sizeSpaceDims);
88 M_HDF5IO.createTable (
"Keys", H5T_STD_U32BE, currentSpaceDims);
89 M_HDF5IO.createTable (
"Values", H5T_STD_U32BE, currentSpaceDims);
91 M_keyBuffer.resize (currentCount[0] * currentCount[1], 0);
92 M_valueBuffer.resize (currentCount[0] * currentCount[1], 0);
94 for (UInt i = 0; i < numParts; ++i)
96 const std::map<UInt, UInt>& curMap =
97 interfaces->at (i)->localDofMap();
99 for (std::map<UInt, UInt>::const_iterator it = curMap.begin();
100 it != curMap.end(); ++it)
102 M_keyBuffer[j] = it->first;
103 M_valueBuffer[j] = it->second;
107 hsize_t sizeOffset[2] = {i, 0};
108 M_HDF5IO.write (
"Sizes", H5T_NATIVE_UINT, sizeCount,
109 sizeOffset, &sizes[i]);
111 hsize_t currentOffset[2] = {i* currentCount[0], 0};
112 M_HDF5IO.write (
"Keys", H5T_NATIVE_UINT, currentCount,
113 currentOffset, &M_keyBuffer[0]);
114 M_HDF5IO.write (
"Values", H5T_NATIVE_UINT, currentCount,
115 currentOffset, &M_valueBuffer[0]);
118 M_HDF5IO.closeTable (
"Sizes");
119 M_HDF5IO.closeTable (
"Keys");
120 M_HDF5IO.closeTable (
"Values");
122 M_HDF5IO.closeFile();
124 M_keyBuffer.resize (0);
125 M_valueBuffer.resize (0);
128 void DOFInterfaceIO::read (dofMapPtr_Type& interface)
130 interface.reset (
new dofMap_Type() );
132 M_HDF5IO.openFile (M_fileName, M_comm,
true);
134 hsize_t sizeSpaceDims[2];
136 M_HDF5IO.openTable (
"Sizes", sizeSpaceDims);
139 hsize_t sizeCount[2] = {1, 1};
140 hsize_t sizeOffset[2] = {M_myRank, 0};
141 M_HDF5IO.read (
"Sizes", H5T_NATIVE_UINT, sizeCount, sizeOffset,
144 M_HDF5IO.closeTable (
"Sizes");
146 hsize_t currentSpaceDims[2];
147 hsize_t currentCount[2];
148 hsize_t currentOffset[2];
150 M_HDF5IO.openTable (
"Keys", currentSpaceDims);
151 M_HDF5IO.openTable (
"Values", currentSpaceDims);
154 currentCount[1] = currentSpaceDims[1];
155 currentOffset[0] = currentCount[0] * M_myRank;
156 currentOffset[1] = 0;
158 M_keyBuffer.resize (currentCount[0] * currentCount[1], 0);
159 M_valueBuffer.resize (currentCount[0] * currentCount[1], 0);
161 M_HDF5IO.read (
"Keys", H5T_NATIVE_UINT, currentCount, currentOffset,
163 M_HDF5IO.read (
"Values", H5T_NATIVE_UINT, currentCount, currentOffset,
166 M_HDF5IO.closeTable (
"Keys");
167 M_HDF5IO.closeTable (
"Values");
169 M_HDF5IO.closeFile();
171 for (UInt i = 0; i < mySize; ++i)
173 interface->insert (std::make_pair (M_keyBuffer[i], M_valueBuffer[i]) );
176 M_keyBuffer.resize (0);
177 M_valueBuffer.resize (0);