36 #ifndef PARTITION_IO_H_ 37 #define PARTITION_IO_H_ 41 #include <Epetra_config.h> 43 #include<lifev/core/LifeV.hpp> 48 #include <Epetra_MpiComm.h> 50 #include <lifev/core/filter/HDF5IO.hpp> 138 template<
typename MeshType>
144 typedef MeshType mesh_Type;
145 typedef std::shared_ptr<mesh_Type> meshPtr_Type;
146 typedef std::vector<meshPtr_Type> meshParts_Type;
147 typedef std::shared_ptr<meshParts_Type> meshPartsPtr_Type;
152 typedef std::shared_ptr<Epetra_MpiComm> commPtr_Type;
170 PartitionIO (
const std::string& fileName,
171 const commPtr_Type& comm,
172 const bool transposeInFile =
false);
175 virtual ~PartitionIO() {}
190 void setup (
const std::string& fileName,
191 const commPtr_Type& comm,
192 const bool transposeInFile =
false);
200 void write (
const meshPartsPtr_Type& meshParts);
209 void read (meshPtr_Type& meshPart);
214 PartitionIO (
const PartitionIO&);
215 PartitionIO& operator= (
const PartitionIO&);
224 void writeElements();
237 std::string M_fileName;
238 bool M_transposeInFile;
239 meshPartsPtr_Type M_meshPartsOut;
240 meshPtr_Type M_meshPartIn;
247 UInt M_maxNumElements;
257 std::vector<UInt> M_uintBuffer;
258 std::vector<Real> M_realBuffer;
262 template<
typename MeshType>
263 inline PartitionIO<MeshType>::PartitionIO (
const std::string& fileName,
264 const commPtr_Type& comm,
265 const bool transposeInFile) :
267 M_fileName (fileName),
268 M_transposeInFile (transposeInFile),
274 M_elementNodes = MeshType::elementShape_Type::S_numPoints;
275 M_faceNodes = MeshType::elementShape_Type::GeoBShape::S_numPoints;
277 M_myRank = M_comm->MyPID();
280 template<
typename MeshType>
281 inline void PartitionIO<MeshType>::setup (
const std::string& fileName,
282 const commPtr_Type& comm,
283 const bool transposeInFile)
286 M_fileName = fileName;
287 M_transposeInFile = transposeInFile;
291 M_maxNumElements = 0;
293 M_elementNodes = MeshType::elementShape_Type::S_numPoints;
294 M_faceNodes = MeshType::elementShape_Type::GeoBShape::S_numPoints;
297 template<
typename MeshType>
298 void PartitionIO<MeshType>::write (
const meshPartsPtr_Type& meshParts)
300 M_meshPartsOut = meshParts;
301 M_numParts = M_meshPartsOut->size();
303 M_HDF5IO.openFile (M_fileName, M_comm,
false);
309 M_HDF5IO.closeFile();
311 M_meshPartsOut.reset();
314 template<
typename MeshType>
315 void PartitionIO<MeshType>::read (meshPtr_Type& meshPart)
318 M_meshPartIn.reset (
new mesh_Type);
320 M_HDF5IO.openFile (M_fileName, M_comm,
true);
326 M_HDF5IO.closeFile();
328 meshPart = M_meshPartIn;
329 M_meshPartIn.reset();
332 template<
typename MeshType>
333 void PartitionIO<MeshType>::writeStats()
337 hsize_t currentSpaceDims[2];
338 hsize_t currentCount[2];
339 if (! M_transposeInFile)
341 currentSpaceDims[0] = M_numParts;
342 currentSpaceDims[1] = 15;
344 currentCount[1] = currentSpaceDims[1];
348 currentSpaceDims[0] = 15;
349 currentSpaceDims[1] = M_numParts;
350 currentCount[0] = currentSpaceDims[0];
355 M_HDF5IO.createTable (
"stats", H5T_STD_U32BE, currentSpaceDims);
358 M_uintBuffer.resize (15);
359 for (UInt i = 0; i < M_numParts; ++i)
361 mesh_Type& currentPart = (* (*M_meshPartsOut) [i]);
362 M_uintBuffer[0] = M_numParts;
366 M_uintBuffer[2] = currentPart.numPoints();
367 if (M_uintBuffer[2] > M_maxNumPoints)
369 M_maxNumPoints = M_uintBuffer[2];
371 M_uintBuffer[3] = currentPart.numBPoints();
372 M_uintBuffer[4] = currentPart.numVertices();
373 M_uintBuffer[5] = currentPart.numBVertices();
374 M_uintBuffer[6] = currentPart.numGlobalVertices();
375 M_uintBuffer[7] = currentPart.numEdges();
376 if (M_uintBuffer[7] > M_maxNumEdges)
378 M_maxNumEdges = M_uintBuffer[7];
380 M_uintBuffer[8] = currentPart.numBEdges();
381 M_uintBuffer[9] = currentPart.numGlobalEdges();
382 M_uintBuffer[10] = currentPart.numFaces();
383 if (M_uintBuffer[10] > M_maxNumFaces)
385 M_maxNumFaces = M_uintBuffer[10];
387 M_uintBuffer[11] = currentPart.numBFaces();
388 M_uintBuffer[12] = currentPart.numGlobalFaces();
389 M_uintBuffer[13] = currentPart.numVolumes();
390 if (M_uintBuffer[13] > M_maxNumElements)
392 M_maxNumElements = M_uintBuffer[13];
394 M_uintBuffer[14] = currentPart.numGlobalVolumes();
396 hsize_t currentOffset[2];
397 if (! M_transposeInFile)
399 currentOffset[0] = i;
400 currentOffset[1] = 0;
404 currentOffset[0] = 0;
405 currentOffset[1] = i;
407 M_HDF5IO.write (
"stats", H5T_NATIVE_UINT, currentCount, currentOffset,
411 M_HDF5IO.closeTable (
"stats");
414 template<
typename MeshType>
415 void PartitionIO<MeshType>::writePoints()
420 hsize_t currentSpaceDims[2];
421 hsize_t currentCount[2];
422 if (! M_transposeInFile)
424 currentSpaceDims[0] = 3 * M_numParts;
425 currentSpaceDims[1] = M_maxNumPoints;
427 currentCount[1] = currentSpaceDims[1];
431 currentSpaceDims[0] = M_maxNumPoints;
432 currentSpaceDims[1] = 3 * M_numParts;
433 currentCount[0] = currentSpaceDims[0];
437 M_HDF5IO.createTable (
"point_ids", H5T_STD_U32BE, currentSpaceDims);
438 M_HDF5IO.createTable (
"point_coords", H5T_IEEE_F64BE, currentSpaceDims);
441 M_uintBuffer.resize (currentCount[0] * currentCount[1], 0);
442 M_realBuffer.resize (currentCount[0] * currentCount[1], 0);
443 UInt stride = currentCount[1];
444 if (! M_transposeInFile)
446 for (UInt i = 0; i < M_numParts; ++i)
448 mesh_Type& currentPart = (* (*M_meshPartsOut) [i]);
449 for (UInt j = 0; j < currentPart.numPoints(); ++j)
451 M_uintBuffer[j] = currentPart.pointList[j].markerID();
452 M_uintBuffer[stride + j] = currentPart.point (j).id();
453 M_uintBuffer[2 * stride + j] =
454 static_cast<
int> (currentPart.pointList[j].flag() );
455 M_realBuffer[j] = currentPart.pointList[j].x();
456 M_realBuffer[stride + j] = currentPart.pointList[j].y();
457 M_realBuffer[2 * stride + j] = currentPart.pointList[j].z();
460 hsize_t currentOffset[2] = {i* currentCount[0], 0};
461 M_HDF5IO.write (
"point_ids", H5T_NATIVE_UINT, currentCount,
462 currentOffset, &M_uintBuffer[0]);
463 M_HDF5IO.write (
"point_coords", H5T_NATIVE_DOUBLE, currentCount,
464 currentOffset, &M_realBuffer[0]);
469 for (UInt i = 0; i < M_numParts; ++i)
471 mesh_Type& currentPart = (* (*M_meshPartsOut) [i]);
472 for (UInt j = 0; j < currentPart.numPoints(); ++j)
474 M_uintBuffer[stride * j] = currentPart.pointList[j].markerID();
475 M_uintBuffer[stride * j + 1] = currentPart.point (j).id();
476 M_uintBuffer[stride * j + 2] =
477 static_cast<
int> (currentPart.pointList[j].flag() );
478 M_realBuffer[stride * j] = currentPart.pointList[j].x();
479 M_realBuffer[stride * j + 1] = currentPart.pointList[j].y();
480 M_realBuffer[stride * j + 2] = currentPart.pointList[j].z();
483 hsize_t currentOffset[2] = {0, i* currentCount[1]};
484 M_HDF5IO.write (
"point_ids", H5T_NATIVE_UINT, currentCount,
485 currentOffset, &M_uintBuffer[0]);
486 M_HDF5IO.write (
"point_coords", H5T_NATIVE_DOUBLE, currentCount,
487 currentOffset, &M_realBuffer[0]);
490 M_realBuffer.resize (0);
492 M_HDF5IO.closeTable (
"point_ids");
493 M_HDF5IO.closeTable (
"point_coords");
496 template<
typename MeshType>
497 void PartitionIO<MeshType>::writeEdges()
501 hsize_t currentSpaceDims[2];
502 hsize_t currentCount[2];
503 if (! M_transposeInFile)
505 currentSpaceDims[0] = 5 * M_numParts;
506 currentSpaceDims[1] = M_maxNumEdges;
508 currentCount[1] = currentSpaceDims[1];
512 currentSpaceDims[0] = M_maxNumEdges;
513 currentSpaceDims[1] = 5 * M_numParts;
514 currentCount[0] = currentSpaceDims[0];
518 M_HDF5IO.createTable (
"edges", H5T_STD_U32BE, currentSpaceDims);
521 M_uintBuffer.resize (currentCount[0] * currentCount[1], 0);
522 UInt stride = currentCount[1];
523 if (! M_transposeInFile)
525 for (UInt i = 0; i < M_numParts; ++i)
527 mesh_Type& currentPart = (* (*M_meshPartsOut) [i]);
528 for (UInt j = 0; j < currentPart.numEdges(); ++j)
530 M_uintBuffer[j] = currentPart.edgeList[j].point (0).localId();
531 M_uintBuffer[stride + j] =
532 currentPart.edgeList[j].point (1).localId();
533 M_uintBuffer[2 * stride + j] =
534 currentPart.edgeList[j].markerID();
535 M_uintBuffer[3 * stride + j] = currentPart.edgeList[j].id();
536 M_uintBuffer[4 * stride + j] =
537 static_cast<
int> (currentPart.edgeList[j].flag() );
540 hsize_t currentOffset[2] = {i* currentCount[0], 0};
541 M_HDF5IO.write (
"edges", H5T_NATIVE_UINT, currentCount,
542 currentOffset, &M_uintBuffer[0]);
547 for (UInt i = 0; i < M_numParts; ++i)
549 mesh_Type& currentPart = (* (*M_meshPartsOut) [i]);
550 for (UInt j = 0; j < currentPart.numEdges(); ++j)
552 M_uintBuffer[stride * j] =
553 currentPart.edgeList[j].point (0).localId();
554 M_uintBuffer[stride * j + 1] =
555 currentPart.edgeList[j].point (1).localId();
556 M_uintBuffer[stride * j + 2] =
557 currentPart.edgeList[j].markerID();
558 M_uintBuffer[stride * j + 3] = currentPart.edgeList[j].id();
559 M_uintBuffer[stride * j + 4] =
560 static_cast<
int> (currentPart.edgeList[j].flag() );
563 hsize_t currentOffset[2] = {0, i* currentCount[1]};
564 M_HDF5IO.write (
"edges", H5T_NATIVE_UINT, currentCount,
565 currentOffset, &M_uintBuffer[0]);
569 M_HDF5IO.closeTable (
"edges");
572 template<
typename MeshType>
573 void PartitionIO<MeshType>::writeFaces()
577 hsize_t currentSpaceDims[2];
578 hsize_t currentCount[2];
579 if (! M_transposeInFile)
581 currentSpaceDims[0] = (7 + M_faceNodes) * M_numParts;
582 currentSpaceDims[1] = M_maxNumFaces;
583 currentCount[0] = 7 + M_faceNodes;
584 currentCount[1] = currentSpaceDims[1];
588 currentSpaceDims[0] = M_maxNumFaces;
589 currentSpaceDims[1] = (7 + M_faceNodes) * M_numParts;
590 currentCount[0] = currentSpaceDims[0];
591 currentCount[1] = 7 + M_faceNodes;
594 M_HDF5IO.createTable (
"faces", H5T_STD_U32BE, currentSpaceDims);
597 M_uintBuffer.resize (currentCount[0] * currentCount[1], 0);
598 UInt stride = currentCount[1];
599 if (! M_transposeInFile)
601 for (UInt i = 0; i < M_numParts; ++i)
603 mesh_Type& currentPart = (* (*M_meshPartsOut) [i]);
604 for (UInt j = 0; j < currentPart.numFaces(); ++j)
606 for (UInt k = 0; k < M_faceNodes; ++k)
608 M_uintBuffer[k * stride + j] =
609 currentPart.faceList[j].point (k).localId();
611 M_uintBuffer[M_faceNodes * stride + j] =
612 currentPart.faceList[j].markerID();
613 M_uintBuffer[ (M_faceNodes + 1) * stride + j] =
614 currentPart.faceList[j].id();
615 M_uintBuffer[ (M_faceNodes + 2) * stride + j] =
616 currentPart.faceList[j].firstAdjacentElementIdentity();
617 M_uintBuffer[ (M_faceNodes + 3) * stride + j] =
618 currentPart.faceList[j].secondAdjacentElementIdentity();
619 M_uintBuffer[ (M_faceNodes + 4) * stride + j] =
620 currentPart.faceList[j].firstAdjacentElementPosition();
621 M_uintBuffer[ (M_faceNodes + 5) * stride + j] =
622 currentPart.faceList[j].secondAdjacentElementPosition();
623 M_uintBuffer[ (M_faceNodes + 6) * stride + j] =
624 static_cast<
int> (currentPart.faceList[j].flag() );
627 hsize_t currentOffset[2] = {i* currentCount[0], 0};
628 M_HDF5IO.write (
"faces", H5T_NATIVE_UINT, currentCount,
629 currentOffset, &M_uintBuffer[0]);
634 for (UInt i = 0; i < M_numParts; ++i)
636 mesh_Type& currentPart = (* (*M_meshPartsOut) [i]);
637 for (UInt j = 0; j < currentPart.numFaces(); ++j)
639 for (UInt k = 0; k < M_faceNodes; ++k)
641 M_uintBuffer[stride * j + k] =
642 currentPart.faceList[j].point (k).localId();
644 M_uintBuffer[stride * j + M_faceNodes] =
645 currentPart.faceList[j].markerID();
646 M_uintBuffer[stride * j + M_faceNodes + 1] =
647 currentPart.faceList[j].id();
648 M_uintBuffer[stride * j + M_faceNodes + 2] =
649 currentPart.faceList[j].firstAdjacentElementIdentity();
650 M_uintBuffer[stride * j + M_faceNodes + 3] =
651 currentPart.faceList[j].secondAdjacentElementIdentity();
652 M_uintBuffer[stride * j + M_faceNodes + 4] =
653 currentPart.faceList[j].firstAdjacentElementPosition();
654 M_uintBuffer[stride * j + M_faceNodes + 5] =
655 currentPart.faceList[j].secondAdjacentElementPosition();
656 M_uintBuffer[stride * j + M_faceNodes + 6] =
657 static_cast<
int> (currentPart.faceList[j].flag() );
660 hsize_t currentOffset[2] = {0, i* currentCount[1]};
661 M_HDF5IO.write (
"faces", H5T_NATIVE_UINT, currentCount,
662 currentOffset, &M_uintBuffer[0]);
666 M_HDF5IO.closeTable (
"faces");
669 template<
typename MeshType>
670 void PartitionIO<MeshType>::writeElements()
674 hsize_t currentSpaceDims[2];
675 hsize_t currentCount[2];
676 if (! M_transposeInFile)
678 currentSpaceDims[0] = (3 + M_elementNodes) * M_numParts;
679 currentSpaceDims[1] = M_maxNumElements;
680 currentCount[0] = 3 + M_elementNodes;
681 currentCount[1] = currentSpaceDims[1];
685 currentSpaceDims[0] = M_maxNumElements;
686 currentSpaceDims[1] = (3 + M_elementNodes) * M_numParts;
687 currentCount[0] = currentSpaceDims[0];;
688 currentCount[1] = 3 + M_elementNodes;
691 M_HDF5IO.createTable (
"elements", H5T_STD_U32BE, currentSpaceDims);
694 M_uintBuffer.resize (currentCount[0] * currentCount[1], 0);
695 UInt stride = currentCount[1];
696 if (! M_transposeInFile)
698 for (UInt i = 0; i < M_numParts; ++i)
700 mesh_Type& currentPart = (* (*M_meshPartsOut) [i]);
701 for (UInt j = 0; j < currentPart.numVolumes(); ++j)
703 for (UInt k = 0; k < M_elementNodes; ++k)
705 M_uintBuffer[k * stride + j] =
706 currentPart.volumeList[j].point (k).localId();
708 M_uintBuffer[M_elementNodes * stride + j] =
709 currentPart.volumeList[j].markerID();
710 M_uintBuffer[ (M_elementNodes + 1) * stride + j] =
711 currentPart.volumeList[j].id();
712 M_uintBuffer[ (M_elementNodes + 2) * stride + j] =
713 static_cast<
int> (currentPart.volumeList[j].flag() );
716 hsize_t currentOffset[2] = {i* currentCount[0], 0};
717 M_HDF5IO.write (
"elements", H5T_NATIVE_UINT, currentCount,
718 currentOffset, &M_uintBuffer[0]);
723 for (UInt i = 0; i < M_numParts; ++i)
725 mesh_Type& currentPart = (* (*M_meshPartsOut) [i]);
726 for (UInt j = 0; j < currentPart.numVolumes(); ++j)
728 for (UInt k = 0; k < M_elementNodes; ++k)
730 M_uintBuffer[stride * j + k] =
731 currentPart.volumeList[j].point (k).localId();
733 M_uintBuffer[stride * j + M_elementNodes] =
734 currentPart.volumeList[j].markerID();
735 M_uintBuffer[stride * j + M_elementNodes + 1] =
736 currentPart.volumeList[j].id();
737 M_uintBuffer[stride * j + M_elementNodes + 2] =
738 static_cast<
int> (currentPart.volumeList[j].flag() );
741 hsize_t currentOffset[2] = {0, i* currentCount[1]};
742 M_HDF5IO.write (
"elements", H5T_NATIVE_UINT, currentCount,
743 currentOffset, &M_uintBuffer[0]);
747 M_HDF5IO.closeTable (
"elements");
750 template<
typename MeshType>
751 void PartitionIO<MeshType>::readStats()
755 hsize_t currentSpaceDims[2];
756 hsize_t currentCount[2];
757 hsize_t currentOffset[2];
759 M_HDF5IO.openTable (
"stats", currentSpaceDims);
761 if (! M_transposeInFile)
764 currentCount[1] = currentSpaceDims[1];
765 currentOffset[0] = M_myRank;
766 currentOffset[1] = 0;
770 currentCount[0] = currentSpaceDims[0];
772 currentOffset[0] = 0;
773 currentOffset[1] = M_myRank;
777 M_uintBuffer.resize (currentCount[0] * currentCount[1], 0);
778 M_HDF5IO.read (
"stats", H5T_NATIVE_UINT, currentCount, currentOffset,
781 M_HDF5IO.closeTable (
"stats");
784 M_numPoints = M_uintBuffer[2];
785 M_meshPartIn->setMaxNumPoints (M_uintBuffer[2],
true);
786 M_meshPartIn->setNumBPoints (M_uintBuffer[3]);
789 M_meshPartIn->setNumVertices (M_uintBuffer[4]);
790 M_meshPartIn->setNumBVertices (M_uintBuffer[5]);
791 M_meshPartIn->setNumGlobalVertices (M_uintBuffer[6]);
794 M_numEdges = M_uintBuffer[7];
795 M_meshPartIn->setNumEdges (M_uintBuffer[7]);
796 M_meshPartIn->setMaxNumEdges (M_uintBuffer[7],
true);
797 M_meshPartIn->setNumBEdges (M_uintBuffer[8]);
798 M_meshPartIn->setMaxNumGlobalEdges (M_uintBuffer[9]);
801 M_numFaces = M_uintBuffer[10];
802 M_meshPartIn->setNumFaces (M_uintBuffer[10]);
803 M_meshPartIn->setMaxNumFaces (M_uintBuffer[10],
true);
804 M_meshPartIn->setNumBFaces (M_uintBuffer[11]);
805 M_meshPartIn->setMaxNumGlobalFaces (M_uintBuffer[12]);
808 M_numElements = M_uintBuffer[13];
809 M_meshPartIn->setMaxNumVolumes (M_uintBuffer[13],
true);
810 M_meshPartIn->setMaxNumGlobalVolumes (M_uintBuffer[14]);
813 template<
typename MeshType>
814 void PartitionIO<MeshType>::readPoints()
819 hsize_t currentSpaceDims[2];
820 hsize_t currentCount[2];
821 hsize_t currentOffset[2];
825 M_HDF5IO.openTable (
"point_ids", currentSpaceDims);
826 M_HDF5IO.openTable (
"point_coords", currentSpaceDims);
828 if (! M_transposeInFile)
831 currentCount[1] = currentSpaceDims[1];
832 currentOffset[0] = currentCount[0] * M_myRank;
833 currentOffset[1] = 0;
837 currentCount[0] = currentSpaceDims[0];
839 currentOffset[0] = 0;
840 currentOffset[1] = currentCount[1] * M_myRank;
843 M_uintBuffer.resize (currentCount[0] * currentCount[1], 0);
844 M_realBuffer.resize (currentCount[0] * currentCount[1], 0);
845 M_HDF5IO.read (
"point_ids", H5T_NATIVE_UINT, currentCount, currentOffset,
847 M_HDF5IO.read (
"point_coords", H5T_NATIVE_DOUBLE, currentCount,
848 currentOffset, &M_realBuffer[0]);
850 M_HDF5IO.closeTable (
"point_ids");
851 M_HDF5IO.closeTable (
"point_coords");
854 M_meshPartIn->pointList.reserve (M_numPoints);
855 M_meshPartIn->_bPoints.reserve (M_meshPartIn->numBPoints() );
857 typename MeshType::point_Type* pp = 0;
859 UInt stride = currentCount[1];
860 if (! M_transposeInFile)
862 for (UInt j = 0; j < M_numPoints; ++j)
864 pp = & ( M_meshPartIn->addPoint (
false,
false ) );
866 static_cast<flag_Type> (M_uintBuffer[2 * stride + j]) );
867 pp->setMarkerID (M_uintBuffer[j]);
868 pp->x() = M_realBuffer[j];
869 pp->y() = M_realBuffer[stride + j];
870 pp->z() = M_realBuffer[2 * stride + j];
871 pp->setId (M_uintBuffer[stride + j]);
876 for (UInt j = 0; j < M_numPoints; ++j)
878 pp = & ( M_meshPartIn->addPoint (
false,
false ) );
880 static_cast<flag_Type> (M_uintBuffer[stride * j + 2]) );
881 pp->setMarkerID (M_uintBuffer[stride * j]);
882 pp->x() = M_realBuffer[stride * j];
883 pp->y() = M_realBuffer[stride * j + 1];
884 pp->z() = M_realBuffer[stride * j + 2];
885 pp->setId (M_uintBuffer[stride * j + 1]);
888 M_realBuffer.resize (0);
891 template<
typename MeshType>
892 void PartitionIO<MeshType>::readEdges()
896 hsize_t currentSpaceDims[2];
897 hsize_t currentCount[2];
898 hsize_t currentOffset[2];
900 M_HDF5IO.openTable (
"edges", currentSpaceDims);
902 if (! M_transposeInFile)
905 currentCount[1] = currentSpaceDims[1];
906 currentOffset[0] = currentCount[0] * M_myRank;
907 currentOffset[1] = 0;
911 currentCount[0] = currentSpaceDims[0];
913 currentOffset[0] = 0;
914 currentOffset[1] = currentCount[1] * M_myRank;
917 M_uintBuffer.resize (currentCount[0] * currentCount[1], 0);
918 M_HDF5IO.read (
"edges", H5T_NATIVE_UINT, currentCount, currentOffset,
921 M_HDF5IO.closeTable (
"edges");
923 M_meshPartIn->edgeList.reserve (M_numEdges);
925 typename MeshType::edge_Type* pe;
927 UInt stride = currentCount[1];
928 if (! M_transposeInFile)
930 for (UInt j = 0; j < M_numEdges; ++j)
932 pe = & (M_meshPartIn->addEdge (
false) );
934 static_cast<flag_Type> (M_uintBuffer[4 * stride + j]) );
935 pe->setId (M_uintBuffer[3 * stride + j]);
936 pe->setPoint (0, M_meshPartIn->point (M_uintBuffer[j]) );
937 pe->setPoint (1, M_meshPartIn->point (M_uintBuffer[stride + j]) );
938 pe->setMarkerID (M_uintBuffer[2 * stride + j]);
943 for (UInt j = 0; j < M_numEdges; ++j)
945 pe = & (M_meshPartIn->addEdge (
false) );
947 static_cast<flag_Type> (M_uintBuffer[stride * j + 4]) );
948 pe->setId (M_uintBuffer[stride * j + 3]);
949 pe->setPoint (0, M_meshPartIn->point (M_uintBuffer[stride * j]) );
950 pe->setPoint (1, M_meshPartIn->point (M_uintBuffer[stride * j + 1]) );
951 pe->setMarkerID (M_uintBuffer[stride * j + 2]);
956 template<
typename MeshType>
957 void PartitionIO<MeshType>::readFaces()
961 hsize_t currentSpaceDims[2];
962 hsize_t currentCount[2];
963 hsize_t currentOffset[2];
965 M_HDF5IO.openTable (
"faces", currentSpaceDims);
967 if (! M_transposeInFile)
969 currentCount[0] = 7 + M_faceNodes;
970 currentCount[1] = currentSpaceDims[1];
971 currentOffset[0] = currentCount[0] * M_myRank;
972 currentOffset[1] = 0;
976 currentCount[0] = currentSpaceDims[0];
977 currentCount[1] = 7 + M_faceNodes;
978 currentOffset[0] = 0;
979 currentOffset[1] = currentCount[1] * M_myRank;
982 M_uintBuffer.resize (currentCount[0] * currentCount[1], 0);
983 M_HDF5IO.read (
"faces", H5T_NATIVE_UINT, currentCount, currentOffset,
986 M_HDF5IO.closeTable (
"faces");
988 typename MeshType::face_Type* pf = 0;
990 M_meshPartIn->faceList.reserve (M_numFaces);
992 UInt stride = currentCount[1];
993 if (! M_transposeInFile)
995 for (UInt j = 0; j < M_numFaces; ++j)
997 pf = & (M_meshPartIn->addFace (
false) );
999 static_cast<flag_Type> (M_uintBuffer[ (6 + M_faceNodes)
1001 pf->setId (M_uintBuffer[ (M_faceNodes + 1) * stride + j]);
1002 pf->firstAdjacentElementIdentity() =
1003 M_uintBuffer[ (M_faceNodes + 2) * stride + j];
1004 pf->secondAdjacentElementIdentity() =
1005 M_uintBuffer[ (M_faceNodes + 3) * stride + j];
1006 pf->firstAdjacentElementPosition() =
1007 M_uintBuffer[ (M_faceNodes + 4) * stride + j];
1008 pf->secondAdjacentElementPosition() =
1009 M_uintBuffer[ (M_faceNodes + 5) * stride + j];
1010 pf->setMarkerID (M_uintBuffer[M_faceNodes * stride + j]);
1011 for (UInt k = 0; k < M_faceNodes; ++k)
1013 pf->setPoint (k, M_meshPartIn->point (
1014 M_uintBuffer[k * stride + j]) );
1020 for (UInt j = 0; j < M_numFaces; ++j)
1022 pf = & (M_meshPartIn->addFace (
false) );
1024 static_cast<flag_Type> (M_uintBuffer[stride * j
1025 + M_faceNodes + 6]) );
1026 pf->setId (M_uintBuffer[stride * j + M_faceNodes + 1]);
1027 pf->firstAdjacentElementIdentity() =
1028 M_uintBuffer[stride * j + M_faceNodes + 2];
1029 pf->secondAdjacentElementIdentity() =
1030 M_uintBuffer[stride * j + M_faceNodes + 3];
1031 pf->firstAdjacentElementPosition() =
1032 M_uintBuffer[stride * j + M_faceNodes + 4];
1033 pf->secondAdjacentElementPosition() =
1034 M_uintBuffer[stride * j + M_faceNodes + 5];
1035 pf->setMarkerID (M_uintBuffer[ (7 + M_faceNodes) * j + M_faceNodes]);
1036 for (UInt k = 0; k < M_faceNodes; ++k)
1038 pf->setPoint (k, M_meshPartIn->point (
1039 M_uintBuffer[stride * j + k]) );
1044 M_meshPartIn->setLinkSwitch (
"HAS_ALL_FACETS");
1045 M_meshPartIn->setLinkSwitch (
"FACETS_HAVE_ADIACENCY");
1048 template<
typename MeshType>
1049 void PartitionIO<MeshType>::readElements()
1053 hsize_t currentSpaceDims[2];
1054 hsize_t currentCount[2];
1055 hsize_t currentOffset[2];
1057 M_HDF5IO.openTable (
"elements", currentSpaceDims);
1059 if (! M_transposeInFile)
1061 currentCount[0] = 3 + M_elementNodes;
1062 currentCount[1] = currentSpaceDims[1];
1063 currentOffset[0] = currentCount[0] * M_myRank;
1064 currentOffset[1] = 0;
1068 currentCount[0] = currentSpaceDims[0];
1069 currentCount[1] = 3 + M_elementNodes;
1070 currentOffset[0] = 0;
1071 currentOffset[1] = currentCount[1] * M_myRank;
1074 M_uintBuffer.resize (currentCount[0] * currentCount[1], 0);
1075 M_HDF5IO.read (
"elements", H5T_NATIVE_UINT, currentCount, currentOffset,
1078 M_HDF5IO.closeTable (
"elements");
1080 M_meshPartIn->volumeList.reserve (M_numElements);
1082 typename MeshType::volume_Type* pv = 0;
1084 UInt stride = currentCount[1];
1085 if (! M_transposeInFile)
1087 for (UInt j = 0; j < M_numElements; ++j)
1089 pv = & (M_meshPartIn->addVolume() );
1091 static_cast<flag_Type> (M_uintBuffer[ (M_elementNodes + 2) * stride + j]) );
1092 pv->setId (M_uintBuffer[ (M_elementNodes + 1) * stride + j]);
1094 for (UInt k = 0; k < M_elementNodes; ++k)
1096 pv->setPoint (k, M_meshPartIn->point (
1097 M_uintBuffer[k * stride + j]) );
1099 pv->setMarkerID (M_uintBuffer[M_elementNodes * stride + j]);
1104 for (UInt j = 0; j < M_numElements; ++j)
1106 pv = & (M_meshPartIn->addVolume() );
1108 static_cast<flag_Type> (M_uintBuffer[stride * j + M_elementNodes + 2]) );
1109 pv->setId (M_uintBuffer[stride * j + M_elementNodes + 1]);
1111 for (UInt k = 0; k < M_elementNodes; ++k)
1113 pv->setPoint (k, M_meshPartIn->point (
1114 M_uintBuffer[stride * j + k]) );
1116 pv->setMarkerID (M_uintBuffer[stride * j + M_elementNodes]);
1120 M_meshPartIn->updateElementEdges (
false,
false);
1121 M_meshPartIn->updateElementFaces (
false,
false);