RBGen  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RBGen_EpetraMVMethodFactory.cpp
1 #include "RBGen_EpetraMVMethodFactory.h"
2 #include "RBGen_LapackPOD.h"
3 #include "Teuchos_Assert.hpp"
4 
5 #ifdef HAVE_RBGEN_ANASAZI
6 #include "RBGen_AnasaziPOD.h"
7 #include "RBGen_ISVD_SingleUDV.h"
8 #include "RBGen_ISVD_MultiCDUDV.h"
9 #include "RBGen_ISVD_MultiSDAUDV.h"
10 #include "RBGen_ISVD_MultiSDBUDV.h"
11 #include "RBGen_StSVD_RTR.h"
12 #endif
13 
14 namespace RBGen {
15 
16  Teuchos::RCP<Method<Epetra_MultiVector,Epetra_Operator> > EpetraMVMethodFactory::create( const Teuchos::ParameterList& params )
17  {
18  TEUCHOS_TEST_FOR_EXCEPTION(!params.isSublist( "Reduced Basis Method" ), std::invalid_argument, "Reduced Basis Method sublist does not exist!");
19 
20  // Get the "Reduced Basis Method" sublist.
21  const Teuchos::ParameterList& rbmethod_params = params.sublist( "Reduced Basis Method" );
22 
23  // Get the file format type
24  std::string method = Teuchos::getParameter<std::string>( const_cast<Teuchos::ParameterList&>(rbmethod_params),
25  "Method" );
26 
28 
29  // POD computed using exact SVD through LAPACK
30  if ( method == "Lapack POD" ) {
31  RBMethod = Teuchos::rcp( new LapackPOD() );
32  }
33  // Inexact POD computed using inexact SVD through Anasazi
34  // IncSVDPOD uses Anasazi utility classes, while AnasaziPOD uses Anasazi for the solution
35 #ifdef HAVE_RBGEN_ANASAZI
36  else if ( method == "IncSVD POD" ) {
37  std::string incsvdmethod = rbmethod_params.get<std::string>("IncSVD Method");
38  if ( incsvdmethod == "Single/UDV" ) {
39  RBMethod = Teuchos::rcp( new ISVD_SingleUDV() );
40  }
41  else if ( incsvdmethod == "MultiCD/UDV" ) {
42  RBMethod = Teuchos::rcp( new ISVD_MultiCDUDV() );
43  }
44  else if ( incsvdmethod == "MultiSDA/UDV" ) {
45  RBMethod = Teuchos::rcp( new ISVD_MultiSDAUDV() );
46  }
47  else if ( incsvdmethod == "MultiSDB/UDV" ) {
48  RBMethod = Teuchos::rcp( new ISVD_MultiSDBUDV() );
49  }
50  }
51  else if ( method == "StSVD/RTR") {
52  RBMethod = Teuchos::rcp( new StSVDRTR() );
53  }
54  else if ( method == "Anasazi POD" ) {
55  RBMethod = Teuchos::rcp( new AnasaziPOD() );
56  } else
57 #endif
58  {
59  std::string err_str = "Reduced basis method, 'Method = " + method + "', is not recognized!";
60  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument, err_str);
61  }
62  //
63  // Return the method created
64  //
65  return RBMethod;
66  }
67 
68 } // end of RBGen namespace
69 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Provides POD method using Anasazi eigensolvers.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
bool isSublist(const std::string &name) const
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")