capytaine.bem.solver module

Solver for the BEM problem.

problem = RadiationProblem(...)
result = BEMSolver(green_functions=..., engine=...).solve(problem)
class capytaine.bem.solver.BEMSolver(*, green_function=None, engine=None, method='indirect')[source]

Bases: object

Solver for linear potential flow problems.

Parameters:
  • green_function (AbstractGreenFunction, optional) – Object handling the computation of the Green function. (default: Delhommeau)

  • engine (MatrixEngine, optional) – Object handling the building of matrices and the resolution of linear systems with these matrices. (default: BasicMatrixEngine)

  • method (string, optional) – select boundary integral equation used to solve the problems. Accepted values: “indirect” (as in e.g. Nemoh), “direct” (as in e.g. WAMIT) Default value: “indirect”

Variables:
  • timer (dict[str, Timer]) – Storing the time spent on each subtasks of the resolution

  • exportable_settings (dict) – Settings of the solver that can be saved to reinit the same solver later.

compute_free_surface_elevation(points, result)[source]

Compute the value of the free surface elevation at given points for a previously solved potential flow problem.

Parameters:
  • points (array of shape (2,) or (N, 2), or 2-ple of arrays returned by meshgrid, or MeshLike object) – Coordinates of the point(s) at which the free surface elevation should be computed

  • result (LinearPotentialFlowResult) – The return of the BEM solver

Returns:

The value of the free surface elevation at the points

Return type:

complex-valued array of shape (1,) or (N,) or (nx, ny, nz) or (mesh.nb_faces,) depending of the kind of input

Raises:

Exception – if the LinearPotentialFlowResult object given as input does not contain the source distribution.:

compute_potential(points, result)[source]

Compute the value of the potential at given points for a previously solved potential flow problem.

Parameters:
  • points (array of shape (3,) or (N, 3), or 3-ple of arrays returned by meshgrid, or MeshLike object) – Coordinates of the point(s) at which the potential should be computed

  • result (LinearPotentialFlowResult) – The return of the BEM solver

Returns:

The value of the potential at the points

Return type:

complex-valued array of shape (1,) or (N,) or (nx, ny, nz) or (mesh.nb_faces,) depending of the kind of input

Raises:

Exception – if the LinearPotentialFlowResult object given as input does not contain the source distribution.:

compute_pressure(points, result)[source]

Compute the value of the pressure at given points for a previously solved potential flow problem.

Parameters:
  • points (array of shape (3,) or (N, 3), or 3-ple of arrays returned by meshgrid, or MeshLike object) – Coordinates of the point(s) at which the pressure should be computed

  • result (LinearPotentialFlowResult) – The return of the BEM solver

Returns:

The value of the pressure at the points

Return type:

complex-valued array of shape (1,) or (N,) or (nx, ny, nz) or (mesh.nb_faces,) depending of the kind of input

Raises:

Exception – if the LinearPotentialFlowResult object given as input does not contain the source distribution.:

compute_velocity(points, result)[source]

Compute the value of the velocity vector at given points for a previously solved potential flow problem.

Parameters:
  • points (array of shape (3,) or (N, 3), or 3-ple of arrays returned by meshgrid, or MeshLike object) – Coordinates of the point(s) at which the velocity should be computed

  • result (LinearPotentialFlowResult) – The return of the BEM solver

Returns:

The value of the velocity at the points

Return type:

complex-valued array of shape (3,) or (N,, 3) or (nx, ny, nz, 3) or (mesh.nb_faces, 3) depending of the kind of input

Raises:

Exception – if the LinearPotentialFlowResult object given as input does not contain the source distribution.:

fill_dataset(dataset, bodies, *, method=None, n_jobs=1, _check_wavelength=True, progress_bar=None, **kwargs)[source]

Solve a set of problems defined by the coordinates of an xarray dataset.

