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

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

#include <DriverArnoldi.h>

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

Public Member Functions

SOLVER_UTILS_EXPORT void ArnoldiSummary (std::ostream &out)
- 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)

Protected Member Functions

 DriverArnoldi (const LibUtilities::SessionReaderSharedPtr pSession)
 Constructor.
virtual ~DriverArnoldi ()
 Destructor.
void CopyArnoldiArrayToField (Array< OneD, NekDouble > &array)
 Copy Arnoldi storage to fields.
void CopyFieldToArnoldiArray (Array< OneD, NekDouble > &array)
 Copy fields to Arnoldi storage.
void CopyFwdToAdj ()
 Copy the forward field to the adjoint system in transient growth calculations.
void WriteFld (std::string file, std::vector< Array< OneD, NekDouble > > coeffs)
void WriteFld (std::string file, Array< OneD, NekDouble > coeffs)
void WriteEvs (ostream &evlout, const int k, const NekDouble real, const NekDouble imag, NekDouble resid=NekConstants::kNekUnsetDouble)
virtual void v_InitObject (ostream &out=cout)
virtual Array< OneD, NekDoublev_GetRealEvl (void)
virtual Array< OneD, NekDoublev_GetImagEvl (void)
- Protected Member Functions inherited from Nektar::SolverUtils::Driver
 Driver (const LibUtilities::SessionReaderSharedPtr pSession)
 Initialises EquationSystem class members.
virtual SOLVER_UTILS_EXPORT void v_Execute (ostream &out=cout)=0
 Virtual function for solve implementation.

Protected Attributes

int m_kdim
int m_nvec
 Dimension of Krylov subspace.
int m_nits
 Number of vectors to test.
NekDouble m_evtol
 Maxmum number of iterations.
NekDouble m_period
 Tolerance of iteratiosn.
bool m_timeSteppingAlgorithm
 Period of time stepping algorithm.
int m_infosteps
 underlying operator is time stepping
int m_nfields
 interval to dump information if required.
NekDouble m_realShift
NekDouble m_imagShift
Array< OneD, NekDoublem_real_evl
Array< OneD, NekDoublem_imag_evl
- Protected Attributes inherited from Nektar::SolverUtils::Driver
LibUtilities::CommSharedPtr m_comm
 Communication object.
LibUtilities::SessionReaderSharedPtr m_session
 Session reader object.
LibUtilities::SessionReaderSharedPtr session_LinNS
 I the Coupling between SFD and arnoldi.
Array< OneD,
EquationSystemSharedPtr
m_equ
 Equation system to solve.
int m_nequ
 number of equations
enum EvolutionOperatorType m_EvolutionOperator
 Evolution Operator.

Friends

class MemoryManager< DriverArnoldi >

Additional Inherited Members

- Static Protected Attributes inherited from Nektar::SolverUtils::Driver
static std::string evolutionOperatorLookupIds []
static std::string evolutionOperatorDef
static std::string driverDefault

Detailed Description

Base class for the development of solvers.

Definition at line 46 of file DriverArnoldi.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 46 of file DriverArnoldi.cpp.

References m_infosteps, and Nektar::SolverUtils::Driver::m_session.

: Driver(pSession)
{
m_session->LoadParameter("IO_InfoSteps", m_infosteps, 1);
};
Nektar::SolverUtils::DriverArnoldi::~DriverArnoldi ( )
protectedvirtual

Destructor.

Definition at line 56 of file DriverArnoldi.cpp.

{
};

Member Function Documentation

void Nektar::SolverUtils::DriverArnoldi::ArnoldiSummary ( std::ostream &  out)

Definition at line 102 of file DriverArnoldi.cpp.

References ASSERTL0, Nektar::SolverUtils::Driver::m_comm, m_evtol, m_imagShift, m_kdim, m_nits, m_nvec, m_realShift, Nektar::SolverUtils::Driver::m_session, and m_timeSteppingAlgorithm.

Referenced by Nektar::SolverUtils::DriverModifiedArnoldi::v_InitObject(), and Nektar::SolverUtils::DriverArpack::v_InitObject().

