Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
HDF5Import_def.hpp
1#ifndef HDF5IMPORT_DEF_hpp
2#define HDF5IMPORT_DEF_hpp
3
13
14namespace FEDD {
15
16template<class SC,class LO,class GO,class NO>
17HDF5Import<SC,LO,GO,NO>::HDF5Import(MapConstPtr_Type readMap, std::string inputFilename):
19comm_()
20{
21 Teuchos::RCP<const Teuchos::MpiComm<int> > mpiComm = Teuchos::rcp_dynamic_cast<const Teuchos::MpiComm<int> >( readMap->getComm() );
22 comm_ = mpiComm;
23
24 readMap_ = readMap; // Defining the read map. All different variables that might be contained in the .h5 file must have the same map
25
26 hdf5importer_.reset( new HDF5_Type(comm_) ); // Build HDF5 importer as HDF5Toolbox Type
27
28 inputFilename_ = inputFilename; // Name of input file
29 hdf5importer_->open(inputFilename_+".h5"); // We 'open' the file and connect to HDF5 importer
30
31 u_import_Tpetra_.reset(new MultiVector_Type(readMap)); // The general import vector is defined via readMap
32
33}
34
35template<class SC,class LO,class GO,class NO>
36typename HDF5Import<SC, LO, GO, NO>::MultiVectorPtr_Type HDF5Import<SC,LO,GO,NO>::readVariablesHDF5(std::string varName){
37 // Testing if requested vairable is contained in file
38 TEUCHOS_TEST_FOR_EXCEPTION( !hdf5importer_->isContained(varName), std::logic_error, "Requested varName: " << varName << " not contained in hdf file "<< inputFilename_ << ".h5.");
39 hdf5importer_->read(varName,readMap_,u_import_Tpetra_); // Reading the variable 'varName' from the file and distribute according to readMap_ to u_import_
40
41 return u_import_Tpetra_;
42
43}
44template<class SC,class LO,class GO,class NO>
45void HDF5Import<SC,LO,GO,NO>::closeImporter(){
46 hdf5importer_->close();
47}
48
49}
50#endif
MultiVectorPtr_Type readVariablesHDF5(std::string varName)
Reading a variable 'varName' from the inputFile with inputFilename of file type HDF5.
Definition HDF5Import_def.hpp:36
std::string inputFilename_
Name of input file.
Definition HDF5Import_decl.hpp:66
MultiVectorPtr_Type u_import_Tpetra_
Imported file in Tpetra format.
Definition HDF5Import_decl.hpp:70
HDF5Import(MapConstPtr_Type readMap, std::string inputFilename)
Constructor of HDF import. Here the general setting are defined. An tpetra map build based on the rea...
Definition HDF5Import_def.hpp:17
MapConstPtr_Type readMap_
Name of Map of import multivector.
Definition HDF5Import_decl.hpp:68
HDF5Ptr_Type hdf5importer_
HDF5 importer based on HDF5Toolbox.
Definition HDF5Import_decl.hpp:59
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement_decl.hpp:36