Skip to content

Commit 91d8c71

Browse files
committed
updated tutorial-3-unv.ipynb to new API
1 parent 3a8a271 commit 91d8c71

File tree

1 file changed

+120
-40
lines changed

1 file changed

+120
-40
lines changed

tutorials/tutorial-3-unv.ipynb

Lines changed: 120 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,62 @@
2626
{
2727
"cell_type": "code",
2828
"execution_count": 1,
29-
"metadata": {},
30-
"outputs": [],
29+
"metadata": {
30+
"execution": {
31+
"iopub.execute_input": "2025-11-12T15:38:26.398940Z",
32+
"iopub.status.busy": "2025-11-12T15:38:26.398784Z",
33+
"iopub.status.idle": "2025-11-12T15:38:26.924892Z",
34+
"shell.execute_reply": "2025-11-12T15:38:26.924430Z"
35+
}
36+
},
37+
"outputs": [
38+
{
39+
"name": "stdout",
40+
"output_type": "stream",
41+
"text": [
42+
"Python Version: 3.9.25 (main, Nov 3 2025, 22:33:05) \n",
43+
"[GCC 11.2.0]\n",
44+
"Platform: linux\n",
45+
"System: Linux 6.12.0-55.41.1.el10_0.x86_64\n"
46+
]
47+
},
48+
{
49+
"name": "stdout",
50+
"output_type": "stream",
51+
"text": [
52+
"PyGeM version: 2.0.0\n"
53+
]
54+
}
55+
],
3156
"source": [
32-
"from pygem import FFDParameters, FFD, UnvHandler\n",
57+
"import sys\n",
58+
"import platform\n",
59+
"print(f\"Python Version: {sys.version}\")\n",
60+
"print(f\"Platform: {sys.platform}\")\n",
61+
"print(f\"System: {platform.system()} {platform.release()}\")\n",
62+
"\n",
63+
"try:\n",
64+
" import pygem\n",
65+
" print(f\"PyGeM version: {pygem.__version__}\")\n",
66+
"except ImportError:\n",
67+
" print(f\"PyGeM not found. Installing...\")\n",
68+
" import subprocess\n",
69+
"\n",
70+
" # Installing from local source. It can be replaced with github installation once pushed and merged.\n",
71+
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"-e\", \".[tut]\"])\n",
72+
" import pygem\n",
73+
"\n",
74+
" print(f\"PyGeM version: {pygem.__version__}\")\n",
75+
"\n",
76+
"import numpy as np\n",
3377
"\n",
34-
"params = FFDParameters()\n",
35-
"params.read_parameters(\n",
78+
"np.random.seed(42)\n",
79+
"\n",
80+
"from pygem import FFD\n",
81+
"from pygem.unvhandler import UnvHandler\n",
82+
"\n",
83+
"ffd = FFD()\n",
84+
"ffd.read_parameters(\n",
3685
" filename=\"../tests/test_datasets/parameters_test_ffd_pipe_unv_C0.prm\"\n",
3786
")"
3887
]
@@ -47,7 +96,14 @@
4796
{
4897
"cell_type": "code",
4998
"execution_count": 2,
50-
"metadata": {},
99+
"metadata": {
100+
"execution": {
101+
"iopub.execute_input": "2025-11-12T15:38:26.930136Z",
102+
"iopub.status.busy": "2025-11-12T15:38:26.929913Z",
103+
"iopub.status.idle": "2025-11-12T15:38:27.046957Z",
104+
"shell.execute_reply": "2025-11-12T15:38:27.046505Z"
105+
}
106+
},
51107
"outputs": [
52108
{
53109
"name": "stdout",
@@ -63,17 +119,17 @@
63119
"n control points y: 2\r\n",
64120
"n control points z: 3\r\n",
65121
"\r\n",
66-
"# box lenght indicates the length of the FFD bounding box along the three canonical directions (x, y, z).\r\n",
122+
"# box length indicates the length of the FFD bounding box along the three canonical directions (x, y, z).\r\n",
67123
"# It uses the local coordinate system.\r\n",
68-
"# For example to create a 2 x 1.5 x 3 meters box use the following: lenght box: 2.0, 1.5, 3.0\r\n",
69-
"box lenght x: 2.2\r\n",
70-
"box lenght y: 2.2\r\n",
71-
"box lenght z: 6.0\r\n",
124+
"# For example to create a 2 x 1.5 x 3 meters box use the following: box length: 2.0, 1.5, 3.0\r\n",
125+
"box length x: 2.2\r\n",
126+
"box length y: 2.2\r\n",
127+
"box length z: 6.0\r\n",
72128
"\r\n",
73129
"# box origin indicates the x, y, and z coordinates of the origin of the FFD bounding box. That is center of\r\n",
74130
"# rotation of the bounding box. It corresponds to the point coordinates with position [0][0][0].\r\n",
75131
"# See section \"Parameters weights\" for more details.\r\n",
76-
"# For example, if the origin is equal to 0., 0., 0., use the following: origin box: 0., 0., 0.\r\n",
132+
"# For example, if the origin is equal to 0., 0., 0., use the following: box origin: 0., 0., 0.\r\n",
77133
"box origin x: -1.1\r\n",
78134
"box origin y: -1.1\r\n",
79135
"box origin z: 2.0\r\n",
@@ -99,7 +155,7 @@
99155
"# | 0 | 1 | 0 | -2.1 |\r\n",
100156
"# | 0 | 0 | 1 | 3.4 |\r\n",
101157
"\r\n",
102-
"# parameter x collects the displacements along x, normalized with the box lenght x.\r\n",
158+
"# parameter x collects the displacements along x, normalized with the box length x.\r\n",
103159
"parameter x: 0 0 0 0.0\r\n",
104160
" 0 0 1 0.8\r\n",
105161
" 0 0 2 0.0\r\n",
@@ -113,7 +169,7 @@
113169
" 1 1 1 0.8\r\n",
114170
" 1 1 2 0.0\r\n",
115171
"\r\n",
116-
"# parameter y collects the displacements along y, normalized with the box lenght y.\r\n",
172+
"# parameter y collects the displacements along y, normalized with the box length y.\r\n",
117173
"parameter y: 0 0 0 0.0\r\n",
118174
" 0 0 1 0.0\r\n",
119175
" 0 0 2 0.0\r\n",
@@ -127,7 +183,7 @@
127183
" 1 1 1 0.0\r\n",
128184
" 1 1 2 0.0\r\n",
129185
"\r\n",
130-
"# parameter z collects the displacements along z, normalized with the box lenght z.\r\n",
186+
"# parameter z collects the displacements along z, normalized with the box length z.\r\n",
131187
"parameter z: 0 0 0 0.0\r\n",
132188
" 0 0 1 0.0\r\n",
133189
" 0 0 2 0.0\r\n",
@@ -159,7 +215,14 @@
159215
{
160216
"cell_type": "code",
161217
"execution_count": 3,
162-
"metadata": {},
218+
"metadata": {
219+
"execution": {
220+
"iopub.execute_input": "2025-11-12T15:38:27.048915Z",
221+
"iopub.status.busy": "2025-11-12T15:38:27.048743Z",
222+
"iopub.status.idle": "2025-11-12T15:38:27.150618Z",
223+
"shell.execute_reply": "2025-11-12T15:38:27.150194Z"
224+
}
225+
},
163226
"outputs": [],
164227
"source": [
165228
"unv_handler = UnvHandler()\n",
@@ -180,12 +243,17 @@
180243
{
181244
"cell_type": "code",
182245
"execution_count": 4,
183-
"metadata": {},
246+
"metadata": {
247+
"execution": {
248+
"iopub.execute_input": "2025-11-12T15:38:27.152910Z",
249+
"iopub.status.busy": "2025-11-12T15:38:27.152742Z",
250+
"iopub.status.idle": "2025-11-12T15:38:27.303104Z",
251+
"shell.execute_reply": "2025-11-12T15:38:27.302539Z"
252+
}
253+
},
184254
"outputs": [],
185255
"source": [
186-
"free_form = FFD(params, mesh_points)\n",
187-
"free_form.perform()\n",
188-
"new_mesh_points = free_form.modified_mesh_points\n",
256+
"new_mesh_points = ffd(mesh_points)\n",
189257
"\n",
190258
"unv_handler.write(new_mesh_points, \"test_pipe_mod_C0.unv\")"
191259
]
@@ -214,7 +282,14 @@
214282
{
215283
"cell_type": "code",
216284
"execution_count": 5,
217-
"metadata": {},
285+
"metadata": {
286+
"execution": {
287+
"iopub.execute_input": "2025-11-12T15:38:27.305275Z",
288+
"iopub.status.busy": "2025-11-12T15:38:27.305095Z",
289+
"iopub.status.idle": "2025-11-12T15:38:27.419912Z",
290+
"shell.execute_reply": "2025-11-12T15:38:27.419460Z"
291+
}
292+
},
218293
"outputs": [
219294
{
220295
"name": "stdout",
@@ -230,17 +305,17 @@
230305
"n control points y: 2\r\n",
231306
"n control points z: 5\r\n",
232307
"\r\n",
233-
"# box lenght indicates the length of the FFD bounding box along the three canonical directions (x, y, z).\r\n",
308+
"# box length indicates the length of the FFD bounding box along the three canonical directions (x, y, z).\r\n",
234309
"# It uses the local coordinate system.\r\n",
235-
"# For example to create a 2 x 1.5 x 3 meters box use the following: lenght box: 2.0, 1.5, 3.0\r\n",
236-
"box lenght x: 2.2\r\n",
237-
"box lenght y: 2.2\r\n",
238-
"box lenght z: 6.0\r\n",
310+
"# For example to create a 2 x 1.5 x 3 meters box use the following: box length: 2.0, 1.5, 3.0\r\n",
311+
"box length x: 2.2\r\n",
312+
"box length y: 2.2\r\n",
313+
"box length z: 6.0\r\n",
239314
"\r\n",
240315
"# box origin indicates the x, y, and z coordinates of the origin of the FFD bounding box. That is center of\r\n",
241316
"# rotation of the bounding box. It corresponds to the point coordinates with position [0][0][0].\r\n",
242317
"# See section \"Parameters weights\" for more details.\r\n",
243-
"# For example, if the origin is equal to 0., 0., 0., use the following: origin box: 0., 0., 0.\r\n",
318+
"# For example, if the origin is equal to 0., 0., 0., use the following: box origin: 0., 0., 0.\r\n",
244319
"box origin x: -1.1\r\n",
245320
"box origin y: -1.1\r\n",
246321
"box origin z: 2.0\r\n",
@@ -266,7 +341,7 @@
266341
"# | 0 | 1 | 0 | -2.1 |\r\n",
267342
"# | 0 | 0 | 1 | 3.4 |\r\n",
268343
"\r\n",
269-
"# parameter x collects the displacements along x, normalized with the box lenght x.\r\n",
344+
"# parameter x collects the displacements along x, normalized with the box length x.\r\n",
270345
"parameter x: 0 0 0 0.0\r\n",
271346
" 0 0 1 0.0\r\n",
272347
" 0 0 2 0.8\r\n",
@@ -288,7 +363,7 @@
288363
" 1 1 3 0.0\r\n",
289364
" 1 1 4 0.0\r\n",
290365
"\r\n",
291-
"# parameter y collects the displacements along y, normalized with the box lenght y.\r\n",
366+
"# parameter y collects the displacements along y, normalized with the box length y.\r\n",
292367
"parameter y: 0 0 0 0.0\r\n",
293368
" 0 0 1 0.0\r\n",
294369
" 0 0 2 0.0\r\n",
@@ -310,7 +385,7 @@
310385
" 1 1 3 0.0\r\n",
311386
" 1 1 4 0.0\r\n",
312387
"\r\n",
313-
"# parameter z collects the displacements along z, normalized with the box lenght z.\r\n",
388+
"# parameter z collects the displacements along z, normalized with the box length z.\r\n",
314389
"parameter z: 0 0 0 0.0\r\n",
315390
" 0 0 1 0.0\r\n",
316391
" 0 0 2 0.0\r\n",
@@ -348,17 +423,22 @@
348423
{
349424
"cell_type": "code",
350425
"execution_count": 6,
351-
"metadata": {},
426+
"metadata": {
427+
"execution": {
428+
"iopub.execute_input": "2025-11-12T15:38:27.421770Z",
429+
"iopub.status.busy": "2025-11-12T15:38:27.421601Z",
430+
"iopub.status.idle": "2025-11-12T15:38:27.569322Z",
431+
"shell.execute_reply": "2025-11-12T15:38:27.568953Z"
432+
}
433+
},
352434
"outputs": [],
353435
"source": [
354-
"params = FFDParameters()\n",
355-
"params.read_parameters(\n",
436+
"ffd = FFD()\n",
437+
"ffd.read_parameters(\n",
356438
" filename=\"../tests/test_datasets/parameters_test_ffd_pipe_unv_C1.prm\"\n",
357439
")\n",
358440
"\n",
359-
"free_form = FFD(params, mesh_points)\n",
360-
"free_form.perform()\n",
361-
"new_mesh_points = free_form.modified_mesh_points\n",
441+
"new_mesh_points = ffd(mesh_points)\n",
362442
"\n",
363443
"unv_handler.write(new_mesh_points, \"test_pipe_mod_C1.unv\")"
364444
]
@@ -379,19 +459,19 @@
379459
"kernelspec": {
380460
"display_name": "Python 2",
381461
"language": "python",
382-
"name": "python2"
462+
"name": "python3"
383463
},
384464
"language_info": {
385465
"codemirror_mode": {
386466
"name": "ipython",
387-
"version": 2
467+
"version": 3
388468
},
389469
"file_extension": ".py",
390470
"mimetype": "text/x-python",
391471
"name": "python",
392472
"nbconvert_exporter": "python",
393-
"pygments_lexer": "ipython2",
394-
"version": "2.7.13"
473+
"pygments_lexer": "ipython3",
474+
"version": "3.9.25"
395475
}
396476
},
397477
"nbformat": 4,

0 commit comments

Comments
 (0)