{
if (m_comm->GetRank() == 0)
{
if(m_session->DefinesSolverInfo("SingleMode"))
{
out << "\tSingle Fourier mode : true " << endl;
ASSERTL0(m_session->DefinesSolverInfo("Homogeneous"),
"Expected a homogeneous expansion to be defined "
"with single mode");
}
else
{
out << "\tSingle Fourier mode : false " << endl;
}
if(m_session->DefinesSolverInfo("BetaZero"))
{
out << "\tBeta set to Zero : true (overrides LHom)"
<< endl;
}
else
{
out << "\tBeta set to Zero : false " << endl;
}
{
out << "\tEvolution operator : "
<< m_session->GetSolverInfo("EvolutionOperator")
<< endl;
}
else
{
out << "\tShift (Real,Imag) : " << m_realShift
<< "," << m_imagShift << endl;
}
out << "\tKrylov-space dimension : " << m_kdim << endl;
out << "\tNumber of vectors : " << m_nvec << endl;
out << "\tMax iterations : " << m_nits << endl;
out << "\tEigenvalue tolerance : " << m_evtol << endl;
out << "======================================================"
<< endl;
}
}
void Nektar::SolverUtils::DriverArnoldi::CopyArnoldiArrayToField ( Array< OneD, NekDouble > &  array)
protected

Copy Arnoldi storage to fields.

Copy Arnoldi array to field variables which depend from either the m_fields or m_forces

Definition at line 151 of file DriverArnoldi.cpp.

References Nektar::SolverUtils::Driver::m_equ, m_nfields, and Vmath::Vcopy().

Referenced by Nektar::SolverUtils::DriverModifiedArnoldi::EV_update(), and Nektar::SolverUtils::DriverArpack::v_Execute().

{
Array<OneD, MultiRegions::ExpListSharedPtr>& fields = m_equ[0]->UpdateFields();
int nq = fields[0]->GetNcoeffs();
for (int k = 0; k < m_nfields; ++k)
{
Vmath::Vcopy(nq, &array[k*nq], 1, &fields[k]->UpdateCoeffs()[0], 1);
fields[k]->SetPhysState(false);
}
};
void Nektar::SolverUtils::DriverArnoldi::CopyFieldToArnoldiArray ( Array< OneD, NekDouble > &  array)
protected

Copy fields to Arnoldi storage.

Copy field variables which depend from either the m_fields or m_forces array the Arnoldi array

Definition at line 168 of file DriverArnoldi.cpp.

References Nektar::SolverUtils::eAdaptiveSFD, Nektar::SolverUtils::Driver::m_equ, Nektar::SolverUtils::Driver::m_EvolutionOperator, Nektar::SolverUtils::Driver::m_nequ, m_nfields, and Vmath::Vcopy().

Referenced by Nektar::SolverUtils::DriverModifiedArnoldi::EV_update(), Nektar::SolverUtils::DriverModifiedArnoldi::v_Execute(), and Nektar::SolverUtils::DriverArpack::v_Execute().

{
Array<OneD, MultiRegions::ExpListSharedPtr> fields;
{
//This matters for the Adaptive SFD method
//because m_equ[1] is the nonlinear problem with non homogeneous BCs.
fields = m_equ[0]->UpdateFields();
}
else
{
fields = m_equ[m_nequ-1]->UpdateFields();
}
for (int k = 0; k < m_nfields; ++k)
{
int nq = fields[0]->GetNcoeffs();
Vmath::Vcopy(nq, &fields[k]->GetCoeffs()[0], 1, &array[k*nq], 1);
fields[k]->SetPhysState(false);
}
};
void Nektar::SolverUtils::DriverArnoldi::CopyFwdToAdj ( )
protected

Copy the forward field to the adjoint system in transient growth calculations.

Initialisation for the transient growth

Definition at line 197 of file DriverArnoldi.cpp.

References ASSERTL0, Nektar::SolverUtils::Driver::m_equ, m_nfields, m_timeSteppingAlgorithm, and Vmath::Vcopy().

