# sfepy.solvers.ls module

class sfepy.solvers.ls.CholeskySolver(conf, **kwargs)

  Interface to scikit-sparse.cholesky solver.

  > Kind: ‘ls.cholesky’

  > For common configuration parameters, see `Solver`.

  > Specific configuration parameters:

  Parameters:
    use_presolve bool (default: False)

      If True, pre-factorize the matrix.

    use_mtx_digest bool (default: True)

      If True, determine automatically a reused matrix using its SHA1 digest. If False, .clear() has to be called manually whenever the matrix changes - expert use only!

  name = 'ls.cholesky'
  presolve(mtx, use_mtx_digest=True)

class sfepy.solvers.ls.MUMPSSolver(conf, **kwargs)

  Interface to MUMPS solver.

  > Kind: ‘ls.mumps’

  > For common configuration parameters, see `Solver`.

  > Specific configuration parameters:

  Parameters:
    use_presolve bool (default: False)

      If True, pre-factorize the matrix.

    use_mtx_digest bool (default: True)

      If True, determine automatically a reused matrix using its SHA1 digest. If False, .clear() has to be called manually whenever the matrix changes - expert use only!

    memory_relaxation int (default: 20)

      The percentage increase in the estimated working space.

  clear()
  static coo_is_symmetric(mtx, tol=1e-09)

    Symmetry check of the sparse matrix.

  name = 'ls.mumps'
  presolve(mtx, use_mtx_digest=True, factorize=True)

class sfepy.solvers.ls.MultiProblem(conf, context=None, **kwargs)

  Conjugate multiple problems.

  Allows to define conjugate multiple problems.

  > Kind: ‘ls.cm_pb’

  > For common configuration parameters, see `Solver`.

  > Specific configuration parameters:

  Parameters:
    method{‘auto’, ‘umfpack’, ‘superlu’} (default: ‘auto’)

      The actual solver to use.

    use_presolve bool (default: False)

      If True, pre-factorize the matrix.

    use_mtx_digest bool (default: True)

      If True, determine automatically a reused matrix using its SHA1 digest. If False, .clear() has to be called manually whenever the matrix changes - expert use only!

    others list

      The list of auxiliary problem definition files.

    coupling_variables list

      The list of coupling variables.

  init_subproblems(conf, **kwargs)
  name = 'ls.cm_pb'
  sparse_submat(Ad, Ar, Ac, gr, gc, S)

    A[gr,gc] = S

class sfepy.solvers.ls.PETScKrylovSolver(conf, comm=None, context=None, **kwargs)

  PETSc Krylov subspace solver.

  The solver supports parallel use with a given MPI communicator (see comm argument of `PETScKrylovSolver.__init__()`) and allows passing in PETSc matrices and vectors. Returns a (global) PETSc solution vector instead of a (local) numpy array, when given a PETSc right-hand side vector.

  The solver and preconditioner types are set upon the solver object creation. Tolerances can be overridden when called by passing a conf object.

  Convergence is reached when rnorm < max(eps_r * rnorm_0, eps_a), where, in PETSc, rnorm is by default the norm of preconditioned residual.

  > Kind: ‘ls.petsc’

  > For common configuration parameters, see `Solver`.

  > Specific configuration parameters:

  Parameters:
    method str (default: ‘cg’)

      The actual solver to use.

    setup_precond callable

      User-supplied function for the preconditioner initialization/setup. It is called as setup_precond(mtx, context), where mtx is the matrix, context is a user-supplied context, and should return an object with setUp(self, pc) and apply(self, pc, x, y) methods. Has precedence over the precond/sub_precond parameters.

    precond str (default: ‘icc’)

      The preconditioner.

    sub_precond str (default: ‘none’)

      The preconditioner for matrix blocks (in parallel runs).

    precond_side{‘left’, ‘right’, ‘symmetric’, None}

      The preconditioner side.

    create_matrix callable

      User-defined function returning the linear system matrix and optionally a precoditioning matrix in a PETSc format. It is called as create_matrix(self, mtx, context, comm), where self is the solver instance, mtx is the matrix passed to self.__call__(), context is a user-supplied context and comm the PETSc communicator.

    block_size int

      The number of degrees of freedom per node.

    i_max int (default: 100)

      The maximum number of iterations.

    eps_a float (default: 1e-08)

      The absolute tolerance for the residual.

    eps_r float (default: 1e-08)

      The relative tolerance for the residual.

    eps_d float (default: 100000.0)

      The divergence tolerance for the residual.

    force_reuse bool (default: False)

      If True, skip the check whether the KSP solver object corresponds to the mtx argument: it is always reused.

    **

      Additional parameters supported by the method. Can be used to pass all PETSc options supported by `petsc.Options()`.

  create_ksp(options=None, comm=None)
  create_petsc_matrix(mtx, comm=None)
  init_ksp(conf=None, comm=None)
  name = 'ls.petsc'
  set_field_split(field_ranges, comm=None)

    Setup local PETSc ranges for fields to be used with ‘fieldsplit’ preconditioner.

    This function must be called before solving the linear system.

