Nektar++
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. 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

 DriverArnoldi (const LibUtilities::SessionReaderSharedPtr pSession)
 Constructor. More...
 
virtual ~DriverArnoldi ()
 Destructor. More...
 
void CopyArnoldiArrayToField (Array< OneD, NekDouble > &array)
 Copy Arnoldi storage to fields. More...
 
void CopyFieldToArnoldiArray (Array< OneD, NekDouble > &array)
 Copy fields to Arnoldi storage. More...
 
void CopyFwdToAdj ()
 Copy the forward field to the adjoint system in transient growth calculations. More...
 
void WriteFld (std::string file, std::vector< Array< OneD, NekDouble > > coeffs)
 Write coefficients to file. More...
 
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, bool DumpInverse=true)
 
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. More...
 
virtual SOLVER_UTILS_EXPORT void v_Execute (ostream &out=cout)=0
 Virtual function for solve implementation. More...
 

Protected Attributes

int m_kdim
 
int m_nvec
 Dimension of Krylov subspace. More...
 
int m_nits
 Number of vectors to test. More...
 
NekDouble m_evtol
 Maxmum number of iterations. More...
 
NekDouble m_period
 Tolerance of iteratiosn. More...
 
bool m_timeSteppingAlgorithm
 Period of time stepping algorithm. More...
 
int m_infosteps
 underlying operator is time stepping More...
 
int m_nfields
 interval to dump information if required. More...
 
NekDouble m_realShift
 
NekDouble m_imagShift
 
int m_negatedOp
 
Array< OneD, NekDoublem_real_evl
 Operator in solve call is negated. More...
 
Array< OneD, NekDoublem_imag_evl
 
- Protected Attributes inherited from Nektar::SolverUtils::Driver
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...
 

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 47 of file DriverArnoldi.h.

Constructor & Destructor Documentation

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

Constructor.

Constructor

Definition at line 47 of file DriverArnoldi.cpp.

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

48  : Driver(pSession)
49 {
50  m_session->LoadParameter("IO_InfoSteps", m_infosteps, 1);
51 };
Driver(const LibUtilities::SessionReaderSharedPtr pSession)
Initialises EquationSystem class members.
Definition: Driver.cpp:76
int m_infosteps
underlying operator is time stepping
Definition: DriverArnoldi.h:62
LibUtilities::SessionReaderSharedPtr m_session
Session reader object.
Definition: Driver.h:88
Nektar::SolverUtils::DriverArnoldi::~DriverArnoldi ( )
protectedvirtual

Destructor.

Destructor

Definition at line 57 of file DriverArnoldi.cpp.

58 {
59 };

Member Function Documentation

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

Definition at line 110 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().

