Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Attributes | Private Attributes | Friends | List of all members
Nektar::SolverUtils::DriverSteadyState Class Reference

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

#include <DriverSteadyState.h>

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

Public Member Functions

void ConvergenceHistory (const Array< OneD, const Array< OneD, NekDouble > > &qBar1, const Array< OneD, const Array< OneD, NekDouble > > &q0, NekDouble &MaxNormDiff_q_qBar, NekDouble &MaxNormDiff_q1_q0)
void EvaluateNextSFDVariables (const int i, const Array< OneD, const Array< OneD, NekDouble > > &q0, const Array< OneD, const Array< OneD, NekDouble > > &qBar0, Array< OneD, Array< OneD, NekDouble > > &q1, Array< OneD, Array< OneD, NekDouble > > &qBar1)
void RunBDF2 (const int i, const Array< OneD, const Array< OneD, NekDouble > > &qMinus1, const Array< OneD, const Array< OneD, NekDouble > > &qBarMinus1, const Array< OneD, const Array< OneD, NekDouble > > &q0, const Array< OneD, const Array< OneD, NekDouble > > &qBar0, Array< OneD, Array< OneD, NekDouble > > &q1, Array< OneD, Array< OneD, NekDouble > > &qBar1)
void RunBDF1 (const int i, const Array< OneD, const Array< OneD, NekDouble > > &q0, const Array< OneD, const Array< OneD, NekDouble > > &qBar0, Array< OneD, Array< OneD, NekDouble > > &q1, Array< OneD, Array< OneD, NekDouble > > &qBar1)
void ExactFilters (const int i, const Array< OneD, const Array< OneD, NekDouble > > &q0, const Array< OneD, const Array< OneD, NekDouble > > &qBar0, Array< OneD, Array< OneD, NekDouble > > &q1, Array< OneD, Array< OneD, NekDouble > > &qBar1)
void SecondOrderFilter (const int i, const Array< OneD, const Array< OneD, NekDouble > > &qBarMinus1, const Array< OneD, const Array< OneD, NekDouble > > &q0, const Array< OneD, const Array< OneD, NekDouble > > &qBar0, Array< OneD, Array< OneD, NekDouble > > &q1, Array< OneD, Array< OneD, NekDouble > > &qBar1)
- Public Member Functions inherited from Nektar::SolverUtils::Driver
virtual ~Driver ()
 Destructor.
SOLVER_UTILS_EXPORT void InitObject (ostream &out=cout)
 Initialise Object.
SOLVER_UTILS_EXPORT void Execute (ostream &out=cout)
 Execute driver.
SOLVER_UTILS_EXPORT Array
< OneD,
EquationSystemSharedPtr
GetEqu ()
SOLVER_UTILS_EXPORT Array
< OneD, NekDouble
GetRealEvl (void)
SOLVER_UTILS_EXPORT Array
< OneD, NekDouble
GetImagEvl (void)

Static Public Member Functions

static DriverSharedPtr create (const LibUtilities::SessionReaderSharedPtr &pSession)
 Creates an instance of this class.

Static Public Attributes

static std::string className = GetDriverFactory().RegisterCreatorFunction("SteadyState", DriverSteadyState::create)
 Name of the class.

Protected Member Functions

SOLVER_UTILS_EXPORT DriverSteadyState (const LibUtilities::SessionReaderSharedPtr pSession)
 Constructor.
virtual SOLVER_UTILS_EXPORT ~DriverSteadyState ()
 Destructor.
virtual SOLVER_UTILS_EXPORT void v_InitObject (ostream &out=cout)
 Second-stage initialisation.
virtual SOLVER_UTILS_EXPORT void v_Execute (ostream &out=cout)
 Virtual function for solve implementation.
- Protected Member Functions inherited from Nektar::SolverUtils::Driver
 Driver (const LibUtilities::SessionReaderSharedPtr pSession)
 Initialises EquationSystem class members.