class sfepy.solvers.ls.PyAMGKrylovSolver(conf, context=None, **kwargs)

  Interface to PyAMG Krylov solvers.

  > Kind: ‘ls.pyamg_krylov’

  > For common configuration parameters, see `Solver`.

  > Specific configuration parameters:

  Parameters:
    method str (default: ‘cg’)

      The actual solver to use.

    setup_precond callable

      User-supplied function for the preconditioner initialization/setup. It is called as setup_precond(mtx, context), where mtx is the matrix, context is a user-supplied context, and should return one of {sparse matrix, dense matrix, LinearOperator}.

    callback callable

      User-supplied function to call after each iteration. It is called as callback(xk), where xk is the current solution vector, except the gmres method, where the argument is the residual norm.

    i_max int (default: 100)

      The maximum number of iterations.

    eps_r float (default: 1e-08)

      The relative tolerance for the residual.

    **

      Additional parameters supported by the method.

  name = 'ls.pyamg_krylov'

class sfepy.solvers.ls.PyAMGSolver(conf, **kwargs)

  Interface to PyAMG solvers.

  The method parameter can be one of: ‘smoothed_aggregation_solver’, ‘ruge_stuben_solver’. The accel parameter specifies the Krylov solver name, that is used as an accelerator for the multigrid solver.

  > Kind: ‘ls.pyamg’

  > For common configuration parameters, see `Solver`.

  > Specific configuration parameters:

  Parameters:
    method str (default: ‘smoothed_aggregation_solver’)

      The actual solver to use.

    accel str

      The accelerator.

    callback callable

      User-supplied function to call after each iteration. It is called as callback(xk), where xk is the current solution vector, except the gmres accelerator, where the argument is the residual norm.

    i_max int (default: 100)

      The maximum number of iterations.

    eps_r float (default: 1e-08)

      The relative tolerance for the residual.

    force_reuse bool (default: False)

      If True, skip the check whether the MG solver object corresponds to the mtx argument: it is always reused.

    **

      Additional parameters supported by the method. Use the ‘method:’ prefix for arguments of the method construction function (e.g. ‘method:max_levels’ : 5), and the ‘solve:’ prefix for the subsequent solver call.

  name = 'ls.pyamg'

