Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 87 additions & 59 deletions docs/user/Notebooks/1-Meshes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@
},
"source": [
"<div style=\"float: right; width: 40%\">\n",
"<img src=\"media/SampleSphericalMesh.png\" width=100%>\n",
"<caption>\n",
"<i>\n",
"</i>\n",
"</caption>\n",
" \n",
"![](media/SampleSphericalMesh.png)\n",
"\n",
"</div>\n",
"\n",
"\n",
"# Notebook 1: Meshes\n",
"## Notebook 1: Meshes\n",
"\n",
"Introducing meshes: how to build them, interrogate them and visualise them.\n",
"\n",
Expand All @@ -36,7 +34,6 @@
"\n",
"Mesh adaptivity is a work-in-progress.\n",
"\n",
"\n",
"\n"
]
},
Expand Down Expand Up @@ -64,7 +61,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 2,
"id": "5a4437ff-63ae-4ffa-9f2b-8ec1b8b4baeb",
"metadata": {
"editable": true,
Expand All @@ -74,7 +71,15 @@
},
"tags": []
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"PostHog telemetry failed: HTTPSConnectionPool(host='eu.i.posthog.com', port=443): Max retries exceeded with url: /capture/ (Caused by NameResolutionError(\"<urllib3.connection.HTTPSConnection object at 0x3049912b0>: Failed to resolve 'eu.i.posthog.com' ([Errno 8] nodename nor servname provided, or not known)\"))\n"
]
}
],
"source": [
"#| output: false # Suppress warnings in html version\n",
"\n",
Expand All @@ -100,7 +105,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 22,
"id": "1c928d60-24a9-4415-ab22-41834695c70a",
"metadata": {
"editable": true,
Expand All @@ -109,15 +114,26 @@
},
"tags": []
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Constructing UW mesh from gmsh .meshes/uw_cubed_spherical_shell_ro1.0_ri0.547_elts8_plexTrue.msh\n",
"Mesh refinement levels: 0\n",
"Mesh coarsening levels: None\n",
"Populating mesh coordinates CoordinateSystemType.SPHERICAL\n"
]
}
],
"source": [
"mesh = uw.meshing.uw.meshing.CubedSphere(\n",
" radiusOuter=1.0,\n",
" radiusInner=0.547,\n",
" numElements=8,\n",
" refinement=0,\n",
" simplex=False,\n",
" verbose=False,\n",
" simplex=True,\n",
" verbose=True,\n",
")"
]
},
Expand All @@ -141,7 +157,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 23,
"id": "b9cfac97-5c19-46b1-aebd-0fb77678b9ed",
"metadata": {},
"outputs": [
Expand All @@ -152,12 +168,12 @@
" [-0.57735027, 0.57735027, -0.57735027],\n",
" [-0.57735027, -0.57735027, -0.57735027],\n",
" ...,\n",
" [ 0.58691901, -0.41511058, -0.41511058],\n",
" [ 0.6269543 , -0.44342636, -0.44342636],\n",
" [ 0.66698958, -0.47174214, -0.47174214]])"
" [ 0.61340251, 0.4866531 , 0.41538064],\n",
" [ 0.56556024, 0.42209717, 0.44274422],\n",
" [ 0.51755571, 0.41031492, 0.44421012]])"
]
},
"execution_count": 4,
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -166,6 +182,14 @@
"mesh.data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a7c5dd7e-58d2-45d0-bfc6-eaded6da20f0",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "1ed56724-adc5-49c6-a33b-4552b619cb07",
Expand Down Expand Up @@ -208,7 +232,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 26,
"id": "1cb8378c-cdb8-4e75-bd12-e85f12169ef7",
"metadata": {
"editable": true,
Expand All @@ -226,13 +250,14 @@
"\n",
"pvmesh = vis.mesh_to_pv_mesh(mesh)\n",
"pvmesh.point_data[\"z\"] = vis.scalar_fn_to_pv_points(pvmesh, mesh.CoordinateSystem.X[2])\n",
"pvmesh1 = pvmesh.copy()\n",
"\n",
"if mesh.dim==3:\n",
" pvmesh_c = pvmesh.clip( normal='z', crinkle=True, inplace=False, origin=(0.0,0.0,0.01))\n",
"\n",
"pl = pv.Plotter(window_size=(750, 750))\n",
"pl.add_mesh(pvmesh_c, show_edges=True, show_scalar_bar=False, opacity=1.0)\n",
"pl.add_mesh(pvmesh, show_edges=True, show_scalar_bar=False, opacity=0.3)\n",
"pl.add_mesh(pvmesh1, show_edges=True, show_scalar_bar=False, opacity=0.3)\n",
"\n",
"\n",
"# Save and show the mesh\n",
Expand All @@ -241,7 +266,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 27,
"id": "fd6cbed0-3159-4c6c-a482-6a9636158854",
"metadata": {
"editable": true,
Expand All @@ -266,10 +291,10 @@
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x155c7fc90>"
"<IPython.lib.display.IFrame at 0x35f726660>"
]
},
"execution_count": 6,
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -320,10 +345,10 @@
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}{ r \\hspace{ 0.0pt } } & { \\theta \\hspace{ 0.01pt } } & { \\phi \\hspace{ 0.02pt } }\\end{matrix}\\right]$"
"$\\displaystyle \\left[\\begin{matrix}r & \\theta & \\phi\\end{matrix}\\right]$"
],
"text/plain": [
"Matrix([[{ r \\hspace{ 0.0pt } }, { \\theta \\hspace{ 0.01pt } }, { \\phi \\hspace{ 0.02pt } }]])"
"Matrix([[r, \\theta, \\phi]])"
]
},
"metadata": {},
Expand Down Expand Up @@ -382,33 +407,44 @@
"\n",
"\n",
"Mesh # 0: .meshes/uw_cubed_spherical_shell_ro1.0_ri0.547_elts8_plexFalse.msh\n",
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f18b77ba1d8d44ae96a3832ea3ffa5a3",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Widget(value='<iframe src=\"http://localhost:50188/index.html?ui=P_0x307b3b5f0_1&reconnect=auto\" class=\"pyvista…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Number of cells: 3072\n",
"\n",
"No variables are defined on the mesh\n",
"\n",
"| Boundary Name | ID | Min Size | Max Size |\n",
"| ------------------------------------------------------ |\n",
"| Lower | 1 | 678 | 678 |\n",
"| Upper | 2 | 678 | 678 |\n",
"| All_Boundaries | 1001 | 768 | 768 |\n",
"| UW_Boundaries | -- | 1356 | 1356 |\n",
"| ------------------------------------------------------ |\n",
"| Boundary Name | ID |\n",
"| -------------------------------- |\n",
"| Lower | 1 |\n",
"| Upper | 2 |\n",
"| Null_Boundary | 666 |\n",
"| All_Boundaries | 1001 |\n",
"| All_Boundaries | 1001 |\n",
"| UW_Boundaries | -- |\n",
"| -------------------------------- |\n",
"\n",
"\n",
"DM Object: uw_.meshes/uw_cubed_spherical_shell_ro1.0_ri0.547_elts8_plexFalse.msh 1 MPI process\n",
" type: plex\n",
"uw_.meshes/uw_cubed_spherical_shell_ro1.0_ri0.547_elts8_plexFalse.msh in 3 dimensions:\n",
" Number of 0-cells per rank: 3474\n",
" Number of 1-cells per rank: 10000\n",
" Number of 2-cells per rank: 9600\n",
" Number of 3-cells per rank: 3072\n",
"Labels:\n",
" depth: 4 strata with value/size (0 (3474), 1 (10000), 2 (9600), 3 (3072))\n",
" All_Boundaries: 1 strata with value/size (1001 (768))\n",
" Elements: 1 strata with value/size (99999 (5130))\n",
" Lower: 1 strata with value/size (1 (678))\n",
" Upper: 1 strata with value/size (2 (678))\n",
" celltype: 4 strata with value/size (0 (3474), 1 (10000), 4 (9600), 7 (3072))\n",
" UW_Boundaries: 2 strata with value/size (1 (678), 2 (678))\n"
"Use view(1) to view detailed mesh information.\n",
"\n"
]
}
],
Expand Down Expand Up @@ -438,25 +474,17 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4c23a076-d47a-4d27-80b7-b28b0ad38523",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "85dd4cc4-ae92-4dba-a917-298590533ca0",
"id": "2374ad95-c893-49a8-9915-de68374135ba",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python (Pixi)",
"language": "python",
"name": "python3"
"name": "pixi-kernel-python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -468,7 +496,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.10"
"version": "3.12.11"
}
},
"nbformat": 4,
Expand Down
Loading