RBGen  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RBGen_EpetraMVFileIOFactory.cpp
1 #include "RBGen_EpetraMVFileIOFactory.h"
2 #include "Teuchos_Assert.hpp"
3 
4 namespace RBGen {
5 
7  {
8  // Insert the acceptable input file types for this factory
9  file_formats.push_back("Burkardt");
10 #ifdef HAVE_RBGEN_NETCDF
11  file_formats.push_back("NetCDF");
12 #endif
13 #ifdef HAVE_RBGEN_EPETRAEXT
14  file_formats.push_back("Matrix Market");
15 #endif
16  }
17 
19  EpetraMVFileIOFactory::create( const Teuchos::ParameterList& params )
20  {
21  // See if the "File I/O" sublist exists
22  TEUCHOS_TEST_FOR_EXCEPTION(!params.isSublist( "File IO" ), std::invalid_argument, "File IO sublist does not exist!");
23 
24  // Get the "File I/O" sublist.
25  const Teuchos::ParameterList& fileio_params = params.sublist( "File IO" );
26 
27  // Get the file format type
28  std::string file_format = Teuchos::getParameter<std::string>( const_cast<Teuchos::ParameterList&>(fileio_params),
29  "Type" );
30 
32 
33  // File input format based on Burkardt's input files
34  if ( file_format == "Burkardt" ) {
35  RBFileIO = Teuchos::rcp( new BurkardtFileIOHandler() );
36  } else
37  // File input format for NetCDF files
38 #ifdef HAVE_RBGEN_NETCDF
39  if ( file_format == "NetCDF" ) {
40  RBFileIO = Teuchos::rcp( new NetCDFFileIOHandler() );
41  } else
42 #endif
43  // File input format for Matrix Market files
44 #ifdef HAVE_RBGEN_EPETRAEXT
45  if ( file_format == "Matrix Market" ) {
46  RBFileIO = Teuchos::rcp( new MatrixMarketFileIOHandler() );
47  } else
48 #endif
49  {
50  // Throw an exception because the format type is not recognized by this factory
51  }
52  //
53  // Return the method created
54  //
55  return RBFileIO;
56  }
57 
58 } // end of RBGen namespace
59 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
FileIOHandler for reading an Epetra_MultiVector from Burkardt data files.
bool isSublist(const std::string &name) const
EpetraMVFileIOFactory()
Default constructor.
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")