60 m_session->MatchSolverInfo(
"SolverType",
"VelocityCorrectionScheme",
75 if (
m_session->DefinesSolverInfo(
"ModeType") &&
76 (boost::iequals(
m_session->GetSolverInfo(
"ModeType"),
"SingleMode") ||
77 boost::iequals(
m_session->GetSolverInfo(
"ModeType"),
"HalfMode")))
81 m_equ[0]->UpdateFields()[i]->SetWaveSpace(
true);
102 if (!
m_session->DefinesSolverInfo(
"HOMOGENEOUS") &&
103 !
m_session->DefinesSolverInfo(
"ModeType"))
106 "Imaginary shift only supported with HOMOGENEOUS "
107 "expansion and ModeType set to SingleMode");
109 else if (!boost::iequals(
m_session->GetSolverInfo(
"ModeType"),
113 "Imaginary shift only supported with HOMOGENEOUS "
114 "expansion and ModeType set to SingleMode");
125 ASSERTL0(
false,
"Specific version of Arnoldi driver not implemented");
133 if (
m_comm->GetRank() == 0)
135 if (
m_session->DefinesSolverInfo(
"ModeType") &&
136 boost::iequals(
m_session->GetSolverInfo(
"ModeType"),
"SingleMode"))
138 out <<
"\tSingle Fourier mode : true " << endl;
140 "Expected a homogeneous expansion to be defined "
145 out <<
"\tSingle Fourier mode : false " << endl;
147 if (
m_session->DefinesSolverInfo(
"BetaZero"))
149 out <<
"\tBeta set to Zero : true (overrides LHom)" << endl;
153 out <<
"\tBeta set to Zero : false " << endl;
158 out <<
"\tEvolution operator : "
159 <<
m_session->GetSolverInfo(
"EvolutionOperator") << endl;
163 out <<
"\tShift (Real,Imag) : " <<
m_realShift <<
","
166 out <<
"\tKrylov-space dimension : " <<
m_kdim << endl;
167 out <<
"\tNumber of vectors : " <<
m_nvec << endl;
168 out <<
"\tMax iterations : " <<
m_nits << endl;
169 out <<
"\tEigenvalue tolerance : " <<
m_evtol << endl;
170 out <<
"======================================================" << endl;
182 m_equ[0]->UpdateFields();
183 int nq = fields[0]->GetNcoeffs();
187 Vmath::Vcopy(nq, &array[k * nq], 1, &fields[k]->UpdateCoeffs()[0], 1);
188 fields[k]->SetPhysState(
false);
206 fields =
m_equ[0]->UpdateFields();
215 int nq = fields[0]->GetNcoeffs();
216 Vmath::Vcopy(nq, &fields[k]->GetCoeffs()[0], 1, &array[k * nq], 1);
217 fields[k]->SetPhysState(
false);
229 "Transient Growth non available for Coupled Solver");
231 fields =
m_equ[0]->UpdateFields();
232 int nq = fields[0]->GetNcoeffs();
237 &
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);
265 std::vector<std::string> variables(
m_nfields);
266 std::vector<Array<OneD, NekDouble>> fieldcoeffs(
m_nfields);
268 int ncoeffs =
m_equ[0]->UpdateFields()[0]->GetNcoeffs();
270 "coeffs is not of sufficient size");
274 variables[i] =
m_equ[0]->GetVariable(i);
275 fieldcoeffs[i] = coeffs + i * ncoeffs;
278 m_equ[0]->WriteFld(file,
m_equ[0]->UpdateFields()[0], fieldcoeffs,
294 evlout <<
"EV: " << setw(2) << i << setw(12) << abs_ev << setw(12)
295 << ang_ev << setw(12) <<
log(abs_ev) /
m_period << setw(12)
300 evlout << setw(12) << resid;
306 NekDouble invmag = 1.0 / (re_ev * re_ev + im_ev * im_ev);
317 evlout <<
"EV: " << setw(2) << i << setw(14) <<
sign * re_ev << setw(14)
328 evlout << setw(12) << resid;
338 std::vector<std::vector<LibUtilities::EquationSharedPtr>> &selectedDomains,
339 std::set<int> &unselectedVariables)
341 selectedDomains.clear();
342 string domain(
"SelectEVCalcDomain0");
343 string condition(
"C0");
344 for (
size_t i = 0; i < 10; ++i)
346 domain[domain.size() - 1] =
'0' + i;
351 for (
size_t j = 0; j < 10; ++j)
353 condition[condition.size() - 1] =
'0' + j;
354 if (!
m_session->DefinesFunction(domain, condition))
360 selectedDomains.push_back(
361 std::vector<LibUtilities::EquationSharedPtr>());
363 selectedDomains[selectedDomains.size() - 1].push_back(
364 m_session->GetFunction(domain, condition));
367 unselectedVariables.clear();
368 string funName(
"SelectEVCalcVariables");
369 std::vector<std::string> variables =
m_session->GetVariables();
372 if (!
m_session->DefinesFunction(funName, variables[v]))
374 unselectedVariables.insert(v);
377 if (unselectedVariables.size() ==
m_nfields)
379 unselectedVariables.clear();
388 std::vector<std::vector<LibUtilities::EquationSharedPtr>> selectedDomains;
389 std::set<int> unselectedVariables;
391 if (selectedDomains.size() == 0 && unselectedVariables.size() == 0)
398 int ncoef =
field->GetNcoeffs();
399 int nphys =
field->GetNpoints();
402 for (
size_t i = 0; i <
field->GetExpSize(); ++i)
406 int nv = geom->GetNumVerts();
409 for (
size_t j = 0; j < nv; ++j)
412 vertex->GetCoords(gct[0], gct[1], gct[2]);
418 for (
size_t m = 0; m < selectedDomains.size(); ++m)
421 for (
size_t n = 0; n < selectedDomains[m].size(); ++n)
423 if (selectedDomains[m][n]->Evaluate(gc[0], gc[1], gc[2]) <= 0.)
440 if (unmask == 0 || unselectedVariables.count(j))
443 exp->GetNcoeffs(), 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
void CopyFwdToAdj()
Copy the forward field to the adjoint system in transient growth calculations.
void v_InitObject(std::ostream &out=std::cout) override
Virtual function for initialisation implementation.
void WriteFld(std::string file, std::vector< Array< OneD, NekDouble > > coeffs)
Write coefficients to file.
NekDouble m_period
Tolerance of iterations.
int m_infosteps
underlying operator is time stepping
void v_Execute(std::ostream &out=std::cout) override
Virtual function for solve implementation.
Array< OneD, NekDouble > m_maskCoeffs
DriverArnoldi(const LibUtilities::SessionReaderSharedPtr pSession, const SpatialDomains::MeshGraphSharedPtr pGraph)
Constructor.
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 GetMaskInfo(std::vector< std::vector< LibUtilities::EquationSharedPtr > > &selectedDomains, std::set< int > &unselectedVariables)
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)
void MaskInit()
Init mask.
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)
Virtual function for initialisation implementation.
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
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)