@@ -72,6 +72,22 @@ def from_pymesh(cls, mesh: "pymesh.Mesh") -> "Mesh":
7272
7373 Returns:
7474 Mesh: Instantiated ppsci.geometry.Mesh object.
75+
76+ Examples:
77+ >>> import ppsci
78+ >>> import pymesh
79+ >>> import numpy as np
80+ >>> box = pymesh.generate_box_mesh(np.array([0, 0, 0]), np.array([1, 1, 1]))
81+ >>> mesh = ppsci.geometry.Mesh.from_pymesh(box)
82+ >>> print(mesh.vertices)
83+ [[0. 0. 0.]
84+ [1. 0. 0.]
85+ [1. 1. 0.]
86+ [0. 1. 0.]
87+ [0. 0. 1.]
88+ [1. 0. 1.]
89+ [1. 1. 1.]
90+ [0. 1. 1.]]
7591 """
7692 # check if pymesh is installed when using Mesh Class
7793 if not checker .dynamic_import_to_globals (["pymesh" ]):
@@ -182,6 +198,40 @@ def translate(self, translation: np.ndarray, relative: bool = True) -> "Mesh":
182198
183199 Returns:
184200 Mesh: Translated Mesh object.
201+
202+ Examples:
203+ >>> import ppsci
204+ >>> import pymesh
205+ >>> import numpy as np
206+ >>> box = pymesh.generate_box_mesh(np.array([0, 0, 0]), np.array([1, 1, 1]))
207+ >>> mesh = ppsci.geometry.Mesh(box)
208+ >>> print(mesh.vertices)
209+ [[0. 0. 0.]
210+ [1. 0. 0.]
211+ [1. 1. 0.]
212+ [0. 1. 0.]
213+ [0. 0. 1.]
214+ [1. 0. 1.]
215+ [1. 1. 1.]
216+ [0. 1. 1.]]
217+ >>> print(mesh.translate((-0.5, 0, 0.5), False).vertices) # the center is moved to the translation vector.
218+ [[-1. -0.5 0. ]
219+ [ 0. -0.5 0. ]
220+ [ 0. 0.5 0. ]
221+ [-1. 0.5 0. ]
222+ [-1. -0.5 1. ]
223+ [ 0. -0.5 1. ]
224+ [ 0. 0.5 1. ]
225+ [-1. 0.5 1. ]]
226+ >>> print(mesh.translate((-0.5, 0, 0.5), True).vertices) # the translation vector is directly added to the geometry coordinates
227+ [[-0.5 0. 0.5]
228+ [ 0.5 0. 0.5]
229+ [ 0.5 1. 0.5]
230+ [-0.5 1. 0.5]
231+ [-0.5 0. 1.5]
232+ [ 0.5 0. 1.5]
233+ [ 0.5 1. 1.5]
234+ [-0.5 1. 1.5]]
185235 """
186236 vertices = np .array (self .vertices , dtype = paddle .get_default_dtype ())
187237 faces = np .array (self .faces )
@@ -221,6 +271,32 @@ def scale(
221271
222272 Returns:
223273 Mesh: Scaled Mesh object.
274+
275+ Examples:
276+ >>> import ppsci
277+ >>> import pymesh
278+ >>> import numpy as np
279+ >>> box = pymesh.generate_box_mesh(np.array([0, 0, 0]), np.array([1, 1, 1]))
280+ >>> mesh = ppsci.geometry.Mesh(box)
281+ >>> print(mesh.vertices)
282+ [[0. 0. 0.]
283+ [1. 0. 0.]
284+ [1. 1. 0.]
285+ [0. 1. 0.]
286+ [0. 0. 1.]
287+ [1. 0. 1.]
288+ [1. 1. 1.]
289+ [0. 1. 1.]]
290+ >>> mesh = mesh.scale(2, (0.25, 0.5, 0.75))
291+ >>> print(mesh.vertices)
292+ [[-0.25 -0.5 -0.75]
293+ [ 1.75 -0.5 -0.75]
294+ [ 1.75 1.5 -0.75]
295+ [-0.25 1.5 -0.75]
296+ [-0.25 -0.5 1.25]
297+ [ 1.75 -0.5 1.25]
298+ [ 1.75 1.5 1.25]
299+ [-0.25 1.5 1.25]]
224300 """
225301 vertices = np .array (self .vertices , dtype = paddle .get_default_dtype ())
226302 faces = np .array (self .faces , dtype = paddle .get_default_dtype ())
0 commit comments