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)[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
)
- Variables:
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 cpt.Mesh or cpt.CollectionOfMeshes 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 cpt.Mesh or cpt.CollectionOfMeshes 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 cpt.Mesh or cpt.CollectionOfMeshes 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 cpt.Mesh or cpt.CollectionOfMeshes 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='indirect', n_jobs=1, **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 approach indirect (i.e.Nemoh)/direct (i.e.WAMIT) (default: indirect)
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 (default: True)) – Display a progress bar while solving
- Return type:
xarray Dataset
- 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 (Mesh or CollectionOfMeshes) – 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='indirect', 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 approach indirect (i.e.Nemoh)/direct (i.e.WAMIT) (default: indirect)
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) – if True, check the mesh resolution with respect to the wavelength
- Returns:
an object storing the problem data and its results
- Return type:
- solve_all(problems, *, method='indirect', n_jobs=1, progress_bar=True, _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 approach indirect (i.e.Nemoh)/direct (i.e.WAMIT) (default: indirect)
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 (default: True)) – Display a progress bar while solving
- Returns:
the solved problems
- Return type:
list of LinearPotentialFlowResult