virtual SOLVER_UTILS_EXPORT
Array< OneD, NekDouble
v_GetRealEvl (void)
virtual SOLVER_UTILS_EXPORT
Array< OneD, NekDouble
v_GetImagEvl (void)

Static Protected Attributes

static std::string driverLookupId = LibUtilities::SessionReader::RegisterEnumValue("Driver","SteadyState",0)
- Static Protected Attributes inherited from Nektar::SolverUtils::Driver
static std::string evolutionOperatorLookupIds []
static std::string evolutionOperatorDef = LibUtilities::SessionReader::RegisterDefaultSolverInfo("EvolutionOperator","Nonlinear")
static std::string driverDefault = LibUtilities::SessionReader::RegisterDefaultSolverInfo("Driver","Standard")

Private Attributes

NekDouble m_Delta
NekDouble m_Delta0
NekDouble m_X
NekDouble m_X0
NekDouble m_dt
NekDouble c1
NekDouble F11
NekDouble F12
NekDouble F21
NekDouble F22
int m_n
int m_Check
int m_infosteps
int m_checksteps
NekDouble m_MinNormDiff_q_qBar
NekDouble m_MaxNormDiff_q_qBar
NekDouble m_First_MinNormDiff_q_qBar
int NumVar_SFD
int MPIrank
NekDouble MaxNormDiff_q_qBar
NekDouble MaxNormDiff_q1_q0
NekDouble Min_MaxNormDiff_q_qBar
std::ofstream m_file

Friends

class MemoryManager< DriverSteadyState >

Additional Inherited Members

- Protected Attributes inherited from Nektar::SolverUtils::Driver
LibUtilities::CommSharedPtr m_comm
 Communication object.
LibUtilities::SessionReaderSharedPtr m_session
 Session reader object.
Array< OneD,
EquationSystemSharedPtr
m_equ
 Equation system to solve.
int m_nequ
 number of equations
enum EvolutionOperatorType m_EvolutionOperator
 Evolution Operator.

Detailed Description

Base class for the development of solvers.

Definition at line 46 of file DriverSteadyState.h.

Constructor & Destructor Documentation

Nektar::SolverUtils::DriverSteadyState::DriverSteadyState ( const LibUtilities::SessionReaderSharedPtr  pSession)
protected

Constructor.

Definition at line 49 of file DriverSteadyState.cpp.

: Driver(pSession)
{
}
Nektar::SolverUtils::DriverSteadyState::~DriverSteadyState ( )
protectedvirtual

Destructor.

Definition at line 58 of file DriverSteadyState.cpp.

{
}

Member Function Documentation

void Nektar::SolverUtils::DriverSteadyState::ConvergenceHistory ( const Array< OneD, const Array< OneD, NekDouble > > &  qBar1,
const Array< OneD, const Array< OneD, NekDouble > > &  q0,
NekDouble MaxNormDiff_q_qBar,
NekDouble MaxNormDiff_q1_q0 
)

Definition at line 213 of file DriverSteadyState.cpp.

References m_Delta0, Nektar::SolverUtils::Driver::m_equ, m_file, m_n, m_X0, MPIrank, and NumVar_SFD.

Referenced by v_Execute().