Parameters:
  • dataset (xarray Dataset) – dataset containing the problems parameters: frequency, radiating_dof, water_depth, …

  • bodies (FloatingBody or list of FloatingBody) – The body or bodies involved in the problems They should all have different names.

  • method (string, optional) – select boundary integral equation used to solve the problems. It is recommended to set the method more globally when initializing the solver. If provided here, the value in argument of fill_dataset overrides the global one.

  • n_jobs (int, optional (default: 1)) – the number of jobs to run in parallel using the optional dependency joblib By defaults: do not use joblib and solve sequentially.

  • progress_bar (bool, optional) – Display a progress bar while solving. If no value is provided to this method directly, check whether the environment variable CAPYTAINE_PROGRESS_BAR is defined and otherwise default to True.

  • _check_wavelength (bool, optional (default: True)) – If True, the frequencies are compared to the mesh resolution and the estimated first irregular frequency to warn the user.

Return type:

xarray Dataset

classmethod from_exported_settings()[source]
get_free_surface_elevation(result, free_surface, keep_details=False)[source]

Compute the elevation of the free surface on a mesh for a previously solved problem.

The newer method compute_free_surface_elevation should be preferred in the future.

Parameters:
  • result (LinearPotentialFlowResult) – the return of the solver

  • free_surface (FreeSurface) – a meshed free surface

  • keep_details (bool, optional) – if True, keep the free surface elevation in the LinearPotentialFlowResult (default:False)

Returns:

the free surface elevation on each faces of the meshed free surface

Return type:

array of shape (free_surface.nb_faces,)

Raises:

Exception – if the Result object given as input does not contain the source distribution.:

get_potential_on_mesh(result, mesh, chunk_size=50)[source]

Compute the potential on a mesh for the potential field of a previously solved problem. Since the interaction matrix does not need to be computed in full to compute the matrix-vector product, only a few lines are evaluated at a time to reduce the memory cost of the operation.

The newer method compute_potential should be preferred in the future.

Parameters:
  • result (LinearPotentialFlowResult) – the return of the BEM solver

  • mesh (MeshLike) – a mesh

  • chunk_size (int, optional) – Number of lines to compute in the matrix. (legacy, should be passed as an engine setting instead).

Returns:

potential on the faces of the mesh

Return type:

array of shape (mesh.nb_faces,)

Raises:

Exception – if the Result object given as input does not contain the source distribution.:

solve(problem, method=None, keep_details=True, _check_wavelength=True)[source]

Solve the linear potential flow problem.

Parameters:
  • problem (LinearPotentialFlowProblem) – the problem to be solved

  • method (string, optional) – select boundary integral equation used to solve the problem. It is recommended to set the method more globally when initializing the solver. If provided here, the value in argument of solve overrides the global one.

  • keep_details (bool, optional) – if True, store the sources and the potential on the floating body in the output object (default: True)

  • _check_wavelength (bool, optional (default: True)) – If True, the frequencies are compared to the mesh resolution and the estimated first irregular frequency to warn the user.

Returns:

an object storing the problem data and its results

Return type:

LinearPotentialFlowResult

solve_all(problems, *, method=None, n_jobs=1, progress_bar=None, _check_wavelength=True, **kwargs)[source]

Solve several problems. Optional keyword arguments are passed to BEMSolver.solve.

Parameters:
  • problems (list of LinearPotentialFlowProblem) – several problems to be solved

  • method (string, optional) – select boundary integral equation used to solve the problems. It is recommended to set the method more globally when initializing the solver. If provided here, the value in argument of solve_all overrides the global one.

  • n_jobs (int, optional (default: 1)) – the number of jobs to run in parallel using the optional dependency joblib By defaults: do not use joblib and solve sequentially.

  • progress_bar (bool, optional) – Display a progress bar while solving. If no value is provided to this method directly, check whether the environment variable CAPYTAINE_PROGRESS_BAR is defined and otherwise default to True.

  • _check_wavelength (bool, optional (default: True)) – If True, the frequencies are compared to the mesh resolution and the estimated first irregular frequency to warn the user.

Returns:

the solved problems

Return type:

list of LinearPotentialFlowResult

timer_summary()[source]