PARCEL SYCL v1.2 / API Reference User Guide API Reference Search Download 日本語

10 Member Functions Common to the Eigenvalue Solvers

These functions are shared by power, inverse_power, and ks_arnoldi (inherited from parcel::krylov::eigen_param). set_linsolve_* configure the inner linear solver of the inverse power method and of the shift-invert mode of the Krylov-Schur method; they are not used by power or by ks_arnoldi without a shift. The defaults of the inner linear solver differ between the solvers (common settings). The orthogonalization in the inner pgmres is fixed to the modified Gram-Schmidt method. The ideas behind the settings of the eigenvalue solvers are given in “Notes on the Eigenvalue Solvers” in Common Items.

10.1 set_precon_spectrum() / get_precon_spectrum()

Description Selects the matrix whose eigenvalues are computed: AA or AK−1AK^{-1}.

Synopsis

void set_precon_spectrum(bool f);
bool get_precon_spectrum() const;

Arguments

Name In/Out Type Description Default
f In bool false: compute eigenvalues of AA. The outer eigenvalue iteration does not use preconditioning. true: compute eigenvalues of AK−1AK^{-1}. KK is built from AA according to the settings of set_precon_algo() and related functions false

MPI Local operation. Give the same value on all ranks.

Notes When true, the inner linear solver (inverse_power, and the shift-invert mode of ks_arnoldi) becomes a right-preconditioned pgmres that solves (AK−1−σI)z=v(AK^{-1} - \sigma I)z = v and returns zz, and the preconditioner is KK itself (set_linsolve_precon_algo() and related functions and ShiftMat are not used).

See Also set_precon_algo(), the “Eigenvalue Solvers” chapter

Example

pw.set_precon_algo(parcel::PRECON_JACOBI);  pw.set_precon_spectrum(true);   // largest eigenvalue of A K^-1

10.2 set_linsolve_algo() / get_linsolve_algo()

Description Sets or gets the type of the inner linear solver of inverse_power.

Synopsis

void       set_linsolve_algo(PARCEL_INT algo);
PARCEL_INT get_linsolve_algo() const;

Arguments

Name In/Out Type Description Default
algo In PARCEL_INT parcel::krylov::LINSOLVE_PGMRES (0, right-preconditioned pgmres) or LINSOLVE_PCG (1, pcg) LINSOLVE_PGMRES

Requirements LINSOLVE_PGMRES or LINSOLVE_PCG. Any other value throws std::invalid_argument. LINSOLVE_PCG is limited to the case where AA is symmetric (positive definite or negative definite; not checked). When set_precon_spectrum(true) is set, pgmres is used regardless of this setting.

MPI Local operation. Give the same value on all ranks.

Notes Effective only for inverse_power with set_precon_spectrum(false). The shift-invert mode of ks_arnoldi always uses pgmres.

Example

ip.set_linsolve_algo(parcel::krylov::LINSOLVE_PCG);

10.3 set_linsolve_tolerance() / get_linsolve_tolerance()

Description Sets or gets the convergence tolerance (relative residual) of the inner linear solver.

Synopsis

void   set_linsolve_tolerance(double tol);
double get_linsolve_tolerance() const;

Arguments

Name In/Out Type Description Default
tol In double Convergence tolerance of the inner linear solver 1.0e-10

Requirements A finite positive value. 0 or less, NaN, and Inf throw std::invalid_argument.

MPI Local operation. Give the same value on all ranks.

Notes The outer iteration continues even if the inner linear solver does not converge. The number of times it did not converge is obtained with get_linsolve_failures().

10.4 set_linsolve_max_iteration() / get_linsolve_max_iteration()

Description Sets or gets the maximum number of iterations of the inner linear solver.

Synopsis

void       set_linsolve_max_iteration(PARCEL_INT itr);
PARCEL_INT get_linsolve_max_iteration() const;

Arguments

Name In/Out Type Description Default
itr In PARCEL_INT Maximum number of iterations of the inner linear solver (for pgmres, the total number of inner iterations) inverse_power 5000, ks_arnoldi 2000

Requirements 1 or greater. 0 or less throws std::invalid_argument. When the inner solver is pgmres, the value need not be a multiple of set_linsolve_restart() and may be smaller than it (the inner solver iterates exactly up to the limit).

MPI Local operation. Give the same value on all ranks.

10.5 set_linsolve_restart() / get_linsolve_restart()

Description Sets or gets the restart length of the inner pgmres.

Synopsis

void       set_linsolve_restart(PARCEL_INT m);
PARCEL_INT get_linsolve_restart() const;

Arguments

Name In/Out Type Description Default
m In PARCEL_INT Restart length of the inner linear solver 30

Requirements 1 or greater. 0 or less throws std::invalid_argument.

MPI Local operation. Give the same value on all ranks.

Notes Not used when the inner solver is pcg.

10.6 set_linsolve_precon_algo() / set_linsolve_blockjacobi() / set_linsolve_jacobi() / get_linsolve_precon_param()

Description Sets the type of the preconditioner KinK_{in} of the inner linear solver, the number of block Jacobi blocks, and the number of Jacobi iterations.

Synopsis

void set_linsolve_precon_algo(PARCEL_INT algo);
void set_linsolve_blockjacobi(PARCEL_INT nblock);
void set_linsolve_jacobi(PARCEL_INT iter);
precon_param *get_linsolve_precon_param();   // access to the settings (get_precon_algo(), etc.)

Arguments

Name In/Out Type Description Default
algo In PARCEL_INT Type of preconditioner of the inner linear solver. Same values as set_precon_algo() PRECON_JACOBI
nblock In PARCEL_INT Number of block Jacobi blocks of KinK_{in} If not called, determined automatically from the device, as for set_blockjacobi()
iter In PARCEL_INT Number of Jacobi iterations of KinK_{in} 1

Requirements Same as set_precon_algo(), set_blockjacobi(), and set_jacobi(). Out-of-range values throw std::invalid_argument.

MPI Local operation. Give the same value on all ranks.

Notes Not used when set_precon_spectrum(true) is set; preconditioning is then done with KK. The conditions under which these settings are used in the shift-invert mode of ks_arnoldi are given in set_shift().

Example

ip.set_linsolve_precon_algo(parcel::PRECON_BLOCKJACOBI);

10.7 set_linsolve_scaling_matrix() / set_linsolve_scaling_vector()

Description Sets whether matrix and vector scaling are applied in KinK_{in}.

Synopsis

void set_linsolve_scaling_matrix(bool f);
void set_linsolve_scaling_vector(bool f);

Arguments

Name In/Out Type Description Default
f In bool false: off, true: on If not called, automatic (same rule as set_scaling_matrix())

MPI Local operation. Give the same value on all ranks.

10.8 get_linsolve_failures()

Description Returns the number of times the inner linear solver did not converge in the most recent solver() call.

Synopsis

PARCEL_INT get_linsolve_failures() const;

Return Value The number of times the inner linear solver (inverse_power, and the shift-invert mode of ks_arnoldi) ended without satisfying the convergence tolerance. 0 for power and for ks_arnoldi without a shift.

MPI Local operation. The value is the same on all ranks.

Notes This is not reflected in the outer convergence status (get_converged_reason()), because the outer iteration can converge even if the inner solver does not reach its tolerance. If the value is nonzero, review set_linsolve_max_iteration() and set_linsolve_precon_algo().

Example

if (ip.get_linsolve_failures() > 0) std::printf("inner solver did not converge %d times\n", (int)ip.get_linsolve_failures());