{
//This routine evaluates |q-qBar|_L2 and save the value in "ConvergenceHistory.txt"
Array<OneD, NekDouble > NormDiff_q_qBar(NumVar_SFD, 1.0);
Array<OneD, NekDouble > NormDiff_q1_q0(NumVar_SFD, 1.0);
//Norm Calculation
for(int i = 0; i < NumVar_SFD; ++i)
{
//To check convergence of SFD
//NormDiff_q_qBar[i] = m_equ[0]->L2Error(i, qBar1[i], false);
NormDiff_q_qBar[i] = m_equ[0]->LinfError(i, qBar1[i]);
//To check convergence of Navier-Stokes
NormDiff_q1_q0[i] = m_equ[0]->LinfError(i, q0[i]);
if (MaxNormDiff_q_qBar < NormDiff_q_qBar[i])
{
MaxNormDiff_q_qBar = NormDiff_q_qBar[i];
}
if (MaxNormDiff_q1_q0 < NormDiff_q1_q0[i])
{
MaxNormDiff_q1_q0 = NormDiff_q1_q0[i];
}
}
#if NEKTAR_USE_MPI
MPI_Comm_rank(MPI_COMM_WORLD,&MPIrank);
if (MPIrank==0)
{
cout << "SFD (MPI) - Step: " << m_n+1 << "; Time: " << m_equ[0]->GetFinalTime() << "; |q-qBar|inf = " << MaxNormDiff_q_qBar << "; |q1-q0|inf = " << MaxNormDiff_q1_q0 << ";\t for X = " << m_X0 <<" and Delta = " << m_Delta0 <<endl;
std::ofstream m_file( "ConvergenceHistory.txt", std::ios_base::app);
m_file << m_n+1 << "\t" << m_equ[0]->GetFinalTime() << "\t" << MaxNormDiff_q_qBar << "\t" << MaxNormDiff_q1_q0 << endl;
m_file.close();
}
#else
cout << "SFD - Step: " << m_n+1 << "; Time: " << m_equ[0]->GetFinalTime() << "; |q-qBar|inf = " << MaxNormDiff_q_qBar << "; |q1-q0|inf = " << MaxNormDiff_q1_q0 << ";\t for X = " << m_X0 <<" and Delta = " << m_Delta0 <<endl;
std::ofstream m_file( "ConvergenceHistory.txt", std::ios_base::app);
m_file << m_n+1 << "\t" << m_equ[0]->GetFinalTime() << "\t" << MaxNormDiff_q_qBar << "\t" << MaxNormDiff_q1_q0 << endl;
m_file.close();
#endif
}
static DriverSharedPtr Nektar::SolverUtils::DriverSteadyState::create ( const LibUtilities::SessionReaderSharedPtr pSession)
inlinestatic

Creates an instance of this class.

Definition at line 52 of file DriverSteadyState.h.

{
p->InitObject();
return p;
}
void Nektar::SolverUtils::DriverSteadyState::EvaluateNextSFDVariables ( const int  i,
const Array< OneD, const Array< OneD, NekDouble > > &  q0,
const Array< OneD, const Array< OneD, NekDouble > > &  qBar0,
Array< OneD, Array< OneD, NekDouble > > &  q1,
Array< OneD, Array< OneD, NekDouble > > &  qBar1 
)
void Nektar::SolverUtils::DriverSteadyState::ExactFilters ( const int  i,
const Array< OneD, const Array< OneD, NekDouble > > &  q0,
const Array< OneD, const Array< OneD, NekDouble > > &  qBar0,
Array< OneD, Array< OneD, NekDouble > > &  q1,
Array< OneD, Array< OneD, NekDouble > > &  qBar1 
)

Definition at line 195 of file DriverSteadyState.cpp.

References F11, F12, F21, F22, Nektar::SolverUtils::Driver::m_equ, and Vmath::Svtvp().

Referenced by v_Execute().

