capytaine 2.3__cp312-cp312-macosx_14_0_arm64.whl → 3.0.0a1__cp312-cp312-macosx_14_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- capytaine/.dylibs/libgcc_s.1.1.dylib +0 -0
- capytaine/.dylibs/libgfortran.5.dylib +0 -0
- capytaine/.dylibs/libquadmath.0.dylib +0 -0
- capytaine/__about__.py +7 -2
- capytaine/__init__.py +8 -12
- capytaine/bem/engines.py +234 -354
- capytaine/bem/problems_and_results.py +30 -21
- capytaine/bem/solver.py +205 -81
- capytaine/bodies/bodies.py +279 -862
- capytaine/bodies/dofs.py +136 -9
- capytaine/bodies/hydrostatics.py +540 -0
- capytaine/bodies/multibodies.py +216 -0
- capytaine/green_functions/{libs/Delhommeau_float32.cpython-312-darwin.so → Delhommeau_float32.cpython-312-darwin.so} +0 -0
- capytaine/green_functions/{libs/Delhommeau_float64.cpython-312-darwin.so → Delhommeau_float64.cpython-312-darwin.so} +0 -0
- capytaine/green_functions/abstract_green_function.py +2 -2
- capytaine/green_functions/delhommeau.py +50 -31
- capytaine/green_functions/hams.py +19 -13
- capytaine/io/legacy.py +3 -103
- capytaine/io/xarray.py +15 -10
- capytaine/meshes/__init__.py +2 -6
- capytaine/meshes/abstract_meshes.py +375 -0
- capytaine/meshes/clean.py +302 -0
- capytaine/meshes/clip.py +347 -0
- capytaine/meshes/export.py +89 -0
- capytaine/meshes/geometry.py +244 -394
- capytaine/meshes/io.py +433 -0
- capytaine/meshes/meshes.py +621 -676
- capytaine/meshes/predefined/cylinders.py +22 -56
- capytaine/meshes/predefined/rectangles.py +26 -85
- capytaine/meshes/predefined/spheres.py +4 -11
- capytaine/meshes/quality.py +118 -407
- capytaine/meshes/surface_integrals.py +48 -29
- capytaine/meshes/symmetric_meshes.py +641 -0
- capytaine/meshes/visualization.py +353 -0
- capytaine/post_pro/free_surfaces.py +1 -4
- capytaine/post_pro/kochin.py +10 -10
- capytaine/tools/block_circulant_matrices.py +275 -0
- capytaine/tools/lists_of_points.py +2 -2
- capytaine/tools/memory_monitor.py +45 -0
- capytaine/tools/symbolic_multiplication.py +31 -5
- capytaine/tools/timer.py +68 -42
- {capytaine-2.3.dist-info → capytaine-3.0.0a1.dist-info}/METADATA +8 -14
- capytaine-3.0.0a1.dist-info/RECORD +65 -0
- capytaine-3.0.0a1.dist-info/WHEEL +6 -0
- capytaine/bodies/predefined/__init__.py +0 -6
- capytaine/bodies/predefined/cylinders.py +0 -151
- capytaine/bodies/predefined/rectangles.py +0 -111
- capytaine/bodies/predefined/spheres.py +0 -70
- capytaine/green_functions/FinGreen3D/.gitignore +0 -1
- capytaine/green_functions/FinGreen3D/FinGreen3D.f90 +0 -3589
- capytaine/green_functions/FinGreen3D/LICENSE +0 -165
- capytaine/green_functions/FinGreen3D/Makefile +0 -16
- capytaine/green_functions/FinGreen3D/README.md +0 -24
- capytaine/green_functions/FinGreen3D/test_program.f90 +0 -39
- capytaine/green_functions/LiangWuNoblesse/.gitignore +0 -1
- capytaine/green_functions/LiangWuNoblesse/LICENSE +0 -504
- capytaine/green_functions/LiangWuNoblesse/LiangWuNoblesseWaveTerm.f90 +0 -751
- capytaine/green_functions/LiangWuNoblesse/Makefile +0 -18
- capytaine/green_functions/LiangWuNoblesse/README.md +0 -2
- capytaine/green_functions/LiangWuNoblesse/test_program.f90 +0 -28
- capytaine/green_functions/libs/__init__.py +0 -0
- capytaine/io/mesh_loaders.py +0 -1086
- capytaine/io/mesh_writers.py +0 -692
- capytaine/io/meshio.py +0 -38
- capytaine/matrices/__init__.py +0 -16
- capytaine/matrices/block.py +0 -592
- capytaine/matrices/block_toeplitz.py +0 -325
- capytaine/matrices/builders.py +0 -89
- capytaine/matrices/linear_solvers.py +0 -232
- capytaine/matrices/low_rank.py +0 -395
- capytaine/meshes/clipper.py +0 -465
- capytaine/meshes/collections.py +0 -334
- capytaine/meshes/mesh_like_protocol.py +0 -37
- capytaine/meshes/properties.py +0 -276
- capytaine/meshes/quadratures.py +0 -80
- capytaine/meshes/symmetric.py +0 -392
- capytaine/tools/lru_cache.py +0 -49
- capytaine/ui/vtk/__init__.py +0 -3
- capytaine/ui/vtk/animation.py +0 -329
- capytaine/ui/vtk/body_viewer.py +0 -28
- capytaine/ui/vtk/helpers.py +0 -82
- capytaine/ui/vtk/mesh_viewer.py +0 -461
- capytaine-2.3.dist-info/RECORD +0 -92
- capytaine-2.3.dist-info/WHEEL +0 -4
- {capytaine-2.3.dist-info → capytaine-3.0.0a1.dist-info}/LICENSE +0 -0
- {capytaine-2.3.dist-info → capytaine-3.0.0a1.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import xarray as xr
|
|
3
|
+
|
|
4
|
+
from capytaine.tools.optional_imports import import_optional_dependency
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def export_mesh(mesh, format: str):
|
|
8
|
+
format = format.lower()
|
|
9
|
+
if format == "pyvista":
|
|
10
|
+
return export_to_pyvista(mesh)
|
|
11
|
+
elif format == "xarray":
|
|
12
|
+
return export_to_xarray(mesh)
|
|
13
|
+
elif format == "meshio":
|
|
14
|
+
return export_to_meshio(mesh)
|
|
15
|
+
elif format == "trimesh":
|
|
16
|
+
return export_to_trimesh(mesh)
|
|
17
|
+
else:
|
|
18
|
+
raise ValueError(f"Unrecognized output format: {format}")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def export_to_pyvista(mesh):
|
|
22
|
+
"""
|
|
23
|
+
Build a PyVista UnstructuredGrid from a list of faces (triangles or quads).
|
|
24
|
+
"""
|
|
25
|
+
pv = import_optional_dependency("pyvista")
|
|
26
|
+
|
|
27
|
+
# flatten into the VTK cell‐array format: [n0, i0, i1, ..., in-1, n1, j0, j1, ...]
|
|
28
|
+
flat_cells = []
|
|
29
|
+
cell_types = []
|
|
30
|
+
for face in mesh._faces:
|
|
31
|
+
n = len(face)
|
|
32
|
+
flat_cells.append(n)
|
|
33
|
+
flat_cells.extend(face)
|
|
34
|
+
if n == 3:
|
|
35
|
+
cell_types.append(pv.CellType.TRIANGLE)
|
|
36
|
+
elif n == 4:
|
|
37
|
+
cell_types.append(pv.CellType.QUAD)
|
|
38
|
+
else:
|
|
39
|
+
# if you ever have ngons, you can map them as POLYGON:
|
|
40
|
+
cell_types.append(pv.CellType.POLYGON)
|
|
41
|
+
|
|
42
|
+
cells_array = np.array(flat_cells, dtype=np.int64)
|
|
43
|
+
cell_types = np.array(cell_types, dtype=np.uint8)
|
|
44
|
+
|
|
45
|
+
return pv.UnstructuredGrid(cells_array, cell_types, mesh.vertices.astype(np.float32))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def export_to_xarray(mesh):
|
|
49
|
+
return xr.Dataset(
|
|
50
|
+
{
|
|
51
|
+
"mesh_vertices": (
|
|
52
|
+
["face", "vertices_of_face", "space_coordinate"],
|
|
53
|
+
mesh.as_array_of_faces()
|
|
54
|
+
)
|
|
55
|
+
},
|
|
56
|
+
coords={
|
|
57
|
+
"space_coordinate": ["x", "y", "z"],
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def export_to_meshio(mesh):
|
|
62
|
+
meshio = import_optional_dependency("meshio")
|
|
63
|
+
|
|
64
|
+
quads = [f for f in mesh._faces if len(f) == 4]
|
|
65
|
+
tris = [f for f in mesh._faces if len(f) == 3]
|
|
66
|
+
|
|
67
|
+
cells = []
|
|
68
|
+
if quads:
|
|
69
|
+
cells.append(meshio.CellBlock("quad", np.array(quads, dtype=np.int32)))
|
|
70
|
+
if tris:
|
|
71
|
+
cells.append(meshio.CellBlock("triangle", np.array(tris, dtype=np.int32)))
|
|
72
|
+
|
|
73
|
+
return meshio.Mesh(points=mesh.vertices, cells=cells)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def export_to_trimesh(mesh):
|
|
77
|
+
trimesh = import_optional_dependency("trimesh")
|
|
78
|
+
triangle_faces = []
|
|
79
|
+
for face in mesh._faces:
|
|
80
|
+
if len(face) == 4 and face[3] != face[2]:
|
|
81
|
+
triangle_faces.append([face[0], face[1], face[2]])
|
|
82
|
+
triangle_faces.append([face[0], face[2], face[3]])
|
|
83
|
+
else:
|
|
84
|
+
triangle_faces.append(face[:3])
|
|
85
|
+
return trimesh.Trimesh(
|
|
86
|
+
vertices=mesh.vertices,
|
|
87
|
+
faces=np.array(triangle_faces),
|
|
88
|
+
process=False
|
|
89
|
+
)
|