37 #ifndef EXPORTER_HDF5_H 38 #define EXPORTER_HDF5_H 1
43 #include <Epetra_ConfigDefs.h> 44 #include <EpetraExt_DistArray.h> 45 #include <EpetraExt_HDF5.h> 46 #include <Epetra_Comm.h> 47 #include <Epetra_IntVector.h> 48 #include <Epetra_MultiVector.h> 50 #include <boost/algorithm/string.hpp> 51 #include <boost/shared_array.hpp> 52 #include <boost/shared_ptr.hpp> 56 #warning warning you should reconfigure Trilinos with -D TPL_ENABLE_HDF5:BOOL=ON 60 #include <lifev/core/LifeV.hpp> 62 #include <lifev/core/array/MapEpetra.hpp> 63 #include <lifev/core/util/StringUtility.hpp> 64 #include <lifev/core/fem/ReferenceFE.hpp> 65 #include <lifev/core/fem/ReferenceFEScalar.hpp> 66 #include <lifev/core/filter/Exporter.hpp> 82 template<
typename MeshType>
83 class ExporterHDF5 :
public Exporter<MeshType>
89 typedef MeshType mesh_Type;
90 typedef Exporter<MeshType> super;
91 typedef typename super::meshPtr_Type meshPtr_Type;
92 typedef typename super::vector_Type vector_Type;
93 typedef typename super::vectorPtr_Type vectorPtr_Type;
94 typedef typename super::exporterData_Type exporterData_Type;
96 typedef EpetraExt::HDF5 hdf5_Type;
97 typedef std::shared_ptr<hdf5_Type> hdf5Ptr_Type;
98 typedef std::vector<std::vector<Int> > graph_Type;
99 typedef std::shared_ptr<graph_Type> graphPtr_Type;
100 typedef std::shared_ptr<std::vector<meshPtr_Type> > serial_meshPtr_Type;
105 static MapEpetraType
const MapType;
126 ExporterHDF5 (
const GetPot& dfile, meshPtr_Type mesh,
const std::string& prefix,
const Int& procId);
136 ExporterHDF5 (
const GetPot& dfile,
const std::string& prefix);
139 virtual ~ExporterHDF5() {}
145 virtual void postProcess (
const Real& time);
152 UInt importFromTime (
const Real& Time );
159 Real importFromIter (
const UInt& );
165 void import (
const Real& startTime,
const Real& dt);
171 void import (
const Real& time);
183 void readVariable ( exporterData_Type& dvar);
195 void setDataFromGetPot (
const GetPot& dataFile,
const std::string& section =
"exporter" );
203 MapEpetraType mapType()
const;
214 void writeInitXdmf();
216 void writeXdmf (
const Real& time);
218 void writeCloseLinesXdmf();
220 void removeCloseLinesXdmf();
222 void writeTopology ( std::ofstream& xdmf );
223 void writeGeometry ( std::ofstream& xdmf );
224 void writeAttributes ( std::ofstream& xdmf );
225 void writeScalarDatastructure ( std::ofstream& xdmf,
const exporterData_Type& dvar );
226 void writeVectorDatastructure ( std::ofstream& xdmf,
const exporterData_Type& dvar );
228 void writeVariable (
const exporterData_Type& dvar);
229 void writeScalar (
const exporterData_Type& dvar);
230 void writeVector (
const exporterData_Type& dvar);
232 void writeGeometry();
234 void readScalar ( exporterData_Type& dvar);
235 void readVector ( exporterData_Type& dvar);
241 std::ofstream M_xdmf;
243 const std::string M_closingLines;
244 std::streampos M_closingLinesPosition;
245 std::string M_outputFileName;
248 bool M_printConnectivity;
253 template<
typename MeshType>
254 MapEpetraType
const ExporterHDF5<MeshType>::MapType (Unique);
260 template<
typename MeshType>
261 ExporterHDF5<MeshType>::ExporterHDF5() :
264 M_closingLines (
"\n </Grid>\n\n </Domain>\n</Xdmf>\n"),
265 M_outputFileName (
"noninitialisedFileName" ),
266 M_printConnectivity (
true )
270 template<
typename MeshType>
271 ExporterHDF5<MeshType>::ExporterHDF5 (
const GetPot& dfile, meshPtr_Type mesh,
const std::string& prefix,
273 super ( dfile, prefix ),
275 M_closingLines (
"\n </Grid>\n\n </Domain>\n</Xdmf>\n"),
276 M_outputFileName (
"noninitialisedFileName" )
278 M_printConnectivity = dfile ( ( prefix +
"/printConnectivity" ).data(), 1);
279 this->setMeshProcId ( mesh, procId );
282 template<
typename MeshType>
283 ExporterHDF5<MeshType>::ExporterHDF5 (
const GetPot& dfile,
const std::string& prefix) :
284 super ( dfile, prefix ),
286 M_closingLines (
"\n </Grid>\n\n </Domain>\n</Xdmf>\n"),
287 M_outputFileName (
"noninitialisedFileName" )
289 M_printConnectivity = dfile ( ( prefix +
"/printConnectivity" ).data(), 1);
296 template<
typename MeshType>
297 void ExporterHDF5<MeshType>::postProcess (
const Real& time)
299 if ( M_HDF5.get() == 0)
301 M_HDF5.reset (
new hdf5_Type (
this->M_dataVector.begin()->storedArrayPtr()->comm() ) );
302 M_outputFileName =
this->M_prefix +
".h5";
303 M_HDF5->Create (
this->M_postDir + M_outputFileName);
308 if (!
this->M_multimesh)
317 this->computePostfix();
319 std::size_t found (
this->M_postfix.find (
"*" ) );
320 if ( found == std::string::npos )
324 std::cout <<
" X- HDF5 post-processing ... " << std::flush;
328 for (
typename super::dataVectorIterator_Type i =
this->M_dataVector.begin(); i !=
this->M_dataVector.end(); ++i)
333 this->M_timeSteps.push_back (time);
337 if (
this->M_multimesh)
349 std::cout <<
"done in " << chrono.diff() <<
" s." << std::endl;
354 template<
typename MeshType>
355 UInt ExporterHDF5<MeshType>::importFromTime (
const Real& Time )
358 std::pair< Real, Int > SelectedTimeAndPostfix;
359 if ( !
this->M_procId )
362 std::ifstream xmfFile;
363 xmfFile.open ( (
this->M_postDir +
this->M_prefix +
".xmf" ).c_str(), std::ios::in );
366 std::vector< std::pair< Real, Int > > TimeAndPostfix;
367 if ( xmfFile.is_open() )
371 std::vector<std::string> stringsVector;
374 while ( !xmfFile.eof() )
376 std::getline ( xmfFile, line,
'\n' );
379 if ( !line.compare ( 0, 10,
"<!-- Time " ) )
381 boost::split ( stringsVector, line, boost::is_any_of (
" " ) );
382 TimeAndPostfix.push_back ( std::make_pair ( string2number ( stringsVector[2] ),
383 string2number ( stringsVector[4] ) ) );
390 SelectedTimeAndPostfix = TimeAndPostfix.front();
391 for ( std::vector< std::pair< Real, Int > >::const_iterator i = TimeAndPostfix.begin();
392 i < TimeAndPostfix.end() ; ++i )
393 if ( std::fabs ( SelectedTimeAndPostfix.first - Time ) >= std::fabs ( (*i).first - Time ) )
395 SelectedTimeAndPostfix = *i;
398 this->M_dataVector.begin()->storedArrayPtr()->comm().Broadcast ( &SelectedTimeAndPostfix.second, 1, 0 );
399 this->M_timeIndex = SelectedTimeAndPostfix.second;
400 this->computePostfix();
403 if ( !
this->M_procId )
405 std::cout <<
" X- HDF5 importing ... " << std::flush;
410 for (
typename super::dataVectorIterator_Type i =
this->M_dataVector.begin(); i !=
this->M_dataVector.end(); ++i)
412 this->readVariable (*i);
416 if ( !
this->M_procId )
417 std::cout <<
"done in " << chrono.diff() <<
" s. (Time " << SelectedTimeAndPostfix.first
418 <<
", Iteration " << SelectedTimeAndPostfix.second <<
" )" << std::endl;
420 return static_cast <UInt> ( SelectedTimeAndPostfix.second );
423 template<
typename MeshType>
424 Real ExporterHDF5<MeshType>::importFromIter (
const UInt& iter )
427 std::pair< Real, Int > SelectedTimeAndPostfix;
428 if ( !
this->M_procId )
431 std::ifstream xmfFile;
432 xmfFile.open ( (
this->M_postDir +
this->M_prefix +
".xmf" ).c_str(), std::ios::in );
435 std::vector< std::pair< Real, UInt > > TimeAndPostfix;
437 if ( xmfFile.is_open() )
441 std::vector<std::string> stringsVector;
444 while ( !xmfFile.eof() )
446 std::getline ( xmfFile, line,
'\n' );
449 if ( !line.compare ( 0, 10,
"<!-- Time " ) )
451 boost::split ( stringsVector, line, boost::is_any_of (
" " ) );
452 TimeAndPostfix.push_back ( std::make_pair ( string2number ( stringsVector[2] ),
453 string2number ( stringsVector[4] ) ) );
461 SelectedTimeAndPostfix = TimeAndPostfix.front();
464 for ( std::vector< std::pair< Real, UInt > >::const_iterator i = TimeAndPostfix.begin();
465 i < TimeAndPostfix.end() ; ++i )
467 if ( i->second == iter )
469 SelectedTimeAndPostfix = *i;
475 ASSERT (found,
"Selected iteration not found");
479 this->M_dataVector.begin()->storedArrayPtr()->Comm().Broadcast ( &SelectedTimeAndPostfix.second, 1, 0 );
480 this->M_timeIndex = SelectedTimeAndPostfix.second;
482 std::ostringstream index;
485 index << std::setw (5) <<
this->M_timeIndex;
486 this->M_postfix =
"." + index.str();
489 if ( !
this->M_procId )
490 std::cout <<
" X- HDF5 importing iteration " 492 <<
" at time " << SelectedTimeAndPostfix.first
493 <<
" ... " << std::flush;
497 for (
typename super::dataVectorIterator_Type i =
this->M_dataVector.begin(); i !=
this->M_dataVector.end(); ++i)
499 this->readVariable (*i);
503 if ( !
this->M_procId )
504 std::cout <<
"done in " << chrono.diff() <<
" s. (Time " << SelectedTimeAndPostfix.first
505 <<
", Iteration " << SelectedTimeAndPostfix.second <<
" )" << std::endl;
507 return SelectedTimeAndPostfix.first;
511 template<
typename MeshType>
512 void ExporterHDF5<MeshType>::import (
const Real& Tstart,
const Real& dt)
515 Real time (Tstart -
this->M_timeIndex * dt);
517 for ( UInt count (0); count <
this->M_timeIndex; ++count )
519 this->M_timeSteps.push_back (time);
528 template<
typename MeshType>
529 void ExporterHDF5<MeshType>::import (
const Real& time)
531 if ( M_HDF5.get() == 0)
533 M_HDF5.reset (
new hdf5_Type (
this->M_dataVector.begin()->storedArrayPtr()->comm() ) );
534 M_HDF5->Open (
this->M_postDir +
this->M_prefix +
".h5");
537 this->M_timeSteps.push_back (time);
539 this->computePostfix();
541 assert (
this->M_postfix !=
"*****" );
545 std::cout <<
" X- HDF5 importing ... " << std::endl;
550 for (
typename super::dataVectorIterator_Type i =
this->M_dataVector.begin(); i !=
this->M_dataVector.end(); ++i)
552 this->readVariable (*i);
557 std::cout <<
"done in " << chrono.diff() <<
" s." << std::endl;
561 template <
typename MeshType>
562 void ExporterHDF5<MeshType>::readVariable (exporterData_Type& dvar)
564 if ( M_HDF5.get() == 0)
566 M_HDF5.reset (
new hdf5_Type (dvar.storedArrayPtr()->blockMap().Comm() ) );
567 M_HDF5->Open (
this->M_postDir +
this->M_prefix +
".h5");
569 super::readVariable (dvar);
575 template<
typename MeshType>
576 void ExporterHDF5<MeshType>::setDataFromGetPot (
const GetPot& dataFile,
const std::string& section )
578 super::setDataFromGetPot ( dataFile, section );
579 M_printConnectivity = dataFile ( ( section +
"/printConnectivity" ).data(), 1);
585 template<
typename MeshType>
586 MapEpetraType ExporterHDF5<MeshType>::mapType()
const 594 template<
typename MeshType>
595 void ExporterHDF5<MeshType>::defineShape()
600 template <
typename MeshType>
601 void ExporterHDF5<MeshType>::writeInitXdmf()
603 if (
this->M_procId == 0)
605 M_xdmf.open ( (
this->M_postDir +
this->M_prefix +
".xmf").c_str(), std::ios_base::out );
607 M_xdmf <<
"<?xml version=\"1.0\" ?>\n" 608 <<
"<!DOCTYPE Xdmf SYSTEM \"" 611 <<
"<!ENTITY DataFile \"" 617 <<
".h5 is generated by LifeV -->\n" 619 <<
" <Domain Name=\"" 624 <<
"Grid\" GridType=\"Collection\" CollectionType=\"Temporal\">\n" 627 writeCloseLinesXdmf();
631 template <
typename MeshType>
632 void ExporterHDF5<MeshType>::writeXdmf (
const Real& time)
677 if (
this->M_procId == 0)
679 removeCloseLinesXdmf();
685 "<!-- Time " << time <<
" Iteration " <<
this->M_postfix.substr (1, 5) <<
" -->\n" <<
686 " <Grid Name=\"Mesh " << time <<
"\">\n" <<
687 " <Time TimeType=\"Single\" Value=\"" << time <<
"\" />\n";
688 writeTopology (M_xdmf);
689 writeGeometry (M_xdmf);
690 writeAttributes (M_xdmf);
698 writeCloseLinesXdmf();
703 template <
typename MeshType>
704 void ExporterHDF5<MeshType>::writeCloseLinesXdmf()
707 M_closingLinesPosition = M_xdmf.tellp();
710 M_xdmf << M_closingLines;
716 template <
typename MeshType>
717 void ExporterHDF5<MeshType>::removeCloseLinesXdmf()
719 M_xdmf.seekp (M_closingLinesPosition);
722 template <
typename MeshType>
723 void ExporterHDF5<MeshType>::writeTopology ( std::ofstream& xdmf )
725 std::string FEstring;
727 switch ( MeshType::elementShape_Type::S_shape )
730 FEstring =
"Tetrahedron";
733 FEstring =
"Hexahedron";
736 FEstring =
"Triangle";
739 FEstring =
"Quadrilateral";
742 FEstring =
"Polyline";
745 ERROR_MSG (
"FE not allowed in HDF5 Exporter" );
748 xdmf <<
" <Topology\n" 752 <<
" NumberOfElements=\"" 753 <<
this->M_mesh->numGlobalElements()
758 <<
" <DataStructure Format=\"HDF\"\n" 760 <<
this->M_mesh->numGlobalElements()
762 <<
this->M_mesh->numLocalVertices()
763 <<
"\"\n" <<
" DataType=\"Int\"\n" 764 <<
" Precision=\"8\">\n" <<
" " 765 << M_outputFileName <<
":/Connections/Values\n" 766 <<
" </DataStructure>\n" <<
" </Topology>\n";
769 template <
typename MeshType>
770 void ExporterHDF5<MeshType>::writeGeometry ( std::ofstream& xdmf )
773 std::string postfix_string;
776 if (
this->M_multimesh)
778 postfix_string =
this->M_postfix;
787 " <Geometry Type=\"X_Y_Z\">\n" <<
788 " <DataStructure Format=\"HDF\"\n" <<
789 " Dimensions=\"" <<
this->M_mesh->numGlobalVertices() <<
"\"\n" <<
790 " DataType=\"Float\"\n" <<
791 " Precision=\"8\">\n" <<
792 " " << M_outputFileName <<
":/" <<
"PointsX" << postfix_string <<
"/Values\n" <<
793 " </DataStructure>\n" <<
794 " <DataStructure Format=\"HDF\"\n" <<
795 " Dimensions=\"" <<
this->M_mesh->numGlobalVertices() <<
"\"\n" <<
796 " DataType=\"Float\"\n" <<
797 " Precision=\"8\">\n" <<
798 " " << M_outputFileName <<
":/" <<
"PointsY" << postfix_string <<
"/Values\n" <<
799 " </DataStructure>\n" <<
800 " <DataStructure Format=\"HDF\"\n" <<
801 " Dimensions=\"" <<
this->M_mesh->numGlobalVertices() <<
"\"\n" <<
802 " DataType=\"Float\"\n" <<
803 " Precision=\"8\">\n" <<
804 " " << M_outputFileName <<
":/" <<
"PointsZ" << postfix_string <<
"/Values\n" <<
805 " </DataStructure>\n" <<
810 template <
typename MeshType>
811 void ExporterHDF5<MeshType>::writeAttributes ( std::ofstream& xdmf )
815 for (
typename super::dataVectorIterator_Type i =
this->M_dataVector.begin(); i !=
this->M_dataVector.end(); ++i)
819 " Type=\"" << i->typeName() <<
"\"\n" <<
820 " Center=\"" << i->whereName() <<
"\"\n" <<
821 " Name=\"" << i->variableName() <<
"\">\n";
823 switch ( i->fieldType() )
825 case exporterData_Type::ScalarField:
826 writeScalarDatastructure (xdmf, *i);
828 case exporterData_Type::VectorField:
829 writeScalarDatastructure (xdmf, *i);
839 template <
typename MeshType>
840 void ExporterHDF5<MeshType>::writeScalarDatastructure ( std::ofstream& xdmf,
const exporterData_Type& dvar )
843 Int globalUnknowns (0);
844 switch ( dvar.where() )
846 case exporterData_Type::Node:
847 globalUnknowns =
this->M_mesh->numGlobalVertices();
849 case exporterData_Type::Cell:
850 globalUnknowns =
this->M_mesh->numGlobalElements();
855 UInt dim = (dvar.fieldDim() == 1) ? 1 : nDimensions;
860 " <DataStructure ItemType=\"HyperSlab\"\n" <<
861 " Dimensions=\"" << globalUnknowns <<
" " << dim <<
"\"\n" <<
862 " Type=\"HyperSlab\">\n" <<
863 " <DataStructure Dimensions=\"3 2\"\n" <<
864 " Format=\"XML\">\n" <<
867 " " << globalUnknowns <<
" " << dim <<
"\n" <<
868 " </DataStructure>\n" <<
870 " <DataStructure Format=\"HDF\"\n" <<
871 " Dimensions=\"" << dvar.numDOF() <<
" " << dim <<
"\"\n" <<
872 " DataType=\"Float\"\n" <<
873 " Precision=\"8\">\n" <<
874 " " << M_outputFileName <<
":/" << dvar.variableName()
875 <<
this->M_postfix <<
"/Values\n" <<
876 " </DataStructure>\n" <<
877 " </DataStructure>\n";
881 template <
typename MeshType>
882 void ExporterHDF5<MeshType>::writeVectorDatastructure ( std::ofstream& xdmf,
const exporterData_Type& dvar )
886 std::string coord[3] = {
"X",
"Y",
"Z"};
888 xdmf <<
" <DataStructure ItemType=\"Function\"\n" 890 <<
this->M_mesh->numGlobalVertices()
894 <<
" Function=\"JOIN($0 , $1, $2)\">\n";
896 for ( UInt i (0); i < nDimensions; ++i )
898 xdmf <<
" <DataStructure Format=\"HDF\"\n" 900 <<
this->M_mesh->numGlobalVertices()
902 <<
" DataType=\"Float\"\n" 903 <<
" Precision=\"8\">\n" 907 << dvar.variableName()
911 <<
" </DataStructure>\n";
914 xdmf <<
" </DataStructure>\n";
917 template <
typename MeshType>
918 void ExporterHDF5<MeshType>::writeVariable (
const exporterData_Type& dvar)
921 switch ( dvar.fieldType() )
923 case exporterData_Type::ScalarField:
926 case exporterData_Type::VectorField:
932 template <
typename MeshType>
933 void ExporterHDF5<MeshType>::writeScalar (
const exporterData_Type& dvar)
945 switch ( dvar.where() )
947 case exporterData_Type::Node:
948 size = dvar.numDOF();
950 case exporterData_Type::Cell:
951 size = dvar.storedArrayPtr()->size();
955 UInt start = dvar.start();
957 MapEpetra subMap (dvar.storedArrayPtr()->blockMap(), start, size);
958 vector_Type subVar (subMap);
959 subVar.subset (*dvar.storedArrayPtr(), start);
961 std::string varname (dvar.variableName() +
this->M_postfix);
962 bool writeTranspose (
true);
963 M_HDF5->Write (varname, subVar.epetraVector(), writeTranspose );
966 template <
typename MeshType>
967 void ExporterHDF5<MeshType>::writeVector (
const exporterData_Type& dvar)
974 switch ( dvar.where() )
976 case exporterData_Type::Node:
977 size = dvar.numDOF();
979 case exporterData_Type::Cell:
980 size = ( (dvar.storedArrayPtr()->size() ) / ( nDimensions ) );
984 UInt start = dvar.start();
988 Real** ArrayOfPointers (
new Real*[nDimensions]);
989 boost::shared_array< std::shared_ptr<vector_Type> >
990 ArrayOfVectors (
new std::shared_ptr<vector_Type>[nDimensions]);
1001 for (UInt d ( 0 ); d < dvar.fieldDim(); ++d)
1003 MapEpetra subMap (dvar.storedArrayPtr()->blockMap(), start + d * size, size);
1004 ArrayOfVectors[d].reset (
new vector_Type (subMap) );
1005 ArrayOfVectors[d]->subset (*dvar.storedArrayPtr(), start + d * size);
1007 ArrayOfVectors[d]->epetraVector().ExtractView (&ArrayOfPointers[d], &MyLDA);
1010 for (UInt d ( dvar.fieldDim() ); d < nDimensions; ++d)
1012 MapEpetra subMap (dvar.storedArrayPtr()->blockMap(), start, size);
1013 ArrayOfVectors[d].reset (
new vector_Type (subMap) );
1015 ArrayOfVectors[d]->epetraVector().ExtractView (&ArrayOfPointers[d], &MyLDA);
1018 MapEpetra subMap (dvar.storedArrayPtr()->blockMap(), start, size);
1019 Epetra_MultiVector multiVector (View, *subMap.map (Unique), ArrayOfPointers, nDimensions);
1022 bool writeTranspose (
true);
1023 std::string varname (dvar.variableName() +
this->M_postfix);
1024 M_HDF5->Write (varname, multiVector, writeTranspose);
1026 delete[] ArrayOfPointers;
1029 template <
typename MeshType>
1030 void ExporterHDF5<MeshType>::writeGeometry()
1053 ASSERT (
this->M_dataVector.size() > 0 ,
"hdf5exporter: ListData is empty");
1057 UInt numberOfPoints = MeshType::elementShape_Type::S_numPoints;
1059 std::vector<Int> elementList;
1060 UInt ownedElements =
this->M_mesh->elementList().countElementsWithFlag ( EntityFlags::GHOST, &Flag::testOneNotSet );
1061 elementList.reserve ( ownedElements * numberOfPoints );
1062 UInt elementCount = 0;
1063 for ( ID i = 0; i <
this->M_mesh->numElements(); ++i )
1065 typename MeshType::element_Type
const& element (
this->M_mesh->element (i) );
1066 if ( element.isOwned() )
1068 UInt lid = elementCount * numberOfPoints;
1069 for (ID j = 0; j < numberOfPoints; ++j, ++lid)
1071 elementList[lid] = element.id() * numberOfPoints + j;
1077 Epetra_Map connectionsMap (
this->M_mesh->numGlobalElements() *numberOfPoints,
1078 ownedElements * numberOfPoints,
1080 0,
this->M_dataVector.begin()->storedArrayPtr()->comm() );
1082 Epetra_IntVector connections (connectionsMap);
1084 for (ID i = 0; i <
this->M_mesh->numElements(); ++i)
1086 typename MeshType::element_Type
const& element (
this->M_mesh->element (i) );
1087 if ( element.isOwned() )
1089 UInt lid = elementCount * numberOfPoints;
1090 for (ID j = 0; j < numberOfPoints; ++j, ++lid)
1092 connections[lid] = element.point (j).id();
1098 this->M_dataVector.begin()->storedArrayPtr()->comm().Barrier();
1106 switch ( MeshType::elementShape_Type::S_shape )
1110 const ReferenceFE& refFEP1 = feTetraP1;
1111 DOF tmpDof ( *
this->M_mesh, refFEP1 );
1112 std::vector<Int> myGlobalElements ( tmpDof.globalElements ( *
this->M_mesh ) );
1114 MapEpetra tmpMapP1 ( -1, myGlobalElements.size(), &myGlobalElements[0],
1115 this->M_dataVector.begin()->storedArrayPtr()->mapPtr()->commPtr() );
1121 const ReferenceFE& refFEP1 = feTriaP1;
1122 DOF tmpDof ( *
this->M_mesh, refFEP1 );
1123 std::vector<Int> myGlobalElements ( tmpDof.globalElements ( *
this->M_mesh ) );
1125 MapEpetra tmpMapP1 ( -1, myGlobalElements.size(), &myGlobalElements[0],
1126 this->M_dataVector.begin()->storedArrayPtr()->mapPtr()->commPtr() );
1132 const ReferenceFE& refFEQ1 = feHexaQ1;
1133 DOF tmpDof ( *
this->M_mesh, refFEQ1 );
1134 std::vector<Int> myGlobalElements ( tmpDof.globalElements ( *
this->M_mesh ) );
1136 MapEpetra tmpMapQ1 ( -1, myGlobalElements.size(), &myGlobalElements[0],
1137 this->M_dataVector.begin()->storedArrayPtr()->mapPtr()->commPtr() );
1143 const ReferenceFE& refFEP11D = feSegP1;
1144 DOF tmpDof ( *
this->M_mesh, refFEP11D );
1145 std::vector<Int> myGlobalElements ( tmpDof.globalElements ( *
this->M_mesh ) );
1147 MapEpetra tmpMapQ11D ( -1, myGlobalElements.size(), &myGlobalElements[0],
1148 this->M_dataVector.begin()->storedArrayPtr()->mapPtr()->commPtr() );
1149 subMap = tmpMapQ11D;
1153 ERROR_MSG (
"FE not allowed in HDF5 Exporter" );
1157 VectorEpetra pointsX (subMap);
1158 VectorEpetra pointsY (subMap);
1159 VectorEpetra pointsZ (subMap);
1162 for (ID i = 0; i <
this->M_mesh->numVertices(); ++i)
1164 typename MeshType::point_Type point;
1165 if (
this->M_multimesh )
1167 point =
this->M_mesh->point (i);
1171 point =
this->M_mesh->meshTransformer().pointInitial (i);
1174 if ( point.isOwned() )
1179 bool insertedX (
true);
1180 bool insertedY (
true);
1181 bool insertedZ (
true);
1183 insertedX = insertedX && pointsX.setCoefficient (gid, point.x() );
1184 insertedY = insertedY && pointsY.setCoefficient (gid, point.y() );
1185 insertedZ = insertedZ && pointsZ.setCoefficient (gid, point.z() );
1191 std::string pointsXVarname (
"PointsX");
1192 std::string pointsYVarname (
"PointsY");
1193 std::string pointsZVarname (
"PointsZ");
1194 std::string connectionsVarname (
"Connections");
1196 if (
this->M_multimesh)
1198 pointsXVarname +=
this->M_postfix;
1199 pointsYVarname +=
this->M_postfix;
1200 pointsZVarname +=
this->M_postfix;
1203 if (
this->M_printConnectivity )
1205 M_HDF5->Write (connectionsVarname, connections);
1206 this->M_printConnectivity =
false;
1210 M_HDF5->Write (pointsXVarname, pointsX.epetraVector(),
true);
1211 M_HDF5->Write (pointsYVarname, pointsY.epetraVector(),
true);
1212 M_HDF5->Write (pointsZVarname, pointsZ.epetraVector(),
true);
1215 template <
typename MeshType>
1216 void ExporterHDF5<MeshType>::readScalar (exporterData_Type& dvar)
1219 UInt size = dvar.numDOF();
1220 UInt start = dvar.start();
1222 MapEpetra subMap (dvar.storedArrayPtr()->blockMap(), start, size);
1223 Epetra_MultiVector* subVar (0);
1225 std::string varname (dvar.variableName() );
1226 if (
this->M_postfix !=
"")
1228 varname +=
this->M_postfix;
1230 bool readTranspose (
true);
1231 M_HDF5->Read (varname, *subMap.map (
this->mapType() ), subVar, readTranspose);
1233 dvar.storedArrayPtr()->subset (*subVar, subMap, 0, start );
1239 template <
typename MeshType>
1240 void ExporterHDF5<MeshType>::readVector ( exporterData_Type& dvar)
1242 UInt size = dvar.numDOF();
1243 UInt start = dvar.start();
1245 using namespace boost;
1250 MapEpetra subMap (dvar.storedArrayPtr()->blockMap(), start, size);
1251 Epetra_MultiVector* subVar (0);
1253 bool readTranspose (
true);
1254 std::string varname (dvar.variableName() );
1256 if (
this->M_postfix !=
"")
1258 varname +=
this->M_postfix;
1261 M_HDF5->Read (varname, *subMap.map (
this->mapType() ), subVar, readTranspose);
1266 for (UInt d ( 0 ); d < dvar.fieldDim(); ++d)
1268 dvar.storedArrayPtr()->subset (*subVar, subMap, 0, start + d * size, d );