capytaine.bodies.bodies module¶
Floating bodies to be used in radiation-diffraction problems.
- class capytaine.bodies.bodies.FloatingBody(mesh=None, dofs=None, *, lid_mesh=None, center_of_mass=None, mass=None, name=None)[source]¶
Bases:
_FloatingBodyHydrostaticsMixin,AbstractBodyA floating body described as a mesh and some degrees of freedom.
The mesh structure is stored as a Mesh from capytaine.mesh.mesh or a CollectionOfMeshes from capytaine.mesh.meshes_collection.
The degrees of freedom (dofs) are stored as a dict associating a name to a complex-valued array of shape (nb_faces, 3). To each face of the body (as indexed in the mesh) corresponds a complex-valued 3d vector, which defines the displacement of the center of the face in frequency domain.
- Parameters:
mesh (AbstractMesh, optional) – the mesh describing the geometry of the hull of the floating body. If none is given, a empty one is created.
dofs (dict, optional) – the degrees of freedom of the body. If none is given, a empty dictionary is initialized.
lid_mesh (AbstractMesh or None, optional) – a mesh of an internal lid for irregular frequencies removal. Unlike the mesh of the hull, no dof is defined on the lid_mesh. If none is given, none is used when solving the Boundary Integral Equation.
center_of_mass (3-element array, optional) – the position of the center of mass. Required only for some hydrostatics computation.
mass (float or None, optional) – the mass of the body in kilograms. Required only for some hydrostatics computation. If None, the mass is implicitly assumed to be the mass of displaced water.
name (str, optional) – a name for the body. If none is given, the one of the mesh is used.
- Variables:
mesh_including_lid (AbstractMesh) – The hull mesh joined with the lid mesh
hull_mask (np.array) – The indices of the faces in mesh_including_lid that are part of the hull
- add_all_rigid_body_dofs(rotation_center=None) None[source]¶
Add the six degrees of freedom of rigid bodies (in place).
- add_rotation_dof(rotation_center=None, direction=None, name=None) None[source]¶
Add a new rotation dof (in place). If no axis is given, the code tries to infer it from the name.
- Parameters:
rotation_center (array of shape (3,), optional) – One point on the rotation axis
direction (array of shape (3,), optional) – The direction of the rotation axis
name (str, optional) – a name for the degree of freedom
- add_translation_dof(direction=None, name=None) None[source]¶
Add a new translation dof (in place). If no direction is given, the code tries to infer it from the name.
- Parameters:
direction (array of shape (3,), optional) – the direction of the translation
name (str, optional) – a name for the degree of freedom
- assemble_regular_array(distance, nb_bodies)[source]¶
Create an regular array of identical bodies.
- Parameters:
distance (float) – Center-to-center distance between objects in the array
nb_bodies (couple of ints) – Number of objects in the x and y directions.
- Return type:
- property bodies¶
For consistency with Multibody
- clipped(*, origin, normal, name=None) FloatingBody[source]¶
- copy(name=None) FloatingBody[source]¶
Return a deep copy of the body.
- Parameters:
name (str, optional) – a name for the new copy
- first_irregular_frequency_estimate(*, g=9.81)[source]¶
Estimates the angular frequency of the lowest irregular frequency. This is based on the formula for the lowest irregular frequency of a parallelepiped of size \(L \times B\) and draft \(H\):
(13)¶\[\omega = \sqrt{ \frac{\pi g \sqrt{\frac{1}{B^2} + \frac{1}{L^2}}} {\tanh\left(\pi H \sqrt{\frac{1}{B^2} + \frac{1}{L^2}} \right)} }\]The formula is applied to all shapes to get an estimate that is usually conservative. The definition of a lid (supposed to be fully covering and horizontal) is taken into account.
- static from_file(filename: str, file_format=None, name=None) FloatingBody[source]¶
Create a FloatingBody from a mesh file using meshmagick. Kinda deprecated, use cpt.load_mesh instead.
- static from_meshio(mesh, name=None) FloatingBody[source]¶
Create a FloatingBody from a meshio mesh object. Kinda deprecated, use cpt.load_mesh instead.
- immersed_part(free_surface=0.0, *, sea_bottom=None, water_depth=None, name=None) FloatingBody[source]¶
- property minimal_computable_wavelength¶
For accuracy of the resolution, wavelength should not be smaller than this value.
- mirrored(plane: Literal['xOz', 'yOz']) FloatingBody[source]¶
- property nb_dofs: int¶
Number of degrees of freedom.
- rename(name: str) FloatingBody[source]¶
- rotated_with_matrix(R, *, name=None) FloatingBody[source]¶
- property rotation_center: array¶
Try to infer a rotation center by looking at the dofs. Most bodies are rigid bodies with one and only one rotation center, but not all. Only used for exporting data, as it might not be defined.
- translated(shift, *, name=None) FloatingBody[source]¶