39 #ifndef EXPORTER_HDF5_MESH_3D_H 40 #define EXPORTER_HDF5_MESH_3D_H 1
43 #include <lifev/core/LifeV.hpp> 47 #include <lifev/core/filter/ExporterHDF5.hpp> 48 #include <lifev/core/fem/DOFInterface3Dto3D.hpp> 75 template <
typename MeshType>
76 class ExporterHDF5Mesh3D :
public ExporterHDF5<MeshType>
79 typedef MeshType mesh_Type;
80 typedef ExporterHDF5<MeshType> base;
81 typedef typename base::meshPtr_Type meshPtr_Type;
82 typedef typename base::vector_Type vector_Type;
83 typedef typename base::vectorPtr_Type vectorPtr_Type;
84 typedef typename base::exporterData_Type exporterData_Type;
86 typedef EpetraExt::HDF5 hdf5_Type;
87 typedef std::shared_ptr<hdf5_Type> hdf5Ptr_Type;
88 typedef std::vector<std::vector<Int> > graph_Type;
89 typedef std::shared_ptr<graph_Type> graphPtr_Type;
90 typedef std::shared_ptr<std::vector<meshPtr_Type> > serialMeshPtr_Type;
92 typedef DOFInterface3Dto3D interface_Type;
93 typedef std::shared_ptr<interface_Type> interfacePtr_Type;
94 typedef std::vector<interfacePtr_Type> interfaceVector_Type;
97 typedef std::shared_ptr<interfaceVector_Type> interfaceVectorPtr_Type;
104 ExporterHDF5Mesh3D() {}
116 ExporterHDF5Mesh3D (
const GetPot& dataFile, meshPtr_Type mesh,
const std::string& prefix,
const Int& procId);
126 ExporterHDF5Mesh3D (
const GetPot& dataFile,
const std::string& prefix);
129 virtual ~ExporterHDF5Mesh3D() {}
135 virtual void postProcess (
const Real& time);
144 void addPartitionGraph (
const graphPtr_Type& graph, std::shared_ptr<Epetra_Comm>& comm)
157 void addMeshPartitionAll (
const serialMeshPtr_Type& meshPointer, std::shared_ptr<Epetra_Comm>& comm)
159 M_serialMesh = meshPointer;
160 M_parallelMesh.reset();
174 void addMyMeshPartition (
const meshPtr_Type& , std::shared_ptr<Epetra_Comm>& )
184 void addDOFInterface (
const interfaceVectorPtr_Type& interfaces,
185 const std::string& type,
186 const Int& firstInterfaceFlag,
187 const Int& secondInterfaceFlag,
188 const std::shared_ptr<Epetra_Comm>& comm);
191 Int queryStoredInterfaceNumber();
194 std::vector<std::string> queryStoredInterfaceTypes();
197 graphPtr_Type getGraph();
200 meshPtr_Type getMeshPartition();
203 std::shared_ptr< std::map<UInt, UInt> > getStoredInterface (Int k) ;
208 void setComm (
const std::shared_ptr<Epetra_Comm>& comm )
221 void writePartition (meshPtr_Type partition, std::string& suffix);
222 void writeParallelMesh();
223 void writeSerialMesh();
224 void writeInterfaces();
227 serialMeshPtr_Type M_serialMesh;
228 meshPtr_Type M_parallelMesh;
229 graphPtr_Type M_graph;
231 std::vector<interfaceVectorPtr_Type> M_DOFInterfaces;
232 std::vector<std::string> M_interfaceTypes;
233 std::vector<Int> M_firstInterfaceFlags;
234 std::vector<Int> M_secondInterfaceFlags;
235 std::shared_ptr<Epetra_Comm> M_comm;
243 template<
typename MeshType>
244 ExporterHDF5Mesh3D<MeshType>::ExporterHDF5Mesh3D (
const GetPot& dataFile, meshPtr_Type mesh,
245 const std::string& prefix,
247 base ( dataFile, mesh, prefix, procId )
251 template<
typename MeshType>
252 ExporterHDF5Mesh3D<MeshType>::ExporterHDF5Mesh3D (
const GetPot& dataFile,
const std::string& prefix) :
253 base ( dataFile, prefix )
261 template<
typename MeshType>
262 void ExporterHDF5Mesh3D<MeshType>::addDOFInterface (
const interfaceVectorPtr_Type& interfaces,
263 const std::string& type,
264 const Int& firstInterfaceFlag,
265 const Int& secondInterfaceFlag,
266 const std::shared_ptr<Epetra_Comm>& comm)
268 M_DOFInterfaces.push_back (interfaces);
269 M_interfaceTypes.push_back (type);
270 M_firstInterfaceFlags.push_back (firstInterfaceFlag);
271 M_secondInterfaceFlags.push_back (secondInterfaceFlag);
276 template<
typename MeshType>
277 void ExporterHDF5Mesh3D<MeshType>::postProcess (
const Real& time)
279 if (
this->M_HDF5.get() == 0)
281 if (
this->M_dataVector.size() != 0)
283 this->M_HDF5.reset (
new hdf5_Type (
this->M_dataVector.begin()->storedArrayPtr()->comm() ) );
287 this->M_HDF5.reset (
new hdf5_Type (*M_comm) );
289 this->M_outputFileName =
this->M_prefix +
".h5";
290 this->M_HDF5->Create (
this->M_postDir +
this->M_outputFileName);
293 this->writeInitXdmf();
295 if (!
this->M_multimesh)
297 if (
this->M_dataVector.size() != 0)
299 this->writeGeometry();
302 if (M_graph.get() != 0)
304 if (M_comm->MyPID() == 0)
310 if (M_serialMesh.get() != 0)
315 if (M_parallelMesh.get() != 0)
320 if (M_DOFInterfaces.size() != 0)
324 this->M_HDF5->Flush();
330 this->computePostfix();
332 if (
this->M_postfix !=
"*****" )
336 std::cout <<
" X- HDF5 post-processing ... " << std::flush;
340 for (
typename base::dataVectorIterator_Type i =
this->M_dataVector.begin(); i !=
this->M_dataVector.end(); ++i)
342 this->writeVariable (*i);
345 this->M_timeSteps.push_back (time);
347 this->writeXdmf (time);
349 if (
this->M_multimesh)
351 this->writeGeometry();
357 this->M_HDF5->Flush();
361 std::cout <<
" done in " << chrono.diff() <<
" s." << std::endl;
366 template <
typename MeshType>
367 int ExporterHDF5Mesh3D<MeshType>::queryStoredInterfaceNumber()
369 if (
this->M_HDF5.get() == 0)
371 this->M_HDF5.reset (
new hdf5_Type (*M_comm) );
373 if (!
this->M_HDF5->IsOpen() )
375 this->M_HDF5->Open (
this->M_postDir +
this->M_prefix +
".h5", H5F_ACC_RDONLY);
378 Int storedInterfaceNumber;
379 this->M_HDF5->Read (
"Interfaces",
"Number", storedInterfaceNumber);
381 return storedInterfaceNumber;
384 template <
typename MeshType>
385 std::vector<std::string> ExporterHDF5Mesh3D<MeshType>::queryStoredInterfaceTypes()
387 if (
this->M_HDF5.get() == 0)
389 this->M_HDF5.reset (
new hdf5_Type (*M_comm) );
391 if (!
this->M_HDF5->IsOpen() )
393 this->M_HDF5->Open (
this->M_postDir +
this->M_prefix +
".h5", H5F_ACC_RDONLY);
396 int storedInterfaceNumber;
397 this->M_HDF5->Read (
"Interfaces",
"Number", storedInterfaceNumber);
399 std::vector<std::string> storedInterfaceTypes (storedInterfaceNumber);
400 for (Int k = 0; k < storedInterfaceNumber; ++k)
402 std::stringstream idx;
404 this->M_HDF5->Read (
"Interfaces",
"Type." + idx.str(), storedInterfaceTypes[k]);
407 return storedInterfaceTypes;
410 template <
typename MeshType>
411 typename ExporterHDF5Mesh3D<MeshType>::graphPtr_Type ExporterHDF5Mesh3D<MeshType>::getGraph()
413 graphPtr_Type tempGraph (
new graphPtr_Type::element_type);
415 if (
this->M_HDF5.get() == 0)
417 this->M_HDF5.reset (
new hdf5_Type (*M_comm) );
419 if (!
this->M_HDF5->IsOpen() )
421 this->M_HDF5->Open (
this->M_postDir +
this->M_prefix +
".h5", H5F_ACC_RDONLY);
426 this->M_HDF5->Read (
"Graph",
"number_partitions", nPartitions);
428 std::vector<Int> partitionSizes (nPartitions);
429 this->M_HDF5->Read (
"Graph",
"partition_sizes", H5T_NATIVE_INT, nPartitions,
432 tempGraph->resize (0);
433 tempGraph->reserve (nPartitions);
435 std::vector<Int> partBuffer;
436 std::stringstream index;
438 for (Int i = 0; i < nPartitions; ++i)
440 partBuffer.resize (partitionSizes[i]);
442 this->M_HDF5->Read (
"Graph_partitions",
"P" + index.str(),
443 H5T_NATIVE_INT, partitionSizes[i],
445 tempGraph->push_back (partBuffer);
446 index.str (std::string() );
453 template <
typename MeshType>
454 typename ExporterHDF5Mesh3D<MeshType>::meshPtr_Type ExporterHDF5Mesh3D<MeshType>::getMeshPartition()
456 meshPtr_Type tempMesh (
new MeshType ( M_comm ) );
458 UInt elementNodes, faceNodes;
459 switch (MeshType::elementShape_Type::S_shape)
470 if (
this->M_HDF5.get() == 0)
472 this->M_HDF5.reset (
new hdf5_Type (*M_comm) );
474 if (!
this->M_HDF5->IsOpen() )
476 this->M_HDF5->Open (
this->M_postDir +
this->M_prefix +
".h5", H5F_ACC_RDONLY);
479 std::stringstream index;
480 index << M_comm->MyPID();
481 std::string suffix =
"." + index.str();
485 std::vector<Int> counters (13);
486 this->M_HDF5->Read (
"Mesh_counters",
"P" + suffix, H5T_NATIVE_INT, 13, &counters[0]);
488 Int numPoints = counters[0];
489 tempMesh->setMaxNumPoints (counters[0],
true);
490 tempMesh->setNumBPoints (counters[1]);
493 tempMesh->setNumVertices (counters[2]);
494 tempMesh->setNumBVertices (counters[3]);
495 tempMesh->setNumGlobalVertices (counters[4]);
498 Int numEdges = counters[5];
499 tempMesh->setNumEdges (counters[5]);
500 tempMesh->setMaxNumEdges (counters[5]);
501 tempMesh->setNumBEdges (counters[6]);
502 tempMesh->setMaxNumGlobalEdges (counters[7]);
505 Int numFaces = counters[8];
506 tempMesh->setNumFaces (counters[8]);
507 tempMesh->setMaxNumFaces (counters[8]);
508 tempMesh->setNumBFaces (counters[9]);
509 tempMesh->setMaxNumGlobalFaces (counters[10]);
512 Int numVolumes = counters[11];
513 tempMesh->setMaxNumVolumes (counters[11],
true);
514 tempMesh->setMaxNumGlobalVolumes (counters[12]);
517 std::vector<Real> tmpVectorDouble (numPoints);
518 std::vector<std::vector<Real> > pointCoordinates (3, tmpVectorDouble);
520 std::vector<Int> pointMarkers (numPoints);
521 std::vector<Int> pointFlags (numPoints);
522 std::vector<Int> pointBoundaryFlags (numPoints);
523 std::vector<Int> pointGlobalId (numPoints);
525 this->M_HDF5->Read (
"Mesh_points_coordinates_x",
"P" + suffix, H5T_NATIVE_DOUBLE, numPoints, &pointCoordinates[0][0]);
526 this->M_HDF5->Read (
"Mesh_points_coordinates_y",
"P" + suffix, H5T_NATIVE_DOUBLE, numPoints, &pointCoordinates[1][0]);
527 this->M_HDF5->Read (
"Mesh_points_coordinates_z",
"P" + suffix, H5T_NATIVE_DOUBLE, numPoints, &pointCoordinates[2][0]);
528 this->M_HDF5->Read (
"Mesh_points_markers",
"P" + suffix, H5T_NATIVE_INT, numPoints, &pointMarkers[0]);
529 this->M_HDF5->Read (
"Mesh_points_flags",
"P" + suffix, H5T_NATIVE_INT, numPoints, &pointFlags[0]);
530 this->M_HDF5->Read (
"Mesh_points_boundary_flag",
"P" + suffix, H5T_NATIVE_INT, numPoints, &pointBoundaryFlags[0]);
531 this->M_HDF5->Read (
"Mesh_points_gid",
"P" + suffix, H5T_NATIVE_INT, numPoints, &pointGlobalId[0]);
533 tempMesh->pointList.reserve (numPoints);
534 tempMesh->_bPoints.reserve (tempMesh->numBPoints() );
536 typename MeshType::point_Type* pp = 0;
538 for (Int j = 0; j < numPoints; ++j)
540 pp = & (tempMesh->addPoint (
false,
false) );
541 pp->setMarkerID (pointMarkers[j]);
542 pp->setFlag (pointFlags[j]);
543 pp->x() = pointCoordinates[0][j];
544 pp->y() = pointCoordinates[1][j];
545 pp->z() = pointCoordinates[2][j];
546 pp->setId (pointGlobalId[j]);
549 pointCoordinates.clear();
550 pointMarkers.clear();
552 pointBoundaryFlags.clear();
553 pointGlobalId.clear();
556 std::vector<Int> tmpVectorInt (numEdges);
557 std::vector<std::vector<Int> > edgePoints (2, tmpVectorInt);
559 std::vector<Int> edgeMarkers (numEdges);
560 std::vector<Int> edgeFlags (numEdges);
561 std::vector<Int> edgeGlobalId (numEdges);
562 std::vector<Int> edgeBoundaryFlags (numEdges);
564 this->M_HDF5->Read (
"Mesh_edges_p1",
"P" + suffix, H5T_NATIVE_INT, numEdges, &edgePoints[0][0]);
565 this->M_HDF5->Read (
"Mesh_edges_p2",
"P" + suffix, H5T_NATIVE_INT, numEdges, &edgePoints[1][0]);
566 this->M_HDF5->Read (
"Mesh_edges_markers",
"P" + suffix, H5T_NATIVE_INT, numEdges, &edgeMarkers[0]);
567 this->M_HDF5->Read (
"Mesh_edges_flags",
"P" + suffix, H5T_NATIVE_INT, numEdges, &edgeFlags[0]);
568 this->M_HDF5->Read (
"Mesh_edges_gid",
"P" + suffix, H5T_NATIVE_INT, numEdges, &edgeGlobalId[0]);
569 this->M_HDF5->Read (
"Mesh_edges_boundary_flag",
"P" + suffix, H5T_NATIVE_INT, numEdges,
570 &edgeBoundaryFlags[0]);
572 tempMesh->edgeList.reserve (numEdges);
574 typename MeshType::edge_Type* pe;
576 for (Int j = 0; j < numEdges; ++j)
578 pe = & (tempMesh->addEdge (edgeBoundaryFlags[j]) );
579 pe->setId (edgeGlobalId[j]);
580 pe->setPoint (0, tempMesh->point (edgePoints[0][j]) );
581 pe->setPoint (1, tempMesh->point (edgePoints[1][j]) );
582 pe->setMarkerID (edgeMarkers[j]);
583 pe->setFlag (edgeFlags[j]);
589 edgeGlobalId.clear();
590 edgeBoundaryFlags.clear();
593 tmpVectorInt.resize (numFaces);
594 std::vector<std::vector<Int> > facePoints (faceNodes, tmpVectorInt);
596 std::vector<Int> faceMarkers (numFaces);
597 std::vector<Int> faceFlags (numFaces);
598 std::vector<Int> faceGlobalId (numFaces);
599 std::vector<Int> faceBoundaryFlags (numFaces);
601 std::vector<std::vector<Int> > faceNeighbourId (2, tmpVectorInt);
602 std::vector<std::vector<Int> > faceNeighbourPos (2, tmpVectorInt);
604 std::stringstream idx;
605 for (UInt k = 0; k < faceNodes; ++k)
608 this->M_HDF5->Read (
"Mesh_faces_points",
"P" + idx.str() + suffix, H5T_NATIVE_INT, numFaces,
610 idx.str (std::string() );
613 this->M_HDF5->Read (
"Mesh_faces_markers",
"P" + suffix, H5T_NATIVE_INT, numFaces, &faceMarkers[0]);
614 this->M_HDF5->Read (
"Mesh_faces_flags",
"P" + suffix, H5T_NATIVE_INT, numFaces, &faceFlags[0]);
615 this->M_HDF5->Read (
"Mesh_faces_gid",
"P" + suffix, H5T_NATIVE_INT, numFaces, &faceGlobalId[0]);
616 this->M_HDF5->Read (
"Mesh_faces_boundary_flags",
"P" + suffix, H5T_NATIVE_INT, numFaces,
617 &faceBoundaryFlags[0]);
619 this->M_HDF5->Read (
"Mesh_faces_neighbour1",
"P" + suffix, H5T_NATIVE_INT, numFaces,
620 &faceNeighbourId[0][0]);
621 this->M_HDF5->Read (
"Mesh_faces_neighbour2",
"P" + suffix, H5T_NATIVE_INT, numFaces,
622 &faceNeighbourId[1][0]);
623 this->M_HDF5->Read (
"Mesh_faces_neighbour_pos1",
"P" + suffix, H5T_NATIVE_INT, numFaces,
624 &faceNeighbourPos[0][0]);
625 this->M_HDF5->Read (
"Mesh_faces_neighbour_pos2",
"P" + suffix, H5T_NATIVE_INT, numFaces,
626 &faceNeighbourPos[1][0]);
629 typename MeshType::face_Type* pf = 0;
631 tempMesh->faceList.reserve (numFaces);
633 for (Int j = 0; j < numFaces; ++j)
635 pf = & (tempMesh->addFace (faceBoundaryFlags[j]) );
636 pf->setId (faceGlobalId[j]);
638 pf->firstAdjacentElementIdentity() = faceNeighbourId[0][j];
639 pf->secondAdjacentElementIdentity() = faceNeighbourId[1][j];
640 pf->firstAdjacentElementPosition() = faceNeighbourPos[0][j];
641 pf->secondAdjacentElementPosition() = faceNeighbourPos[1][j];
643 pf->setMarkerID (faceMarkers[j]);
644 pf->setFlag (faceFlags[j]);
645 for (UInt k = 0; k < faceNodes; ++k)
647 pf->setPoint (k, tempMesh->point (facePoints[k][j]) );
651 tempMesh->setLinkSwitch (
"HAS_ALL_FACETS");
652 tempMesh->setLinkSwitch (
"FACETS_HAVE_ADIACENCY");
657 faceGlobalId.clear();
658 faceBoundaryFlags.clear();
659 faceNeighbourId.clear();
660 faceNeighbourPos.clear();
663 tmpVectorInt.resize (numVolumes);
664 std::vector<std::vector<Int> > volumePoints (elementNodes, tmpVectorInt);
666 std::vector<Int> volumeMarkers (numVolumes);
667 std::vector<Int> volumeFlags (numVolumes);
668 std::vector<Int> volumeGlobalId (numVolumes);
670 for (UInt k = 0; k < elementNodes; ++k)
673 this->M_HDF5->Read (
"Mesh_volumes_points",
"P" + idx.str() + suffix, H5T_NATIVE_INT, numVolumes,
674 &volumePoints[k][0]);
675 idx.str (std::string() );
678 this->M_HDF5->Read (
"Mesh_volumes_markers",
"P" + suffix, H5T_NATIVE_INT, numVolumes, &volumeMarkers[0]);
679 this->M_HDF5->Read (
"Mesh_volumes_flags",
"P" + suffix, H5T_NATIVE_INT, numVolumes, &volumeFlags[0]);
680 this->M_HDF5->Read (
"Mesh_volumes_gid",
"P" + suffix, H5T_NATIVE_INT, numVolumes, &volumeGlobalId[0]);
682 tempMesh->volumeList.reserve (numVolumes);
684 typename MeshType::volume_Type* pv = 0;
686 for (Int j = 0; j < numVolumes; ++j)
688 pv = & (tempMesh->addVolume() );
689 pv->setId (volumeGlobalId[j]);
690 for (UInt k = 0; k < elementNodes; ++k)
692 pv->setPoint (k, tempMesh->point (volumePoints[k][j]) );
694 pv->setMarkerID (volumeMarkers[j]);
695 pv->setFlag (volumeFlags[j]);
698 volumePoints.clear();
699 volumeMarkers.clear();
701 volumeGlobalId.clear();
703 tempMesh->updateElementEdges (
false,
false);
704 tempMesh->updateElementFaces (
false,
false);
709 template <
typename MeshType>
710 std::shared_ptr< std::map<UInt, UInt> > ExporterHDF5Mesh3D<MeshType>::getStoredInterface (
int k)
712 if (
this->M_HDF5.get() == 0)
714 this->M_HDF5.reset (
new hdf5_Type (*M_comm) );
716 if (!
this->M_HDF5->IsOpen() )
718 this->M_HDF5->Open (
this->M_postDir +
this->M_prefix +
".h5", H5F_ACC_RDONLY);
721 int myRank = M_comm->MyPID();
723 std::stringstream idx;
724 idx << k <<
"." << myRank;
726 std::shared_ptr<std::map<UInt, UInt> > interface (
new std::map<UInt, UInt>);
729 this->M_HDF5->Read (
"Interfaces",
"Size." + idx.str(), size);
731 std::vector<UInt> keyVector (size);
732 std::vector<UInt> valueVector (size);
734 this->M_HDF5->Read (
"Interfaces",
"Key." + idx.str(), H5T_NATIVE_INT, size,
736 this->M_HDF5->Read (
"Interfaces",
"Value." + idx.str(), H5T_NATIVE_INT, size,
739 for (Int i = 0; i < size; ++i)
741 interface->insert (std::make_pair (keyVector[i], valueVector[i]) );
751 template <
typename MeshType>
752 void ExporterHDF5Mesh3D<MeshType>::writeGraph()
754 std::vector<Int> partitionSizes;
755 Int size, maxSize = 0;
759 partitionSizes.reserve (M_graph->size() );
760 for (std::vector<std::vector<Int> >::iterator it = M_graph->begin();
761 it != M_graph->end(); ++it)
768 partitionSizes.push_back (size);
771 this->M_HDF5->Write (
"Graph",
"partition_sizes", H5T_NATIVE_INT,
772 M_graph->size(), &partitionSizes[0]);
775 this->M_HDF5->Write (
"Graph",
"number_partitions",
static_cast<Int> ( (M_graph->size() ) ) );
778 std::stringstream index;
779 for (UInt i = 0; i < M_graph->size(); ++i)
782 this->M_HDF5->Write (
"Graph_partitions",
"P" + index.str(),
783 H5T_NATIVE_INT, partitionSizes[i],
784 & (*M_graph) [i][0]);
785 index.str (std::string() );
788 this->M_HDF5->Flush();
790 std::cout <<
"Wrote graph for partition " << i << std::endl;
794 template <
typename MeshType>
795 void ExporterHDF5Mesh3D<MeshType>::writePartition (meshPtr_Type mesh, std::string& suffix)
797 UInt elementNodes, faceNodes;
798 switch (MeshType::elementShape_Type::S_shape)
808 ERROR_MSG (
"element type not supported");
811 std::vector<Int> counters;
812 counters.push_back (
static_cast<Int> (mesh->numPoints() ) );
813 counters.push_back (
static_cast<Int> (mesh->numBPoints() ) );
814 counters.push_back (
static_cast<Int> (mesh->numVertices() ) );
815 counters.push_back (
static_cast<Int> (mesh->numBVertices() ) );
816 counters.push_back (
static_cast<Int> (mesh->numGlobalVertices() ) );
817 counters.push_back (
static_cast<Int> (mesh->numEdges() ) );
818 counters.push_back (
static_cast<Int> (mesh->numBEdges() ) );
819 counters.push_back (
static_cast<Int> (mesh->numGlobalEdges() ) );
820 counters.push_back (
static_cast<Int> (mesh->numFaces() ) );
821 counters.push_back (
static_cast<Int> (mesh->numBFaces() ) );
822 counters.push_back (
static_cast<Int> (mesh->numGlobalFaces() ) );
823 counters.push_back (
static_cast<Int> (mesh->numVolumes() ) );
824 counters.push_back (
static_cast<Int> (mesh->numGlobalVolumes() ) );
826 this->M_HDF5->Write (
"Mesh_counters",
"P" + suffix, H5T_NATIVE_INT, 13, &counters[0]);
827 this->M_HDF5->Flush();
829 UInt numPoints = mesh->numPoints();
830 std::vector<Real> tmpVectorDouble (numPoints);
831 std::vector<std::vector<Real> > pointCoordinates (3, tmpVectorDouble);
833 std::vector<Int> pointMarkers (numPoints);
834 std::vector<Int> pointFlags (numPoints);
835 std::vector<Int> pointGlobalId (numPoints);
836 std::vector<Int> pointBoundaryFlags (numPoints);
838 for (UInt j = 0; j < numPoints; ++j)
840 pointCoordinates[0][j] = mesh->pointList[j].x();
841 pointCoordinates[1][j] = mesh->pointList[j].y();
842 pointCoordinates[2][j] = mesh->pointList[j].z();
843 pointMarkers[j] = mesh->pointList[j].markerID();
844 pointFlags[j] = mesh->pointList[j].flag();
845 pointGlobalId[j] = mesh->point (j).id();
846 if (mesh->isBoundaryPoint (j) )
848 pointBoundaryFlags[j] = 1;
852 this->M_HDF5->Write (
"Mesh_points_coordinates_x",
"P" + suffix, H5T_NATIVE_DOUBLE, numPoints, &pointCoordinates[0][0]);
853 this->M_HDF5->Write (
"Mesh_points_coordinates_y",
"P" + suffix, H5T_NATIVE_DOUBLE, numPoints, &pointCoordinates[1][0]);
854 this->M_HDF5->Write (
"Mesh_points_coordinates_z",
"P" + suffix, H5T_NATIVE_DOUBLE, numPoints, &pointCoordinates[2][0]);
855 this->M_HDF5->Write (
"Mesh_points_markers",
"P" + suffix, H5T_NATIVE_INT, numPoints, &pointMarkers[0]);
856 this->M_HDF5->Write (
"Mesh_points_flags",
"P" + suffix, H5T_NATIVE_INT, numPoints, &pointFlags[0]);
857 this->M_HDF5->Write (
"Mesh_points_gid",
"P" + suffix, H5T_NATIVE_INT, numPoints, &pointGlobalId[0]);
858 this->M_HDF5->Write (
"Mesh_points_boundary_flag",
"P" + suffix, H5T_NATIVE_INT, numPoints,
859 &pointBoundaryFlags[0]);
861 this->M_HDF5->Flush();
863 pointCoordinates.clear();
864 pointMarkers.clear();
866 pointBoundaryFlags.clear();
867 pointGlobalId.clear();
869 Int numEdges = mesh->numEdges();
870 std::vector<Int> tmpVectorInt (numEdges);
871 std::vector<std::vector<Int> > edgePoints (2, tmpVectorInt);
873 std::vector<Int> edgeMarkers (numEdges);
874 std::vector<Int> edgeFlags (numEdges);
875 std::vector<Int> edgeGlobalId (numEdges);
876 std::vector<Int> edgeBoundaryFlags (numEdges);
878 for (Int j = 0; j < numEdges; ++j)
880 edgePoints[0][j] = mesh->edgeList[j].point (0).localId();
881 edgePoints[1][j] = mesh->edgeList[j].point (1).localId();
882 edgeMarkers[j] = mesh->edgeList[j].markerID();
883 edgeFlags[j] = mesh->edgeList[j].flag();
884 edgeGlobalId[j] = mesh->edgeList[j].id();
886 if (mesh->isBoundaryEdge (j) )
888 edgeBoundaryFlags[j] = 1;
892 this->M_HDF5->Write (
"Mesh_edges_p1",
"P" + suffix, H5T_NATIVE_INT, numEdges, &edgePoints[0][0]);
893 this->M_HDF5->Write (
"Mesh_edges_p2",
"P" + suffix, H5T_NATIVE_INT, numEdges, &edgePoints[1][0]);
894 this->M_HDF5->Write (
"Mesh_edges_markers",
"P" + suffix, H5T_NATIVE_INT, numEdges, &edgeMarkers[0]);
895 this->M_HDF5->Write (
"Mesh_edges_flags",
"P" + suffix, H5T_NATIVE_INT, numEdges, &edgeFlags[0]);
896 this->M_HDF5->Write (
"Mesh_edges_gid",
"P" + suffix, H5T_NATIVE_INT, numEdges, &edgeGlobalId[0]);
897 this->M_HDF5->Write (
"Mesh_edges_boundary_flag",
"P" + suffix, H5T_NATIVE_INT, numEdges,
898 &edgeBoundaryFlags[0]);
900 this->M_HDF5->Flush();
905 edgeGlobalId.clear();
906 edgeBoundaryFlags.clear();
908 Int numFaces = mesh->numFaces();
909 tmpVectorInt.resize (numFaces);
910 std::vector<std::vector<Int> > facePoints (faceNodes, tmpVectorInt);
912 std::vector<Int> faceMarkers (numFaces);
913 std::vector<Int> faceFlags (numFaces);
914 std::vector<Int> faceGlobalId (numFaces);
915 std::vector<Int> faceBoundaryFlags (numFaces);
917 std::vector<std::vector<Int> > faceNeighbourId (2, tmpVectorInt);
918 std::vector<std::vector<Int> > faceNeighbourPos (2, tmpVectorInt);
920 for (Int j = 0; j < numFaces; ++j)
922 for (UInt k = 0; k < faceNodes; ++k)
924 facePoints[k][j] = mesh->faceList[j].point (k).localId();
926 faceMarkers[j] = mesh->faceList[j].markerID();
927 faceFlags[j] = mesh->faceList[j].flag();
928 faceGlobalId[j] = mesh->faceList[j].id();
930 faceNeighbourId[0][j] = mesh->faceList[j].firstAdjacentElementIdentity();
931 faceNeighbourId[1][j] = mesh->faceList[j].secondAdjacentElementIdentity();
932 faceNeighbourPos[0][j] = mesh->faceList[j].firstAdjacentElementPosition();
933 faceNeighbourPos[1][j] = mesh->faceList[j].secondAdjacentElementPosition();
935 if (mesh->isBoundaryFace (j) )
937 faceBoundaryFlags[j] = 1;
941 std::stringstream idx;
942 for (UInt k = 0; k < faceNodes; ++k)
945 this->M_HDF5->Write (
"Mesh_faces_points",
"P" + idx.str() + suffix, H5T_NATIVE_INT, numFaces,
947 idx.str (std::string() );
950 this->M_HDF5->Write (
"Mesh_faces_markers",
"P" + suffix, H5T_NATIVE_INT, numFaces, &faceMarkers[0]);
951 this->M_HDF5->Write (
"Mesh_faces_flags",
"P" + suffix, H5T_NATIVE_INT, numFaces, &faceFlags[0]);
952 this->M_HDF5->Write (
"Mesh_faces_gid",
"P" + suffix, H5T_NATIVE_INT, numFaces, &faceGlobalId[0]);
953 this->M_HDF5->Write (
"Mesh_faces_boundary_flags",
"P" + suffix, H5T_NATIVE_INT, numFaces,
954 &faceBoundaryFlags[0]);
956 this->M_HDF5->Write (
"Mesh_faces_neighbour1",
"P" + suffix, H5T_NATIVE_INT, numFaces,
957 &faceNeighbourId[0][0]);
958 this->M_HDF5->Write (
"Mesh_faces_neighbour2",
"P" + suffix, H5T_NATIVE_INT, numFaces,
959 &faceNeighbourId[1][0]);
960 this->M_HDF5->Write (
"Mesh_faces_neighbour_pos1",
"P" + suffix, H5T_NATIVE_INT, numFaces,
961 &faceNeighbourPos[0][0]);
962 this->M_HDF5->Write (
"Mesh_faces_neighbour_pos2",
"P" + suffix, H5T_NATIVE_INT, numFaces,
963 &faceNeighbourPos[1][0]);
965 this->M_HDF5->Flush();
970 faceGlobalId.clear();
971 faceBoundaryFlags.clear();
972 faceNeighbourId.clear();
973 faceNeighbourPos.clear();
975 Int numVolumes = mesh->numVolumes();
976 tmpVectorInt.resize (numVolumes);
977 std::vector<std::vector<Int> > volumePoints (elementNodes, tmpVectorInt);
979 std::vector<Int> volumeMarkers (numVolumes);
980 std::vector<Int> volumeFlags (numVolumes);
981 std::vector<Int> volumeGlobalId (numVolumes);
983 for (Int j = 0; j < numVolumes; ++j)
985 for (UInt k = 0; k < elementNodes; ++k)
987 volumePoints[k][j] = mesh->volumeList[j].point (k).localId();
989 volumeMarkers[j] = mesh->volumeList[j].markerID();
990 volumeFlags[j] = mesh->volumeList[j].flag();
991 volumeGlobalId[j] = mesh->volumeList[j].id();
994 for (UInt k = 0; k < elementNodes; ++k)
997 this->M_HDF5->Write (
"Mesh_volumes_points",
"P" + idx.str() + suffix, H5T_NATIVE_INT, numVolumes,
998 &volumePoints[k][0]);
999 idx.str (std::string() );
1002 this->M_HDF5->Write (
"Mesh_volumes_markers",
"P" + suffix, H5T_NATIVE_INT, numVolumes, &volumeMarkers[0]);
1003 this->M_HDF5->Write (
"Mesh_volumes_flags",
"P" + suffix, H5T_NATIVE_INT, numVolumes, &volumeFlags[0]);
1004 this->M_HDF5->Write (
"Mesh_volumes_gid",
"P" + suffix, H5T_NATIVE_INT, numVolumes, &volumeGlobalId[0]);
1006 this->M_HDF5->Flush();
1008 volumePoints.clear();
1009 volumeMarkers.clear();
1010 volumeFlags.clear();
1011 volumeGlobalId.clear();
1014 template <
typename MeshType>
1015 void ExporterHDF5Mesh3D<MeshType>::writeSerialMesh()
1017 std::stringstream index;
1020 for (UInt i = 0; i < M_serialMesh->size(); ++i)
1023 suffix =
"." + index.str();
1025 writePartition ( (*M_serialMesh) [i], suffix);
1027 index.str (std::string() );
1030 std::cout <<
"Wrote mesh partition " << i << std::endl;
1034 template <
typename MeshType>
1035 void ExporterHDF5Mesh3D<MeshType>::writeParallelMesh()
1037 std::stringstream index;
1040 index << M_comm->MyPID();
1041 suffix =
"." + index.str();
1043 writePartition (M_parallelMesh, suffix);
1046 template <
typename MeshType>
1047 void ExporterHDF5Mesh3D<MeshType>::writeInterfaces()
1049 Int interfaceNumber = M_DOFInterfaces.size();
1051 std::vector<Int> firstDOF;
1052 std::vector<Int> secondDOF;
1054 this->M_HDF5->Write (
"Interfaces",
"Number", interfaceNumber);
1056 for (Int i = 0; i < interfaceNumber; ++i)
1058 interfaceVector_Type& currentInterfaceSet = * (M_DOFInterfaces[i]);
1060 Int partitionNumber = currentInterfaceSet.size();
1061 std::stringstream idx;
1063 this->M_HDF5->Write (
"Interfaces",
"Partitions." + idx.str(), partitionNumber);
1065 Int flag1 = M_firstInterfaceFlags[i];
1066 Int flag2 = M_secondInterfaceFlags[i];
1067 std::string type = M_interfaceTypes[i];
1069 this->M_HDF5->Write (
"Interfaces",
"Flag1." + idx.str(), flag1);
1070 this->M_HDF5->Write (
"Interfaces",
"Flag2." + idx.str(), flag2);
1071 this->M_HDF5->Write (
"Interfaces",
"Type." + idx.str(), type);
1073 for (Int j = 0; j < partitionNumber; ++j)
1075 interface_Type& currentInterface = * (currentInterfaceSet[j]);
1077 const std::map<UInt, UInt>& locDofMap = currentInterface.localDofMap();
1079 Int size = locDofMap.size();
1081 idx.str (std::string() );
1083 idx << i <<
"." << j;
1084 this->M_HDF5->Write (
"Interfaces",
"Size." + idx.str(), size);
1088 firstDOF.resize (size);
1089 secondDOF.resize (size);
1092 for (std::map<UInt, UInt>::const_iterator it = locDofMap.begin();
1093 it != locDofMap.end(); ++it)
1095 firstDOF[k] = it->first;
1096 secondDOF[k] = it->second;
1099 this->M_HDF5->Write (
"Interfaces",
"Key." + idx.str(), H5T_NATIVE_INT, size, &firstDOF[0]);
1100 this->M_HDF5->Write (
"Interfaces",
"Value." + idx.str(), H5T_NATIVE_INT, size, &secondDOF[0]);