Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jorgensd/dolfinx-tutorial
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: ZLoverty/dolfinx-tutorial
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Apr 26, 2025

  1. Copy the full SHA
    08eae58 View commit details
Showing with 18 additions and 91 deletions.
  1. +18 −91 chapter1/fundamentals_code.ipynb
109 changes: 18 additions & 91 deletions chapter1/fundamentals_code.ipynb
Original file line number Diff line number Diff line change
@@ -68,11 +68,7 @@
"cell_type": "code",
"execution_count": null,
"id": "2",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"from mpi4py import MPI\n",
@@ -105,11 +101,7 @@
"cell_type": "code",
"execution_count": null,
"id": "4",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"from dolfinx.fem import functionspace\n",
@@ -120,11 +112,7 @@
"cell_type": "code",
"execution_count": null,
"id": "5",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"from dolfinx import fem\n",
@@ -146,14 +134,9 @@
"cell_type": "code",
"execution_count": null,
"id": "7",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"import numpy\n",
"# Create facet to cell connectivity required to determine boundary facets\n",
"tdim = domain.topology.dim\n",
"fdim = tdim - 1\n",
@@ -180,11 +163,7 @@
"cell_type": "code",
"execution_count": null,
"id": "9",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"boundary_dofs = fem.locate_dofs_topological(V, fdim, boundary_facets)\n",
@@ -208,11 +187,7 @@
"cell_type": "code",
"execution_count": null,
"id": "11",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"import ufl\n",
@@ -233,11 +208,7 @@
"cell_type": "code",
"execution_count": null,
"id": "13",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"from dolfinx import default_scalar_type\n",
@@ -261,11 +232,7 @@
"cell_type": "code",
"execution_count": null,
"id": "15",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"a = ufl.dot(ufl.grad(u), ufl.grad(v)) * ufl.dx\n",
@@ -306,11 +273,7 @@
"cell_type": "code",
"execution_count": null,
"id": "17",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"from dolfinx.fem.petsc import LinearProblem\n",
@@ -332,11 +295,7 @@
"cell_type": "code",
"execution_count": null,
"id": "19",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"V2 = fem.functionspace(domain, (\"Lagrange\", 2))\n",
@@ -357,11 +316,7 @@
"cell_type": "code",
"execution_count": null,
"id": "21",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"L2_error = fem.form(ufl.inner(uh - uex, uh - uex) * ufl.dx)\n",
@@ -386,11 +341,7 @@
"cell_type": "code",
"execution_count": null,
"id": "23",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"error_max = numpy.max(numpy.abs(uD.x.array-uh.x.array))\n",
@@ -427,11 +378,7 @@
"cell_type": "code",
"execution_count": null,
"id": "26",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"from dolfinx import plot\n",
@@ -462,11 +409,7 @@
"cell_type": "code",
"execution_count": null,
"id": "29",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"plotter = pyvista.Plotter()\n",
@@ -491,11 +434,7 @@
"cell_type": "code",
"execution_count": null,
"id": "31",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"u_topology, u_cell_types, u_geometry = plot.vtk_mesh(V)"
@@ -513,11 +452,7 @@
"cell_type": "code",
"execution_count": null,
"id": "33",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"u_grid = pyvista.UnstructuredGrid(u_topology, u_cell_types, u_geometry)\n",
@@ -542,11 +477,7 @@
"cell_type": "code",
"execution_count": null,
"id": "35",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"warped = u_grid.warp_by_scalar()\n",
@@ -569,11 +500,7 @@
"cell_type": "code",
"execution_count": null,
"id": "37",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"from dolfinx import io\n",