capytaine 2.3__cp312-cp312-win_amd64.whl → 3.0.0a1__cp312-cp312-win_amd64.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/__about__.py +7 -2
- capytaine/__init__.py +11 -15
- 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.cp312-win_amd64.dll.a → Delhommeau_float32.cp312-win_amd64.dll.a} +0 -0
- capytaine/green_functions/Delhommeau_float32.cp312-win_amd64.pyd +0 -0
- capytaine/green_functions/{libs/Delhommeau_float64.cp312-win_amd64.dll.a → Delhommeau_float64.cp312-win_amd64.dll.a} +0 -0
- capytaine/green_functions/Delhommeau_float64.cp312-win_amd64.pyd +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-3.0.0a1.dist-info/DELVEWHEEL +2 -0
- {capytaine-2.3.dist-info → capytaine-3.0.0a1.dist-info}/METADATA +8 -14
- capytaine-3.0.0a1.dist-info/RECORD +70 -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/Delhommeau_float32.cp312-win_amd64.pyd +0 -0
- capytaine/green_functions/libs/Delhommeau_float64.cp312-win_amd64.pyd +0 -0
- 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/DELVEWHEEL +0 -2
- capytaine-2.3.dist-info/RECORD +0 -97
- {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}/WHEEL +0 -0
- {capytaine-2.3.dist-info → capytaine-3.0.0a1.dist-info}/entry_points.txt +0 -0
capytaine/bodies/dofs.py
CHANGED
|
@@ -1,19 +1,146 @@
|
|
|
1
1
|
# Copyright (C) 2017-2022 Matthieu Ancellin
|
|
2
2
|
# See LICENSE file at <https://github.com/capytaine/capytaine>
|
|
3
3
|
|
|
4
|
+
from abc import ABC, abstractmethod
|
|
5
|
+
from functools import lru_cache
|
|
6
|
+
import logging
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
import numpy as np
|
|
9
|
+
import xarray as xr
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
LOG = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class AbstractDof(ABC):
|
|
15
|
+
@abstractmethod
|
|
16
|
+
def evaluate_motion(self, mesh):
|
|
17
|
+
...
|
|
18
|
+
|
|
19
|
+
@abstractmethod
|
|
20
|
+
def evaluate_gradient_of_motion(self, mesh):
|
|
21
|
+
...
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class TranslationDof(AbstractDof):
|
|
25
|
+
def __init__(self, direction):
|
|
26
|
+
self.direction = np.asarray(direction)
|
|
27
|
+
assert self.direction.shape == (3,)
|
|
10
28
|
|
|
11
29
|
def __str__(self):
|
|
12
|
-
return "
|
|
30
|
+
return f"TranslationDof(direction={self.direction})"
|
|
31
|
+
|
|
32
|
+
@lru_cache
|
|
33
|
+
def evaluate_motion(self, mesh) -> np.array:
|
|
34
|
+
return np.tile(self.direction, (mesh.nb_faces, 1))
|
|
35
|
+
|
|
36
|
+
@lru_cache
|
|
37
|
+
def evaluate_gradient_of_motion(self, mesh) -> np.array:
|
|
38
|
+
return np.zeros((mesh.nb_faces, 3, 3))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class RotationDof(AbstractDof):
|
|
42
|
+
def __init__(self, rotation_center, direction):
|
|
43
|
+
self.direction = np.asarray(direction)
|
|
44
|
+
assert self.direction.shape == (3,)
|
|
45
|
+
if rotation_center is None:
|
|
46
|
+
self.rotation_center = np.array([0, 0, 0])
|
|
47
|
+
LOG.warning("Rigid body rotation dof has been initialized "
|
|
48
|
+
"around the origin of the domain (0, 0, 0).")
|
|
49
|
+
else:
|
|
50
|
+
self.rotation_center = np.asarray(rotation_center)
|
|
51
|
+
assert self.rotation_center.shape == (3,)
|
|
52
|
+
|
|
53
|
+
def __str__(self):
|
|
54
|
+
return f"RotationDof(rotation_center={self.rotation_center}, direction={self.direction})"
|
|
55
|
+
|
|
56
|
+
@lru_cache
|
|
57
|
+
def evaluate_motion(self, mesh) -> np.array:
|
|
58
|
+
if mesh.nb_faces == 0:
|
|
59
|
+
return np.empty((mesh.nb_faces, 3))
|
|
60
|
+
else:
|
|
61
|
+
motion = np.cross(self.direction, mesh.faces_centers - self.rotation_center)
|
|
62
|
+
return motion
|
|
63
|
+
|
|
64
|
+
@lru_cache
|
|
65
|
+
def evaluate_gradient_of_motion(self, mesh) -> np.array:
|
|
66
|
+
grad = np.cross(self.direction, np.eye(3))
|
|
67
|
+
return np.tile(grad, (mesh.nb_faces, 1, 1))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class DofOnSubmesh(AbstractDof):
|
|
71
|
+
def __init__(self, dof: AbstractDof, faces):
|
|
72
|
+
self.dof = dof
|
|
73
|
+
self.faces = faces
|
|
74
|
+
|
|
75
|
+
def evaluate_motion(self, mesh):
|
|
76
|
+
motion = np.zeros((mesh.nb_faces, 3))
|
|
77
|
+
motion[self.faces, :] = self.dof.evaluate_motion(mesh.extract_faces(self.faces))
|
|
78
|
+
return motion
|
|
79
|
+
|
|
80
|
+
def evaluate_gradient_of_motion(self, mesh) -> np.array:
|
|
81
|
+
grad = np.zeros((mesh.nb_faces, 3, 3))
|
|
82
|
+
grad[self.faces, :, :] = self.dof.evaluate_gradient_of_motion(mesh.extract_faces(self.faces))
|
|
83
|
+
return grad
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def is_rigid_body_dof(dof):
|
|
87
|
+
return (
|
|
88
|
+
isinstance(dof, TranslationDof)
|
|
89
|
+
or isinstance(dof, RotationDof)
|
|
90
|
+
# or (isinstance(dof, DofOnSubmesh) and is_rigid_body_dof(dof.dof))
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def rigid_body_dofs(only=None, rotation_center=None):
|
|
95
|
+
"""Pass this to FloatingBody initializer to give it rigid body dofs.
|
|
96
|
+
|
|
97
|
+
Parameters
|
|
98
|
+
----------
|
|
99
|
+
only: sequence of str, optional
|
|
100
|
+
list of the name of the rigid body dofs to be included.
|
|
101
|
+
By default: all six of them
|
|
102
|
+
rotation_center: np.array, optional
|
|
103
|
+
the center for the definition of the rotations
|
|
104
|
+
"""
|
|
105
|
+
if rotation_center is None:
|
|
106
|
+
rotation_center = np.array([0, 0, 0])
|
|
107
|
+
|
|
108
|
+
if not (only is not None
|
|
109
|
+
and set(only).issubset({"Surge", "Sway", "Heave"})
|
|
110
|
+
): # Skip the warning if only translations are required.
|
|
111
|
+
LOG.warning("Rigid body rotation dofs have been initialized "
|
|
112
|
+
"around the origin of the domain (0, 0, 0).")
|
|
113
|
+
# This warning is redundant with the one in RotationDof.__init__,
|
|
114
|
+
# but it is done here to have a single warning displayed on screen
|
|
115
|
+
# when a rigid body is initialized.
|
|
116
|
+
|
|
117
|
+
dofs = {
|
|
118
|
+
"Surge": TranslationDof(direction=(1, 0, 0)),
|
|
119
|
+
"Sway": TranslationDof(direction=(0, 1, 0)),
|
|
120
|
+
"Heave": TranslationDof(direction=(0, 0, 1)),
|
|
121
|
+
"Roll": RotationDof(rotation_center=rotation_center, direction=(1, 0, 0)),
|
|
122
|
+
"Pitch": RotationDof(rotation_center=rotation_center, direction=(0, 1, 0)),
|
|
123
|
+
"Yaw": RotationDof(rotation_center=rotation_center, direction=(0, 0, 1)),
|
|
124
|
+
}
|
|
125
|
+
if only is not None:
|
|
126
|
+
dofs = {k: v for k, v in dofs.items() if k in only}
|
|
127
|
+
return dofs
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def normalize_name(name):
|
|
131
|
+
return name[0].upper() + name[1:].lower()
|
|
13
132
|
|
|
14
|
-
def _repr_pretty_(self, p, cycle):
|
|
15
|
-
p.text(self.__str__())
|
|
16
133
|
|
|
134
|
+
def add_dofs_labels_to_vector(dof_names, vector):
|
|
135
|
+
"""Helper function turning a bare vector into a vector labelled by the name of the dofs,
|
|
136
|
+
to be used for instance for the computation of RAO."""
|
|
137
|
+
return xr.DataArray(data=np.asarray(vector), dims=['influenced_dof'],
|
|
138
|
+
coords={'influenced_dof': list(dof_names)},
|
|
139
|
+
)
|
|
17
140
|
|
|
18
|
-
def
|
|
19
|
-
|
|
141
|
+
def add_dofs_labels_to_matrix(dof_names, matrix):
|
|
142
|
+
"""Helper function turning a bare matrix into a matrix labelled by the name of the dofs,
|
|
143
|
+
to be used for instance for the computation of RAO."""
|
|
144
|
+
return xr.DataArray(data=np.asarray(matrix), dims=['influenced_dof', 'radiating_dof'],
|
|
145
|
+
coords={'influenced_dof': list(dof_names), 'radiating_dof': list(dof_names)},
|
|
146
|
+
)
|