capytaine.bem.engines module

Definition of the methods to build influence matrices, using possibly some sparse structures.

class capytaine.bem.engines.BasicMatrixEngine(*, linear_solver='lu_decomposition', matrix_cache_size=1)[source]

Bases: MatrixEngine

Simple engine that assemble a full matrix (except for one reflection symmetry). Basically only calls green_function.evaluate.

Parameters:
  • linear_solver (str or function, optional) – Setting of the numerical solver for linear problems Ax = b. It can be set with the name of a preexisting solver (available: “direct” and “gmres”, the former is the default choice) or by passing directly a solver function.

  • matrix_cache_size (int, optional) – number of matrices to keep in cache

available_linear_solvers = {'direct': <function solve_directly>, 'gmres': <function solve_gmres>, 'lu_decomposition': <bound method LUSolverWithCache.solve of <capytaine.matrices.linear_solvers.LUSolverWithCache object>>}
build_matrices(mesh1, mesh2, free_surface, water_depth, wavenumber, green_function, adjoint_double_layer=True)[source]

Build the influence matrices between mesh1 and mesh2.

Parameters:
  • mesh1 (Mesh or CollectionOfMeshes) – mesh of the receiving body (where the potential is measured)

  • mesh2 (Mesh or CollectionOfMeshes) – mesh of the source body (over which the source distribution is integrated)

  • free_surface (float) – position of the free surface (default: \(z = 0\))

  • water_depth (float) – position of the sea bottom (default: \(z = -\infty\))

  • wavenumber (float) – wavenumber (default: 1.0)

  • green_function (AbstractGreenFunction) – object with an “evaluate” method that computes the Green function.

  • adjoint_double_layer (bool, optional) – compute double layer for direct method (F) or adjoint double layer for indirect method (T) matrices (default: True)

Returns:

the matrices \(S\) and \(K\)

Return type:

tuple of matrix-like

class capytaine.bem.engines.HierarchicalPrecondMatrixEngine(*, ACA_distance=8.0, ACA_tol=0.01, matrix_cache_size=1)[source]

Bases: HierarchicalToeplitzMatrixEngine

An experimental matrix engine that build a hierarchical matrix with

some block-Toeplitz structure.

Parameters:
  • ACA_distance (float, optional) – Above this distance, the ACA is used to approximate the matrix with a low-rank block.

  • ACA_tol (float, optional) – The tolerance of the ACA when building a low-rank matrix.

  • matrix_cache_size (int, optional) – number of matrices to keep in cache

build_matrices(mesh1, mesh2, free_surface, water_depth, wavenumber, green_function, adjoint_double_layer=True)[source]

Recursively builds a hierarchical matrix between mesh1 and mesh2, and precomputes some of the quantities needed for the preconditioner.

Same arguments as BasicMatrixEngine.build_matrices(), except for rec_depth

class capytaine.bem.engines.HierarchicalToeplitzMatrixEngine(*, ACA_distance=8.0, ACA_tol=0.01, matrix_cache_size=1)[source]

Bases: MatrixEngine

An experimental matrix engine that build a hierarchical matrix with

some block-Toeplitz structure.

Parameters:
  • ACA_distance (float, optional) – Above this distance, the ACA is used to approximate the matrix with a low-rank block.

  • ACA_tol (float, optional) – The tolerance of the ACA when building a low-rank matrix.

  • matrix_cache_size (int, optional) – number of matrices to keep in cache

build_matrices(mesh1, mesh2, free_surface, water_depth, wavenumber, green_function, adjoint_double_layer=True)[source]
class capytaine.bem.engines.MatrixEngine[source]

Bases: ABC

Abstract method to build a matrix.

build_S_matrix(*args, **kwargs)[source]

Similar to build_matrices, but returning only \(S\)

abstract build_matrices(mesh1, mesh2, free_surface, water_depth, wavenumber, green_function, adjoint_double_layer)[source]