16 Teuchos::RCP<const Teuchos::MpiComm<int> > mpiComm = Teuchos::rcp_dynamic_cast<const Teuchos::MpiComm<int> >( writeMap->getComm() );
17 commEpetra_.reset(
new Epetra_MpiComm( *mpiComm->getRawMpiComm() ) );
20 Teuchos::ArrayView< const GO > indices = writeMap->getNodeElementList();
21 int* intGlobIDs =
new int[indices.size()];
22 for (
int i=0; i<indices.size(); i++) {
23 intGlobIDs[i] = (int) indices[i];
26 int nmbPointsGlob = writeMap->getGlobalNumElements();
28 EpetraMapPtr_Type mapEpetra = Teuchos::rcp(
new Epetra_Map((
int)nmbPointsGlob,indices.size(),intGlobIDs,0,*commEpetra_));
30 writeMap_ = mapEpetra;
32 hdf5exporter_.reset(
new HDF5_Type(*commEpetra_) );
34 hdf5exporter_->Create(outputFilename+
".h5");
36 outputFilename_ = outputFilename;
42 EpetraMVPtr_Type u_export(
new Epetra_MultiVector(*(writeMap_),1));
44 TEUCHOS_TEST_FOR_EXCEPTION( std::abs(writeMap_->NumMyElements() - writeVector->getLocalLength()) > 1e-12, std::logic_error,
" The local length of map does not match the local mv length. Map and MultiVector are not compatible");
47 Teuchos::ArrayRCP<const SC> tmpData = writeVector->getData(0);
48 for (
int i=0; i<writeVector->getLocalLength(); i++) {
49 u_export->ReplaceMyValue( i, 0, tmpData[i] );
52 hdf5exporter_->Write(varName,*u_export);
54 if(writeVector->getMap()->getComm()->getRank() == 0 )
55 std::cout <<
" HDF5_Export:: Exporting to file " << outputFilename_ <<
" with variable name " << varName << std::endl;
57 hdf5exporter_->Flush();
HDF5Export(MapConstPtr_Type writeMap, std::string outputFilename)
Constructor for HDF5 Exporter.
Definition HDF5Export_def.hpp:10
void writeVariablesHDF5(std::string varName, MultiVectorConstPtr_Type writeVector)
Exporting MultiVector writeVector as HDF5 File with the variable name varName.
Definition HDF5Export_def.hpp:40