Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 (std::ostream &out=std::cout)
 Initialise Object. More...
 
SOLVER_UTILS_EXPORT void Execute (std::ostream &out=std::cout)
 Execute driver. More...
 
SOLVER_UTILS_EXPORT Array
< OneD,
EquationSystemSharedPtr
GetEqu ()
 
SOLVER_UTILS_EXPORT Array
< OneD, NekDouble
GetRealEvl (void)
 
SOLVER_UTILS_EXPORT Array
< OneD, NekDouble
GetImagEvl (void)
 

Protected Member Functions

 Driver (const LibUtilities::SessionReaderSharedPtr pSession)
 Initialises EquationSystem class members. More...
 
virtual SOLVER_UTILS_EXPORT void v_InitObject (std::ostream &out=std::cout)
 
virtual SOLVER_UTILS_EXPORT void v_Execute (std::ostream &out=std::cout)=0
 Virtual function for solve implementation. More...
 
virtual SOLVER_UTILS_EXPORT
Array< OneD, NekDouble
v_GetRealEvl (void)
 
virtual SOLVER_UTILS_EXPORT
Array< OneD, NekDouble
v_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,
EquationSystemSharedPtr
m_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 84 of file Driver.cpp.

86 {
87 }
Nektar::SolverUtils::Driver::Driver ( const LibUtilities::SessionReaderSharedPtr  pSession)
protected

Initialises EquationSystem class members.

Definition at line 78 of file Driver.cpp.

79  : m_comm(pSession->GetComm()),
80  m_session(pSession)
81 {
82 }
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 ( std::ostream &  out = std::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(std::ostream &out=std::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:200
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:194
void Nektar::SolverUtils::Driver::InitObject ( std::ostream &  out = std::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(std::ostream &out=std::cout)
Definition: Driver.cpp:92
virtual SOLVER_UTILS_EXPORT void Nektar::SolverUtils::Driver::v_Execute ( std::ostream &  out = std::cout)
protectedpure virtual
Array< OneD, NekDouble > Nektar::SolverUtils::Driver::v_GetImagEvl ( void  )
protectedvirtual

Reimplemented in Nektar::SolverUtils::DriverArnoldi.

Definition at line 200 of file Driver.cpp.

References ASSERTL0, and Nektar::NullNekDouble1DArray.

Referenced by GetImagEvl().

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

Reimplemented in Nektar::SolverUtils::DriverArnoldi.

Definition at line 194 of file Driver.cpp.

References ASSERTL0, and Nektar::NullNekDouble1DArray.

Referenced by GetRealEvl().

195 {
196  ASSERTL0(false,"This routine is not valid in this class");
197  return NullNekDouble1DArray;
198 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
static Array< OneD, NekDouble > NullNekDouble1DArray
void Nektar::SolverUtils::Driver::v_InitObject ( std::ostream &  out = std::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::DriverAdaptive, Nektar::SolverUtils::DriverModifiedArnoldi, and Nektar::SolverUtils::DriverStandard.

Definition at line 92 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::DriverAdaptive::v_Execute(), Nektar::SolverUtils::DriverStandard::v_InitObject(), Nektar::SolverUtils::DriverAdaptive::v_InitObject(), and Nektar::SolverUtils::DriverArnoldi::v_InitObject().

93 {
94  try
95  {
96  // Retrieve the equation system to solve.
97  ASSERTL0(m_session->DefinesSolverInfo("EqType"),
98  "EqType SolverInfo tag must be defined.");
99  std::string vEquation = m_session->GetSolverInfo("EqType");
100  if (m_session->DefinesSolverInfo("SolverType"))
101  {
102  vEquation = m_session->GetSolverInfo("SolverType");
103  }
104 
105  // Check such a module exists for this equation.
106  ASSERTL0(GetEquationSystemFactory().ModuleExists(vEquation),
107  "EquationSystem '" + vEquation + "' is not defined.\n"
108  "Ensure equation name is correct and module is compiled.\n");
109 
110  // Retrieve the type of evolution operator to use
111  /// @todo At the moment this is Navier-Stokes specific - generalise?
113  m_session->GetSolverInfoAsEnum<EvolutionOperatorType>(
114  "EvolutionOperator");
115 
117  m_EvolutionOperator == eAdaptiveSFD) ? 2 : 1);
118 
119  m_equ = Array<OneD, EquationSystemSharedPtr>(m_nequ);
120 
121  // Set the AdvectiveType tag and create EquationSystem objects.
122  switch (m_EvolutionOperator)
123  {
124  case eNonlinear:
125  m_session->SetTag("AdvectiveType","Convective");
127  vEquation, m_session);
128  break;
129  case eDirect:
130  m_session->SetTag("AdvectiveType","Linearised");
132  vEquation, m_session);
133  break;
134  case eAdjoint:
135  m_session->SetTag("AdvectiveType","Adjoint");
137  vEquation, m_session);
138  break;
139  case eTransientGrowth:
140  //forward timestepping
141  m_session->SetTag("AdvectiveType","Linearised");
143  vEquation, m_session);
144 
145  //backward timestepping
146  m_session->SetTag("AdvectiveType","Adjoint");
148  vEquation, m_session);
149  break;
150  case eSkewSymmetric:
151  m_session->SetTag("AdvectiveType","SkewSymmetric");
153  vEquation, m_session);
154  break;
155  case eAdaptiveSFD:
156  {
157  // Coupling SFD method and Arnoldi algorithm
158  // For having 2 equation systems defined into 2 different
159  // session files (with the mesh into a file named 'session'.gz)
160  string meshfile;
161  string LinNSCondFile;
162  vector<string> LinNSFilename;
163  meshfile = m_session->GetFilenames()[0];
164  LinNSCondFile = m_session->GetSessionName();
165  LinNSCondFile += "_LinNS.xml";
166  LinNSFilename.push_back(meshfile);
167  LinNSFilename.push_back(LinNSCondFile);
169  0, NULL, LinNSFilename, m_session->GetComm());
170 
171  //For running stability analysis
172  session_LinNS->SetTag("AdvectiveType","Linearised");
174  vEquation, session_LinNS);
175 
176  //For running the SFD method on the nonlinear problem
177  m_session->SetTag("AdvectiveType","Convective");
179  vEquation, m_session);
180  }
181  break;
182  default:
183  ASSERTL0(false, "Unrecognised evolution operator.");
184 
185  }
186  }
187  catch (int e)
188  {
189  ASSERTL0(e == -1, "No such class class defined.");
190  out << "An error occurred during driver initialisation." << endl;
191  }
192 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
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().