{
q1[i] = Array<OneD, NekDouble> (m_equ[0]->GetTotPoints(),0.0);
qBar1[i] = Array<OneD, NekDouble> (m_equ[0]->GetTotPoints(),0.0);
//Exact solution of the Filters equation
Vmath::Svtvp(q1[i].num_elements(), F11, q0[i], 1, q1[i], 1, q1[i], 1 );
Vmath::Svtvp(q1[i].num_elements(), F12, qBar0[i], 1, q1[i], 1, q1[i], 1 );
Vmath::Svtvp(qBar1[i].num_elements(), F21, q0[i], 1, qBar1[i], 1, qBar1[i], 1 );
Vmath::Svtvp(qBar1[i].num_elements(), F22, qBar0[i], 1, qBar1[i], 1, qBar1[i], 1 );
}
void Nektar::SolverUtils::DriverSteadyState::RunBDF1 ( const int  i,
const Array< OneD, const Array< OneD, NekDouble > > &  q0,
const Array< OneD, const Array< OneD, NekDouble > > &  qBar0,
Array< OneD, Array< OneD, NekDouble > > &  q1,
Array< OneD, Array< OneD, NekDouble > > &  qBar1 
)
void Nektar::SolverUtils::DriverSteadyState::RunBDF2 ( const int  i,
const Array< OneD, const Array< OneD, NekDouble > > &  qMinus1,
const Array< OneD, const Array< OneD, NekDouble > > &  qBarMinus1,
const Array< OneD, const Array< OneD, NekDouble > > &  q0,
const Array< OneD, const Array< OneD, NekDouble > > &  qBar0,
Array< OneD, Array< OneD, NekDouble > > &  q1,
Array< OneD, Array< OneD, NekDouble > > &  qBar1 
)
void Nektar::SolverUtils::DriverSteadyState::SecondOrderFilter ( const int  i,
const Array< OneD, const Array< OneD, NekDouble > > &  qBarMinus1,
const Array< OneD, const Array< OneD, NekDouble > > &  q0,
const Array< OneD, const Array< OneD, NekDouble > > &  qBar0,
Array< OneD, Array< OneD, NekDouble > > &  q1,
Array< OneD, Array< OneD, NekDouble > > &  qBar1 
)
void Nektar::SolverUtils::DriverSteadyState::v_Execute ( ostream &  out = cout)
protectedvirtual

Virtual function for solve implementation.

Implements Nektar::SolverUtils::Driver.

Definition at line 72 of file DriverSteadyState.cpp.

References c1, ConvergenceHistory(), ExactFilters(), F11, F12, F21, F22, m_Check, m_checksteps, Nektar::SolverUtils::Driver::m_comm, m_Delta, m_Delta0, m_dt, Nektar::SolverUtils::Driver::m_equ, m_file, m_infosteps, m_n, Nektar::SolverUtils::Driver::m_session, m_X, m_X0, MaxNormDiff_q1_q0, MaxNormDiff_q_qBar, Min_MaxNormDiff_q_qBar, NumVar_SFD, and TOL.

