|
19 | 19 | "source": [ |
20 | 20 | "# Linear elasticity\n", |
21 | 21 | "\n", |
22 | | - "*This work is adapted from the FEniCS tutorial: https://fenicsproject.org/pub/tutorial/html/._ftut1008.html#ftut:elast*\n", |
| 22 | + "*This work is adapted from an earlier FEniCS tutorial.*\n", |
23 | 23 | "\n", |
24 | 24 | "Having studied a few scalar-valued problems, we now move on to a vector-valued problem. The equations of linear elasticity. Here, we'll treat the isotropic case.\n", |
25 | 25 | "\n", |
|
75 | 75 | "outputs": [], |
76 | 76 | "source": [ |
77 | 77 | "from firedrake import *\n", |
| 78 | + "from firedrake.__future__ import interpolate\n", |
78 | 79 | "length = 1\n", |
79 | 80 | "width = 0.2\n", |
80 | 81 | "mesh = RectangleMesh(40, 20, length, width)" |
|
109 | 110 | "metadata": {}, |
110 | 111 | "outputs": [], |
111 | 112 | "source": [ |
112 | | - "bc = DirichletBC(V, Constant([0, 0]), 1)" |
| 113 | + "bc = DirichletBC(V, as_vector([0., 0.]), 1)" |
113 | 114 | ] |
114 | 115 | }, |
115 | 116 | { |
|
189 | 190 | "metadata": {}, |
190 | 191 | "outputs": [], |
191 | 192 | "source": [ |
192 | | - "displaced_coordinates = interpolate(SpatialCoordinate(mesh) + uh, V)\n", |
| 193 | + "displaced_coordinates = assemble(interpolate(SpatialCoordinate(mesh) + uh, V))\n", |
193 | 194 | "displaced_mesh = Mesh(displaced_coordinates)" |
194 | 195 | ] |
195 | 196 | }, |
|
263 | 264 | " lambda_ = Constant(0.25)\n", |
264 | 265 | " Id = Identity(mesh.geometric_dimension()) # 2x2 Identity tensor\n", |
265 | 266 | " \n", |
266 | | - " bc = DirichletBC(V, Constant([0, 0]), 1)\n", |
| 267 | + " bc = DirichletBC(V, as_vector([0., 0.]), 1)\n", |
267 | 268 | " u = TrialFunction(V)\n", |
268 | 269 | " v = TestFunction(V)\n", |
269 | 270 | " a = inner(sigma(u), epsilon(v))*dx\n", |
|
344 | 345 | "\n", |
345 | 346 | " def sigma(u):\n", |
346 | 347 | " return lambda_*div(u)*Id + 2*mu*epsilon(u) \n", |
347 | | - " bc = DirichletBC(V, Constant([0, 0]), 1)\n", |
| 348 | + " bc = DirichletBC(V, as_vector([0., 0.]), 1)\n", |
348 | 349 | " u = TrialFunction(V)\n", |
349 | 350 | " v = TestFunction(V)\n", |
350 | 351 | " a = inner(sigma(u), epsilon(v))*dx\n", |
|
355 | 356 | " b0 = Function(V)\n", |
356 | 357 | " b1 = Function(V)\n", |
357 | 358 | " b2 = Function(V)\n", |
358 | | - " b0.interpolate(Constant([1, 0]))\n", |
359 | | - " b1.interpolate(Constant([0, 1]))\n", |
| 359 | + " b0.interpolate(as_vector([1., 0.]))\n", |
| 360 | + " b1.interpolate(as_vector([0., 1.]))\n", |
360 | 361 | " b2.interpolate(as_vector([-y, x]))\n", |
361 | 362 | " nullmodes = VectorSpaceBasis([b0, b1, b2])\n", |
362 | 363 | " # Make sure they're orthonormal.\n", |
|
406 | 407 | } |
407 | 408 | ], |
408 | 409 | "metadata": { |
| 410 | + "kernelspec": { |
| 411 | + "display_name": "Python 3 (ipykernel)", |
| 412 | + "language": "python", |
| 413 | + "name": "python3" |
| 414 | + }, |
409 | 415 | "language_info": { |
410 | | - "name": "python" |
| 416 | + "codemirror_mode": { |
| 417 | + "name": "ipython", |
| 418 | + "version": 3 |
| 419 | + }, |
| 420 | + "file_extension": ".py", |
| 421 | + "mimetype": "text/x-python", |
| 422 | + "name": "python", |
| 423 | + "nbconvert_exporter": "python", |
| 424 | + "pygments_lexer": "ipython3", |
| 425 | + "version": "3.13.1" |
411 | 426 | } |
412 | 427 | }, |
413 | 428 | "nbformat": 4, |
|
0 commit comments