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:
[legend]

Public Member Functions

virtual ~Driver ()=default
 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, EquationSystemSharedPtrGetEqu ()
 

Protected Member Functions

 Driver (const LibUtilities::SessionReaderSharedPtr pSession, const SpatialDomains::MeshGraphSharedPtr pGraph)
 Initialises EquationSystem class members. More...
 
virtual SOLVER_UTILS_EXPORT void v_InitObject (std::ostream &out=std::cout)
 Virtual function for initialisation implementation. More...
 
virtual SOLVER_UTILS_EXPORT void v_Execute (std::ostream &out=std::cout)=0
 Virtual function for solve implementation. More...
 

Protected Attributes

LibUtilities::CommSharedPtr m_comm
 Communication object. More...
 
LibUtilities::SessionReaderSharedPtr m_session
 Session reader object. More...
 
LibUtilities::SessionReaderSharedPtr session_LinNS
 Coupling between SFD and arnoldi. More...
 
SpatialDomains::MeshGraphSharedPtr m_graph
 MeshGraph object. 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 64 of file Driver.h.

Constructor & Destructor Documentation

◆ ~Driver()

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

Destructor.

◆ Driver()

Nektar::SolverUtils::Driver::Driver ( const LibUtilities::SessionReaderSharedPtr  pSession,
const SpatialDomains::MeshGraphSharedPtr  pGraph 
)
protected

Initialises EquationSystem class members.

Definition at line 75 of file Driver.cpp.

77 : m_comm(pSession->GetComm()), m_session(pSession), m_graph(pGraph)
78{
79}
LibUtilities::SessionReaderSharedPtr m_session
Session reader object.
Definition: Driver.h:83
LibUtilities::CommSharedPtr m_comm
Communication object.
Definition: Driver.h:80
SpatialDomains::MeshGraphSharedPtr m_graph
MeshGraph object.
Definition: Driver.h:89

Member Function Documentation

◆ Execute()

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

Execute driver.

Definition at line 122 of file Driver.h.

123{
124 v_Execute(out);
125}
virtual SOLVER_UTILS_EXPORT void v_Execute(std::ostream &out=std::cout)=0
Virtual function for solve implementation.

References v_Execute().

◆ GetEqu()

Array< OneD, EquationSystemSharedPtr > Nektar::SolverUtils::Driver::GetEqu ( )
inline

Definition at line 127 of file Driver.h.

128{
129 return m_equ;
130}
Array< OneD, EquationSystemSharedPtr > m_equ
Equation system to solve.
Definition: Driver.h:92

References m_equ.

◆ InitObject()

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

Initialise Object.

Definition at line 117 of file Driver.h.

118{
119 v_InitObject(out);
120}
virtual SOLVER_UTILS_EXPORT void v_InitObject(std::ostream &out=std::cout)
Virtual function for initialisation implementation.
Definition: Driver.cpp:84

References v_InitObject().

◆ v_Execute()

virtual SOLVER_UTILS_EXPORT void Nektar::SolverUtils::Driver::v_Execute ( std::ostream &  out = std::cout)
protectedpure virtual

◆ v_InitObject()

void Nektar::SolverUtils::Driver::v_InitObject ( std::ostream &  out = std::cout)
protectedvirtual

Virtual function for initialisation implementation.

Todo:
At the moment this is Navier-Stokes specific - generalise?

Reimplemented in Nektar::SolverUtils::DriverAdaptive, Nektar::SolverUtils::DriverArnoldi, Nektar::SolverUtils::DriverArpack, Nektar::SolverUtils::DriverModifiedArnoldi, Nektar::SolverUtils::DriverParallelInTime, Nektar::SolverUtils::DriverParareal, Nektar::SolverUtils::DriverPFASST, Nektar::SolverUtils::DriverStandard, and Nektar::SolverUtils::DriverSteadyState.

Definition at line 84 of file Driver.cpp.

