autopdex.solver.solve_linear

autopdex.solver.solve_linear(dofs, settings, static_settings, **kwargs)[source]

Solves a linear system using the specified backend and solver settings.

This function determines the appropriate linear solver based on the provided settings and forwards the call to the selected solver function. It supports both JAX matrix-free solvers and external solvers like PETSc, PARDISO, PyAMG, and Scipy using jax.pure_callback.

Parameters:
  • dofs (jnp.ndarray or dict) – Degrees of freedom or initial guess for the solution.

  • settings (dict) – Dictionary containing various settings and parameters required for assembling the problem.

  • static_settings (dict) – Dictionary containing static settings such as solver backend, type of solver, and preconditioner.

  • **kwargs (dict) – Additional keyword arguments passed to the specific solver functions.

Returns:

The solution obtained from the selected linear solver.

Return type:

jnp.ndarray

Solver Backends:
  • ‘jax’ : Uses JAX’s matrix-free solvers.

  • ‘petsc’ : Uses PETSc for solving linear systems.

  • ‘pardiso’ : Uses PARDISO for solving linear systems.

  • ‘pyamg’ : Uses PyAMG for solving linear systems.

  • ‘scipy’ : Uses Scipy’s sparse solvers for solving linear systems.

Notes

  • If nodal imposition is detected in the static_settings, the function imposes Dirichlet boundary conditions and adjusts the degrees of freedom accordingly.

  • The function assembles the residual and tangent matrix before solving the system in case an external solver is used.

  • If the tangent matrix is dense and an external solver is used, it is converted to a sparse format.

  • The function uses JAX’s pure_callback to call external solvers and handle the solution.