You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: chapter1/fundamentals_code.ipynb
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -290,7 +290,8 @@
290
290
"The inner product $\\int_\\Omega \\nabla u \\cdot \\nabla v ~\\mathrm{d} x$ can be expressed in various ways in UFL. We have used the notation `ufl.dot(ufl.grad(u), ufl.grad(v))*ufl.dx`.\n",
291
291
"The dot product in UFL computes the sum (contraction) over the last index of the first factor and first index of the second factor.\n",
292
292
"In this case, both factors are tensors of rank one (vectors) and so the sum is just over the single index of both $\\nabla u$ and $\\nabla v$.\n",
293
-
"To compute an inner product of matrices (with two indices), one must instead of `ufl.dot` use the function `ufl.inner`. For vectors, `ufl.dot` and `ufl.inner` are equivalent.\n",
293
+
"To compute an inner product of matrices (with two indices), on must use use the function `ufl.inner` instead of `ufl.dot`.\n",
294
+
"For vectors, `ufl.dot` and `ufl.inner` are equivalent.\n",
294
295
"\n",
295
296
"```{admonition} Complex numbers\n",
296
297
"In DOLFINx, one can solve complex number problems by using an installation of PETSc using complex numbers.\n",
Copy file name to clipboardExpand all lines: chapter1/fundamentals_code.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -173,7 +173,8 @@
173
173
# The inner product $\int_\Omega \nabla u \cdot \nabla v ~\mathrm{d} x$ can be expressed in various ways in UFL. We have used the notation `ufl.dot(ufl.grad(u), ufl.grad(v))*ufl.dx`.
174
174
# The dot product in UFL computes the sum (contraction) over the last index of the first factor and first index of the second factor.
175
175
# In this case, both factors are tensors of rank one (vectors) and so the sum is just over the single index of both $\nabla u$ and $\nabla v$.
176
-
# To compute an inner product of matrices (with two indices), one must instead of `ufl.dot` use the function `ufl.inner`. For vectors, `ufl.dot` and `ufl.inner` are equivalent.
176
+
# To compute an inner product of matrices (with two indices), on must use use the function `ufl.inner` instead of `ufl.dot`.
177
+
# For vectors, `ufl.dot` and `ufl.inner` are equivalent.
177
178
#
178
179
# ```{admonition} Complex numbers
179
180
# In DOLFINx, one can solve complex number problems by using an installation of PETSc using complex numbers.
Copy file name to clipboardExpand all lines: chapter2/linearelasticity_code.ipynb
+5-3Lines changed: 5 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,10 @@
14
14
"- Compute Von Mises stresses\n",
15
15
"\n",
16
16
"## Test problem\n",
17
-
"As a test example, we will model a clamped beam deformed under its own weight in 3D. This can be modeled, by setting the right-hand side body force per unit volume to $f=(0,0,-\\rho g)$ with $\\rho$ the density of the beam and $g$ the acceleration of gravity. The beam is box-shaped with length $L$ and has a square cross section of width $W$. We set $u=u_D=(0,0,0)$ at the clamped end, x=0. The rest of the boundary is traction free, that is, we set $T=0$. We start by defining the physical variables used in the program."
17
+
"As a test example, we will model a clamped beam deformed under its own weight in 3D.\n",
18
+
"This can be modeled, by setting the right-hand side body force per unit volume to $f=(0,0,-\\rho g)$ with $\\rho$ the density of the beam and $g$ the acceleration of gravity.\n",
19
+
"The beam is box-shaped with length $L$ and has a square cross section of width $W$. We set $u=u_D=(0,0,0)$ at the clamped end, x=0. The rest of the boundary is traction free, that is, we set $T=0$.\n",
20
+
"We start by defining the physical variables used in the program."
"Next we generate a general function to assemble the mass matrix for a unit cube. Note that we use `dolfinx.fem.form` to compile the variational form. For codes using `dolfinx.fem.petsc.LinearProblem`, you can supply `jit_options` as a keyword argument."
51
+
"Next we generate a general function to assemble the mass matrix for a unit cube. Note that we use `dolfinx.fem.form` to compile the variational form.\n",
52
+
"For codes using `dolfinx.fem.petsc.LinearProblem`, you can supply `jit_options` as a keyword argument."
"We have now stored all the results to a dictionary. To visualize it, we use pandas and its Dataframe class. We can inspect the data in a jupyter notebook as follows"
155
+
"We have now stored all the results to a dictionary. To visualize it, we use pandas and its Dataframe class.\n",
156
+
"To instpect the data in a Jupyter notebook, call the code below.\n",
157
+
"If you are running this code in a script, you can use `print(results_df)` instead."
154
158
]
155
159
},
156
160
{
@@ -169,7 +173,8 @@
169
173
"id": "12",
170
174
"metadata": {},
171
175
"source": [
172
-
"We can now make a plot for each element type to see the variation given the different compile options. We create a new colum for each element type and degree."
176
+
"Next, we inspect the impact of the compiler option on each type of finite element family.\n",
177
+
"To achieve this, we add an extra column to the dataframe, which combines the space and degree of the finite element."
173
178
]
174
179
},
175
180
{
@@ -195,7 +200,8 @@
195
200
"id": "14",
196
201
"metadata": {},
197
202
"source": [
198
-
"We observe that the compile time increases when increasing the degree of the function space, and that we get most speedup by using \"-O3\" or \"-Ofast\" combined with \"-march=native\"."
203
+
"We observe that the compile time increases when increasing the degree of the function space,\n",
204
+
"and that we get most speedup by using \"-O3\" or \"-Ofast\" combined with \"-march=native\"."
print(f"Directory to put C files in: {cache_dir}")
47
45
# -
48
46
49
-
# Next we generate a general function to assemble the mass matrix for a unit cube. Note that we use `dolfinx.fem.form` to compile the variational form. For codes using `dolfinx.fem.petsc.LinearProblem`, you can supply `jit_options` as a keyword argument.
47
+
# Next we generate a general function to assemble the mass matrix for a unit cube. Note that we use `dolfinx.fem.form` to compile the variational form.
48
+
# For codes using `dolfinx.fem.petsc.LinearProblem`, you can supply `jit_options` as a keyword argument.
# We have now stored all the results to a dictionary. To visualize it, we use pandas and its Dataframe class. We can inspect the data in a jupyter notebook as follows
99
+
# We have now stored all the results to a dictionary. To visualize it, we use pandas and its Dataframe class.
100
+
# To instpect the data in a Jupyter notebook, call the code below.
101
+
# If you are running this code in a script, you can use `print(results_df)` instead.
98
102
99
103
results_df=pd.DataFrame.from_dict(results)
100
104
results_df
101
105
102
-
# We can now make a plot for each element type to see the variation given the different compile options. We create a new colum for each element type and degree.
106
+
# Next, we inspect the impact of the compiler option on each type of finite element family.
107
+
# To achieve this, we add an extra column to the dataframe, which combines the space and degree of the finite element.
# We observe that the compile time increases when increasing the degree of the function space, and that we get most speedup by using "-O3" or "-Ofast" combined with "-march=native".
119
+
# We observe that the compile time increases when increasing the degree of the function space,
120
+
# and that we get most speedup by using "-O3" or "-Ofast" combined with "-march=native".
0 commit comments