111 {
112  if (m_comm->GetRank() == 0)
113  {
114  if(m_session->DefinesSolverInfo("ModeType") &&
115  boost::iequals(m_session->GetSolverInfo("ModeType"),
116  "SingleMode"))
117  {
118  out << "\tSingle Fourier mode : true " << endl;
119  ASSERTL0(m_session->DefinesSolverInfo("Homogeneous"),
120  "Expected a homogeneous expansion to be defined "
121  "with single mode");
122  }
123  else
124  {
125  out << "\tSingle Fourier mode : false " << endl;
126  }
127  if(m_session->DefinesSolverInfo("BetaZero"))
128  {
129  out << "\tBeta set to Zero : true (overrides LHom)"
130  << endl;
131  }
132  else
133  {
134  out << "\tBeta set to Zero : false " << endl;
135  }
136 
138  {
139  out << "\tEvolution operator : "
140  << m_session->GetSolverInfo("EvolutionOperator")
141  << endl;
142  }
143  else
144  {
145  out << "\tShift (Real,Imag) : " << m_realShift
146  << "," << m_imagShift << endl;
147  }
148  out << "\tKrylov-space dimension : " << m_kdim << endl;
149  out << "\tNumber of vectors : " << m_nvec << endl;
150  out << "\tMax iterations : " << m_nits << endl;
151  out << "\tEigenvalue tolerance : " << m_evtol << endl;
152  out << "======================================================"
153  << endl;
154  }
155 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
NekDouble m_evtol
Maxmum number of iterations.
Definition: DriverArnoldi.h:58
int m_nvec
Dimension of Krylov subspace.
Definition: DriverArnoldi.h:56
bool m_timeSteppingAlgorithm
Period of time stepping algorithm.
Definition: DriverArnoldi.h:60
LibUtilities::CommSharedPtr m_comm
Communication object.
Definition: Driver.h:85
LibUtilities::SessionReaderSharedPtr m_session
Session reader object.
Definition: Driver.h:88
int m_nits
Number of vectors to test.
Definition: DriverArnoldi.h:57
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 161 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().

162 {
163 
164  Array<OneD, MultiRegions::ExpListSharedPtr>& fields = m_equ[0]->UpdateFields();
165  int nq = fields[0]->GetNcoeffs();
166 
167  for (int k = 0; k < m_nfields; ++k)
168  {
169  Vmath::Vcopy(nq, &array[k*nq], 1, &fields[k]->UpdateCoeffs()[0], 1);
170  fields[k]->SetPhysState(false);
171  }
172 };
int m_nfields
interval to dump information if required.
Definition: DriverArnoldi.h:64
Array< OneD, EquationSystemSharedPtr > m_equ
Equation system to solve.
Definition: Driver.h:94
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1038
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 178 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().

179 {
180 
182 
184  {
185  // This matters for the Adaptive SFD method because
186  // m_equ[1] is the nonlinear problem with non
187  // homogeneous BCs.
188  fields = m_equ[0]->UpdateFields();
189  }
190  else
191  {
192  fields = m_equ[m_nequ-1]->UpdateFields();
193  }
194 
195  for (int k = 0; k < m_nfields; ++k)
196  {
197  int nq = fields[0]->GetNcoeffs();
198  Vmath::Vcopy(nq, &fields[k]->GetCoeffs()[0], 1, &array[k*nq], 1);
199  fields[k]->SetPhysState(false);
200 
201  }
202 };
enum EvolutionOperatorType m_EvolutionOperator
Evolution Operator.
Definition: Driver.h:100
int m_nfields
interval to dump information if required.
Definition: DriverArnoldi.h:64
Array< OneD, EquationSystemSharedPtr > m_equ
Equation system to solve.
Definition: Driver.h:94
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1038
int m_nequ
number of equations
Definition: Driver.h:97
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 208 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().

209 {
211 
213  {
214  fields = m_equ[0]->UpdateFields();
215  int nq = fields[0]->GetNcoeffs();
216 
217  for (int k=0 ; k < m_nfields; ++k)
218  {
219  Vmath::Vcopy(nq,
220  &fields[k]->GetCoeffs()[0], 1,
221  &m_equ[1]->UpdateFields()[k]->UpdateCoeffs()[0], 1);
222 
223  }
224  }
225  else
226  {
227  ASSERTL0(false,"Transient Growth non available for Coupled Solver");
228 
229  }
230 };
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
int m_nfields
interval to dump information if required.
Definition: DriverArnoldi.h:64
bool m_timeSteppingAlgorithm
Period of time stepping algorithm.
Definition: DriverArnoldi.h:60
Array< OneD, EquationSystemSharedPtr > m_equ
Equation system to solve.
Definition: Driver.h:94
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1038
virtual Array<OneD, NekDouble> Nektar::SolverUtils::DriverArnoldi::v_GetImagEvl ( void  )
inlineprotectedvirtual

Reimplemented from Nektar::SolverUtils::Driver.

Definition at line 107 of file DriverArnoldi.h.

References m_imag_evl.

108  {
109  return m_imag_evl;
110  }
Array< OneD, NekDouble > m_imag_evl
Definition: DriverArnoldi.h:70
virtual Array<OneD, NekDouble> Nektar::SolverUtils::DriverArnoldi::v_GetRealEvl ( void  )
inlineprotectedvirtual

Reimplemented from Nektar::SolverUtils::Driver.

Definition at line 102 of file DriverArnoldi.h.

References m_real_evl.

103  {
104  return m_real_evl;
105  }
Array< OneD, NekDouble > m_real_evl
Operator in solve call is negated.
Definition: DriverArnoldi.h:69
void Nektar::SolverUtils::DriverArnoldi::v_InitObject ( ostream &  out = cout)
protectedvirtual

Arnoldi driver initialisation

Reimplemented from Nektar::SolverUtils::Driver.

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

Definition at line 65 of file DriverArnoldi.cpp.

References Nektar::SolverUtils::Driver::m_equ, m_evtol, m_imagShift, m_kdim, m_negatedOp, m_nfields, m_nits, m_nvec, m_period, m_realShift, Nektar::SolverUtils::Driver::m_session, m_timeSteppingAlgorithm, and Nektar::SolverUtils::Driver::v_InitObject().

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

66 {
68  m_session->MatchSolverInfo("SolverType",
69  "VelocityCorrectionScheme",
71 
73  {
74  m_period = m_session->GetParameter("TimeStep")
75  * m_session->GetParameter("NumSteps");
76  m_nfields = m_equ[0]->UpdateFields().num_elements() - 1;
77 
78  }
79  else
80  {
81  m_period = 1.0;
82  m_nfields = m_equ[0]->UpdateFields().num_elements();
83  }
84 
85  if(m_session->DefinesSolverInfo("ModeType") &&
86  (boost::iequals(m_session->GetSolverInfo("ModeType"),
87  "SingleMode")||
88  boost::iequals(m_session->GetSolverInfo("ModeType"),
89  "HalfMode")))
90  {
91  for(int i = 0; i < m_nfields; ++i)
92  {
93  m_equ[0]->UpdateFields()[i]->SetWaveSpace(true);
94  }
95  }
96  m_negatedOp = m_equ[0]->v_NegatedOp();
97 
98  m_session->LoadParameter("kdim", m_kdim, 16);
99  m_session->LoadParameter("nvec", m_nvec, 2);
100  m_session->LoadParameter("nits", m_nits, 500);
101  m_session->LoadParameter("evtol", m_evtol, 1e-06);
102 
103  m_session->LoadParameter("realShift", m_realShift, 0.0);
104  m_equ[0]->SetLambda(m_realShift);
105 
106  m_session->LoadParameter("imagShift", m_imagShift, 0.0);
107 
108 }
NekDouble m_evtol
Maxmum number of iterations.
Definition: DriverArnoldi.h:58
virtual SOLVER_UTILS_EXPORT void v_InitObject(ostream &out=cout)
Definition: Driver.cpp:90
int m_nvec
Dimension of Krylov subspace.
Definition: DriverArnoldi.h:56
int m_nfields
interval to dump information if required.
Definition: DriverArnoldi.h:64
bool m_timeSteppingAlgorithm
Period of time stepping algorithm.
Definition: DriverArnoldi.h:60
Array< OneD, EquationSystemSharedPtr > m_equ
Equation system to solve.
Definition: Driver.h:94
NekDouble m_period
Tolerance of iteratiosn.
Definition: DriverArnoldi.h:59
LibUtilities::SessionReaderSharedPtr m_session
Session reader object.
Definition: Driver.h:88
int m_nits
Number of vectors to test.
Definition: DriverArnoldi.h:57
void Nektar::SolverUtils::DriverArnoldi::WriteEvs ( ostream &  evlout,
const int  k,
const NekDouble  real,
const NekDouble  imag,
NekDouble  resid = NekConstants::kNekUnsetDouble,
bool  DumpInverse = true 
)
protected

Definition at line 265 of file DriverArnoldi.cpp.

References Nektar::NekConstants::kNekUnsetDouble, m_imagShift, m_negatedOp, m_period, m_realShift, m_timeSteppingAlgorithm, and sign.

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

272 {
274  {
275  NekDouble abs_ev = hypot (re_ev, im_ev);
276  NekDouble ang_ev = atan2 (im_ev, re_ev);
277 
278  evlout << "EV: " << setw(2) << i
279  << setw(12) << abs_ev
280  << setw(12) << ang_ev
281  << setw(12) << log (abs_ev) / m_period
282  << setw(12) << ang_ev / m_period;
283 
284  if(resid != NekConstants::kNekUnsetDouble)
285  {
286  evlout << setw(12) << resid;
287  }
288  evlout << endl;
289  }
290  else
291  {
292  NekDouble invmag = 1.0/(re_ev*re_ev + im_ev*im_ev);
293  NekDouble sign;
294  if(m_negatedOp)
295  {
296  sign = -1.0;
297  }
298  else
299  {
300  sign = 1.0;
301  }
302 
303  evlout << "EV: " << setw(2) << i
304  << setw(14) << sign*re_ev
305  << setw(14) << sign*im_ev;
306 
307  if(DumpInverse)
308  {
309  evlout << setw(14) << sign*re_ev*invmag + m_realShift
310  << setw(14) << sign*im_ev*invmag + m_imagShift;
311  }
312 
313  if(resid != NekConstants::kNekUnsetDouble)
314  {
315  evlout << setw(12) << resid;
316  }
317  evlout << endl;
318  }
319 }
#define sign(a, b)
return the sign(b)*a
Definition: Polylib.cpp:22
double NekDouble
static const NekDouble kNekUnsetDouble
bool m_timeSteppingAlgorithm
Period of time stepping algorithm.
Definition: DriverArnoldi.h:60
NekDouble m_period
Tolerance of iteratiosn.
Definition: DriverArnoldi.h:59
void Nektar::SolverUtils::DriverArnoldi::WriteFld ( std::string  file,
std::vector< Array< OneD, NekDouble > >  coeffs 
)
protected

Write coefficients to file.

Definition at line 232 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().

233 {
234 
235  std::vector<std::string> variables(m_nfields);
236 
237  ASSERTL1(coeffs.size() >= m_nfields, "coeffs is not of the correct length");
238  for(int i = 0; i < m_nfields; ++i)
239  {
240  variables[i] = m_equ[0]->GetVariable(i);
241  }
242 
243  m_equ[0]->WriteFld(file,m_equ[0]->UpdateFields()[0], coeffs, variables);
244 }
int m_nfields
interval to dump information if required.
Definition: DriverArnoldi.h:64
Array< OneD, EquationSystemSharedPtr > m_equ
Equation system to solve.
Definition: Driver.h:94
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:191
void Nektar::SolverUtils::DriverArnoldi::WriteFld ( std::string  file,
Array< OneD, NekDouble coeffs 
)
protected

Definition at line 247 of file DriverArnoldi.cpp.

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

248 {
249 
250  std::vector<std::string> variables(m_nfields);
251  std::vector<Array<OneD, NekDouble> > fieldcoeffs(m_nfields);
252 
253  int ncoeffs = m_equ[0]->UpdateFields()[0]->GetNcoeffs();
254  ASSERTL1(coeffs.num_elements() >= ncoeffs*m_nfields,"coeffs is not of sufficient size");
255 
256  for(int i = 0; i < m_nfields; ++i)
257  {
258  variables[i] = m_equ[0]->GetVariable(i);
259  fieldcoeffs[i] = coeffs + i*ncoeffs;
260  }
261 
262  m_equ[0]->WriteFld(file,m_equ[0]->UpdateFields()[0], fieldcoeffs, variables);
263 }
int m_nfields
interval to dump information if required.
Definition: DriverArnoldi.h:64
Array< OneD, EquationSystemSharedPtr > m_equ
Equation system to solve.
Definition: Driver.h:94
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:191

Friends And Related Function Documentation

friend class MemoryManager< DriverArnoldi >
friend

Definition at line 50 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 62 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_negatedOp
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 59 of file DriverArnoldi.h.

Referenced by v_InitObject(), and WriteEvs().

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

Operator in solve call is negated.

Definition at line 69 of file DriverArnoldi.h.

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

NekDouble Nektar::SolverUtils::DriverArnoldi::m_realShift
protected
bool Nektar::SolverUtils::DriverArnoldi::m_timeSteppingAlgorithm
protected