85{
86 try
87 {
88 // Retrieve the equation system to solve.
89 ASSERTL0(m_session->DefinesSolverInfo("EqType"),
90 "EqType SolverInfo tag must be defined.");
91 std::string vEquation = m_session->GetSolverInfo("EqType");
92 if (m_session->DefinesSolverInfo("SolverType"))
93 {
94 vEquation = m_session->GetSolverInfo("SolverType");
95 }
96
97 // Check such a module exists for this equation.
99 GetEquationSystemFactory().ModuleExists(vEquation),
100 "EquationSystem '" + vEquation +
101 "' is not defined.\n"
102 "Ensure equation name is correct and module is compiled.\n");
103
104 // Retrieve the type of evolution operator to use
105 /// @todo At the moment this is Navier-Stokes specific - generalise?
107 m_session->GetSolverInfoAsEnum<EvolutionOperatorType>(
108 "EvolutionOperator");
109
112 ? 2
113 : 1);
114
115 m_equ = Array<OneD, EquationSystemSharedPtr>(m_nequ);
116
117 // Set the AdvectiveType tag and create EquationSystem objects.
118 switch (m_EvolutionOperator)
119 {
120 case eNonlinear:
121 m_session->SetTag("AdvectiveType", "Convective");
123 vEquation, m_session, m_graph);
124 break;
125 case eDirect:
126 m_session->SetTag("AdvectiveType", "Linearised");
128 vEquation, m_session, m_graph);
129 break;
130 case eAdjoint:
131 m_session->SetTag("AdvectiveType", "Adjoint");
133 vEquation, m_session, m_graph);
134 break;
135 case eTransientGrowth:
136 // forward timestepping
137 m_session->SetTag("AdvectiveType", "Linearised");
139 vEquation, m_session, m_graph);
140
141 // backward timestepping
142 m_session->SetTag("AdvectiveType", "Adjoint");
144 vEquation, m_session, m_graph);
145 break;
146 case eSkewSymmetric:
147 m_session->SetTag("AdvectiveType", "SkewSymmetric");
149 vEquation, m_session, m_graph);
150 break;
151 case eAdaptiveSFD:
152 {
153 // use-opt-file
154 bool useOptFile =
155 m_session->DefinesCmdLineArgument("use-opt-file");
156 std::string optfilename =
157 useOptFile ? m_session->GetFilenames()[0] : "";
158
159 char *argv[] = {const_cast<char *>("IncNavierStokesSolver"),
160 const_cast<char *>("--use-opt-file"),
161 const_cast<char *>(optfilename.c_str()),
162 nullptr};
163
164 size_t argc = useOptFile ? 3 : 1;
165
166 std::vector<std::string> LinNSFilename;
167 if (m_comm->GetSize() == 1)
168 {
169 // Use .xml.gz file for serial case
170 LinNSFilename.push_back(m_session->GetSessionName() +
171 ".xml.gz");
172 }
173 else
174 {
175 // Use previous partition for parallel case
176 LinNSFilename.push_back(m_session->GetSessionName() +
177 "_xml");
178 }
179 LinNSFilename.push_back(m_session->GetSessionName() +
180 "_LinNS.xml");
181
183 argc, argv, LinNSFilename, m_comm);
184
185 // Set graph for LinNs solver.
188
189 // For running stability analysis
190 session_LinNS->SetTag("AdvectiveType", "Linearised");
192 vEquation, session_LinNS, graph_linns);
193
194 // For running the SFD method on the nonlinear problem
195 m_session->SetTag("AdvectiveType", "Convective");
197 vEquation, m_session, m_graph);
198 }
199 break;
200 default:
201 ASSERTL0(false, "Unrecognised evolution operator.");
202 }
203 }
204 catch (int e)
205 {
206 ASSERTL0(e == -1, "No such class class defined.");
207 out << "An error occurred during driver initialisation." << endl;
208 }
209}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
LibUtilities::SessionReaderSharedPtr session_LinNS
Coupling between SFD and arnoldi.
Definition: Driver.h:86
enum EvolutionOperatorType m_EvolutionOperator
Evolution Operator.
Definition: Driver.h:98
int m_nequ
number of equations
Definition: Driver.h:95
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::DomainRangeShPtr rng=LibUtilities::NullDomainRangeShPtr, bool fillGraph=true, SpatialDomains::MeshGraphSharedPtr partitionedGraph=nullptr)
Definition: MeshGraphIO.cpp:53
EquationSystemFactory & GetEquationSystemFactory()
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174

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

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

