48 DriverArnoldi::DriverArnoldi(
72 "VelocityCorrectionScheme",
88 if(
m_session->DefinesSolverInfo(
"ModeType") &&
89 (boost::iequals(
m_session->GetSolverInfo(
"ModeType"),
91 boost::iequals(
m_session->GetSolverInfo(
"ModeType"),
96 m_equ[0]->UpdateFields()[i]->SetWaveSpace(
true);
117 if(!
m_session->DefinesSolverInfo(
"HOMOGENEOUS")&&!
m_session->DefinesSolverInfo(
"ModeType"))
121 else if(!boost::iequals(
m_session->GetSolverInfo(
"ModeType"),
"SingleMode"))
131 if (
m_comm->GetRank() == 0)
133 if(
m_session->DefinesSolverInfo(
"ModeType") &&
134 boost::iequals(
m_session->GetSolverInfo(
"ModeType"),
137 out <<
"\tSingle Fourier mode : true " << endl;
139 "Expected a homogeneous expansion to be defined "
144 out <<
"\tSingle Fourier mode : false " << endl;
146 if(
m_session->DefinesSolverInfo(
"BetaZero"))
148 out <<
"\tBeta set to Zero : true (overrides LHom)"
153 out <<
"\tBeta set to Zero : false " << endl;
158 out <<
"\tEvolution operator : "
159 <<
m_session->GetSolverInfo(
"EvolutionOperator")
167 out <<
"\tKrylov-space dimension : " <<
m_kdim << endl;
168 out <<
"\tNumber of vectors : " <<
m_nvec << endl;
169 out <<
"\tMax iterations : " <<
m_nits << endl;
170 out <<
"\tEigenvalue tolerance : " <<
m_evtol << endl;
171 out <<
"======================================================"
184 int nq = fields[0]->GetNcoeffs();
188 Vmath::Vcopy(nq, &array[k*nq], 1, &fields[k]->UpdateCoeffs()[0], 1);
189 fields[k]->SetPhysState(
false);
207 fields =
m_equ[0]->UpdateFields();
216 int nq = fields[0]->GetNcoeffs();
217 Vmath::Vcopy(nq, &fields[k]->GetCoeffs()[0], 1, &array[k*nq], 1);
218 fields[k]->SetPhysState(
false);
232 "Transient Growth non available for Coupled Solver");
234 fields =
m_equ[0]->UpdateFields();
235 int nq = fields[0]->GetNcoeffs();
240 &fields[k]->GetCoeffs()[0], 1,
241 &
m_equ[1]->UpdateFields()[k]->UpdateCoeffs()[0], 1);
248 std::vector<std::string> variables(
m_nfields);
253 variables[i] =
m_equ[0]->GetVariable(i);
256 m_equ[0]->WriteFld(file,
m_equ[0]->UpdateFields()[0], coeffs, variables);
263 std::vector<std::string> variables(
m_nfields);
264 std::vector<Array<OneD, NekDouble> > fieldcoeffs(
m_nfields);
266 int ncoeffs =
m_equ[0]->UpdateFields()[0]->GetNcoeffs();
271 variables[i] =
m_equ[0]->GetVariable(i);
272 fieldcoeffs[i] = coeffs + i*ncoeffs;
275 m_equ[0]->WriteFld(file,
m_equ[0]->UpdateFields()[0], fieldcoeffs, variables);
291 evlout <<
"EV: " << setw(2) << i
292 << setw(12) << abs_ev
293 << setw(12) << ang_ev
299 evlout << setw(12) << resid;
305 NekDouble invmag = 1.0/(re_ev*re_ev + im_ev*im_ev);
316 evlout <<
"EV: " << setw(2) << i
317 << setw(14) <<
sign*re_ev
318 << setw(14) <<
sign*im_ev;
328 evlout << setw(12) << resid;
336 string Unmask0(
"Unmask0");
338 for(
size_t i=0; 1; ++i)
340 Unmask0[Unmask0.size()-1] =
'0' + i;
345 for(
size_t j=0; 1; ++j)
347 C0[C0.size()-1] =
'0' + j;
348 if(!
m_session->DefinesFunction(Unmask0, C0))
354 unmaskfun.push_back(std::vector<LibUtilities::EquationSharedPtr>());
356 unmaskfun[unmaskfun.size()-1].push_back(
m_session->GetFunction(Unmask0, C0));
363 std::vector<std::vector<LibUtilities::EquationSharedPtr> > unmaskfun;
365 if(unmaskfun.size()==0)
372 int ncoef = field->GetNcoeffs();
373 int nphys = field->GetNpoints();
376 for(
size_t i=0; i<field->GetExpSize(); ++i)
380 int nv = geom->GetNumVerts();
383 for(
size_t j=0; j<nv; ++j)
386 vertex->GetCoords(gct[0],gct[1],gct[2]);
392 for(
size_t m=0; m<unmaskfun.size(); ++m)
395 for(
size_t n=0; n<unmaskfun[m].size(); ++n)
397 if(unmaskfun[m][n]->Evaluate(gc[0], gc[1], gc[2])<=0.)
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#define sign(a, b)
return the sign(b)*a
virtual ~DriverArnoldi()
Destructor.
void CopyFwdToAdj()
Copy the forward field to the adjoint system in transient growth calculations.
void GetUnmaskFunction(std::vector< std::vector< LibUtilities::EquationSharedPtr > > &unmaskfun)
void WriteFld(std::string file, std::vector< Array< OneD, NekDouble > > coeffs)
Write coefficients to file.
NekDouble m_period
Tolerance of iteratiosn.
int m_infosteps
underlying operator is time stepping
Array< OneD, NekDouble > m_maskCoeffs
void CopyFieldToArnoldiArray(Array< OneD, NekDouble > &array)
Copy fields to Arnoldi storage.
virtual void v_InitObject(std::ostream &out=std::cout)
int m_nvec
Dimension of Krylov subspace.
bool m_timeSteppingAlgorithm
Period of time stepping algorithm.
int m_nits
Number of vectors to test.
void CopyArnoldiArrayToField(Array< OneD, NekDouble > &array)
Copy Arnoldi storage to fields.
Array< OneD, NekDouble > m_maskPhys
NekDouble m_evtol
Maxmum number of iterations.
int m_nfields
interval to dump information if required.
SOLVER_UTILS_EXPORT void ArnoldiSummary(std::ostream &out)
void WriteEvs(std::ostream &evlout, const int k, const NekDouble real, const NekDouble imag, NekDouble resid=NekConstants::kNekUnsetDouble, bool DumpInverse=true)
Base class for the development of solvers.
LibUtilities::SessionReaderSharedPtr m_session
Session reader object.
virtual SOLVER_UTILS_EXPORT void v_InitObject(std::ostream &out=std::cout)
LibUtilities::CommSharedPtr m_comm
Communication object.
enum EvolutionOperatorType m_EvolutionOperator
Evolution Operator.
Array< OneD, EquationSystemSharedPtr > m_equ
Equation system to solve.
int m_nequ
number of equations
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Expansion > ExpansionSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
static const NekDouble kNekUnsetDouble
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::shared_ptr< PointGeom > PointGeomSharedPtr
std::shared_ptr< Geometry > GeometrySharedPtr
The above copyright notice and this permission notice shall be included.
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
scalarT< T > log(scalarT< T > in)