capytaine.bem.solver module¶
Solver for the BEM problem.
Example
problem = RadiationProblem(...)
result = BEMSolver(green_functions=..., engine=...).solve(problem)
- class capytaine.bem.solver.BEMSolver(*, green_function=<capytaine.green_functions.delhommeau.Delhommeau object>, engine=<capytaine.bem.engines.BasicMatrixEngine object>)[source]¶
Bases:
object
Solver for linear potential flow problems.
- Parameters:
green_function (AbstractGreenFunction) – Object handling the computation of the Green function.
engine (MatrixEngine) – Object handling the building of matrices and the resolution of linear systems with these matrices.
- Variables:
exportable_settings (dict) – Settings of the solver that can be saved to reinit the same solver later.
- fill_dataset(dataset, bodies, *, 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.
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.
- 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.
- 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.
- 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, keep_details=True)[source]¶
Solve the linear potential flow problem.
- Parameters:
problem (LinearPotentialFlowProblem) – the problem to be solved
keep_details (bool, optional) – if True, store the sources and the potential on the floating body in the output object (default: True)
- Returns:
an object storing the problem data and its results
- Return type:
- solve_all(problems, *, n_jobs=1, **kwargs)[source]¶
Solve several problems. Optional keyword arguments are passed to BEMSolver.solve.
- Parameters:
problems (list of LinearPotentialFlowProblem) – several problems to be solved
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.
- Returns:
the solved problems
- Return type:
list of LinearPotentialFlowResult