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

 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 (std::ostream &evlout, const int k, const NekDouble real, const NekDouble imag, NekDouble resid=NekConstants::kNekUnsetDouble, bool DumpInverse=true)
 
virtual void v_InitObject (std::ostream &out=std::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 (std::ostream &out=std::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,
EquationSystemSharedPtr
m_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 49 of file DriverArnoldi.cpp.

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

50  : Driver(pSession)
51 {
52  m_session->LoadParameter("IO_InfoSteps", m_infosteps, 1);
53 };
Driver(const LibUtilities::SessionReaderSharedPtr pSession)
Initialises EquationSystem class members.
Definition: Driver.cpp:78
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 59 of file DriverArnoldi.cpp.

60 {
61 };

Member Function Documentation

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

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

115 {
116  if (m_comm->GetRank() == 0)
117  {
118  if(m_session->DefinesSolverInfo("ModeType") &&
119  boost::iequals(m_session->GetSolverInfo("ModeType"),
120  "SingleMode"))
121  {
122  out << "\tSingle Fourier mode : true " << endl;
123  ASSERTL0(m_session->DefinesSolverInfo("Homogeneous"),
124  "Expected a homogeneous expansion to be defined "
125  "with single mode");
126  }
127  else
128  {
129  out << "\tSingle Fourier mode : false " << endl;
130  }
131  if(m_session->DefinesSolverInfo("BetaZero"))
132  {
133  out << "\tBeta set to Zero : true (overrides LHom)"
134  << endl;
135  }
136  else
137  {
138  out << "\tBeta set to Zero : false " << endl;
139  }
140 
142  {
143  out << "\tEvolution operator : "
144  << m_session->GetSolverInfo("EvolutionOperator")
145  << endl;
146  }
147  else
148  {
149  out << "\tShift (Real,Imag) : " << m_realShift
150  << "," << m_imagShift << endl;
151  }
152  out << "\tKrylov-space dimension : " << m_kdim << endl;
153  out << "\tNumber of vectors : " << m_nvec << endl;
154  out << "\tMax iterations : " << m_nits << endl;
155  out << "\tEigenvalue tolerance : " << m_evtol << endl;
156  out << "======================================================"
157  << endl;
158  }
159 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
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 165 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().

166 {
167 
168  Array<OneD, MultiRegions::ExpListSharedPtr>& fields = m_equ[0]->UpdateFields();
169  int nq = fields[0]->GetNcoeffs();
170 
171  for (int k = 0; k < m_nfields; ++k)
172  {
173  Vmath::Vcopy(nq, &array[k*nq], 1, &fields[k]->UpdateCoeffs()[0], 1);
174  fields[k]->SetPhysState(false);
175  }
176 };
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:1047
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 182 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().

183 {
184 
185  Array<OneD, MultiRegions::ExpListSharedPtr> fields;
186 
188  {
189  // This matters for the Adaptive SFD method because
190  // m_equ[1] is the nonlinear problem with non
191  // homogeneous BCs.
192  fields = m_equ[0]->UpdateFields();
193  }
194  else
195  {
196  fields = m_equ[m_nequ-1]->UpdateFields();
197  }
198 
199  for (int k = 0; k < m_nfields; ++k)
200  {
201  int nq = fields[0]->GetNcoeffs();
202  Vmath::Vcopy(nq, &fields[k]->GetCoeffs()[0], 1, &array[k*nq], 1);
203  fields[k]->SetPhysState(false);
204 
205  }
206 };
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:1047
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 212 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().

213 {
214  Array<OneD, MultiRegions::ExpListSharedPtr> fields;
215 
217  {
218  fields = m_equ[0]->UpdateFields();
219  int nq = fields[0]->GetNcoeffs();
220 
221  for (int k=0 ; k < m_nfields; ++k)
222  {
223  Vmath::Vcopy(nq,
224  &fields[k]->GetCoeffs()[0], 1,
225  &m_equ[1]->UpdateFields()[k]->UpdateCoeffs()[0], 1);
226 
227  }
228  }
229  else
230  {
231  ASSERTL0(false,"Transient Growth non available for Coupled Solver");
232 
233  }
234 };
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
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:1047
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 ( std::ostream &  out = std::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 67 of file DriverArnoldi.cpp.

References ASSERTL0, 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().

68 {
70  m_session->MatchSolverInfo("SolverType",
71  "VelocityCorrectionScheme",
73 
75  {
76  m_period = m_session->GetParameter("TimeStep")
77  * m_session->GetParameter("NumSteps");
78  m_nfields = m_equ[0]->UpdateFields().num_elements() - 1;
79 
80  }
81  else
82  {
83  m_period = 1.0;
84  m_nfields = m_equ[0]->UpdateFields().num_elements();
85  }
86 
87  if(m_session->DefinesSolverInfo("ModeType") &&
88  (boost::iequals(m_session->GetSolverInfo("ModeType"),
89  "SingleMode")||
90  boost::iequals(m_session->GetSolverInfo("ModeType"),
91  "HalfMode")))
92  {
93  for(int i = 0; i < m_nfields; ++i)
94  {
95  m_equ[0]->UpdateFields()[i]->SetWaveSpace(true);
96  }
97  }
98  m_negatedOp = m_equ[0]->v_NegatedOp();
99 
100  m_session->LoadParameter("kdim", m_kdim, 16);
101  m_session->LoadParameter("nvec", m_nvec, 2);
102  m_session->LoadParameter("nits", m_nits, 500);
103  m_session->LoadParameter("evtol", m_evtol, 1e-06);
104 
105  ASSERTL0( m_kdim >= m_nvec, "nvec cannot be larger than kdim.");
106 
107  m_session->LoadParameter("realShift", m_realShift, 0.0);
108  m_equ[0]->SetLambda(m_realShift);
109 
110  m_session->LoadParameter("imagShift", m_imagShift, 0.0);
111 
112 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
NekDouble m_evtol
Maxmum number of iterations.
Definition: DriverArnoldi.h:58
virtual SOLVER_UTILS_EXPORT void v_InitObject(std::ostream &out=std::cout)
Definition: Driver.cpp:92
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 ( std::ostream &  evlout,
const int  k,
const NekDouble  real,
const NekDouble  imag,
NekDouble  resid = NekConstants::kNekUnsetDouble,
bool  DumpInverse = true 
)
protected

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

276 {
278  {
279  NekDouble abs_ev = hypot (re_ev, im_ev);
280  NekDouble ang_ev = atan2 (im_ev, re_ev);
281 
282  evlout << "EV: " << setw(2) << i
283  << setw(12) << abs_ev
284  << setw(12) << ang_ev
285  << setw(12) << log (abs_ev) / m_period
286  << setw(12) << ang_ev / m_period;
287 
288  if(resid != NekConstants::kNekUnsetDouble)
289  {
290  evlout << setw(12) << resid;
291  }
292  evlout << endl;
293  }
294  else
295  {
296  NekDouble invmag = 1.0/(re_ev*re_ev + im_ev*im_ev);
297  NekDouble sign;
298  if(m_negatedOp)
299  {
300  sign = -1.0;
301  }
302  else
303  {
304  sign = 1.0;
305  }
306 
307  evlout << "EV: " << setw(2) << i
308  << setw(14) << sign*re_ev
309  << setw(14) << sign*im_ev;
310 
311  if(DumpInverse)
312  {
313  evlout << setw(14) << sign*re_ev*invmag + m_realShift
314  << setw(14) << sign*im_ev*invmag + m_imagShift;
315  }
316 
317  if(resid != NekConstants::kNekUnsetDouble)
318  {
319  evlout << setw(12) << resid;
320  }
321  evlout << endl;
322  }
323 }
#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 236 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().

237 {
238 
239  std::vector<std::string> variables(m_nfields);
240 
241  ASSERTL1(coeffs.size() >= m_nfields, "coeffs is not of the correct length");
242  for(int i = 0; i < m_nfields; ++i)
243  {
244  variables[i] = m_equ[0]->GetVariable(i);
245  }
246 
247  m_equ[0]->WriteFld(file,m_equ[0]->UpdateFields()[0], coeffs, variables);
248 }
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:218
void Nektar::SolverUtils::DriverArnoldi::WriteFld ( std::string  file,
Array< OneD, NekDouble coeffs 
)
protected

Definition at line 251 of file DriverArnoldi.cpp.

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

252 {
253 
254  std::vector<std::string> variables(m_nfields);
255  std::vector<Array<OneD, NekDouble> > fieldcoeffs(m_nfields);
256 
257  int ncoeffs = m_equ[0]->UpdateFields()[0]->GetNcoeffs();
258  ASSERTL1(coeffs.num_elements() >= ncoeffs*m_nfields,"coeffs is not of sufficient size");
259 
260  for(int i = 0; i < m_nfields; ++i)
261  {
262  variables[i] = m_equ[0]->GetVariable(i);
263  fieldcoeffs[i] = coeffs + i*ncoeffs;
264  }
265 
266  m_equ[0]->WriteFld(file,m_equ[0]->UpdateFields()[0], fieldcoeffs, variables);
267 }
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:218

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