pymoto.solvers.GeometricMultigrid

class pymoto.solvers.GeometricMultigrid(domain: VoxelDomain, A=None, cycle: str = 'V', inner_level: LinearSolver = None, smoother: LinearSolver = None, smooth_steps: int = 5)

Geometric multigrid preconditioner

__init__(domain: VoxelDomain, A=None, cycle: str = 'V', inner_level: LinearSolver = None, smoother: LinearSolver = None, smooth_steps: int = 5)

Initialize the geometric multigrid preconditioner

Parameters:
  • domain (pymoto.VoxelDomain) – The domain

  • A (matrix, optional) – The matrix

  • cycle (str, optional) – _description_. Defaults to “V”.

  • inner_level (pymoto.solvers.LinearSolver, optional) – Inner solver for the coarse grid, for instance, a direct solver or another MG level. The default is a direct solver.

  • smoother (optional) – Smoother to use to smooth the residual and solution before and after coarse level. The default is DampedJacobi(w=0.5).

  • smooth_steps (int, optional) – Number of smoothing steps to execute. Defaults to 5.

Methods

__init__(domain[, A, cycle, inner_level, ...])

Initialize the geometric multigrid preconditioner

residual(A, x, b[, trans])

Calculates the (relative) residual of the linear system of equations

setup_interpolation(A)

solve(rhs[, x0, trans])

Solves the linear system of equations \(\mathbf{A} \mathbf{x} = \mathbf{b}\)

update(A)

Updates with a new matrix of the same structure

Attributes

defined

update(A)

Updates with a new matrix of the same structure

Parameters:

A (matrix) – The new matrix of size (N, N)

Returns:

self

setup_interpolation(A)
solve(rhs, x0=None, trans='N')

Solves the linear system of equations \(\mathbf{A} \mathbf{x} = \mathbf{b}\)

Parameters:
  • rhs – Right hand side \(\mathbf{b}\) of shape (N) or (N, K) for multiple right-hand-sides

  • x0 (optional) – Initial guess for the solution

  • trans (optional) – Option to transpose matrix ‘N’: A @ x == rhs (default) Normal matrix ‘T’: A^T @ x == rhs Transposed matrix ‘H’: A^H @ x == rhs Hermitian transposed matrix (conjugate transposed)

Returns:

Solution vector \(\mathbf{x}\) of same shape as \(\mathbf{b}\)

defined = True
static residual(A, x, b, trans='N')

Calculates the (relative) residual of the linear system of equations

The residual is calculated as \(r = \frac{\left| \mathbf{A} \mathbf{x} - \mathbf{b} \right|}{\left| \mathbf{b} \right|}\)

Parameters:
  • A – The matrix

  • x – Solution vector

  • b – Right-hand side

  • trans (optional) – Matrix tranformation (N is normal, T is transposed, H is hermitian transposed)

Returns:

Residual value