Member Data Documentation

◆ driverDefault

std::string Nektar::SolverUtils::Driver::driverDefault
staticprotected
Initial value:
=
"Standard")
static std::string RegisterDefaultSolverInfo(const std::string &pName, const std::string &pValue)
Registers the default string value of a solver info property.

Definition at line 114 of file Driver.h.

◆ evolutionOperatorDef

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

Definition at line 113 of file Driver.h.

◆ evolutionOperatorLookupIds

std::string Nektar::SolverUtils::Driver::evolutionOperatorLookupIds
staticprotected
Initial value:
= {
"Nonlinear", eNonlinear),
"Direct", eDirect),
"Adjoint", eAdjoint),
"EvolutionOperator", "TransientGrowth", eTransientGrowth),
"EvolutionOperator", "SkewSymmetric", eSkewSymmetric),
"EvolutionOperator", "AdaptiveSFD", eAdaptiveSFD)}
static std::string RegisterEnumValue(std::string pEnum, std::string pString, int pEnumValue)
Registers an enumeration value.

Definition at line 112 of file Driver.h.

◆ m_comm

LibUtilities::CommSharedPtr Nektar::SolverUtils::Driver::m_comm
protected

Communication object.

Definition at line 80 of file Driver.h.

Referenced by Nektar::SolverUtils::DriverParareal::ApplyWindowing(), Nektar::SolverUtils::DriverPFASST::ApplyWindowing(), Nektar::SolverUtils::DriverArnoldi::ArnoldiSummary(), Nektar::SolverUtils::DriverSteadyState::ConvergenceHistory(), Nektar::SolverUtils::DriverParareal::CopyConvergedCheckPoints(), Nektar::SolverUtils::DriverParallelInTime::EstimateCommunicationTime(), Nektar::SolverUtils::DriverModifiedArnoldi::EV_big(), Nektar::SolverUtils::DriverModifiedArnoldi::EV_post(), Nektar::SolverUtils::DriverModifiedArnoldi::EV_small(), Nektar::SolverUtils::DriverModifiedArnoldi::EV_test(), Nektar::SolverUtils::DriverParallelInTime::PrintErrorNorm(), Nektar::SolverUtils::DriverParallelInTime::PrintHeader(), Nektar::SolverUtils::DriverParallelInTime::PrintSolverInfo(), Nektar::SolverUtils::DriverParallelInTime::RecvFromPreviousProc(), Nektar::SolverUtils::DriverParallelInTime::SendToNextProc(), Nektar::SolverUtils::DriverAdaptive::v_Execute(), Nektar::SolverUtils::DriverArpack::v_Execute(), Nektar::SolverUtils::DriverModifiedArnoldi::v_Execute(), Nektar::SolverUtils::DriverParareal::v_Execute(), Nektar::SolverUtils::DriverPFASST::v_Execute(), Nektar::SolverUtils::DriverStandard::v_Execute(), Nektar::SolverUtils::DriverSteadyState::v_Execute(), v_InitObject(), Nektar::SolverUtils::DriverArpack::v_InitObject(), Nektar::SolverUtils::DriverModifiedArnoldi::v_InitObject(), and Nektar::SolverUtils::DriverParallelInTime::v_InitObject().

◆ m_equ

Array<OneD, EquationSystemSharedPtr> Nektar::SolverUtils::Driver::m_equ
protected

◆ m_EvolutionOperator

enum EvolutionOperatorType Nektar::SolverUtils::Driver::m_EvolutionOperator
protected

◆ m_graph

SpatialDomains::MeshGraphSharedPtr Nektar::SolverUtils::Driver::m_graph
protected

◆ m_nequ

int Nektar::SolverUtils::Driver::m_nequ
protected

◆ m_session

LibUtilities::SessionReaderSharedPtr Nektar::SolverUtils::Driver::m_session
protected

◆ session_LinNS

LibUtilities::SessionReaderSharedPtr Nektar::SolverUtils::Driver::session_LinNS
protected

Coupling between SFD and arnoldi.

Definition at line 86 of file Driver.h.

Referenced by v_InitObject().