2 #include "RBGen_Params.h"
3 #include "RBGen_Utils.h"
4 #include "RBGen_EpetraMVFileIOFactory.h"
5 #include "RBGen_EpetraMVMethodFactory.h"
6 #include "RBGen_EpetraMVPreprocessorFactory.h"
7 #include "RBGen_EpetraCrsMatrixFileIOHandler.h"
8 #include "RBGen_PODMethod.hpp"
10 #include "Epetra_Map.h"
11 #include "Epetra_LocalMap.h"
12 #include "Epetra_LAPACK.h"
13 #include "Epetra_MultiVector.h"
16 #include "Epetra_MpiComm.h"
19 #include "Epetra_SerialComm.h"
27 #include "Teuchos_Assert.hpp"
29 int main(
int argc,
char* argv[] )
34 MPI_Init(&argc,&argv);
47 std::string xml_file =
"";
48 RBGen_CLP.
setOption(
"verbose",
"quiet", &verbose,
"Print messages and results.");
49 RBGen_CLP.
setOption(
"xml-file", &xml_file,
"XML Input File");
53 parseReturn= RBGen_CLP.
parse( argc, argv );
65 TEUCHOS_TEST_FOR_EXCEPTION(xml_file ==
"", std::invalid_argument,
"ERROR: An XML file was not provided; use --xml-file to provide an XML input file for this RBGen driver.");
74 if (verbose && Comm.
MyPID() == 0)
76 std::cout<<
"-------------------------------------------------------"<<std::endl;
77 std::cout<<
"Input Parameter List: "<<std::endl;
78 std::cout<<
"-------------------------------------------------------"<<std::endl;
100 mvFileIO = fio_factory.create( *BasisParams );
104 mvFileIO->Initialize( BasisParams );
105 opFileIO->Initialize( BasisParams );
107 if (verbose && Comm.
MyPID() == 0)
109 std::cout<<
"-------------------------------------------------------"<<std::endl;
110 std::cout<<
"File I/O Handlers Generated"<<std::endl;
111 std::cout<<
"-------------------------------------------------------"<<std::endl;
121 timersRBGen.
push_back( timerSnapshotIn );
126 testMV = mvFileIO->Read( *filenames );
132 timersRBGen.
push_back( timerCreatePreprocessor );
136 prep = preprocess_factory.create( *BasisParams );
140 prep->Initialize( BasisParams, mvFileIO );
144 timersRBGen.
push_back( timerPreprocess );
147 prep->Preprocess( testMV );
150 if (verbose && Comm.
MyPID() == 0)
152 std::cout<<
"-------------------------------------------------------"<<std::endl;
153 std::cout<<
"Snapshot Set Imported and Preprocessed"<<std::endl;
154 std::cout<<
"-------------------------------------------------------"<<std::endl;
168 timersRBGen.
push_back( timerCreateMethod );
172 method = mthd_factory.create( *BasisParams );
176 method->Initialize( BasisParams, testMV, opFileIO );
182 timersRBGen.
push_back( timerComputeBasis );
185 method->computeBasis();
195 const std::vector<double> sv = pod_method->getSingularValues();
197 if (verbose && Comm.
MyPID() == 0) {
198 std::cout<<
"-------------------------------------------------------"<<std::endl;
199 std::cout<<
"Computed Singular Values : "<<std::endl;
200 std::cout<<
"-------------------------------------------------------"<<std::endl;
201 for (
unsigned int i=0; i<sv.size(); ++i) { std::cout << sv[i] << std::endl; }
204 if (Comm.
MyPID() == 0) {
205 std::cout<<
"-------------------------------------------------------"<<std::endl;
206 std::cout<<
"RBGen Computation Time Breakdown (seconds) : "<<std::endl;
207 std::cout<<
"-------------------------------------------------------"<<std::endl;
208 for (
unsigned int i=0; i<timersRBGen.
size(); ++i)
209 std::cout << std::left << std::setw(40) << timersRBGen[i]->name() <<
" : "
210 << std::setw(15) << timersRBGen[i]->totalElapsedTime() << std::endl;
211 std::cout<<
"-------------------------------------------------------"<<std::endl;
223 if ( BasisParams->
isSublist(
"File IO" ) ) {
225 if ( fileio_params.
isParameter(
"Reduced Basis Output File" ) ) {
226 std::string outfile = Teuchos::getParameter<std::string>( fileio_params,
"Reduced Basis Output File" );
227 mvFileIO->Write( basisMV, outfile );
Teuchos::RCP< Teuchos::ParameterList > createParams(const std::string &filename)
Create a Teuchos::ParameterList from an XML file.
void recogniseAllOptions(const bool &recogniseAllOptions)
Specialization of a PreprocessorFactor for Epetra_MultiVector datasets.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
FileIOHandler for reading EpetraCrsMatrix data from a file using EpetraExt.
Specialization of MethodFactory for Epetra_MultiVector datasets.
Abstract factory for creating a concrete FileIOFactory for reading an Epetra_MultiVector.
Teuchos::RCP< std::vector< std::string > > genFileList(const Teuchos::ParameterList ¶ms)
Extract the filename list from a Teuchos::ParameterList.
bool isParameter(const std::string &name) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
bool isSublist(const std::string &name) const
EParseCommandLineReturn parse(int argc, char *argv[], std::ostream *errout=&std::cerr) const
void throwExceptions(const bool &throwExceptions)
void push_back(const value_type &x)
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")