Referenced by Nektar::SolverUtils::DriverModifiedArnoldi::EV_update(), and Nektar::SolverUtils::DriverArpack::v_Execute().

{
Array<OneD, MultiRegions::ExpListSharedPtr> fields;
{
fields = m_equ[0]->UpdateFields();
int nq = fields[0]->GetNcoeffs();
for (int k=0 ; k < m_nfields; ++k)
{
Vmath::Vcopy(nq, &fields[k]->GetCoeffs()[0], 1,&m_equ[1]->UpdateFields()[k]->UpdateCoeffs()[0], 1);
}
}
else
{
ASSERTL0(false,"Transient Growth non available for Coupled Solver");
}
};
virtual Array<OneD, NekDouble> Nektar::SolverUtils::DriverArnoldi::v_GetImagEvl ( void  )
inlineprotectedvirtual

Reimplemented from Nektar::SolverUtils::Driver.

Definition at line 102 of file DriverArnoldi.h.

References m_imag_evl.

{
return m_imag_evl;
}
virtual Array<OneD, NekDouble> Nektar::SolverUtils::DriverArnoldi::v_GetRealEvl ( void  )
inlineprotectedvirtual

Reimplemented from Nektar::SolverUtils::Driver.

Definition at line 97 of file DriverArnoldi.h.

References m_real_evl.

{
return m_real_evl;
}
void Nektar::SolverUtils::DriverArnoldi::v_InitObject ( ostream &  out = cout)
protectedvirtual

Reimplemented from Nektar::SolverUtils::Driver.

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

Definition at line 64 of file DriverArnoldi.cpp.

References ASSERTL0, Nektar::SolverUtils::Driver::m_equ, m_evtol, m_imagShift, m_kdim, m_nfields, m_nits, m_nvec, m_period, m_realShift, Nektar::SolverUtils::Driver::m_session, and m_timeSteppingAlgorithm.

{
m_session->MatchSolverInfo("SolverType","VelocityCorrectionScheme",m_timeSteppingAlgorithm, false);
{
m_period = m_session->GetParameter("TimeStep")* m_session->GetParameter("NumSteps");
m_nfields = m_equ[0]->UpdateFields().num_elements() - 1;
if(m_session->DefinesSolverInfo("ModeType") &&
(m_session->GetSolverInfo("ModeType")=="SingleMode"|| m_session->GetSolverInfo("ModeType")=="HalfMode") )
{
for(int i = 0; i < m_nfields; ++i)
{
m_equ[0]->UpdateFields()[i]->SetWaveSpace(true);
}
}
}
else
{
m_period = 1.0;
ASSERTL0(m_session->DefinesFunction("BodyForce"),"A BodyForce section needs to be defined for this solver type");
m_nfields = m_equ[0]->UpdateFields().num_elements();
}
m_session->LoadParameter("kdim", m_kdim, 16);
m_session->LoadParameter("nvec", m_nvec, 2);
m_session->LoadParameter("nits", m_nits, 500);
m_session->LoadParameter("evtol", m_evtol, 1e-06);
m_session->LoadParameter("realShift", m_realShift, 0.0);
m_equ[0]->SetLambda(m_realShift);
m_session->LoadParameter("imagShift", m_imagShift, 0.0);
}
void Nektar::SolverUtils::DriverArnoldi::WriteEvs ( ostream &  evlout,
const int  k,
const NekDouble  real,
const NekDouble  imag,
NekDouble  resid = NekConstants::kNekUnsetDouble 
)
protected

Definition at line 253 of file DriverArnoldi.cpp.

References Nektar::NekConstants::kNekUnsetDouble, m_period, m_realShift, and m_timeSteppingAlgorithm.

Referenced by Nektar::SolverUtils::DriverModifiedArnoldi::EV_test(), and Nektar::SolverUtils::DriverArpack::v_Execute().