{
//With a loop over "DoSolve", this Driver implements the "encaplulated" Selective Frequency Damping method
//to find the steady state of a flow above the critical Reynolds number.
m_equ[0]->PrintSummary(out);
m_equ[0]->DoInitialise();
// - SFD Routine -
// Compressible case
NumVar_SFD = m_equ[0]->UpdateFields()[0]->GetCoordim(0);
if (m_session->GetSolverInfo("EqType") == "EulerCFE" ||
m_session->GetSolverInfo("EqType") == "NavierStokesCFE")
{
NumVar_SFD += 2; //Number of variables for the compressible equations
}
Array<OneD, Array<OneD, NekDouble> > q0(NumVar_SFD);
Array<OneD, Array<OneD, NekDouble> > q1(NumVar_SFD);
Array<OneD, Array<OneD, NekDouble> > qBar0(NumVar_SFD);
Array<OneD, Array<OneD, NekDouble> > qBar1(NumVar_SFD);
m_n=0;
m_Check=0;
m_session->LoadParameter("FilterWidth", m_Delta0, 1);
m_session->LoadParameter("ControlCoeff",m_X0, 1);
m_session->LoadParameter("TOL", TOL, 1.0e-08);
m_session->LoadParameter("IO_InfoSteps", m_infosteps, 1000);
m_session->LoadParameter("IO_CheckSteps", m_checksteps, 100000);
m_dt = m_equ[0]->GetTimeStep();
//The time-step is applied here to clarify the matrix F expression
//Exact solution of the Filters equation (ici on a X_tilde et Delta_tile!!!)
c1 = 1.0/(1.0 + m_X*m_Delta);
F11 = c1*(1.0 + m_X*m_Delta*exp(-(m_X + 1.0/m_Delta)));
F12 = c1*(m_X*m_Delta*(1.0 - exp(-(m_X + 1.0/m_Delta))));
F21 = c1*(1.0 - exp(-(m_X + 1.0/m_Delta)));
F22 = c1*(m_X*m_Delta + exp(-(m_X + 1.0/m_Delta)));
cout << "------------------ SFD Parameters ------------------" << endl;
cout << "\tX = " << m_X0 << endl;
cout << "\tDelta = " << m_Delta0 << endl;
cout << "----------------------------------------------------" << endl;
m_equ[0]->SetStepsToOne(); //m_steps is set to 1. Then "m_equ[0]->DoSolve()" will run for only one time step
ofstream m_file("ConvergenceHistory.txt", ios::out | ios::trunc);
for(int i = 0; i < NumVar_SFD; ++i)
{
q0[i] = Array<OneD, NekDouble> (m_equ[0]->GetTotPoints(), 0.0); //q0 is initialised
qBar0[i] = Array<OneD, NekDouble> (m_equ[0]->GetTotPoints(), 0.0);
m_equ[0]->CopyFromPhysField(i, qBar0[i]); //qBar0 is initially set at beiing equal to the initial conditions provided in the input file
}
{
//First order Splitting with exact resolution of the filters equation
m_equ[0]->DoSolve();
for(int i = 0; i < NumVar_SFD; ++i)
{
m_equ[0]->CopyFromPhysField(i, q0[i]);
//Apply the linear operator F to the outcome of the solver
ExactFilters(i, q0, qBar0, q1, qBar1);
qBar0[i] = qBar1[i];
m_equ[0]->CopyToPhysField(i, q1[i]);
}
if(m_infosteps && !((m_n+1)%m_infosteps))
{
}
if(m_checksteps && m_n&&(!((m_n+1)%m_checksteps)))
{
m_Check++;
m_equ[0]->Checkpoint_Output(m_Check);
}
m_n++;
}
cout << "\nFINAL Filter Width: Delta = " << m_Delta << "; FINAL Control Coeff: X = " << m_X << "\n" << endl;
m_equ[0]->Checkpoint_Output(m_Check);
m_file.close();
// - End SFD Routine -
m_equ[0]->Output();
// Evaluate and output computation time and solution accuracy.
// The specific format of the error output is essential for the
// regression tests to work.
// Evaluate L2 Error
for(int i = 0; i < m_equ[0]->GetNvariables(); ++i)
{
NekDouble vL2Error = m_equ[0]->L2Error(i,false);
NekDouble vLinfError = m_equ[0]->LinfError(i);
if (m_comm->GetRank() == 0)
{
out << "L 2 error (variable " << m_equ[0]->GetVariable(i) << ") : " << vL2Error << endl;
out << "L inf error (variable " << m_equ[0]->GetVariable(i) << ") : " << vLinfError << endl;
}
}
}
void Nektar::SolverUtils::DriverSteadyState::v_InitObject ( ostream &  out = cout)
protectedvirtual

Second-stage initialisation.

Reimplemented from Nektar::SolverUtils::Driver.

Definition at line 66 of file DriverSteadyState.cpp.

Friends And Related Function Documentation

friend class MemoryManager< DriverSteadyState >
friend

Definition at line 49 of file DriverSteadyState.h.

Member Data Documentation

NekDouble Nektar::SolverUtils::DriverSteadyState::c1
private

Definition at line 124 of file DriverSteadyState.h.

Referenced by v_Execute().

string Nektar::SolverUtils::DriverSteadyState::className = GetDriverFactory().RegisterCreatorFunction("SteadyState", DriverSteadyState::create)
static

Name of the class.

Definition at line 59 of file DriverSteadyState.h.

string Nektar::SolverUtils::DriverSteadyState::driverLookupId = LibUtilities::SessionReader::RegisterEnumValue("Driver","SteadyState",0)
staticprotected

Definition at line 113 of file DriverSteadyState.h.

