44 std::string DriverArpack::arpackProblemTypeLookupIds[6] = {
45 LibUtilities::SessionReader::RegisterEnumValue(
"ArpackProblemType",
47 LibUtilities::SessionReader::RegisterEnumValue(
"ArpackProblemType",
49 LibUtilities::SessionReader::RegisterEnumValue(
"ArpackProblemType",
51 LibUtilities::SessionReader::RegisterEnumValue(
"ArpackProblemType",
53 LibUtilities::SessionReader::RegisterEnumValue(
"ArpackProblemType",
55 LibUtilities::SessionReader::RegisterEnumValue(
"ArpackProblemType",
58 std::string DriverArpack::arpackProblemTypeDefault =
59 LibUtilities::SessionReader::RegisterDefaultSolverInfo(
"ArpackProblemType",
61 std::string DriverArpack::driverLookupId =
62 LibUtilities::SessionReader::RegisterEnumValue(
"Driver",
"Arpack", 0);
64 std::string DriverArpack::className =
67 std::string DriverArpack::ArpackProblemTypeTrans[6] = {
"LR",
"SR",
"LI",
105 "..ARPACK is not currently set-up for parallel execution...\n");
106 m_equ[0]->PrintSummary(out);
109 "ARPACK Arnoldi solver does not support execution in parallel.");
112 out <<
"\tArnoldi solver type : Arpack" << endl;
114 out <<
"\tArpack problem type : ";
116 "ArpackProblemType")]
120 for (
int i = 0; i <
m_nequ; ++i)
122 m_equ[i]->DoInitialise();
161 if (
m_session->DefinesFunction(
"InitialConditions"))
163 out <<
"\tInital vector : input file " << endl;
169 out <<
"\tInital vector : random " << endl;
212 const char *problem =
214 "ArpackProblemType")]
218 ofstream pFile(
name.c_str());
227 iparam, ipntr, &workd[0], &workl[0], lworkl, info);
231 out <<
"\rIteration " << cycle <<
", output: " << info
232 <<
", ido=" << ido <<
" " << std::flush;
234 if (!((cycle - 1) %
m_kdim) && (cycle >
m_kdim) && (ido != 2))
236 pFile <<
"Krylov spectrum at iteration: " << cycle << endl;
240 pFile <<
"EV Magnitude Angle Growth Frequency "
246 pFile <<
"EV Real Imaginary inverse real inverse "
252 for (
int k = 0; k <
m_kdim; ++k)
255 WriteEvs(pFile, k, workl[ipntr[5] - 1 + k],
256 workl[ipntr[6] - 1 + k]);
272 m_equ[0]->TransCoeffToPhys();
280 m_equ[1]->TransCoeffToPhys();
300 m_equ[0]->TransCoeffToPhys();
303 m_equ[0]->UpdateFields();
304 for (
int i = 0; i < fields.size(); ++i)
306 fields[i]->IProductWRTBase(fields[i]->GetPhys(),
307 fields[i]->UpdateCoeffs());
315 ASSERTL0(
false,
"Unexpected reverse communication request.");
319 out << endl <<
"Converged in " << iparam[8] <<
" iterations" << endl;
321 ASSERTL0(info >= 0,
" Error with Dnaupd");
344 Arpack::Dneupd(1,
"A", ritzSelect.get(), dr.get(), di.get(), z.get(), n,
345 sigmar, sigmai, workev.get(), &B, n, problem,
m_nvec,
347 workd.get(), workl.get(), lworkl, info);
349 ASSERTL0(info == 0,
" Error with Dneupd");
351 int nconv = iparam[4];
364 "Need to implement Ritz re-evaluation of"
365 "eigenvalue. Only one half of complex "
366 "value will be correct");
369 m_equ[0]->UpdateFields();
371 out <<
"Converged Eigenvalues: " << nconv << endl;
372 pFile <<
"Converged Eigenvalues: " << nconv << endl;
376 out <<
" Magnitude Angle Growth Frequency" << endl;
377 pFile <<
" Magnitude Angle Growth Frequency"
379 for (
int i = 0; i < nconv; ++i)
384 std::string file =
m_session->GetSessionName() +
"_eig_" +
385 boost::lexical_cast<std::string>(i) +
".fld";
391 out <<
" Real Imaginary " << endl;
392 pFile <<
" Real Imaginary " << endl;
393 for (
int i = 0; i < nconv; ++i)
400 std::string file =
m_session->GetSessionName() +
"_eig_" +
401 boost::lexical_cast<std::string>(i) +
".fld";
411 for (
int j = 0; j <
m_equ[0]->GetNvariables(); ++j)
415 if (
m_comm->GetRank() == 0)
417 out <<
"L 2 error (variable " <<
m_equ[0]->GetVariable(j)
418 <<
") : " << vL2Error << endl;
419 out <<
"L inf error (variable " <<
m_equ[0]->GetVariable(j)
420 <<
") : " << vLinfError << endl;
#define ASSERTL0(condition, msg)
#define WARNINGL0(condition, msg)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Base class for the development of solvers.
void CopyFwdToAdj()
Copy the forward field to the adjoint system in transient growth calculations.
virtual void v_InitObject(std::ostream &out=std::cout) override
int m_infosteps
underlying operator is time stepping
void WriteFld(std::string file, std::vector< Array< OneD, NekDouble >> coeffs)
Write coefficients to file.
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.
Array< OneD, NekDouble > m_imag_evl
void CopyArnoldiArrayToField(Array< OneD, NekDouble > &array)
Copy Arnoldi storage to fields.
NekDouble m_evtol
Maxmum number of iterations.
int m_nfields
interval to dump information if required.
SOLVER_UTILS_EXPORT void ArnoldiSummary(std::ostream &out)
Array< OneD, NekDouble > m_real_evl
Operator in solve call is negated.
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) override
Virtual function for initialisation implementation.
virtual ~DriverArpack()
Destructor.
virtual void v_Execute(std::ostream &out=std::cout) override
Virtual function for solve implementation.
static std::string ArpackProblemTypeTrans[]
LibUtilities::SessionReaderSharedPtr m_session
Session reader object.
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
static void Dnaupd(int &ido, const char *bmat, const int &n, const char *which, const int &nev, const double &tol, double *resid, const int &ncv, double *v, const int &ldv, int *iparam, int *ipntr, double *workd, double *workl, const int &lworkl, int &info)
Top level reverse communication interface to solve real double-precision non-symmetric problems.
static void Dneupd(const int &rvec, const char *howmny, const int *select, double *dr, double *di, double *z, const int &ldz, const double &sigmar, const double &sigmai, double *workev, const char *bmat, const int &n, const char *which, const int &nev, const double &tol, double *resid, const int &ncv, double *v, const int &ldv, int *iparam, int *ipntr, double *workd, double *workl, const int &lworkl, int &info)
Post-processing routine to computed eigenvector of computed eigenvalues in Dnaupd.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
static const NekDouble kNekUnsetDouble
static const NekDouble kNekZeroTol
DriverFactory & GetDriverFactory()
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
The above copyright notice and this permission notice shall be included.
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add scalar y = alpha + x.