Nektar++
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Nektar::SolverUtils::Driver Class Referenceabstract

Base class for the development of solvers. More...

#include <Driver.h>

Inheritance diagram for Nektar::SolverUtils::Driver:
Inheritance graph
[legend]
Collaboration diagram for Nektar::SolverUtils::Driver:
Collaboration graph
[legend]

Public Member Functions

virtual ~Driver ()
 Destructor. More...
 
SOLVER_UTILS_EXPORT void InitObject (ostream &out=cout)
 Initialise Object. More...
 
SOLVER_UTILS_EXPORT void Execute (ostream &out=cout)
 Execute driver. More...
 
SOLVER_UTILS_EXPORT Array< OneD, EquationSystemSharedPtrGetEqu ()
 
SOLVER_UTILS_EXPORT Array< OneD, NekDoubleGetRealEvl (void)
 
SOLVER_UTILS_EXPORT Array< OneD, NekDoubleGetImagEvl (void)
 

Protected Member Functions

 Driver (const LibUtilities::SessionReaderSharedPtr pSession)
 Initialises EquationSystem class members. More...
 
virtual SOLVER_UTILS_EXPORT void v_InitObject (ostream &out=cout)
 
virtual SOLVER_UTILS_EXPORT void v_Execute (ostream &out=cout)=0
 Virtual function for solve implementation. More...
 
virtual SOLVER_UTILS_EXPORT Array< OneD, NekDoublev_GetRealEvl (void)
 
virtual SOLVER_UTILS_EXPORT Array< OneD, NekDoublev_GetImagEvl (void)
 

Protected Attributes

LibUtilities::CommSharedPtr m_comm
 Communication object. More...
 
LibUtilities::SessionReaderSharedPtr m_session
 Session reader object. More...
 
LibUtilities::SessionReaderSharedPtr session_LinNS
 I the Coupling between SFD and arnoldi. More...
 
Array< OneD, EquationSystemSharedPtrm_equ
 Equation system to solve. More...
 
int m_nequ
 number of equations More...
 
enum EvolutionOperatorType m_EvolutionOperator
 Evolution Operator. More...
 

Static Protected Attributes

static std::string evolutionOperatorLookupIds []
 
static std::string evolutionOperatorDef
 
static std::string driverDefault
 

Detailed Description

Base class for the development of solvers.

Definition at line 65 of file Driver.h.

Constructor & Destructor Documentation

Nektar::SolverUtils::Driver::~Driver ( )
virtual

Destructor.

Definition at line 82 of file Driver.cpp.

84 {
85 }
Nektar::SolverUtils::Driver::Driver ( const LibUtilities::SessionReaderSharedPtr  pSession)
protected

Initialises EquationSystem class members.

Definition at line 76 of file Driver.cpp.

77  : m_comm(pSession->GetComm()),
78  m_session(pSession)
79 {
80 }
LibUtilities::CommSharedPtr m_comm
Communication object.
Definition: Driver.h:85
LibUtilities::SessionReaderSharedPtr m_session
Session reader object.
Definition: Driver.h:88

Member Function Documentation

void Nektar::SolverUtils::Driver::Execute ( ostream &  out = cout)
inline

Execute driver.

Definition at line 126 of file Driver.h.

References v_Execute().

127 {
128  v_Execute(out);
129 }
virtual SOLVER_UTILS_EXPORT void v_Execute(ostream &out=cout)=0
Virtual function for solve implementation.
Array< OneD, EquationSystemSharedPtr > Nektar::SolverUtils::Driver::GetEqu ( )
inline

Definition at line 131 of file Driver.h.

References m_equ.

132 {
133  return m_equ;
134 }
Array< OneD, EquationSystemSharedPtr > m_equ
Equation system to solve.
Definition: Driver.h:94
Array< OneD, NekDouble > Nektar::SolverUtils::Driver::GetImagEvl ( void  )
inline

Definition at line 141 of file Driver.h.

References v_GetImagEvl().

142 {
143  return v_GetImagEvl();
144 }
virtual SOLVER_UTILS_EXPORT Array< OneD, NekDouble > v_GetImagEvl(void)
Definition: Driver.cpp:198
Array< OneD, NekDouble > Nektar::SolverUtils::Driver::GetRealEvl ( void  )
inline

Definition at line 136 of file Driver.h.

References v_GetRealEvl().