NekDouble Nektar::SolverUtils::DriverSteadyState::F11
private

Definition at line 125 of file DriverSteadyState.h.

Referenced by ExactFilters(), and v_Execute().

NekDouble Nektar::SolverUtils::DriverSteadyState::F12
private

Definition at line 126 of file DriverSteadyState.h.

Referenced by ExactFilters(), and v_Execute().

NekDouble Nektar::SolverUtils::DriverSteadyState::F21
private

Definition at line 127 of file DriverSteadyState.h.

Referenced by ExactFilters(), and v_Execute().

NekDouble Nektar::SolverUtils::DriverSteadyState::F22
private

Definition at line 128 of file DriverSteadyState.h.

Referenced by ExactFilters(), and v_Execute().

int Nektar::SolverUtils::DriverSteadyState::m_Check
private

Definition at line 131 of file DriverSteadyState.h.

Referenced by v_Execute().

int Nektar::SolverUtils::DriverSteadyState::m_checksteps
private

Definition at line 134 of file DriverSteadyState.h.

Referenced by v_Execute().

NekDouble Nektar::SolverUtils::DriverSteadyState::m_Delta
private

Definition at line 117 of file DriverSteadyState.h.

Referenced by v_Execute().

NekDouble Nektar::SolverUtils::DriverSteadyState::m_Delta0
private

Definition at line 118 of file DriverSteadyState.h.

Referenced by ConvergenceHistory(), and v_Execute().

NekDouble Nektar::SolverUtils::DriverSteadyState::m_dt
private

Definition at line 121 of file DriverSteadyState.h.

Referenced by v_Execute().

std::ofstream Nektar::SolverUtils::DriverSteadyState::m_file
private

Definition at line 149 of file DriverSteadyState.h.

Referenced by ConvergenceHistory(), and v_Execute().

NekDouble Nektar::SolverUtils::DriverSteadyState::m_First_MinNormDiff_q_qBar
private

Definition at line 138 of file DriverSteadyState.h.

int Nektar::SolverUtils::DriverSteadyState::m_infosteps
private

Definition at line 133 of file DriverSteadyState.h.

Referenced by v_Execute().

NekDouble Nektar::SolverUtils::DriverSteadyState::m_MaxNormDiff_q_qBar
private

Definition at line 137 of file DriverSteadyState.h.

NekDouble Nektar::SolverUtils::DriverSteadyState::m_MinNormDiff_q_qBar
private

Definition at line 136 of file DriverSteadyState.h.

int Nektar::SolverUtils::DriverSteadyState::m_n
private

Definition at line 130 of file DriverSteadyState.h.

Referenced by ConvergenceHistory(), and v_Execute().

NekDouble Nektar::SolverUtils::DriverSteadyState::m_X
private

Definition at line 119 of file DriverSteadyState.h.

Referenced by v_Execute().

NekDouble Nektar::SolverUtils::DriverSteadyState::m_X0
private

Definition at line 120 of file DriverSteadyState.h.

Referenced by ConvergenceHistory(), and v_Execute().

NekDouble Nektar::SolverUtils::DriverSteadyState::MaxNormDiff_q1_q0
private

Definition at line 145 of file DriverSteadyState.h.

Referenced by v_Execute().

NekDouble Nektar::SolverUtils::DriverSteadyState::MaxNormDiff_q_qBar
private

Definition at line 144 of file DriverSteadyState.h.

Referenced by v_Execute().

NekDouble Nektar::SolverUtils::DriverSteadyState::Min_MaxNormDiff_q_qBar
private

Definition at line 147 of file DriverSteadyState.h.

Referenced by v_Execute().

int Nektar::SolverUtils::DriverSteadyState::MPIrank
private

Definition at line 142 of file DriverSteadyState.h.

Referenced by ConvergenceHistory().

int Nektar::SolverUtils::DriverSteadyState::NumVar_SFD
private

Definition at line 140 of file DriverSteadyState.h.

Referenced by ConvergenceHistory(), and v_Execute().