|
19 | 19 | "source": [ |
20 | 20 | "# Linear elasticity\n", |
21 | 21 | "\n", |
22 | | - "*This work is adapted from an earlier FEniCS tutorial.*\n", |
| 22 | + "*This work is adapted from a previous FEniCS tutorial no longer online*\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", |
26 | 26 | "For small deformations, the governing equation is:\n", |
27 | 27 | "\n", |
28 | 28 | "$$ -\\nabla \\cdot \\sigma = f \\text{ in } \\Omega, $$\n", |
29 | | - "with\n", |
30 | | - "$$ \\DeclareMathOperator{\\Tr}{Tr}\n", |
31 | | - "\\text{the stress tensor}\\quad \\sigma := \\lambda \\Tr(\\epsilon)\\mathbb{I} + 2\\mu\\epsilon\\\\\n", |
32 | | - "\\text{and the symmetric strain rate tensor}\\quad \\epsilon := \\frac{1}{2}\\left(\\nabla u + (\\nabla u)^T\\right), $$\n", |
| 29 | + "with the stress tensor:\n", |
| 30 | + "$$ \\sigma := \\lambda \\operatorname{Tr}(\\epsilon)\\mathbb{I} + 2\\mu\\epsilon$$\n", |
| 31 | + "and the symmetric strain rate tensor:\n", |
| 32 | + "$$\\epsilon := \\frac{1}{2}\\left(\\nabla u + (\\nabla u)^T\\right), $$\n", |
33 | 33 | "where $u$ is the unknown vector displacement field, and $\\mu$ and $\\lambda$ are the Lamè parameters.\n", |
34 | 34 | "\n", |
35 | 35 | "As before, the variational formulation consists of multiplying by a test function in some suitable finite element space, $v \\in V$, and integrating. Note that this time, the solution $u$, and hence the test space $V$ are *vector*-valued (so multiplication actually means taking the inner product).\n", |
|
75 | 75 | "outputs": [], |
76 | 76 | "source": [ |
77 | 77 | "from firedrake import *\n", |
78 | | - "from firedrake.__future__ import interpolate\n", |
79 | 78 | "length = 1\n", |
80 | 79 | "width = 0.2\n", |
81 | 80 | "mesh = RectangleMesh(40, 20, length, width)" |
|
110 | 109 | "metadata": {}, |
111 | 110 | "outputs": [], |
112 | 111 | "source": [ |
113 | | - "bc = DirichletBC(V, as_vector([0., 0.]), 1)" |
| 112 | + "bc = DirichletBC(V, Constant([0, 0]), 1)" |
114 | 113 | ] |
115 | 114 | }, |
116 | 115 | { |
|
241 | 240 | "source": [ |
242 | 241 | "# Solving bigger problems\n", |
243 | 242 | "\n", |
244 | | - "Up to now, we've only really solved quite small problems, and therefore haven't really had to worry about tuning the solver. As we increase the size of the problem we're solving, the direct solver approach will no longer be good enough. Firedrake uses [PETSc](http://www.mcs.anl.gov/petsc) to provide solvers, and uses PETSc solver parameters to control them.\n", |
| 243 | + "Up to now, we've only really solved quite small problems, and therefore haven't really had to worry about tuning the solver. As we increase the size of the problem we're solving, the direct solver approach will no longer be good enough. Firedrake uses [PETSc](http://petsc.org) to provide solvers, and uses PETSc solver parameters to control them.\n", |
245 | 244 | "\n", |
246 | 245 | "Let's dive straight in. We'll write a function that solves the same elasticity problem, but takes parameters for the number of cells in the mesh, as well as a dictionary of solver options." |
247 | 246 | ] |
|
264 | 263 | " lambda_ = Constant(0.25)\n", |
265 | 264 | " Id = Identity(mesh.geometric_dimension()) # 2x2 Identity tensor\n", |
266 | 265 | " \n", |
267 | | - " bc = DirichletBC(V, as_vector([0., 0.]), 1)\n", |
| 266 | + " bc = DirichletBC(V, Constant([0, 0]), 1)\n", |
268 | 267 | " u = TrialFunction(V)\n", |
269 | 268 | " v = TestFunction(V)\n", |
270 | 269 | " a = inner(sigma(u), epsilon(v))*dx\n", |
|
345 | 344 | "\n", |
346 | 345 | " def sigma(u):\n", |
347 | 346 | " return lambda_*div(u)*Id + 2*mu*epsilon(u) \n", |
348 | | - " bc = DirichletBC(V, as_vector([0., 0.]), 1)\n", |
| 347 | + " bc = DirichletBC(V, Constant([0, 0]), 1)\n", |
349 | 348 | " u = TrialFunction(V)\n", |
350 | 349 | " v = TestFunction(V)\n", |
351 | 350 | " a = inner(sigma(u), epsilon(v))*dx\n", |
|
356 | 355 | " b0 = Function(V)\n", |
357 | 356 | " b1 = Function(V)\n", |
358 | 357 | " b2 = Function(V)\n", |
359 | | - " b0.interpolate(as_vector([1., 0.]))\n", |
360 | | - " b1.interpolate(as_vector([0., 1.]))\n", |
| 358 | + " b0.interpolate(Constant([1, 0]))\n", |
| 359 | + " b1.interpolate(Constant([0, 1]))\n", |
361 | 360 | " b2.interpolate(as_vector([-y, x]))\n", |
362 | 361 | " nullmodes = VectorSpaceBasis([b0, b1, b2])\n", |
363 | 362 | " # Make sure they're orthonormal.\n", |
|
422 | 421 | "name": "python", |
423 | 422 | "nbconvert_exporter": "python", |
424 | 423 | "pygments_lexer": "ipython3", |
425 | | - "version": "3.13.1" |
| 424 | + "version": "3.12.10" |
426 | 425 | } |
427 | 426 | }, |
428 | 427 | "nbformat": 4, |
|
0 commit comments