44 std::string DriverArpack::arpackProblemTypeLookupIds[6] = {
45 LibUtilities::SessionReader::RegisterEnumValue(
"ArpackProblemType",
"LargestReal" ,0),
46 LibUtilities::SessionReader::RegisterEnumValue(
"ArpackProblemType",
"SmallestReal" ,1),
47 LibUtilities::SessionReader::RegisterEnumValue(
"ArpackProblemType",
"LargestImag" ,2),
48 LibUtilities::SessionReader::RegisterEnumValue(
"ArpackProblemType",
"SmallestImag" ,3),
49 LibUtilities::SessionReader::RegisterEnumValue(
"ArpackProblemType",
"LargestMag" ,4),
50 LibUtilities::SessionReader::RegisterEnumValue(
"ArpackProblemType",
"SmallestMag" ,5),
52 std::string DriverArpack::arpackProblemTypeDefault = LibUtilities::SessionReader::RegisterDefaultSolverInfo(
"ArpackProblemType",
"LargestMag");
53 std::string DriverArpack::driverLookupId = LibUtilities::SessionReader::RegisterEnumValue(
"Driver",
"Arpack",0);
57 std::string DriverArpack::ArpackProblemTypeTrans[6] =
58 {
"LR",
"SR",
"LI",
"SI",
"LM",
"SM" };
95 ASSERTL0(
m_comm->GetSize()==1,
"..ARPACK is not currently set-up for parallel execution...\n");
96 m_equ[0]->PrintSummary(out);
99 "ARPACK Arnoldi solver does not support execution in parallel.");
102 out <<
"\tArnoldi solver type : Arpack" << endl;
104 out <<
"\tArpack problem type : ";
108 for(
int i = 0; i <
m_nequ; ++i)
110 m_equ[i]->DoInitialise();
124 int nq =
m_equ[0]->UpdateFields()[0]->GetNcoeffs();
147 if(
m_session->DefinesFunction(
"InitialConditions"))
149 out <<
"\tInital vector : input file " << endl;
155 out <<
"\tInital vector : random " << endl;
200 ofstream pFile(
name.c_str());
210 &v[0], n, iparam, ipntr, &workd[0],
211 &workl[0], lworkl, info);
215 out <<
"\rIteration " << cycle <<
", output: " << info <<
", ido=" << ido <<
" " << std::flush;
219 pFile <<
"Krylov spectrum at iteration: " << cycle << endl;
223 pFile <<
"EV Magnitude Angle Growth Frequency Residual" << endl;
227 pFile <<
"EV Real Imaginary inverse real inverse imag Residual" << endl;
231 for(
int k = 0; k <
m_kdim; ++k)
234 WriteEvs(pFile,k, workl[ipntr[5]-1+k],workl[ipntr[6]-1+k]);
238 if (ido == 99)
break;
249 m_equ[0]->TransCoeffToPhys();
257 m_equ[1]->TransCoeffToPhys();
277 m_equ[0]->TransCoeffToPhys();
280 for (
int i = 0; i < fields.size(); ++i)
282 fields[i]->IProductWRTBase(fields[i]->GetPhys(),
283 fields[i]->UpdateCoeffs());
291 ASSERTL0(
false,
"Unexpected reverse communication request.");
296 out<< endl <<
"Converged in " << iparam[8] <<
" iterations" << endl;
298 ASSERTL0(info >= 0,
" Error with Dnaupd");
322 z.get(), n, sigmar, sigmai, workev.get(), &B,
324 v.get(), n, iparam, ipntr, workd.get(),
325 workl.get(),lworkl,info);
327 ASSERTL0(info == 0,
" Error with Dneupd");
342 "Need to implement Ritz re-evaluation of"
343 "eigenvalue. Only one half of complex "
344 "value will be correct");
349 out <<
"Converged Eigenvalues: " << nconv << endl;
350 pFile <<
"Converged Eigenvalues: " << nconv << endl;
354 out <<
" Magnitude Angle Growth Frequency" << endl;
355 pFile <<
" Magnitude Angle Growth Frequency" << endl;
356 for(
int i= 0; i< nconv; ++i)
361 std::string file =
m_session->GetSessionName() +
"_eig_"
362 + boost::lexical_cast<std::string>(i)
369 out <<
" Real Imaginary " << endl;
370 pFile <<
" Real Imaginary " << endl;
371 for(
int i= 0; i< nconv; ++i)
378 std::string file =
m_session->GetSessionName() +
"_eig_"
379 + boost::lexical_cast<std::string>(i)
390 for(
int j = 0; j <
m_equ[0]->GetNvariables(); ++j)
394 if (
m_comm->GetRank() == 0)
396 out <<
"L 2 error (variable " <<
m_equ[0]->GetVariable(j) <<
") : " << vL2Error << endl;
397 out <<
"L inf error (variable " <<
m_equ[0]->GetVariable(j) <<
") : " << 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.
void WriteFld(std::string file, std::vector< Array< OneD, NekDouble > > coeffs)
Write coefficients to file.
int m_infosteps
underlying operator is time stepping
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.
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)
Virtual function for initialisation implementation.
virtual ~DriverArpack()
Destructor.
virtual void v_Execute(std::ostream &out=std::cout)
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 vector y = alpha - x.