capytaine.meshes.abstract_meshes module

class capytaine.meshes.abstract_meshes.AbstractMesh[source]

Bases: SurfaceIntegralsMixin, ABC

abstractmethod clipped(*, origin, normal, name=None) AbstractMesh[source]
abstractmethod copy() AbstractMesh[source]
edges_faces_water_line()[source]

Extract the water line of the mesh.

Returns:

A tuple (edges, faces) where the edges are the edges of the water line (pairs of vertex indices) and the faces are the corresponding faces of the mesh that contain these edges (quadruplet of vertex indices).

Return type:

(np.ndarray, np.ndarray)

property edges_waterline

Return an array with the edges of the water line as pairs of vertex indices with shape (nb_edges_waterline,2).

abstractmethod export(format, **kwargs)[source]
export_to_meshio(**kwargs)[source]
export_to_pyvista(**kwargs)[source]
export_to_trimesh(**kwargs)[source]
export_to_xarray(**kwargs)[source]
abstractmethod extract_faces(faces_id, *, name=None) AbstractMesh[source]
abstractmethod extract_lid(z=0.0)[source]
extract_wedge(n: int, axis: str = 'z') AbstractMesh[source]

Extract a wedge (angular sector) from the mesh for rotational symmetry.

Extracts a 1/n sector of the mesh by clipping at angular boundaries. This creates proper faces at the wedge boundaries for clean reconstruction.

Parameters:
  • n (int) – The rotation order. The wedge will span 360/n degrees.

  • axis (str, optional) – Only “z” is currently supported.

Returns:

A new mesh containing the wedge sector with proper boundary faces.

Return type:

Mesh

Examples

Extract 1/3 of a sphere (120-degree wedge):

>>> sphere = mesh_sphere(radius=1.0, resolution=(12, 12))
>>> wedge = sphere.extract_wedge(n=3)
>>> wedge.nb_faces  # Approximately 1/3 of sphere.nb_faces
abstract property faces: ndarray
abstract property faces_areas: ndarray
abstract property faces_centers: ndarray
abstract property faces_normals: ndarray
abstract property faces_radiuses: ndarray
property faces_water_line

Return an array with the faces of the water line as quadruplets of vertex indices with shape (nb_edges_waterline,4).

abstractmethod generate_lid(z=0.0, faces_max_radius=None, name=None)[source]
immersed_part(free_surface=0.0, *, sea_bottom=None, water_depth=None) AbstractMesh[source]

Clip the mesh to keep only the part below the free surface.

Parameters:
  • free_surface (float) – The \(z\) coordinate of the free surface (default: 0.0)

  • water_depth (Optional[float]) – The water depth, as a positive value (default: infinity)

Returns:

A new Mesh instance that has been clipped.

Return type:

Mesh

abstractmethod join_meshes(*, return_masks=False, name=None) AbstractMesh[source]
property length_edges_water_line

Return an array with the lengths of the edges of the water line with shape (nb_edges_waterline,).

lowest_lid_position(omega_max, *, g=9.81)[source]
abstractmethod merged() AbstractMesh[source]
mirrored(plane: Literal['xOz', 'yOz'], *, name=None) AbstractMesh[source]
property nb_edges_waterline: int

Number of edges in the water line.

abstract property nb_faces: int
abstract property nb_vertices: int
pop_metadata(metadata_name) Tuple[AbstractMesh, ndarray][source]
abstract property quadrature_points: ndarray
rotated_such_that_vectors_are_aligned(a, b, *, eps=1e-08, name=None) AbstractMesh[source]
abstractmethod rotated_with_matrix(R, *, name=None) AbstractMesh[source]
rotated_x(angle: float, *, name=None) AbstractMesh[source]

Return a new Mesh rotated around the x-axis using the provided rotation angle in radians

rotated_y(angle: float, *, name=None) AbstractMesh[source]

Return a new Mesh rotated around the y-axis using the provided rotation angle in radians

rotated_z(angle: float, *, name=None) AbstractMesh[source]

Return a new Mesh rotated around the z-axis using the provided rotation angle in radians

abstractmethod show(*, backend=None, **kwargs)[source]
show_matplotlib(**kwargs)[source]

Equivalent to show(backend=”matplotlib”). See also show_matplotlib()

show_pyvista(**kwargs)[source]

Equivalent to show(backend=”pyvista”). See also show_pyvista()

abstractmethod translated(shift, *, name=None) AbstractMesh[source]
translated_x(dx: float, *, name=None) AbstractMesh[source]

Return a new Mesh translated in the x-direction along dx.

translated_y(dy: float, *, name=None) AbstractMesh[source]

Return a new Mesh translated in the y-direction along dy.

translated_z(dz: float, *, name=None) AbstractMesh[source]

Return a new Mesh translated in the z-direction along dz.

water_line_integral(data)[source]

Returns integral of given data along the water line.

Parameters:

data (np.ndarray) – Values of the function to integrate, with shape (nb_edges_waterline,).

Returns:

Value of the integral.

Return type:

float

with_metadata(**new_metadata) AbstractMesh[source]
abstractmethod with_normal_vector_going_down(**kwargs) AbstractMesh[source]
abstractmethod with_quadrature(quadrature_method)[source]
without_any_metadata() AbstractMesh[source]
without_metadata(*metadata_names) AbstractMesh[source]
property z_span: Tuple[float, float]