class sfepy.solvers.ls.PyPardisoSolver(conf, method=None, **kwargs)

  PyPardiso direct solver.

  PyPardiso (https://github.com/haasad/PyPardiso) is a python package to solve large sparse linear systems of equations with the Intel oneAPI Math Kernel Library PARDISO solver, a shared-memory multiprocessing parallel direct sparse solver. PyPardiso is not a python interface to the PARDISO Solver Project (https://panua.ch/pardiso).

  > Kind: ‘ls.pypardiso’

  > For common configuration parameters, see `Solver`.

  > Specific configuration parameters:

  Parameters:
    use_presolve bool (default: False)

      If True, pre-factorize the matrix. It is not needed for performance here, as it just calls pypardiso.spsolve() on zeros.

  name = 'ls.pypardiso'
  presolve(mtx, use_mtx_digest=True)

class sfepy.solvers.ls.RMMSolver(conf, context=None, **kwargs)

  Special solver for explicit transient elastodynamics.

  The solver uses the reciprocal mass matrix algorithm [1], [2] to directly construct a sparse inverse mass matrix. Instead of solving a linear system, calling the solver simply performs a sparse matrix multiplication.

  Limitations:

  - Assumes that the density is constant in time.

  - Uses the direct EBC application, i.e., no EBC projection matrix.

  [1]

  González, J.A., Kolman, R., Cho, S.S., Felippa, C.A., Park, K.C., 2018. Inverse mass matrix via the method of localized Lagrange multipliers. International Journal for Numerical Methods in Engineering 113, 277–295. https://doi.org/10.1002/nme.5613

  [2]
  González, J.A., Kopačka, J., Kolman, R., Cho, S.S., Park, K.C.,

    2019. Inverse mass matrix for isogeometric explicit transient analysis via the method of localized Lagrange multipliers. International Journal for Numerical Methods in Engineering 117, 939–966. https://doi.org/10.1002/nme.5986

  Kind: ‘ls.rmm’

  For common configuration parameters, see `Solver`.

  Specific configuration parameters:

  Parameters:
    rmm_term str

      The RMM term definition, see `MassTerm`.

    debug bool (default: False)

      If True, run in debug mode.

  init_rmm(mtx)
  name = 'ls.rmm'

class sfepy.solvers.ls.SchurMumps(conf, **kwargs)

  Mumps Schur complement solver.

  > Kind: ‘ls.schur_mumps’

  > For common configuration parameters, see `Solver`.

  > Specific configuration parameters:

  Parameters:
    use_presolve bool (default: False)

      If True, pre-factorize the matrix.

    use_mtx_digest bool (default: True)

      If True, determine automatically a reused matrix using its SHA1 digest. If False, .clear() has to be called manually whenever the matrix changes - expert use only!

    memory_relaxation int (default: 20)

      The percentage increase in the estimated working space.

    schur_variables list

      The list of Schur variables.

  name = 'ls.schur_mumps'

class sfepy.solvers.ls.ScipyDirect(conf, method=None, **kwargs)

  Direct sparse solver from SciPy.

  > Kind: ‘ls.scipy_direct’

  > For common configuration parameters, see `Solver`.

  > Specific configuration parameters:

  Parameters:
    method{‘auto’, ‘umfpack’, ‘superlu’} (default: ‘auto’)

      The actual solver to use.

    use_presolve bool (default: False)

      If True, pre-factorize the matrix.

    use_mtx_digest bool (default: True)

      If True, determine automatically a reused matrix using its SHA1 digest. If False, .clear() has to be called manually whenever the matrix changes - expert use only!

  clear()
  name = 'ls.scipy_direct'
  presolve(mtx, use_mtx_digest=True)

class sfepy.solvers.ls.ScipyIterative(conf, context=None, **kwargs)

  Interface to SciPy iterative solvers.

  The eps_r tolerance is both absolute and relative - the solvers stop when either the relative or the absolute residual is below it.

  > Kind: ‘ls.scipy_iterative’

  > For common configuration parameters, see `Solver`.

  > Specific configuration parameters:

  Parameters:
    method str (default: ‘cg’)

      The actual solver to use.

    setup_precond callable

      User-supplied function for the preconditioner initialization/setup. It is called as setup_precond(mtx, context), where mtx is the matrix, context is a user-supplied context, and should return one of {sparse matrix, dense matrix, LinearOperator}.

    callback callable

      User-supplied function to call after each iteration. It is called as callback(xk), where xk is the current solution vector, except the gmres method, where the argument is the residual.

    i_max int (default: 100)

      The maximum number of iterations.

    eps_a float (default: 1e-08)

      The absolute tolerance for the residual.

    eps_r float (default: 1e-08)

      The relative tolerance for the residual.

    **

      Additional parameters supported by the method.

  name = 'ls.scipy_iterative'

class sfepy.solvers.ls.ScipySuperLU(conf, **kwargs)

  SuperLU - direct sparse solver from SciPy.

  > Kind: ‘ls.scipy_superlu’

  > For common configuration parameters, see `Solver`.

  > Specific configuration parameters:

  Parameters:
    use_presolve bool (default: False)

      If True, pre-factorize the matrix.

    use_mtx_digest bool (default: True)

      If True, determine automatically a reused matrix using its SHA1 digest. If False, .clear() has to be called manually whenever the matrix changes - expert use only!

  name = 'ls.scipy_superlu'

class sfepy.solvers.ls.ScipyUmfpack(conf, **kwargs)

  UMFPACK - direct sparse solver from SciPy.

  > Kind: ‘ls.scipy_umfpack’

  > For common configuration parameters, see `Solver`.

  > Specific configuration parameters:

  Parameters:
    use_presolve bool (default: False)

      If True, pre-factorize the matrix.

    use_mtx_digest bool (default: True)

      If True, determine automatically a reused matrix using its SHA1 digest. If False, .clear() has to be called manually whenever the matrix changes - expert use only!

  name = 'ls.scipy_umfpack'

sfepy.solvers.ls.petsc_call(call)

  Decorator handling argument preparation and timing for PETSc-based linear solvers.

sfepy.solvers.ls.solve(mtx, rhs, solver_class=None, solver_conf=None)

  Solve the linear system with the matrix mtx and the right-hand side rhs.

  Convenience wrapper around the linear solver classes below.

sfepy.solvers.ls.standard_call(call)

  Decorator handling argument preparation and timing for linear solvers.