48 DriverArnoldi::DriverArnoldi(
69 m_session->MatchSolverInfo(
"SolverType",
"VelocityCorrectionScheme",
84 if (
m_session->DefinesSolverInfo(
"ModeType") &&
85 (boost::iequals(
m_session->GetSolverInfo(
"ModeType"),
"SingleMode") ||
86 boost::iequals(
m_session->GetSolverInfo(
"ModeType"),
"HalfMode")))
90 m_equ[0]->UpdateFields()[i]->SetWaveSpace(
true);
111 if (!
m_session->DefinesSolverInfo(
"HOMOGENEOUS") &&
112 !
m_session->DefinesSolverInfo(
"ModeType"))
115 "Imaginary shift only supported with HOMOGENEOUS "
116 "expansion and ModeType set to SingleMode");
118 else if (!boost::iequals(
m_session->GetSolverInfo(
"ModeType"),
122 "Imaginary shift only supported with HOMOGENEOUS "
123 "expansion and ModeType set to SingleMode");
131 if (
m_comm->GetRank() == 0)
133 if (
m_session->DefinesSolverInfo(
"ModeType") &&
134 boost::iequals(
m_session->GetSolverInfo(
"ModeType"),
"SingleMode"))
136 out <<
"\tSingle Fourier mode : true " << endl;
138 "Expected a homogeneous expansion to be defined "
143 out <<
"\tSingle Fourier mode : false " << endl;
145 if (
m_session->DefinesSolverInfo(
"BetaZero"))
147 out <<
"\tBeta set to Zero : true (overrides LHom)" << endl;
151 out <<
"\tBeta set to Zero : false " << endl;
156 out <<
"\tEvolution operator : "
157 <<
m_session->GetSolverInfo(
"EvolutionOperator") << endl;
161 out <<
"\tShift (Real,Imag) : " <<
m_realShift <<
","
164 out <<
"\tKrylov-space dimension : " <<
m_kdim << endl;
165 out <<
"\tNumber of vectors : " <<
m_nvec << endl;
166 out <<
"\tMax iterations : " <<
m_nits << endl;
167 out <<
"\tEigenvalue tolerance : " <<
m_evtol << endl;
168 out <<
"======================================================" << endl;
180 m_equ[0]->UpdateFields();
181 int nq = fields[0]->GetNcoeffs();
185 Vmath::Vcopy(nq, &array[k * nq], 1, &fields[k]->UpdateCoeffs()[0], 1);
186 fields[k]->SetPhysState(
false);
204 fields =
m_equ[0]->UpdateFields();
213 int nq = fields[0]->GetNcoeffs();
214 Vmath::Vcopy(nq, &fields[k]->GetCoeffs()[0], 1, &array[k * nq], 1);
215 fields[k]->SetPhysState(
false);
227 "Transient Growth non available for Coupled Solver");
229 fields =
m_equ[0]->UpdateFields();
230 int nq = fields[0]->GetNcoeffs();
235 &
m_equ[1]->UpdateFields()[k]->UpdateCoeffs()[0], 1);
243 std::vector<std::string> variables(
m_nfields);
248 variables[i] =
m_equ[0]->GetVariable(i);
251 m_equ[0]->WriteFld(file,
m_equ[0]->UpdateFields()[0], coeffs, variables);
257 std::vector<std::string> variables(
m_nfields);
258 std::vector<Array<OneD, NekDouble>> fieldcoeffs(
m_nfields);
260 int ncoeffs =
m_equ[0]->UpdateFields()[0]->GetNcoeffs();
262 "coeffs is not of sufficient size");
266 variables[i] =
m_equ[0]->GetVariable(i);
267 fieldcoeffs[i] = coeffs + i * ncoeffs;
270 m_equ[0]->WriteFld(file,
m_equ[0]->UpdateFields()[0], fieldcoeffs,
283 evlout <<
"EV: " << setw(2) << i << setw(12) << abs_ev << setw(12)
284 << ang_ev << setw(12) <<
log(abs_ev) /
m_period << setw(12)
289 evlout << setw(12) << resid;
295 NekDouble invmag = 1.0 / (re_ev * re_ev + im_ev * im_ev);
306 evlout <<
"EV: " << setw(2) << i << setw(14) <<
sign * re_ev << setw(14)
317 evlout << setw(12) << resid;
324 std::vector<std::vector<LibUtilities::EquationSharedPtr>> &unmaskfun)
326 string Unmask0(
"Unmask0");
328 for (
size_t i = 0; 1; ++i)
330 Unmask0[Unmask0.size() - 1] =
'0' + i;
331 if (!
m_session->DefinesFunction(Unmask0))
335 for (
size_t j = 0; 1; ++j)
337 C0[C0.size() - 1] =
'0' + j;
338 if (!
m_session->DefinesFunction(Unmask0, C0))
345 std::vector<LibUtilities::EquationSharedPtr>());
347 unmaskfun[unmaskfun.size() - 1].push_back(
355 std::vector<std::vector<LibUtilities::EquationSharedPtr>> unmaskfun;
357 if (unmaskfun.size() == 0)
364 int ncoef = field->GetNcoeffs();
365 int nphys = field->GetNpoints();
368 for (
size_t i = 0; i < field->GetExpSize(); ++i)
372 int nv = geom->GetNumVerts();
375 for (
size_t j = 0; j < nv; ++j)
378 vertex->GetCoords(gct[0], gct[1], gct[2]);
384 for (
size_t m = 0; m < unmaskfun.size(); ++m)
387 for (
size_t n = 0; n < unmaskfun[m].size(); ++n)
389 if (unmaskfun[m][n]->Evaluate(gc[0], gc[1], gc[2]) <= 0.)
407 exp->GetNcoeffs(), 0.,
408 &
m_maskCoeffs[field->GetCoeff_Offset(i) + j * ncoef], 1);
410 &
m_maskPhys[field->GetPhys_Offset(i) + j * nphys],
#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.
virtual void v_InitObject(std::ostream &out=std::cout) override
NekDouble m_period
Tolerance of iteratiosn.
int m_infosteps
underlying operator is time stepping
void WriteFld(std::string file, std::vector< Array< OneD, NekDouble >> coeffs)
Write coefficients to file.
Array< OneD, NekDouble > m_maskCoeffs
void CopyFieldToArnoldiArray(Array< OneD, NekDouble > &array)
Copy fields to Arnoldi storage.
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.
void GetUnmaskFunction(std::vector< std::vector< LibUtilities::EquationSharedPtr >> &unmaskfun)
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)