137 {
138  return v_GetRealEvl();
139 }
virtual SOLVER_UTILS_EXPORT Array< OneD, NekDouble > v_GetRealEvl(void)
Definition: Driver.cpp:192
void Nektar::SolverUtils::Driver::InitObject ( ostream &  out = cout)
inline

Initialise Object.

Definition at line 121 of file Driver.h.

References v_InitObject().

122 {
123  v_InitObject(out);
124 }
virtual SOLVER_UTILS_EXPORT void v_InitObject(ostream &out=cout)
Definition: Driver.cpp:90
virtual SOLVER_UTILS_EXPORT void Nektar::SolverUtils::Driver::v_Execute ( ostream &  out = cout)
protectedpure virtual
Array< OneD, NekDouble > Nektar::SolverUtils::Driver::v_GetImagEvl ( void  )
protectedvirtual

Reimplemented in Nektar::SolverUtils::DriverArnoldi.

Definition at line 198 of file Driver.cpp.

References ASSERTL0, and Nektar::NullNekDouble1DArray.

Referenced by GetImagEvl().

199 {
200  ASSERTL0(false,"This routine is not valid in this class");
201  return NullNekDouble1DArray;
202 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
static Array< OneD, NekDouble > NullNekDouble1DArray
Array< OneD, NekDouble > Nektar::SolverUtils::Driver::v_GetRealEvl ( void  )
protectedvirtual

Reimplemented in Nektar::SolverUtils::DriverArnoldi.

Definition at line 192 of file Driver.cpp.

References ASSERTL0, and Nektar::NullNekDouble1DArray.

Referenced by GetRealEvl().

193 {
194  ASSERTL0(false,"This routine is not valid in this class");
195  return NullNekDouble1DArray;
196 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
static Array< OneD, NekDouble > NullNekDouble1DArray
void Nektar::SolverUtils::Driver::v_InitObject ( ostream &  out = cout)
protectedvirtual
Todo:
At the moment this is Navier-Stokes specific - generalise?

Reimplemented in Nektar::SolverUtils::DriverSteadyState, Nektar::SolverUtils::DriverArnoldi, Nektar::SolverUtils::DriverArpack, Nektar::SolverUtils::DriverModifiedArnoldi, and Nektar::SolverUtils::DriverStandard.

Definition at line 90 of file Driver.cpp.

References ASSERTL0, Nektar::LibUtilities::SessionReader::CreateInstance(), Nektar::LibUtilities::NekFactory< tKey, tBase, >::CreateInstance(), Nektar::SolverUtils::eAdaptiveSFD, Nektar::SolverUtils::eAdjoint, Nektar::SolverUtils::eDirect, Nektar::SolverUtils::eNonlinear, Nektar::SolverUtils::eSkewSymmetric, Nektar::SolverUtils::eTransientGrowth, Nektar::SolverUtils::GetEquationSystemFactory(), m_equ, m_EvolutionOperator, m_nequ, m_session, and session_LinNS.

Referenced by InitObject(), Nektar::SolverUtils::DriverStandard::v_InitObject(), and Nektar::SolverUtils::DriverArnoldi::v_InitObject().

91 {
92  try
93  {
94  // Retrieve the equation system to solve.
95  ASSERTL0(m_session->DefinesSolverInfo("EqType"),
96  "EqType SolverInfo tag must be defined.");
97  std::string vEquation = m_session->GetSolverInfo("EqType");
98  if (m_session->DefinesSolverInfo("SolverType"))
99  {
100  vEquation = m_session->GetSolverInfo("SolverType");
101  }
102 
103  // Check such a module exists for this equation.
104  ASSERTL0(GetEquationSystemFactory().ModuleExists(vEquation),
105  "EquationSystem '" + vEquation + "' is not defined.\n"
106  "Ensure equation name is correct and module is compiled.\n");
107 
108  // Retrieve the type of evolution operator to use
109  /// @todo At the moment this is Navier-Stokes specific - generalise?
111  m_session->GetSolverInfoAsEnum<EvolutionOperatorType>(
112  "EvolutionOperator");
113 
115  m_EvolutionOperator == eAdaptiveSFD) ? 2 : 1);
116 
118 
119  // Set the AdvectiveType tag and create EquationSystem objects.
120  switch (m_EvolutionOperator)
121  {
122  case eNonlinear:
123  m_session->SetTag("AdvectiveType","Convective");
125  vEquation, m_session);
126  break;
127  case eDirect:
128  m_session->SetTag("AdvectiveType","Linearised");
130  vEquation, m_session);
131  break;
132  case eAdjoint:
133  m_session->SetTag("AdvectiveType","Adjoint");
135  vEquation, m_session);
136  break;
137  case eTransientGrowth:
138  //forward timestepping
139  m_session->SetTag("AdvectiveType","Linearised");
141  vEquation, m_session);
142 
143  //backward timestepping
144  m_session->SetTag("AdvectiveType","Adjoint");
146  vEquation, m_session);
147  break;
148  case eSkewSymmetric:
149  m_session->SetTag("AdvectiveType","SkewSymmetric");
151  vEquation, m_session);
152  break;
153  case eAdaptiveSFD:
154  {
155  // Coupling SFD method and Arnoldi algorithm
156  // For having 2 equation systems defined into 2 different
157  // session files (with the mesh into a file named 'session'.gz)
158  string meshfile;
159  string LinNSCondFile;
160  vector<string> LinNSFilename;
161  meshfile = m_session->GetFilenames()[0];
162  LinNSCondFile = m_session->GetSessionName();
163  LinNSCondFile += "_LinNS.xml";
164  LinNSFilename.push_back(meshfile);
165  LinNSFilename.push_back(LinNSCondFile);
167  0, NULL, LinNSFilename, m_session->GetComm());
168 
169  //For running stability analysis
170  session_LinNS->SetTag("AdvectiveType","Linearised");
172  vEquation, session_LinNS);
173 
174  //For running the SFD method on the nonlinear problem
175  m_session->SetTag("AdvectiveType","Convective");
177  vEquation, m_session);
178  }
179  break;
180  default:
181  ASSERTL0(false, "Unrecognised evolution operator.");
182 
183  }
184  }
185  catch (int e)
186  {
187  ASSERTL0(e == -1, "No such class class defined.");
188  out << "An error occurred during driver initialisation." << endl;
189  }
190 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:162
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
LibUtilities::SessionReaderSharedPtr session_LinNS
I the Coupling between SFD and arnoldi.
Definition: Driver.h:91
enum EvolutionOperatorType m_EvolutionOperator
Evolution Operator.
Definition: Driver.h:100
EquationSystemFactory & GetEquationSystemFactory()
Array< OneD, EquationSystemSharedPtr > m_equ
Equation system to solve.
Definition: Driver.h:94
LibUtilities::SessionReaderSharedPtr m_session
Session reader object.
Definition: Driver.h:88
int m_nequ
number of equations
Definition: Driver.h:97