{
{
NekDouble abs_ev = hypot (re_ev, im_ev);
NekDouble ang_ev = atan2 (im_ev, re_ev);
evlout << setw(2) << i
<< setw(12) << abs_ev
<< setw(12) << ang_ev
<< setw(12) << log (abs_ev) / m_period
<< setw(12) << ang_ev / m_period;
{
evlout << setw(12) << resid;
}
evlout << endl;
}
else
{
NekDouble invmag = 1.0/(re_ev*re_ev + im_ev*im_ev);
evlout << setw(2) << i
<< setw(14) << re_ev
<< setw(14) << im_ev
<< setw(14) << -re_ev*invmag + m_realShift
<< setw(14) << im_ev*invmag;
{
evlout << setw(12) << resid;
}
evlout << endl;
}
}
void Nektar::SolverUtils::DriverArnoldi::WriteFld ( std::string  file,
std::vector< Array< OneD, NekDouble > >  coeffs 
)
protected

Definition at line 220 of file DriverArnoldi.cpp.

References ASSERTL1, Nektar::SolverUtils::Driver::m_equ, and m_nfields.

Referenced by Nektar::SolverUtils::DriverModifiedArnoldi::EV_post(), and Nektar::SolverUtils::DriverArpack::v_Execute().

{
std::vector<std::string> variables(m_nfields);
ASSERTL1(coeffs.size() >= m_nfields, "coeffs is not of the correct length");
for(int i = 0; i < m_nfields; ++i)
{
variables[i] = m_equ[0]->GetVariable(i);
}
m_equ[0]->WriteFld(file,m_equ[0]->UpdateFields()[0], coeffs, variables);
}
void Nektar::SolverUtils::DriverArnoldi::WriteFld ( std::string  file,
Array< OneD, NekDouble coeffs 
)
protected

Definition at line 235 of file DriverArnoldi.cpp.

References ASSERTL1, Nektar::SolverUtils::Driver::m_equ, and m_nfields.

{
std::vector<std::string> variables(m_nfields);
std::vector<Array<OneD, NekDouble> > fieldcoeffs(m_nfields);
int ncoeffs = m_equ[0]->UpdateFields()[0]->GetNcoeffs();
ASSERTL1(coeffs.num_elements() >= ncoeffs*m_nfields,"coeffs is not of sufficient size");
for(int i = 0; i < m_nfields; ++i)
{
variables[i] = m_equ[0]->GetVariable(i);
fieldcoeffs[i] = coeffs + i*ncoeffs;
}
m_equ[0]->WriteFld(file,m_equ[0]->UpdateFields()[0], fieldcoeffs, variables);
}

Friends And Related Function Documentation

friend class MemoryManager< DriverArnoldi >
friend

Definition at line 49 of file DriverArnoldi.h.

Member Data Documentation

NekDouble Nektar::SolverUtils::DriverArnoldi::m_evtol
protected
Array<OneD, NekDouble> Nektar::SolverUtils::DriverArnoldi::m_imag_evl
protected
NekDouble Nektar::SolverUtils::DriverArnoldi::m_imagShift
protected
int Nektar::SolverUtils::DriverArnoldi::m_infosteps
protected

underlying operator is time stepping

Definition at line 61 of file DriverArnoldi.h.

Referenced by DriverArnoldi(), and Nektar::SolverUtils::DriverArpack::v_Execute().

int Nektar::SolverUtils::DriverArnoldi::m_kdim
protected
int Nektar::SolverUtils::DriverArnoldi::m_nfields
protected
int Nektar::SolverUtils::DriverArnoldi::m_nits
protected
int Nektar::SolverUtils::DriverArnoldi::m_nvec
protected
NekDouble Nektar::SolverUtils::DriverArnoldi::m_period
protected

Tolerance of iteratiosn.

Definition at line 58 of file DriverArnoldi.h.

Referenced by v_InitObject(), and WriteEvs().

Array<OneD, NekDouble> Nektar::SolverUtils::DriverArnoldi::m_real_evl
protected
NekDouble Nektar::SolverUtils::DriverArnoldi::m_realShift
protected
bool Nektar::SolverUtils::DriverArnoldi::m_timeSteppingAlgorithm
protected