Member Data Documentation

std::string Nektar::SolverUtils::Driver::driverDefault
staticprotected
Initial value:

Definition at line 117 of file Driver.h.

std::string Nektar::SolverUtils::Driver::evolutionOperatorDef
staticprotected
Initial value:
=
"EvolutionOperator","Nonlinear")

Definition at line 116 of file Driver.h.

std::string Nektar::SolverUtils::Driver::evolutionOperatorLookupIds
staticprotected
Initial value:
= {
"EvolutionOperator","Nonlinear" ,eNonlinear),
"EvolutionOperator","Direct" ,eDirect),
"EvolutionOperator","Adjoint" ,eAdjoint),
"EvolutionOperator","TransientGrowth",eTransientGrowth),
"EvolutionOperator","SkewSymmetric" ,eSkewSymmetric),
"EvolutionOperator","AdaptiveSFD" ,eAdaptiveSFD)
}

Definition at line 115 of file Driver.h.

LibUtilities::CommSharedPtr Nektar::SolverUtils::Driver::m_comm
protected
Array<OneD, EquationSystemSharedPtr> Nektar::SolverUtils::Driver::m_equ
protected
enum EvolutionOperatorType Nektar::SolverUtils::Driver::m_EvolutionOperator
protected
int Nektar::SolverUtils::Driver::m_nequ
protected
LibUtilities::SessionReaderSharedPtr Nektar::SolverUtils::Driver::m_session
protected
LibUtilities::SessionReaderSharedPtr Nektar::SolverUtils::Driver::session_LinNS
protected

I the Coupling between SFD and arnoldi.

Definition at line 91 of file Driver.h.

Referenced by v_InitObject().