Neuton Regular - Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/neuton-fontfacekit/stylesheet.css:
--------------------------------------------------------------------------------
1 | /* Generated by Font Squirrel (http://www.fontsquirrel.com) on June 12, 2011 05:33:46 AM America/New_York */
2 |
3 |
4 |
5 | @font-face {
6 | font-family: 'NeutonRegular';
7 | src: url('Neuton-webfont.eot');
8 | src: url('Neuton-webfont.eot?#iefix') format('embedded-opentype'),
9 | url('Neuton-webfont.woff') format('woff'),
10 | url('Neuton-webfont.ttf') format('truetype'),
11 | url('Neuton-webfont.svg#NeutonRegular') format('svg');
12 | font-weight: normal;
13 | font-style: normal;
14 |
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile-webfont.eot
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile-webfont.ttf
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile-webfont.woff
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile_bold-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile_bold-webfont.eot
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile_bold-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile_bold-webfont.ttf
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile_bold-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile_bold-webfont.woff
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile_bold_italic-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile_bold_italic-webfont.eot
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile_bold_italic-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile_bold_italic-webfont.ttf
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile_bold_italic-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile_bold_italic-webfont.woff
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile_italic-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile_italic-webfont.eot
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile_italic-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile_italic-webfont.ttf
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile_italic-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/nobile_italic-webfont.woff
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/nobile-fontfacekit/stylesheet.css:
--------------------------------------------------------------------------------
1 | /* Generated by Font Squirrel (http://www.fontsquirrel.com) on June 12, 2011 05:30:25 AM America/New_York */
2 |
3 |
4 |
5 | @font-face {
6 | font-family: 'NobileRegular';
7 | src: url('nobile-webfont.eot');
8 | src: url('nobile-webfont.eot?#iefix') format('embedded-opentype'),
9 | url('nobile-webfont.woff') format('woff'),
10 | url('nobile-webfont.ttf') format('truetype'),
11 | url('nobile-webfont.svg#NobileRegular') format('svg');
12 | font-weight: normal;
13 | font-style: normal;
14 |
15 | }
16 |
17 | @font-face {
18 | font-family: 'NobileItalic';
19 | src: url('nobile_italic-webfont.eot');
20 | src: url('nobile_italic-webfont.eot?#iefix') format('embedded-opentype'),
21 | url('nobile_italic-webfont.woff') format('woff'),
22 | url('nobile_italic-webfont.ttf') format('truetype'),
23 | url('nobile_italic-webfont.svg#NobileItalic') format('svg');
24 | font-weight: normal;
25 | font-style: normal;
26 |
27 | }
28 |
29 | @font-face {
30 | font-family: 'NobileBold';
31 | src: url('nobile_bold-webfont.eot');
32 | src: url('nobile_bold-webfont.eot?#iefix') format('embedded-opentype'),
33 | url('nobile_bold-webfont.woff') format('woff'),
34 | url('nobile_bold-webfont.ttf') format('truetype'),
35 | url('nobile_bold-webfont.svg#NobileBold') format('svg');
36 | font-weight: normal;
37 | font-style: normal;
38 |
39 | }
40 |
41 | @font-face {
42 | font-family: 'NobileBoldItalic';
43 | src: url('nobile_bold_italic-webfont.eot');
44 | src: url('nobile_bold_italic-webfont.eot?#iefix') format('embedded-opentype'),
45 | url('nobile_bold_italic-webfont.woff') format('woff'),
46 | url('nobile_bold_italic-webfont.ttf') format('truetype'),
47 | url('nobile_bold_italic-webfont.svg#NobileBoldItalic') format('svg');
48 | font-weight: normal;
49 | font-style: normal;
50 |
51 | }
52 |
53 |
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/plus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/_static/plus.png
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/sample-news-image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/_static/sample-news-image.png
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/transparent.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/_static/transparent.gif
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/unknown.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/_static/unknown.png
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/up-pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/_static/up-pressed.png
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/_static/up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/_static/up.png
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/cbc.rans-MekIT11.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/cbc.rans-MekIT11.pdf
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys-sphinx/objects.inv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys-sphinx/objects.inv
--------------------------------------------------------------------------------
/.sandbox/cbcpdesys/pdesys_latex2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/cbcpdesys/pdesys_latex2.pdf
--------------------------------------------------------------------------------
/.sandbox/da.py:
--------------------------------------------------------------------------------
1 | """
2 | Solve a Poisson equation and its adjoint.
3 | """
4 |
5 | from dolfin import *
6 |
7 | # Create mesh and define function space
8 | mesh = UnitSquareMesh(6, 6)
9 | V = FunctionSpace(mesh, 'Lagrange', 1)
10 |
11 | # Define boundary conditions
12 | bc = DirichletBC(V, 0, "on_boundary")
13 |
14 | nu = 1
15 |
16 | # Define variational problem
17 | u = TrialFunction(V)
18 | v = TestFunction(V)
19 | f = Constant(-6)
20 | a = nu*inner(nabla_grad(u), nabla_grad(v))*dx
21 | L = f*v*dx
22 |
23 | # Compute solution
24 | u = Function(V)
25 | solve(a == L, u, bc)
26 |
27 | # Compute adjoint solution (when the adjoint PDE is derived by hand)
28 | lambda_ = TrialFunction(V)
29 | a = nu*inner(nabla_grad(v), nabla_grad(lambda_))*dx
30 | u_d = Expression('sin(pi*x[0])')
31 | L = -(u - u_d)*v*dx
32 | lambda_ = Function(V)
33 | solve(a == L, lambda_, bc)
34 |
35 | # Plot solution and mesh
36 | plot(u, interactive=True)
37 | plot(mesh, interactive=True)
38 |
39 | # Dump solution to file in VTK format
40 | file = File('poisson.pvd')
41 | file << u
42 |
--------------------------------------------------------------------------------
/.sandbox/da2.py:
--------------------------------------------------------------------------------
1 | """
2 | Solve a Poisson equation and its adjoint.
3 | """
4 |
5 | from dolfin import *
6 | from dolfin_adjoint import *
7 |
8 | # Create mesh and define function space
9 | mesh = UnitSquareMesh(6, 6)
10 | V = FunctionSpace(mesh, 'Lagrange', 1)
11 |
12 | # Define boundary conditions
13 | bc = DirichletBC(V, 0.0, "on_boundary")
14 |
15 | # All parameters in dolfin-adjoint must be Constant or Function
16 | nu = Constant(1)
17 |
18 | # Define variational problem
19 | u = TrialFunction(V)
20 | v = TestFunction(V)
21 | f = Constant(1.0)
22 | f = interpolate(Constant(1.0), V) # Must be function for da to work
23 | a = nu*inner(nabla_grad(u), nabla_grad(v))*dx
24 | L = f*v*dx
25 |
26 | # Compute solution
27 | u = Function(V)
28 | solve(a == L, u, bc)
29 |
30 | # Compute adjoint solution
31 | u_d = Expression('sin(pi*x[0])')
32 | J = Functional(0.5*inner(u-u_d, u-u_d)*dx)
33 | m1 = SteadyParameter(f)
34 | m2 = ScalarParameter(nu)
35 | dJdm = compute_gradient(J, [m1, m2], project=True)
36 | print type(dJdm), dJdm.__class__.__name__, dJdm[0].__class__.__name__, dJdm[1].__class__.__name__
37 |
38 | # Should compare with da.py
39 |
40 | # Plot solution and mesh
41 | plot(dJdm[0], interactive=True)
42 | print float(dJdm[1])
43 |
--------------------------------------------------------------------------------
/.sandbox/dolfinprm2datapool.py:
--------------------------------------------------------------------------------
1 | import sys, re
2 | from scitools.misc import str2obj, str2bool
3 |
4 | # NOTE: should first run the .h file through cpp with all the right
5 | # options to filter out all the right branches in #ifdef's!
6 |
7 | dolfin_addline_regex = re.compile(r'add\s*\("(.+?)"\s*,\s*(.+)\)\s*;')
8 | dolfin_heading_regex = re.compile(r'//\s*--+\s+(.+)\s+--+')
9 |
10 | def read_dolfin_prmfile(filename):
11 | f = open(filename, 'r')
12 | lines = f.readlines()
13 | f.close()
14 |
15 | menus = {}
16 | heading = None
17 | for line in lines:
18 | # check for heading (new submenu):
19 | m = dolfin_heading_regex.search(line)
20 | if m:
21 | heading = m.group(1)
22 | menus[heading] = []
23 | # check for parameter definition:
24 | m = dolfin_addline_regex.search(line)
25 | if m:
26 | if not heading:
27 | print 'No heading before "add" call - error'
28 | sys.exit(1)
29 | name = m.group(1).strip()
30 | value = m.group(2).strip()
31 | if value[0] == '"' and value[-1] == '"': # C++ string, strip ""
32 | value = value[1:-1]
33 | #if value == 'true': value = True
34 | #if value == 'false': value = False
35 | # find out if value is float or int or string?
36 | value = str2obj(value)
37 | if isinstance(value, float):
38 | s2t = float
39 | elif isinstance(value, bool):
40 | s2t = str2bool
41 | elif isinstance(value, int):
42 | s2t = int
43 | elif isinstance(value, basestring):
44 | s2t = str
45 | menus[heading].append((name, value, s2t))
46 | return menus
47 |
48 | import pprint
49 | pprint.pprint(read_dolfin_prmfile(sys.argv[1]))
50 |
--------------------------------------------------------------------------------
/.sandbox/domain_hollow_circle.py:
--------------------------------------------------------------------------------
1 | """Transform rectangular mesh to a hollow circle."""
2 | from dolfin import *
3 | import numpy
4 |
5 | # Hollow circle, Theta radians,
6 | # with inner radius a and outer radius b
7 | Theta = pi/2
8 | a, b = 1, 5.0
9 | nr = 10 # divisions in r direction
10 | nt = 20 # divisions in theta direction
11 | mesh = Rectangle(a, 0, b, 1, nr, nt, 'crossed')
12 |
13 | # First make a denser mesh towards r=a
14 | x = mesh.coordinates()[:,0]
15 | y = mesh.coordinates()[:,1]
16 | s = 1.3
17 |
18 | def denser(x, y):
19 | return [a + (b-a)*((x-a)/(b-a))**s, y]
20 |
21 | x_bar, y_bar = denser(x, y)
22 | xy_bar_coor = numpy.array([x_bar, y_bar]).transpose()
23 | mesh.coordinates()[:] = xy_bar_coor
24 | plot(mesh, title='stretched mesh')
25 |
26 | def cylinder(r, s):
27 | return [r*numpy.cos(Theta*s), r*numpy.sin(Theta*s)]
28 |
29 | x_hat, y_hat = cylinder(x_bar, y_bar)
30 | xy_hat_coor = numpy.array([x_hat, y_hat]).transpose()
31 | mesh.coordinates()[:] = xy_hat_coor
32 | plot(mesh, title='hollow cylinder')
33 | interactive()
34 |
35 |
--------------------------------------------------------------------------------
/.sandbox/domain_types.py:
--------------------------------------------------------------------------------
1 | """Demonstrate mesh generating objects in DOLFIN."""
2 |
3 | from dolfin import *
4 |
5 | mesh = UnitInterval(20)
6 | mesh = Interval(20, -1, 1) # domain [-1,1]
7 | print mesh
8 |
9 | mesh = UnitSquare(6, 10) # 'right' diagonal is default
10 | viz = plot(mesh, title='UnitSquare(6, 10)')
11 | #print 'Add labels:'
12 | #viz.add_point_labels()
13 | #viz.update(mesh)
14 | # The third argument governs directions of diagonals:
15 | mesh = UnitSquare(6, 10, 'left')
16 | plot(mesh, title='UnitSquare(6, 10, "left")')
17 | mesh = UnitSquare(6, 10, 'crossed')
18 | plot(mesh, title='UnitSquare(6, 10, "crossed")')
19 |
20 | print mesh
21 |
22 | # Domain [0,3]x[0,2] with 6x10 divisions and left diagonals
23 | mesh = Rectangle(0, 0, 3, 2, 6, 10, 'left')
24 | plot(mesh, title='Rectangle(0, 0, 3, 2, 6, 10, "left")')
25 | print mesh
26 |
27 | # 6x10x5 boxes in the unit cube, each box gets 6 tetrahedra:
28 | mesh = UnitCube(6, 10, 5)
29 | plot(mesh, title='UnitCube')
30 | print mesh
31 |
32 | # Domain [-1,1]x[-1,0]x[-1,2] with 6x10x5 divisions
33 | mesh = Box(-1, -1, -1, 1, 0, 2, 6, 10, 5)
34 | plot(mesh, title='Box(-1, -1, -1, 1, 0, 2, 6, 10, 5)')
35 | print mesh
36 |
37 | # 10 divisions in radial directions
38 | mesh = UnitCircle(10, 'crossed', 'maxn')
39 | plot(mesh, title='UnitCircle(10, "crossed", "maxn")')
40 | mesh = UnitCircle(10, 'right', 'maxn')
41 | plot(mesh, title='UnitCircle(10, "right", "maxn")')
42 | mesh = UnitCircle(10)
43 | plot(mesh, title='UnitCircle(10)')
44 | print mesh
45 |
46 | mesh = UnitSphere(10) # 10 divisions in radial directions
47 | plot(mesh, title='UnitSphere(10)')
48 | print mesh
49 |
50 |
51 | interactive()
52 |
--------------------------------------------------------------------------------
/.sandbox/extra/Kent_demo_subdomains.py:
--------------------------------------------------------------------------------
1 |
2 | from dolfin import *
3 | import numpy
4 |
5 | class DirichletBoundary(SubDomain):
6 | def inside(self, x, on_boundary):
7 | return on_boundary
8 |
9 | class InnerStuff(SubDomain):
10 | def inside(self, x, on_boundary):
11 | if x[0]**2 + x[1]**2 < 0.1:
12 | return True
13 | return False
14 |
15 | mesh = Mesh("circle.xml.gz")
16 |
17 | W = FunctionSpace(mesh, "CG", 1)
18 | V = VectorFunctionSpace(mesh, "CG", 1)
19 | u = TrialFunction(V)
20 | v = TestFunction(V)
21 |
22 | bc_func = Function(V, ("0.01*x[0] + 0.01*x[1]", "0.01*x[1]" ))
23 | bc = DirichletBC(V, bc_func, DirichletBoundary())
24 |
25 | subdomains = MeshFunction("uint", mesh, 0)
26 |
27 | innerstuff = InnerStuff()
28 | innerstuff.mark(subdomains, 1)
29 |
30 | #plot(subdomains)
31 |
32 | coeff_values = numpy.zeros(len(subdomains.values()))
33 | for i in range(len(subdomains.values())):
34 | val = subdomains.values()[i]
35 | print val
36 | if val == 1:
37 | coeff_values[i] = 1.0
38 | else:
39 | coeff_values[i] = 0.001
40 |
41 | coeff = Function(W)
42 | coeff.vector().set(coeff_values)
43 |
44 | plot(coeff)
45 | interactive()
46 |
47 |
48 | for i in range(0, 20):
49 |
50 | f = Function(V, ("0.0", "0.0" ))
51 |
52 | a = coeff*dot(grad(v), grad(u))*dx
53 | L = dot(v,f)*dx
54 |
55 | # Compute solution
56 | problem = VariationalProblem(a, L, bc)
57 | U = problem.solve()
58 |
59 | # Plot solution
60 | # plot(U)
61 |
62 | mesh.move(U)
63 | plot(mesh)
64 |
65 |
66 | interactive()
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/.sandbox/extra/demo.py:
--------------------------------------------------------------------------------
1 | """This demo program solves Poisson's equation
2 |
3 | - div grad u(x, y) = f(x, y)
4 |
5 | on the unit square with source f given by
6 |
7 | f(x, y) = 500*exp(-((x-0.5)^2 + (y-0.5)^2)/0.02)
8 |
9 | and boundary conditions given by
10 |
11 | u(x, y) = 0
12 | du/dn(x, y) = 0
13 |
14 | using a discontinuous Galerkin formulation (interior penalty method).
15 | """
16 |
17 | __author__ = "Kristian B. Oelgaard (k.b.oelgaard@tudelft.nl)"
18 | __date__ = "2007-10-02 -- 2008-12-19"
19 | __copyright__ = "Copyright (C) 2007 Kristian B. Oelgaard"
20 | __license__ = "GNU LGPL Version 2.1"
21 |
22 | # Modified by Anders Logg, 2008.
23 |
24 | from dolfin import *
25 |
26 | # Create mesh and define function space
27 | mesh = UnitSquare(24, 24)
28 | V = FunctionSpace(mesh, "DG", 1)
29 |
30 | # Define test and trial functions
31 | u = TrialFunction(V)
32 | v = TestFunction(V)
33 |
34 | # Define normal component, mesh size and right-hand side
35 | n = FacetNormal(mesh)
36 | h = CellSize(mesh)
37 | h_avg = (h('+') + h('-'))/2
38 | f = Expression("500.0*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)", V = V)
39 |
40 | # Define parameters
41 | alpha = 4.0
42 | gamma = 8.0
43 |
44 | # Define bilinear form
45 | a = dot(grad(v), grad(u))*dx \
46 | - dot(avg(grad(v)), jump(u, n))*dS \
47 | - dot(jump(v, n), avg(grad(u)))*dS \
48 | + alpha/h_avg*dot(jump(v, n), jump(u, n))*dS \
49 | - dot(grad(v), u*n)*ds \
50 | - dot(v*n, grad(u))*ds \
51 | + gamma/h*v*u*ds
52 |
53 | # Define linear form
54 | L = v*f*dx
55 |
56 | # Compute solution
57 | problem = VariationalProblem(a, L)
58 | u = problem.solve()
59 |
60 | # Project solution to piecewise linears
61 | P1 = FunctionSpace(mesh, "CG", 1)
62 | u_proj = project(u, P1)
63 |
64 | # Save solution to file
65 | file = File("poisson.pvd")
66 | file << u_proj
67 |
68 | # Plot solution
69 | plot(u_proj, interactive=True)
70 |
71 |
--------------------------------------------------------------------------------
/.sandbox/extra/dolfin_failed_trick.py:
--------------------------------------------------------------------------------
1 | # wrapper for with extensions to dolfin...
2 | import sys, os
3 | # make sure official dolfin is loaded before the present dolfin.py
4 | # module in os.curdir:
5 | print sys.prefix
6 | print sys.version
7 | dolfin_dir = os.path.join(sys.prefix, 'lib', 'python' + sys.version[:3],
8 | 'dist-packages')
9 | print dolfin_dir
10 | del sys.path[0]
11 | sys.path.insert(0, dolfin_dir)
12 | import pprint; pprint.pprint(sys.path)
13 | from dolfin import Mesh
14 |
15 | # add stuff here
16 | print dir()
17 |
18 |
--------------------------------------------------------------------------------
/.sandbox/extra/hpl2b.py:
--------------------------------------------------------------------------------
1 | """
2 | FEniCS tutorial demo program 2. -Laplace(u) = f, u = u0 on the boundary.
3 | u0 = u = 1 + x^2 + 2y^2, f = -6.
4 | """
5 |
6 | from dolfin import *
7 | import numpy
8 |
9 | # Create mesh and define function space
10 | mesh = UnitSquare(2, 1)
11 | V = FunctionSpace(mesh, 'CG', 1)
12 |
13 |
14 | # Define boundary conditions
15 | u0 = Function(V, '1 + x[0]*x[0] + 2*x[1]*x[1]')
16 |
17 | class Boundary(SubDomain): # define the Dirichlet boundary
18 | def inside(self, x, on_boundary):
19 | return on_boundary
20 |
21 | u0_boundary = Boundary()
22 | bc = DirichletBC(V, u0, u0_boundary)
23 |
24 | # Define variational problem
25 | u = TrialFunction(V)
26 | v = TestFunction(V)
27 | f = Function(V, '-6')
28 | a = dot(grad(v), grad(u))*dx
29 | L = v*f*dx
30 |
31 | # Assemble and solve linear system
32 | A = assemble(a)
33 | b = assemble(L)
34 | bc.apply(A, b)
35 | u = Function(V)
36 | solve(A, u.vector(), b)
37 |
38 |
39 | #plot(u)
40 | #interactive()
41 |
42 | print """
43 | Solution of the Poisson problem -Laplace(u) = f,
44 | with u = u0 on the boundary and a
45 | %s
46 | """ % mesh
47 |
48 | # Dump solution to the screen
49 | u_nodal_values = u.vector()
50 | u_array = u_nodal_values.array()
51 | coor = mesh.coordinates()
52 | for i in range(len(u_array)):
53 | print 'u(%8g,%8g) = %g' % (coor[i][0], coor[i][1], u_array[i])
54 |
55 |
56 | # Verification
57 | tolerance = 1E-14
58 | u0.interpolate()
59 | u0_array = u0.vector().array()
60 | ok = numpy.allclose(u_array, u0_array,
61 | rtol=tolerance, atol=tolerance)
62 | print 'Solution is', 'ok' if ok else 'not correct'
63 |
64 | # Compare numerical and exact solution at (0.5, 0.5)
65 | center_point = numpy.array((0.5, 0.5))
66 | u_value = numpy.zeros(1)
67 | u.eval(u_value, center_point)
68 | u0_value = numpy.zeros(1)
69 | u0.eval(u0_value, center_point)
70 | print 'numerical u at the center point:', u_value
71 | print 'exact u at the center point:', u0_value
72 |
73 |
74 |
--------------------------------------------------------------------------------
/.sandbox/extra/hpl5.py:
--------------------------------------------------------------------------------
1 | """
2 | ROBIN - does not work!!!!
3 |
4 | FEniCS tutorial demo program 1. -Laplace(u) = f on the unit square.
5 | u = u0 on x=0,
6 | u0 = u = 1 + x^2 + 2y^2,
7 | f = -6.
8 | """
9 |
10 | from dolfin import *
11 | import numpy
12 |
13 | # Create mesh and define function space
14 | mesh = UnitSquare(3, 3)
15 | V = FunctionSpace(mesh, 'CG', 1)
16 |
17 |
18 | # Define boundary conditions
19 | u0 = Function(V, '1 + x[0]*x[0] + 2*x[1]*x[1]')
20 |
21 | class DirichletBoundary(SubDomain):
22 | def inside(self, x, on_boundary):
23 | if on_boundary and x[0] == 0:
24 | return True
25 | else:
26 | return False
27 |
28 | u0_boundary = DirichletBoundary()
29 | bc = DirichletBC(V, u0, u0_boundary)
30 |
31 | # Define variational problem
32 | u = TrialFunction(V)
33 | v = TestFunction(V)
34 | f = Function(V, '-6')
35 | g = Function(V, '-4*x[1]')
36 | S = Function(V, 'x[1]*x[1]')
37 | p = -1
38 | a = dot(grad(v), grad(u))*dx + p*(u-S)*ds
39 | L = v*f*dx - v*g*ds
40 |
41 | # Compute solution
42 | problem = VariationalProblem(a, L, bc)
43 | u = problem.solve()
44 |
45 | #plot(u)
46 | #interactive()
47 |
48 | print """
49 | Solution of the Poisson problem -Laplace(u) = f,
50 | with u = u0 on the boundary and a
51 | %s
52 | """ % mesh
53 |
54 | # Dump solution to the screen
55 | u_nodal_values = u.vector()
56 | u_array = u_nodal_values.array()
57 | coor = mesh.coordinates()
58 | for i in range(len(u_array)):
59 | print 'u(%8g,%8g) = %g' % (coor[i][0], coor[i][1], u_array[i])
60 |
61 |
62 | # Verification
63 | tolerance = 1E-14
64 | u0.interpolate()
65 | u0_array = u0.vector().array()
66 | ok = numpy.allclose(u_array, u0_array,
67 | rtol=tolerance, atol=tolerance)
68 | print 'Solution is', 'ok' if ok else 'not correct'
69 |
70 | # Compare numerical and exact solution at (0.5, 0.5)
71 | center_point = numpy.array((0.5, 0.5))
72 | u_value = numpy.zeros(1)
73 | u.eval(u_value, center_point)
74 | u0_value = numpy.zeros(1)
75 | u0.eval(u0_value, center_point)
76 | print 'numerical u at the center point:', u_value
77 | print 'exact u at the center point:', u0_value
78 |
79 |
80 |
--------------------------------------------------------------------------------
/.sandbox/extra/hpl7.py:
--------------------------------------------------------------------------------
1 | """
2 | FEniCS tutorial demo program 1. -Laplace(u) = f on the unit square.
3 | u = u0 on x=0,
4 | u0 = u = 1 + x^2 + 2y^2,
5 | f = -6.
6 | """
7 |
8 | from dolfin import *
9 | import numpy
10 |
11 | # Create mesh and define function space
12 | mesh = UnitSquare(4, 4)
13 | V = FunctionSpace(mesh, 'CG', 1)
14 |
15 |
16 | # Define boundary conditions
17 | u0 = Function(V, '1 + x[0]*x[0] + 2*x[1]*x[1]')
18 |
19 | class DirichletBoundary(SubDomain):
20 | def inside(self, x, on_boundary):
21 | tol = 1E-14 # tolerance for coordinate comparisons
22 | return on_boundary
23 |
24 | u0_boundary = DirichletBoundary()
25 | bc = DirichletBC(V, u0, u0_boundary)
26 |
27 | # Define variational problem
28 | u = TrialFunction(V)
29 | v = TestFunction(V)
30 | p = Function(V, 'x[0] + x[1]')
31 | f = Function(V, '-8*x[0] - 10*x[1]')
32 | a = p*dot(grad(v), grad(u))*dx
33 | L = v*f*dx
34 |
35 | # Compute solution
36 | problem = VariationalProblem(a, L, bc)
37 | u = problem.solve()
38 |
39 | #plot(u)
40 | #interactive()
41 |
42 | print """
43 | Solution of the Poisson problem -Laplace(u) = f,
44 | with u = u0 on x=0,1 and -du/dn = g at y=0,1.
45 | %s
46 | """ % mesh
47 |
48 | # Dump solution to the screen
49 | u_nodal_values = u.vector()
50 | u_array = u_nodal_values.array()
51 | coor = mesh.coordinates()
52 | for i in range(len(u_array)):
53 | print 'u(%8g,%8g) = %g' % (coor[i][0], coor[i][1], u_array[i])
54 |
55 | # Verification
56 | tolerance = 1E-14
57 | u0.interpolate()
58 | u0_array = u0.vector().array()
59 | ok = numpy.allclose(u_array, u0_array,
60 | rtol=tolerance, atol=tolerance)
61 | print 'Solution is', 'ok' if ok else 'not correct'
62 |
63 | # Compare numerical and exact solution at (0.5, 0.5)
64 | center_point = numpy.array((0.5, 0.5))
65 | u_value = numpy.zeros(1)
66 | u.eval(u_value, center_point)
67 | u0_value = numpy.zeros(1)
68 | u0.eval(u0_value, center_point)
69 | print 'numerical u at the center point:', u_value
70 | print 'exact u at the center point:', u0_value
71 |
72 |
73 |
--------------------------------------------------------------------------------
/.sandbox/membrane2.py:
--------------------------------------------------------------------------------
1 | """
2 | FEniCS program for the deflection w(x,y) of a membrane:
3 | -Laplace(w) = p = Gaussian function, in a unit circle,
4 | with w = 0 on the boundary.
5 | As membrane1.py, but with computation of the energy (a
6 | quantity derived from the solution).
7 | """
8 |
9 | from dolfin import *
10 | import numpy
11 |
12 | # Set pressure function:
13 | T = 10.0 # tension
14 | A = 1.0 # pressure amplitude
15 | R = 0.3 # radius of domain
16 | theta = 0.2
17 | x0 = 0.6*R*cos(theta)
18 | y0 = 0.6*R*sin(theta)
19 | sigma = 0.025
20 | n = 40 # approx no of elements in radial direction
21 | mesh = UnitCircle(n)
22 | V = FunctionSpace(mesh, 'Lagrange', 1)
23 |
24 | # Define boundary condition w=0
25 |
26 | def boundary(x, on_boundary):
27 | return on_boundary
28 |
29 | bc = DirichletBC(V, Constant(0.0), boundary)
30 |
31 | # Define variational problem
32 | w = TrialFunction(V)
33 | v = TestFunction(V)
34 | a = inner(nabla_grad(w), nabla_grad(v))*dx
35 | f = Expression('4*exp(-0.5*(pow((R*x[0] - x0)/sigma, 2)) '
36 | ' - 0.5*(pow((R*x[1] - y0)/sigma, 2)))',
37 | R=R, x0=x0, y0=y0, sigma=sigma)
38 | L = f*v*dx
39 |
40 | # Compute solution
41 | w = Function(V)
42 | problem = LinearVariationalProblem(a, L, w, bc)
43 | solver = LinearVariationalSolver(problem)
44 | solver.parameters['linear_solver'] = 'cg'
45 | solver.parameters['preconditioner'] = 'ilu'
46 | solver.solve()
47 |
48 | # Plot solution and mesh
49 | plot(mesh, title='Mesh over scaled domain')
50 | plot(w, title='Scaled deflection')
51 | p = interpolate(f, V)
52 | plot(p, title='Scaled pressure')
53 |
54 | # Find maximum real deflection
55 | max_w = w.vector().array().max()
56 | max_D = A*max_w/(8*pi*sigma*T)
57 | print 'Maximum real deflection is', max_D
58 |
59 | # Compute elastic energy: integral of T*abs(grad(w))^2
60 | E_functional = 0.5*(A*R/(8*pi*sigma))**2*inner(nabla_grad(w), nabla_grad(w))*dx
61 | E = assemble(E_functional)
62 | #E = assemble(E_functional, mesh=mesh)
63 | print 'Elastic energy:', E
64 |
65 | # Should be at the end
66 | #interactive()
67 |
--------------------------------------------------------------------------------
/.sandbox/membrane2_experiment.py:
--------------------------------------------------------------------------------
1 | from membrane2_class import Problem, Viz
2 |
3 | for sigma in 0.1, 1, 10:
4 | for A in 1, 100, 1000:
5 | print '\n\n ****************** sigma:', sigma
6 | dir = 'case-%g' % sigma
7 | os.mkdir(dir)
8 | os.chdir(dir)
9 | problem = Problem(sigma=sigma)
10 | problem.solve()
11 | visualizer = Viz(problem)
12 | visualizer.batch_viz()
13 | os.chdir(os.pardir)
14 |
15 |
--------------------------------------------------------------------------------
/.sandbox/nonlin_solver.py:
--------------------------------------------------------------------------------
1 | """Rough code from Mikael. Develop this to a general class
2 | that can take a form (func or class) and run Newton or Picard
3 | on it. A first step toward pdesys. The nonline class has all
4 | necessary parameters in a parameters dict.
5 | """
6 |
7 |
8 | import sys
9 | from dolfin import *
10 | mesh=UnitSquare(10, 10)
11 | V = FunctionSpace(mesh, 'CG', 1)
12 | u = TrialFunction(V)
13 | v = TestFunction(V)
14 | u_ = Function(V)
15 | bc = DirichletBC(V, Constant(0.), DomainBoundary())
16 | x = u_.vector()
17 | bc.apply(x)
18 | omega = 1.
19 | error = 1.
20 |
21 | method = sys.argv[-1]
22 |
23 | def form(u, v, u_, **kwargs):
24 | return (1.-u_)*inner(grad(u), grad(v))*dx + Constant(1.)*v*dx
25 |
26 | if method == 'Newton':
27 | u_old = u
28 | u = u_
29 | F_ = form(**vars())
30 | u = u_old
31 | J = derivative(F_, u_, u)
32 | a, L = J, -F_
33 | dx = Vector(x)
34 | i = 0
35 | while error > 1e-8:
36 | A = assemble(a)
37 | b = assemble(L)
38 | bc.apply(A, b, x)
39 | solve(A, dx, b)
40 | x.axpy(omega, dx)
41 | error = norm(dx)
42 | i+=1
43 | print i, 'error = ', error
44 |
45 | elif method == 'Picard':
46 | F = form(**vars())
47 | a, L = lhs(F), rhs(F)
48 | x_star = Vector(x)
49 | i = 0
50 | while error > 1e-8:
51 | A = assemble(a)
52 | b = assemble(L)
53 | bc.apply(A, b)
54 | x_star[:] = x[:]
55 | solve(A, x_star, b)
56 | # x = (1-omega)*x + omega*x_star = x + omega*(x_star-x):
57 | x_star.axpy(-1., x); x.axpy(omega, x_star)
58 | error = norm(x_star)
59 | i+=1
60 | print i, 'error = ', error
61 |
62 | plot(u_)
63 |
--------------------------------------------------------------------------------
/.sandbox/sin__class_daD.py:
--------------------------------------------------------------------------------
1 | """
2 | Temperature variations in the ground.
3 | Class version of diffusion123D_sin.py.
4 | NOTE: go on with class Problem, but use the rest of the code
5 | from the newer sin_daD.py.
6 | """
7 |
8 | class Problem:
9 | def __init__(self):
10 | """Set default values of problem parameters."""
11 | self.d = 2
12 | self.degree = 1
13 | self.physics = dict(T_R = 0, T_A=0, omega=7.27E-5)
14 | self.numerics = dict(num_steps_per_period=14, num_periods=5)
15 |
16 | def update(self):
17 | """Update problem parameters that depend on others."""
18 | omega = self.physics['omega']
19 | period = 2*pi/omega
20 | self.numerics['dt'] = period/self.numerics['num_steps_per_period']
21 | self.numerics['tstop'] = period*self.numerics['num_periods']
22 |
23 | def T_0(self):
24 | return Expression(
25 | 'T_R + T_A*sin(omega*t)',
26 | 'T_R': self.physics['T_R'],
27 | 'T_A': self.physics['T_A'],
28 | 'omega': self.physics['omega'])
29 |
30 | def exact_solution(self, x, t):
31 | pass
32 |
33 | [[[[ not ready
34 |
--------------------------------------------------------------------------------
/.sandbox/test1.py:
--------------------------------------------------------------------------------
1 | from dolfin import *
2 | import numpy
3 |
4 | mesh2D = UnitSquare(5, 4)
5 | V2D = FunctionSpace(mesh2D, 'Lagrange', 1)
6 |
7 | mesh1D = UnitInterval(4)
8 | V1D = FunctionSpace(mesh1D, 'Lagrange', 1)
9 |
10 | v_formula = Expression('4*x[0]*(1 - x[0])')
11 |
12 | v1D = project(v_formula, V1D)
13 | print 'v1D:', v1D.vector().array()
14 |
15 | # How to let v be a function of y and populate a Function u in V2D?
16 | # (channel flow)
17 |
18 | class v_interpolate2D(Expression):
19 | def eval(self, value, x):
20 | assert len(x) == 2
21 | point = [x[1]]
22 | value[0] = self.v(point)
23 |
24 | v2D_extension = v_interpolate2D()
25 | v2D_extension.v = v1D
26 |
27 | u = project(v2D_extension, V2D)
28 | print 'u:', u.vector().array()
29 |
30 |
--------------------------------------------------------------------------------
/.sandbox/triangle/2DO:
--------------------------------------------------------------------------------
1 | Try new github version of meshpy:
2 | https://github.com/inducer/meshpy
3 |
4 | See also
5 | https://answers.launchpad.net/dolfin/+question/225893
6 |
--------------------------------------------------------------------------------
/.sandbox/triangle/plotmesh.py:
--------------------------------------------------------------------------------
1 | from prepro2D import load_triangle_mesh, plot_mesh
2 | coordinates, connectivity, materials = load_triangle_mesh('tmp', '1')
3 | plot_mesh(coordinates, connectivity, materials)
4 |
--------------------------------------------------------------------------------
/.sandbox/triangle/triangle.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/.sandbox/triangle/triangle.zip
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | The FEniCS Tutorial
2 | ===================
3 |
4 | By Hans Petter Langtangen and Anders Logg
5 |
6 | This repository contains all source files, published documents, and
7 | example programs for the FEniCS Tutorial.
8 |
9 | * `pub`: Published versions of all documents (book, online version, programs)
10 | * `src`: Sources for all documents (book, online version, programs)
11 | * `review`: Referee reports from Springer
12 | * `chinese`: Chinese version (does not use Doconce)
13 |
--------------------------------------------------------------------------------
/chinese/Makefile:
--------------------------------------------------------------------------------
1 | BOOK=fenics-tutorial-chinese
2 |
3 | all:
4 | xelatex $(BOOK)
5 |
6 | final:
7 | xelatex $(BOOK)
8 | biber $(BOOK)
9 | makeindex $(BOOK)
10 | xelatex $(BOOK)
11 | xelatex $(BOOK)
12 |
13 | clean:
14 | rm -f *.aux *.mtc* *.out *.idx *.bcf *.log *~ *.ptc *.toc *.run.xml *.maf
15 |
--------------------------------------------------------------------------------
/chinese/README.md:
--------------------------------------------------------------------------------
1 | This directory contains the Chinese edition of the book (volume I).
2 | Note that this version does not use Doconce bus instead manually
3 | translated from the generated LaTeX sources.
4 |
5 | To build the book, type `make`.
6 |
--------------------------------------------------------------------------------
/chinese/chapters/preface.tex:
--------------------------------------------------------------------------------
1 | \chapter*{前言}
2 | \addcontentsline{toc}{chapter}{前言}
3 |
4 | 本书简要介绍了有限元素
5 | 基于流行的FEniCS软件库在Python中进行编程。
6 | FEniCS可以在C++和Python中编程,但本教程
7 | 专注于Python编程,因为这是最简单的
8 | 并为初学者提供最有效的方法。 消化过后
9 | 本教程中的示例,读者应该能够了解更多
10 | 从FEniCS文档中可以看到众多演示程序
11 | 与软件和综合FEniCS书 \emph{Automated
12 | Solution of Differential Equations by the Finite Element Method}
13 | \cite{FEniCS}。 本教程是开幕式的进一步发展
14 | \cite{FEniCS}中的章节。
15 |
16 | 我们感谢Johan Hake,Kent-Andre Mardal和Kristian Valen-Sendstad
17 | 在准备第一个时候进行许多有益的讨论
18 | 本教程的版本为FEniCS书\cite{FEniCS}。 我们是
19 | 特别感谢Douglas Arnold非常有价值
20 | 对文本早期版本的反馈。 Øystein Sørensen指出
21 | 许多打字错误,并提供了许多有用的意见。 许多错误
22 | 还有Mauricio Angeles,IdaDrøsdal,
23 | Miroslav Kuchta,Hans Ekkehard Plesser,Marie Rognes,Hans Joachim
24 | Scroll,Glenn Terje Lines,Simon Funke,Matthew Moelter和Magne
25 | Nordaas。 Ekkehard Ellmann以及两位匿名评审员
26 | 一系列建议和改进。 特别感谢
27 | Benjamin Kehlet为他所有的工作与\texttt{mshr}工具和快速
28 | 实施我们对本教程的要求。
29 |
30 | 注释和更正可以报告为本书Git存储库的\ emph {issue}:
31 | \begin{center}
32 | \url{https://github.com/hplgit/fenics-tutorial}
33 | \end{center}
34 |
35 | \vspace{1cm}
36 |
37 | \noindent
38 | {\it Oslo and Smögen, November 2016} \hfill {\it Hans Petter Langtangen, Anders Logg}
39 |
--------------------------------------------------------------------------------
/chinese/cover/cover.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/cover/cover.jpg
--------------------------------------------------------------------------------
/chinese/cover/cover.xcf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/cover/cover.xcf
--------------------------------------------------------------------------------
/chinese/fenics-tutorial-chinese.tex:
--------------------------------------------------------------------------------
1 | \documentclass{tstextbook}
2 |
3 | \begin{document}
4 |
5 | \tsbook{在Python中解决PDE \\
6 | FEniCS教程}
7 | {Hans Petter Langtangen \& Anders Logg}
8 | {}
9 | {2017}
10 | {xxxxx}{xxx--xx--xxxx--xx--x}{0.0}
11 | {Chinese translation by Jiping Xin}
12 | {Wuxi, China}
13 |
14 | \input{newcommands}
15 |
16 | %---------------------------------------------------------------------------
17 | % Chapters
18 | %---------------------------------------------------------------------------
19 |
20 | \input{chapters/preface}
21 | \input{chapters/chapter1}
22 | \input{chapters/chapter2}
23 | \input{chapters/chapter3}
24 | \input{chapters/chapter4}
25 | \input{chapters/chapter5}
26 |
27 | %---------------------------------------------------------------------------
28 | % Bibliography
29 | %---------------------------------------------------------------------------
30 |
31 | \addcontentsline{toc}{chapter}{\textcolor{tssteelblue}{参考书目}}
32 | \printbibliography[title=参考书目]{}
33 |
34 | %---------------------------------------------------------------------------
35 | % Index
36 | %---------------------------------------------------------------------------
37 |
38 | \printindex
39 |
40 | \end{document}
41 |
--------------------------------------------------------------------------------
/chinese/fig/elasticity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/elasticity.png
--------------------------------------------------------------------------------
/chinese/fig/heat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/heat.png
--------------------------------------------------------------------------------
/chinese/fig/magnetostatics_field.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/magnetostatics_field.png
--------------------------------------------------------------------------------
/chinese/fig/magnetostatics_geometry.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/magnetostatics_geometry.pdf
--------------------------------------------------------------------------------
/chinese/fig/magnetostatics_geometry.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/magnetostatics_geometry.png
--------------------------------------------------------------------------------
/chinese/fig/magnetostatics_mesh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/magnetostatics_mesh.png
--------------------------------------------------------------------------------
/chinese/fig/magnetostatics_potential.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/magnetostatics_potential.png
--------------------------------------------------------------------------------
/chinese/fig/navier_stokes_channel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/navier_stokes_channel.png
--------------------------------------------------------------------------------
/chinese/fig/navier_stokes_cylinder_geometry.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/navier_stokes_cylinder_geometry.pdf
--------------------------------------------------------------------------------
/chinese/fig/navier_stokes_cylinder_geometry.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/navier_stokes_cylinder_geometry.png
--------------------------------------------------------------------------------
/chinese/fig/navier_stokes_cylinder_pressure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/navier_stokes_cylinder_pressure.png
--------------------------------------------------------------------------------
/chinese/fig/navier_stokes_cylinder_velocity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/navier_stokes_cylinder_velocity.png
--------------------------------------------------------------------------------
/chinese/fig/poisson_extended.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/poisson_extended.pdf
--------------------------------------------------------------------------------
/chinese/fig/poisson_extended.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/poisson_extended.png
--------------------------------------------------------------------------------
/chinese/fig/poisson_membrane_curves.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/poisson_membrane_curves.png
--------------------------------------------------------------------------------
/chinese/fig/poisson_membrane_deflection_load.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/poisson_membrane_deflection_load.png
--------------------------------------------------------------------------------
/chinese/fig/poisson_paraview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/poisson_paraview.png
--------------------------------------------------------------------------------
/chinese/fig/poisson_plot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/poisson_plot.png
--------------------------------------------------------------------------------
/chinese/fig/reaction_system.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/reaction_system.png
--------------------------------------------------------------------------------
/chinese/fig/subdomains.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/subdomains.pdf
--------------------------------------------------------------------------------
/chinese/fig/subdomains.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/subdomains.png
--------------------------------------------------------------------------------
/chinese/fig/vertex_numbering.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/fig/vertex_numbering.png
--------------------------------------------------------------------------------
/chinese/images/background.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/images/background.jpg
--------------------------------------------------------------------------------
/chinese/images/cover.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/images/cover.jpg
--------------------------------------------------------------------------------
/chinese/images/idea.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/images/idea.pdf
--------------------------------------------------------------------------------
/chinese/images/image-info:
--------------------------------------------------------------------------------
1 | The background picture with clouds were aquired from:
2 | https://pixabay.com/en/lake-water-brightness-reflection-430508/
3 |
4 | Free for commercial use
5 | No attribution required
6 |
7 | Free download
8 |
--------------------------------------------------------------------------------
/chinese/input/README.md:
--------------------------------------------------------------------------------
1 | This file contains the original version of the Tutorial (2017-06-01)
2 | as well as a modified version used as basis for the Chinese translation.
3 |
--------------------------------------------------------------------------------
/chinese/input/fenics-tutorial-vol1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/chinese/input/fenics-tutorial-vol1.pdf
--------------------------------------------------------------------------------
/pub/README.md:
--------------------------------------------------------------------------------
1 | This directory contains the generated FEniCS Tutorial in various formats.
2 |
--------------------------------------------------------------------------------
/pub/html/README.md:
--------------------------------------------------------------------------------
1 | This directory contains the generated FEniCS Tutorial in HTML format.
2 |
--------------------------------------------------------------------------------
/pub/pdf/README.md:
--------------------------------------------------------------------------------
1 | This directory contains the generated FEniCS Tutorial in PDF format.
2 |
--------------------------------------------------------------------------------
/pub/python/vol1/README.md:
--------------------------------------------------------------------------------
1 | This directory contains the example programs generated from the FEniCS Tutorial Vol 1.
2 |
--------------------------------------------------------------------------------
/pub/python/vol1/ft01_poisson.py:
--------------------------------------------------------------------------------
1 | """
2 | FEniCS tutorial demo program: Poisson equation with Dirichlet conditions.
3 | Test problem is chosen to give an exact solution at all nodes of the mesh.
4 |
5 | -Laplace(u) = f in the unit square
6 | u = u_D on the boundary
7 |
8 | u_D = 1 + x^2 + 2y^2
9 | f = -6
10 | """
11 |
12 | from __future__ import print_function
13 | from fenics import *
14 | import matplotlib.pyplot as plt
15 |
16 | # Create mesh and define function space
17 | mesh = UnitSquareMesh(8, 8)
18 | V = FunctionSpace(mesh, 'P', 1)
19 |
20 | # Define boundary condition
21 | u_D = Expression('1 + x[0]*x[0] + 2*x[1]*x[1]', degree=2)
22 |
23 | def boundary(x, on_boundary):
24 | return on_boundary
25 |
26 | bc = DirichletBC(V, u_D, boundary)
27 |
28 | # Define variational problem
29 | u = TrialFunction(V)
30 | v = TestFunction(V)
31 | f = Constant(-6.0)
32 | a = dot(grad(u), grad(v))*dx
33 | L = f*v*dx
34 |
35 | # Compute solution
36 | u = Function(V)
37 | solve(a == L, u, bc)
38 |
39 | # Plot solution and mesh
40 | plot(u)
41 | plot(mesh)
42 |
43 | # Save solution to file in VTK format
44 | vtkfile = File('poisson/solution.pvd')
45 | vtkfile << u
46 |
47 | # Compute error in L2 norm
48 | error_L2 = errornorm(u_D, u, 'L2')
49 |
50 | # Compute maximum error at vertices
51 | vertex_values_u_D = u_D.compute_vertex_values(mesh)
52 | vertex_values_u = u.compute_vertex_values(mesh)
53 | import numpy as np
54 | error_max = np.max(np.abs(vertex_values_u_D - vertex_values_u))
55 |
56 | # Print errors
57 | print('error_L2 =', error_L2)
58 | print('error_max =', error_max)
59 |
60 | # Hold plot
61 | plt.show()
62 |
--------------------------------------------------------------------------------
/pub/python/vol1/ft02_poisson_membrane.py:
--------------------------------------------------------------------------------
1 | """
2 | FEniCS tutorial demo program: Deflection of a membrane.
3 |
4 | -Laplace(w) = p in the unit circle
5 | w = 0 on the boundary
6 |
7 | The load p is a Gaussian function centered at (0, 0.6).
8 | """
9 |
10 | from __future__ import print_function
11 | from fenics import *
12 | from mshr import *
13 | import numpy as np
14 |
15 | # Create mesh and define function space
16 | domain = Circle(Point(0, 0), 1)
17 | mesh = generate_mesh(domain, 64)
18 | V = FunctionSpace(mesh, 'P', 2)
19 |
20 | # Define boundary condition
21 | w_D = Constant(0)
22 |
23 | def boundary(x, on_boundary):
24 | return on_boundary
25 |
26 | bc = DirichletBC(V, w_D, boundary)
27 |
28 | # Define load
29 | beta = 8
30 | R0 = 0.6
31 | p = Expression('4*exp(-pow(beta, 2)*(pow(x[0], 2) + pow(x[1] - R0, 2)))',
32 | degree=1, beta=beta, R0=R0)
33 |
34 | # Define variational problem
35 | w = TrialFunction(V)
36 | v = TestFunction(V)
37 | a = dot(grad(w), grad(v))*dx
38 | L = p*v*dx
39 |
40 | # Compute solution
41 | w = Function(V)
42 | solve(a == L, w, bc)
43 |
44 | # Plot solution
45 | p = interpolate(p, V)
46 | plot(w, title='Deflection')
47 | plot(p, title='Load')
48 |
49 | # Save solution to file in VTK format
50 | vtkfile_w = File('poisson_membrane/deflection.pvd')
51 | vtkfile_w << w
52 | vtkfile_p = File('poisson_membrane/load.pvd')
53 | vtkfile_p << p
54 |
55 | # Curve plot along x = 0 comparing p and w
56 | import numpy as np
57 | import matplotlib.pyplot as plt
58 | tol = 0.001 # avoid hitting points outside the domain
59 | y = np.linspace(-1 + tol, 1 - tol, 101)
60 | points = [(0, y_) for y_ in y] # 2D points
61 | w_line = np.array([w(point) for point in points])
62 | p_line = np.array([p(point) for point in points])
63 | plt.plot(y, 50*w_line, 'k', linewidth=2) # magnify w
64 | plt.plot(y, p_line, 'b--', linewidth=2)
65 | plt.grid(True)
66 | plt.xlabel('$y$')
67 | plt.legend(['Deflection ($\\times 50$)', 'Load'], loc='upper left')
68 | plt.savefig('poisson_membrane/curves.pdf')
69 | plt.savefig('poisson_membrane/curves.png')
70 |
71 | # Hold plots
72 | interactive()
73 | plt.show()
74 |
--------------------------------------------------------------------------------
/pub/python/vol1/ft03_heat.py:
--------------------------------------------------------------------------------
1 | """
2 | FEniCS tutorial demo program: Heat equation with Dirichlet conditions.
3 | Test problem is chosen to give an exact solution at all nodes of the mesh.
4 |
5 | u'= Laplace(u) + f in the unit square
6 | u = u_D on the boundary
7 | u = u_0 at t = 0
8 |
9 | u = 1 + x^2 + alpha*y^2 + \beta*t
10 | f = beta - 2 - 2*alpha
11 | """
12 |
13 | from __future__ import print_function
14 | from fenics import *
15 | import numpy as np
16 |
17 | T = 2.0 # final time
18 | num_steps = 10 # number of time steps
19 | dt = T / num_steps # time step size
20 | alpha = 3 # parameter alpha
21 | beta = 1.2 # parameter beta
22 |
23 | # Create mesh and define function space
24 | nx = ny = 8
25 | mesh = UnitSquareMesh(nx, ny)
26 | V = FunctionSpace(mesh, 'P', 1)
27 |
28 | # Define boundary condition
29 | u_D = Expression('1 + x[0]*x[0] + alpha*x[1]*x[1] + beta*t',
30 | degree=2, alpha=alpha, beta=beta, t=0)
31 |
32 | def boundary(x, on_boundary):
33 | return on_boundary
34 |
35 | bc = DirichletBC(V, u_D, boundary)
36 |
37 | # Define initial value
38 | u_n = interpolate(u_D, V)
39 | #u_n = project(u_D, V)
40 |
41 | # Define variational problem
42 | u = TrialFunction(V)
43 | v = TestFunction(V)
44 | f = Constant(beta - 2 - 2*alpha)
45 |
46 | F = u*v*dx + dt*dot(grad(u), grad(v))*dx - (u_n + dt*f)*v*dx
47 | a, L = lhs(F), rhs(F)
48 |
49 | # Time-stepping
50 | u = Function(V)
51 | t = 0
52 | for n in range(num_steps):
53 |
54 | # Update current time
55 | t += dt
56 | u_D.t = t
57 |
58 | # Compute solution
59 | solve(a == L, u, bc)
60 |
61 | # Plot solution
62 | plot(u)
63 |
64 | # Compute error at vertices
65 | u_e = interpolate(u_D, V)
66 | error = np.abs(u_e.vector().array() - u.vector().array()).max()
67 | print('t = %.2f: error = %.3g' % (t, error))
68 |
69 | # Update previous solution
70 | u_n.assign(u)
71 |
72 | # Hold plot
73 | interactive()
74 |
--------------------------------------------------------------------------------
/pub/python/vol1/ft04_heat_gaussian.py:
--------------------------------------------------------------------------------
1 | """
2 | FEniCS tutorial demo program: Diffusion of a Gaussian hill.
3 |
4 | u'= Laplace(u) + f in a square domain
5 | u = u_D on the boundary
6 | u = u_0 at t = 0
7 |
8 | u_D = f = 0
9 |
10 | The initial condition u_0 is chosen as a Gaussian hill.
11 | """
12 |
13 | from __future__ import print_function
14 | from fenics import *
15 | import time
16 |
17 | T = 2.0 # final time
18 | num_steps = 50 # number of time steps
19 | dt = T / num_steps # time step size
20 |
21 | # Create mesh and define function space
22 | nx = ny = 30
23 | mesh = RectangleMesh(Point(-2, -2), Point(2, 2), nx, ny)
24 | V = FunctionSpace(mesh, 'P', 1)
25 |
26 | # Define boundary condition
27 | def boundary(x, on_boundary):
28 | return on_boundary
29 |
30 | bc = DirichletBC(V, Constant(0), boundary)
31 |
32 | # Define initial value
33 | u_0 = Expression('exp(-a*pow(x[0], 2) - a*pow(x[1], 2))',
34 | degree=2, a=5)
35 | u_n = interpolate(u_0, V)
36 |
37 | # Define variational problem
38 | u = TrialFunction(V)
39 | v = TestFunction(V)
40 | f = Constant(0)
41 |
42 | F = u*v*dx + dt*dot(grad(u), grad(v))*dx - (u_n + dt*f)*v*dx
43 | a, L = lhs(F), rhs(F)
44 |
45 | # Create VTK file for saving solution
46 | vtkfile = File('heat_gaussian/solution.pvd')
47 |
48 | # Time-stepping
49 | u = Function(V)
50 | t = 0
51 | for n in range(num_steps):
52 |
53 | # Update current time
54 | t += dt
55 |
56 | # Compute solution
57 | solve(a == L, u, bc)
58 |
59 | # Save to file and plot solution
60 | vtkfile << (u, t)
61 | plot(u)
62 |
63 | # Update previous solution
64 | u_n.assign(u)
65 |
66 | # Hold plot
67 | interactive()
68 |
--------------------------------------------------------------------------------
/pub/python/vol1/ft05_poisson_nonlinear.py:
--------------------------------------------------------------------------------
1 | """
2 | FEniCS tutorial demo program: Nonlinear Poisson equation.
3 |
4 | -div(q(u)*grad(u)) = f in the unit square.
5 | u = u_D on the boundary.
6 | """
7 |
8 | from __future__ import print_function
9 |
10 | # Warning: from fenics import * will import both `sym` and
11 | # `q` from FEniCS. We therefore import FEniCS first and then
12 | # overwrite these objects.
13 | from fenics import *
14 |
15 | def q(u):
16 | "Return nonlinear coefficient"
17 | return 1 + u**2
18 |
19 | # Use SymPy to compute f from the manufactured solution u
20 | import sympy as sym
21 | x, y = sym.symbols('x[0], x[1]')
22 | u = 1 + x + 2*y
23 | f = - sym.diff(q(u)*sym.diff(u, x), x) - sym.diff(q(u)*sym.diff(u, y), y)
24 | f = sym.simplify(f)
25 | u_code = sym.printing.ccode(u)
26 | f_code = sym.printing.ccode(f)
27 | print('u =', u_code)
28 | print('f =', f_code)
29 |
30 | # Create mesh and define function space
31 | mesh = UnitSquareMesh(8, 8)
32 | V = FunctionSpace(mesh, 'P', 1)
33 |
34 | # Define boundary condition
35 | u_D = Expression(u_code, degree=2)
36 |
37 | def boundary(x, on_boundary):
38 | return on_boundary
39 |
40 | bc = DirichletBC(V, u_D, boundary)
41 |
42 | # Define variational problem
43 | u = Function(V) # Note: not TrialFunction!
44 | v = TestFunction(V)
45 | f = Expression(f_code, degree=2)
46 | F = q(u)*dot(grad(u), grad(v))*dx - f*v*dx
47 |
48 | # Compute solution
49 | solve(F == 0, u, bc)
50 |
51 | # Plot solution
52 | plot(u)
53 |
54 | # Compute maximum error at vertices. This computation illustrates
55 | # an alternative to using compute_vertex_values as in poisson.py.
56 | u_e = interpolate(u_D, V)
57 | import numpy as np
58 | error_max = np.abs(u_e.vector().array() - u.vector().array()).max()
59 | print('error_max = ', error_max)
60 |
61 | # Hold plot
62 | interactive()
63 |
--------------------------------------------------------------------------------
/pub/python/vol1/ft06_elasticity.py:
--------------------------------------------------------------------------------
1 | """
2 | FEniCS tutorial demo program: Linear elastic problem.
3 |
4 | -div(sigma(u)) = f
5 |
6 | The model is used to simulate an elastic beam clamped at
7 | its left end and deformed under its own weight.
8 | """
9 |
10 | from __future__ import print_function
11 | from fenics import *
12 |
13 | # Scaled variables
14 | L = 1; W = 0.2
15 | mu = 1
16 | rho = 1
17 | delta = W/L
18 | gamma = 0.4*delta**2
19 | beta = 1.25
20 | lambda_ = beta
21 | g = gamma
22 |
23 | # Create mesh and define function space
24 | mesh = BoxMesh(Point(0, 0, 0), Point(L, W, W), 10, 3, 3)
25 | V = VectorFunctionSpace(mesh, 'P', 1)
26 |
27 | # Define boundary condition
28 | tol = 1E-14
29 |
30 | def clamped_boundary(x, on_boundary):
31 | return on_boundary and x[0] < tol
32 |
33 | bc = DirichletBC(V, Constant((0, 0, 0)), clamped_boundary)
34 |
35 | # Define strain and stress
36 |
37 | def epsilon(u):
38 | return 0.5*(nabla_grad(u) + nabla_grad(u).T)
39 | #return sym(nabla_grad(u))
40 |
41 | def sigma(u):
42 | return lambda_*nabla_div(u)*Identity(d) + 2*mu*epsilon(u)
43 |
44 | # Define variational problem
45 | u = TrialFunction(V)
46 | d = u.geometric_dimension() # space dimension
47 | v = TestFunction(V)
48 | f = Constant((0, 0, -rho*g))
49 | T = Constant((0, 0, 0))
50 | a = inner(sigma(u), epsilon(v))*dx
51 | L = dot(f, v)*dx + dot(T, v)*ds
52 |
53 | # Compute solution
54 | u = Function(V)
55 | solve(a == L, u, bc)
56 |
57 | # Plot solution
58 | plot(u, title='Displacement', mode='displacement')
59 |
60 | # Plot stress
61 | s = sigma(u) - (1./3)*tr(sigma(u))*Identity(d) # deviatoric stress
62 | von_Mises = sqrt(3./2*inner(s, s))
63 | V = FunctionSpace(mesh, 'P', 1)
64 | von_Mises = project(von_Mises, V)
65 | plot(von_Mises, title='Stress intensity')
66 |
67 | # Compute magnitude of displacement
68 | u_magnitude = sqrt(dot(u, u))
69 | u_magnitude = project(u_magnitude, V)
70 | plot(u_magnitude, 'Displacement magnitude')
71 | print('min/max u:',
72 | u_magnitude.vector().array().min(),
73 | u_magnitude.vector().array().max())
74 |
75 | # Save solution to file in VTK format
76 | File('elasticity/displacement.pvd') << u
77 | File('elasticity/von_mises.pvd') << von_Mises
78 | File('elasticity/magnitude.pvd') << u_magnitude
79 |
80 | # Hold plot
81 | interactive()
82 |
--------------------------------------------------------------------------------
/reviews/fenics_tutorial_review_2016_1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/reviews/fenics_tutorial_review_2016_1.pdf
--------------------------------------------------------------------------------
/reviews/fenics_tutorial_review_2016_2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/reviews/fenics_tutorial_review_2016_2.pdf
--------------------------------------------------------------------------------
/reviews/fenics_tutorial_review_2016_3.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/reviews/fenics_tutorial_review_2016_3.pdf
--------------------------------------------------------------------------------
/reviews/fenics_tutorial_review_2016_4.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/reviews/fenics_tutorial_review_2016_4.pdf
--------------------------------------------------------------------------------
/reviews/fenics_tutorial_review_2016_4_new.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/reviews/fenics_tutorial_review_2016_4_new.pdf
--------------------------------------------------------------------------------
/src/Makefile:
--------------------------------------------------------------------------------
1 | all:
2 | bash scripts/make.sh
3 |
4 | 1:
5 | bash scripts/make.sh 1
6 |
7 | 2:
8 | bash scripts/make.sh 2
9 |
10 | simple:
11 | bash scripts/make_simple.sh
12 |
13 | publish:
14 | bash scripts/publish.sh
15 |
--------------------------------------------------------------------------------
/src/README.md:
--------------------------------------------------------------------------------
1 | This directory contains the source code for the FEniCS Tutorial.
2 |
3 | The tutorial is written in DocOnce and compiled to LaTeX PDF, Sphinx
4 | (FEniCS style), and Bootstrap HTML.
5 |
6 | The parent documents are:
7 |
8 | * `ftut1.do.txt` (FEniCS Tutorial Volume 1
9 | * `ftut2.do.txt` (FEniCS Tutorial Volume 2, in preparation)
10 |
11 | The directories `vol1` and `vol2` contain the sources for chapters
12 | and code for the two volumes.
13 |
14 | To build the book (in all formats), type `make` or run `scripts/make.sh`.
15 |
16 | Building the book requires a relatively long list of packages, most notably
17 | `doconce`, `preprocess`, `publish`, and `sphinx`. The easiest way to install
18 | these packages is via the script `install_rich.sh` which can be found in
19 | the subdirectory `scripts`. If running on Ubuntu, the script should just
20 | work and install all required packages.
21 |
22 | If running on another operating system, the easiest solution is to
23 | create a FEniCS Docker image and run the script from within that
24 | directory. Make sure you have installed Docker and the FEniCS Docker
25 | scripts; see `http://fenicsproject.org/download for instructions`.
26 | The position yourself in the top level directory of this repository
27 | and then run the following commands:
28 |
29 | fenicsproject create fenics-tutorial stable
30 | fenicsproject start fenics-tutorial
31 |
32 | Then run the install script inside the container:
33 |
34 | src/scripts/install.sh
35 |
--------------------------------------------------------------------------------
/src/bib/venues.list:
--------------------------------------------------------------------------------
1 | publisher: Prentice-Hall
2 | publisher: O'Reilly
3 | publisher: APress
4 | publisher: Irwin
5 |
--------------------------------------------------------------------------------
/src/exer/clean.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | rm -rf *~ *.vtu *.pvd dolfin_plot* __pychache__ tmp*
3 |
--------------------------------------------------------------------------------
/src/exer/p2D_flat_Neumann1.py:
--------------------------------------------------------------------------------
1 | """
2 | FEniCS tutorial demo program:
3 | Poisson equation with Dirichlet and Neumann conditions.
4 | The solution is checked to coincide with the exact solution at all nodes.
5 |
6 | -Laplace(u) = f on the unit square.
7 | u = u0 on x=0 and x=1.
8 | -du/dn = g on y=0 and y=1.
9 | u0 = u = 1 + x^2 + 2y^2, f = -6, g = -4y.
10 | """
11 |
12 | from __future__ import print_function
13 | from fenics import *
14 | import numpy
15 |
16 | # Create mesh and define function space
17 | mesh = UnitSquareMesh(3, 2)
18 | V = FunctionSpace(mesh, 'Lagrange', 1)
19 |
20 | # Define Dirichlet boundary conditions
21 | u0 = Expression('1 + x[0]*x[0] + 2*x[1]*x[1]')
22 |
23 | def Dirichlet_boundary(x, on_boundary):
24 | tol = 1E-14 # tolerance for coordinate comparisons
25 | return on_boundary and \
26 | (abs(x[0]) < tol or abs(x[0] - 1) < tol)
27 |
28 | bc = DirichletBC(V, u0, Dirichlet_boundary)
29 |
30 | # Define variational problem
31 | u = TrialFunction(V)
32 | v = TestFunction(V)
33 | f = Constant(-6.0)
34 | g = Expression('-4*x[1]')
35 | a = inner(grad(u), grad(v))*dx
36 | L = f*v*dx - g*v*ds
37 |
38 | # Compute solution
39 | u = Function(V)
40 | solve(a == L, u, bc)
41 |
42 | #plot(u)
43 |
44 | print("""
45 | Solution of the Poisson problem -Laplace(u) = f,
46 | with u = u0 on x=0,1 and -du/dn = g at y=0,1.
47 | %s
48 | """ % mesh)
49 |
50 | # Verification
51 | u_e = interpolate(u0, V)
52 | u_e_array = u_e.vector().array()
53 | u_array = u.vector().array()
54 | print('Max error:', numpy.abs(u_e_array - u_array).max())
55 |
56 | # Compare numerical and exact solution
57 | center = (0.5, 0.5)
58 | print('numerical u at the center point:', u(center))
59 | print('exact u at the center point:', u0(center))
60 |
61 | #interactive()
62 |
--------------------------------------------------------------------------------
/src/exer/vol1/Expression_efficiency.py:
--------------------------------------------------------------------------------
1 | from __future__ import print_function
2 | from fenics import *
3 | import time
4 |
5 | def make_sine_Function(N, method):
6 | """Fill a Function with sin(x*y*z) values."""
7 | mesh = UnitCubeMesh(N, N, N)
8 | V = FunctionSpace(mesh, 'Lagrange', 2)
9 |
10 | if method.startswith('Python'):
11 | if method.endswith('fenics.sin'):
12 | # Need sin as local variable in this function
13 | from fenics import sin
14 | elif method.endswith('math.sin'):
15 | from math import sin
16 | elif method.endswith('numpy.sin'):
17 | from numpy import sin
18 | elif method.endswith('sympy.sin'):
19 | from sympy import sin
20 | else:
21 | raise NotImplementedError('method=%s' % method)
22 | print('sin:', sin, type(sin))
23 |
24 | class SineXYZ(Expression):
25 | def __init__(self, a, b):
26 | self.a, self.b = a, b
27 |
28 | def eval(self, value, x):
29 | value[0] = self.a*sin(self.b*x[0]*x[1]*x[2])
30 |
31 | expr = SineXYZ(a=1, b=2)
32 |
33 | elif method == 'C++':
34 | expr = Expression('a*sin(b*x[0]*x[1]*x[2])', a=1, b=2)
35 |
36 | t0 = time.clock()
37 | u = interpolate(expr, V)
38 | t1 = time.clock()
39 | return u, t1-t0
40 |
41 | def main(N):
42 | u, cpu_py_fenics = make_sine_Function(N, 'Python-fenics.sin')
43 | u, cpu_py_math = make_sine_Function(N, 'Python-math.sin')
44 | u, cpu_py_numpy = make_sine_Function(N, 'Python-numpy.sin')
45 | u, cpu_py_sympy = make_sine_Function(N, 'Python-sympy.sin')
46 | u, cpu_cpp = make_sine_Function(N, 'C++')
47 | print("""DOFs: %d
48 | Python:
49 | fenics.sin: %.2f
50 | math.sin: %.2f
51 | numpy.sin: %.2f
52 | sympy.sin: %.2f
53 | C++: %.2f
54 | Speed-up: math: %.2f sympy: %.2f""" %
55 | (u.function_space().dim(),
56 | cpu_py_fenics, cpu_py_math,
57 | cpu_py_numpy, cpu_py_sympy,
58 | cpu_cpp,
59 | cpu_py_math/float(cpu_cpp),
60 | cpu_py_sympy/float(cpu_cpp)))
61 |
62 | def profile():
63 | import cProfile
64 | prof = cProfile.Profile()
65 | prof.runcall(main)
66 | prof.dump_stats("tmp.profile")
67 | # http://docs.python.org/2/library/profile.html
68 |
69 | main(20)
70 | #profile()
71 |
--------------------------------------------------------------------------------
/src/exer/vol1/poisson_fsin_flat.py:
--------------------------------------------------------------------------------
1 | from __future__ import print_function
2 | from fenics import *
3 |
4 | Nx = Ny = 20
5 | error = []
6 | for i in range(2):
7 | Nx *= (i+1)
8 | Ny *= (i+1)
9 |
10 | # Create mesh and define function space
11 | mesh = UnitSquareMesh(Nx, Ny)
12 | V = FunctionSpace(mesh, 'Lagrange', 1)
13 |
14 | # Define boundary conditions
15 | u0 = Constant(0)
16 |
17 | def u0_boundary(x, on_boundary):
18 | return on_boundary
19 |
20 | bc = DirichletBC(V, u0, u0_boundary)
21 |
22 | # Define variational problem
23 | u = TrialFunction(V)
24 | v = TestFunction(V)
25 | f = Expression('-2*exp(-2*x[0])*sin(pi*x[1])*('
26 | '(4-5*pow(pi,2))*sin(2*pi*x[0]) '
27 | ' - 8*pi*cos(2*pi*x[0]))')
28 | # Note: no need for pi=DOLFIN_PI in f, pi is valid variable
29 | a = inner(nabla_grad(u), nabla_grad(v))*dx
30 | L = f*v*dx
31 |
32 | # Compute solution
33 | u = Function(V)
34 | solve(a == L, u, bc)
35 |
36 | u_e = Expression(
37 | '2*exp(-2*x[0])*sin(2*pi*x[0])*sin(pi*x[1])')
38 |
39 | u_e_Function = interpolate(u_e, V) # exact solution
40 | u_e_array = u_e_Function.vector().array() # dof values
41 | max_error = (u_e_array - u.vector().array()).max()
42 | print('max error:', max_error, '%dx%d mesh' % (Nx, Ny))
43 | error.append(max_error)
44 |
45 | print('Error reduction:', error[1]/error[0])
46 |
47 | # Plot solution and mesh
48 | plot(u)
49 |
50 | # Dump solution to file in VTK format
51 | file = File("poisson.pvd")
52 | file << u
53 |
54 | # Hold plot
55 | interactive()
56 |
--------------------------------------------------------------------------------
/src/exer/vol1/poisson_fsin_func.py:
--------------------------------------------------------------------------------
1 | from __future__ import print_function
2 | #from fenics import * # not necessary, need only a few
3 | import os, sys
4 | path = os.path.join(os.pardir, os.pardir, os.pardir,
5 | 'src', 'stationary', 'poisson')
6 | sys.path.insert(0, path)
7 | from poisson_solver import (
8 | solver, Expression, Constant, interpolate, File, plot,
9 | interactive)
10 |
11 | def data():
12 | """Return data for this Poisson problem."""
13 | u0 = Constant(0)
14 | u_e = Expression(
15 | '2*exp(-2*x[0])*sin(2*pi*x[0])*sin(pi*x[1])')
16 | f = Expression('-2*exp(-2*x[0])*sin(pi*x[1])*('
17 | '(4-5*pow(pi,2))*sin(2*pi*x[0]) '
18 | ' - 8*pi*cos(2*pi*x[0]))')
19 | return u0, f, u_e
20 |
21 | def test_solver():
22 | """Check convergence rate of solver."""
23 | u0, f, u_e = data()
24 | Nx = 20
25 | Ny = Nx
26 | error = []
27 | # Loop over refined meshes
28 | for i in range(2):
29 | Nx *= i+1
30 | Ny *= i+1
31 | print('solving on 2(%dx%d) mesh' % (Nx, Ny))
32 | u = solver(f, u0, Nx, Ny, degree=1)
33 | # Make a finite element function of the exact u_e
34 | V = u.function_space()
35 | u_e_array = interpolate(u_e, V).vector().array()
36 | max_error = (u_e_array - u.vector().array()).max() # Linf norm
37 | error.append(max_error)
38 | print('max error:', max_error)
39 | for i in range(1, len(error)):
40 | error_reduction = error[i]/error[i-1]
41 | print('error reduction:', error_reduction)
42 | assert abs(error_reduction - 0.25) < 0.1
43 |
44 | def application():
45 | """Plot the solution."""
46 | u0, f, u_e = data()
47 | Nx = 40
48 | Ny = Nx
49 | u = solver(f, u0, Nx, Ny, 1)
50 | # Dump solution to file in VTK format
51 | file = File("poisson.pvd")
52 | file << u
53 | # Plot solution and mesh
54 | plot(u)
55 |
56 | if __name__ == '__main__':
57 | test_solver()
58 | application()
59 | # Hold plot
60 | interactive()
61 |
--------------------------------------------------------------------------------
/src/fig/elasticity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/elasticity.png
--------------------------------------------------------------------------------
/src/fig/heat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/heat.png
--------------------------------------------------------------------------------
/src/fig/magnetostatics_field.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/magnetostatics_field.png
--------------------------------------------------------------------------------
/src/fig/magnetostatics_geometry.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/magnetostatics_geometry.pdf
--------------------------------------------------------------------------------
/src/fig/magnetostatics_geometry.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/magnetostatics_geometry.png
--------------------------------------------------------------------------------
/src/fig/magnetostatics_mesh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/magnetostatics_mesh.png
--------------------------------------------------------------------------------
/src/fig/magnetostatics_potential.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/magnetostatics_potential.png
--------------------------------------------------------------------------------
/src/fig/navier_stokes_channel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/navier_stokes_channel.png
--------------------------------------------------------------------------------
/src/fig/navier_stokes_cylinder_geometry.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/navier_stokes_cylinder_geometry.pdf
--------------------------------------------------------------------------------
/src/fig/navier_stokes_cylinder_geometry.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/navier_stokes_cylinder_geometry.png
--------------------------------------------------------------------------------
/src/fig/navier_stokes_cylinder_pressure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/navier_stokes_cylinder_pressure.png
--------------------------------------------------------------------------------
/src/fig/navier_stokes_cylinder_velocity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/navier_stokes_cylinder_velocity.png
--------------------------------------------------------------------------------
/src/fig/poisson_extended.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/poisson_extended.pdf
--------------------------------------------------------------------------------
/src/fig/poisson_extended.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/poisson_extended.png
--------------------------------------------------------------------------------
/src/fig/poisson_membrane_curves.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/poisson_membrane_curves.png
--------------------------------------------------------------------------------
/src/fig/poisson_membrane_deflection_load.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/poisson_membrane_deflection_load.png
--------------------------------------------------------------------------------
/src/fig/poisson_paraview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/poisson_paraview.png
--------------------------------------------------------------------------------
/src/fig/poisson_plot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/poisson_plot.png
--------------------------------------------------------------------------------
/src/fig/reaction_system.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/reaction_system.png
--------------------------------------------------------------------------------
/src/fig/subdomains.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/subdomains.pdf
--------------------------------------------------------------------------------
/src/fig/subdomains.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/subdomains.png
--------------------------------------------------------------------------------
/src/fig/vertex_numbering.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/fig/vertex_numbering.png
--------------------------------------------------------------------------------
/src/ftut2.do.txt:
--------------------------------------------------------------------------------
1 | # #include "mako_code.txt"
2 |
3 | % if FORMAT == "sphinx":
4 | # Sphinx cannot have more than 63 chars in the title...
5 | #TITLE: Writing Advanced State-of-the-Art Finite Element Solvers in Hours
6 | #TITLE: More Advanced FEniCS Finite Element Programming
7 | TITLE: The FEniCS Tutorial Volume II
8 | % elif FORMAT == "pdflatex":
9 | # Get newlines right
10 | #TITLE: More Advanced FEniCS Finite Element Programming
11 | TITLE: Solving PDEs in Hours - \\ The FEniCS Tutorial Volume II
12 | % else:
13 | #TITLE: More Advanced FEniCS Finite Element Programming
14 | TITLE: Solving PDEs in Hours - The FEniCS Tutorial Volume II
15 | #- Writing Advanced State-of-the-Art Finite Element Solvers in Hours
16 | % endif
17 | AUTHOR: Hans Petter Langtangen {copyright|CC BY} Email: hpl@simula.no at Center for Biomedical Computing, Simula Research Laboratory & Department of Informatics, University of Oslo
18 | AUTHOR: Anders Logg {copyright|CC BY} Email: logg@chalmers.se at Department of Mathematics, Chalmers University of Technology & Center for Biomedical Computing, Simula Research Laboratory & Computational Engineeing and Design, Fraunhofer-Chalmers Centre
19 |
20 | # Can refer to ftut1 as with the xr package in latex (just use ref{} and cite{})
21 | # Externaldocuments: ftut1
22 |
23 | __Preface.__
24 | This book addresses...
25 |
26 | DATE: today
27 |
28 | !split
29 | TOC: on
30 |
31 | !split
32 | # #include "vol2/heat.do.txt"
33 |
34 | !split
35 | # #include "vol2/nlpoisson.do.txt"
36 |
37 | !split
38 | ========= Mixed finite element programming =========
39 | label{ch:mixedFEM}
40 |
41 | ========= High-performance computing =========
42 | label{ch:HPC}
43 |
44 | How to take an ordinary FEniCS program, profile it, optimize the code,
45 | and turn into an HPC application for parallel platforms.
46 |
47 | ========= Multi-physics in multi-domains =========
48 | label{ch:multiphys}
49 |
50 | Systems of PDEs, coupling of domains, typically elasticity with a
51 | larger domain for heat transfer, simple fluid-structure interaction?
52 |
53 | ========= Vol II ends here now =========
54 |
55 | ========= More old stuff =========
56 |
57 | # #include "vol2/misc.do.txt"
58 |
59 | # #include "vol2/troubleshooting.do.txt"
60 |
61 | !split
62 | ======= Bibliography =======
63 |
64 | BIBFILE: bib/papers.pub
65 |
--------------------------------------------------------------------------------
/src/mako_code.txt:
--------------------------------------------------------------------------------
1 | ## Mako variables and functions
2 | <%
3 | src_url = 'https://fenicsproject.org/pub/tutorial/python/vol1'
4 | pub_url = 'https://fenicsproject.org/pub/tutorial'
5 | fenics_version = '2016.2'
6 |
7 | # AL: Stuff at the bottom added manually for now to get vol2 to compile.
8 |
9 | # Automatically computed by number_src_files.py
10 | prog = {
11 | 'poisson': 'ft01_poisson',
12 | 'poisson_membrane': 'ft02_poisson_membrane',
13 | 'heat': 'ft03_heat',
14 | 'heat_gaussian': 'ft04_heat_gaussian',
15 | 'poisson_nonlinear': 'ft05_poisson_nonlinear',
16 | 'elasticity': 'ft06_elasticity',
17 | 'navier_stokes_channel': 'ft07_navier_stokes_channel',
18 | 'navier_stokes_cylinder': 'ft08_navier_stokes_cylinder',
19 | 'reaction_system': 'ft09_reaction_system',
20 | 'poisson_extended': 'ft10_poisson_extended',
21 | 'magnetostatics': 'ft11_magnetostatics',
22 | 'poisson_solver': 'ft12_poisson_solver'
23 | }
24 |
25 | %>
26 |
--------------------------------------------------------------------------------
/src/mov/heat_gaussian.ogv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/mov/heat_gaussian.ogv
--------------------------------------------------------------------------------
/src/mov/navier_stokes_cylinder.ogv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/mov/navier_stokes_cylinder.ogv
--------------------------------------------------------------------------------
/src/mov/reaction_system.ogv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/mov/reaction_system.ogv
--------------------------------------------------------------------------------
/src/notes.org:
--------------------------------------------------------------------------------
1 | * Ideas for volume 2
2 | Parallel computing
3 | Periodic table of finite elements
4 | Pictures of elements and numbering
5 | Mesh generation: mshr and MeshEditor
6 | Troubleshooting: pick most common problems from Q&A
7 | DirichletBC: pointwise, topological, geometric
8 | PDE-constrained optimization?
9 | Adaptivity and mesh refinement
10 | Higher-order time-stepping schemes
11 | Programming FEniCS in C++
12 |
13 |
--------------------------------------------------------------------------------
/src/old/fig/Poisson2D_D1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/Poisson2D_D1.pdf
--------------------------------------------------------------------------------
/src/old/fig/Poisson2D_D1_mesh.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/Poisson2D_D1_mesh.pdf
--------------------------------------------------------------------------------
/src/old/fig/Poisson2D_D1_wireframe.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/Poisson2D_D1_wireframe.pdf
--------------------------------------------------------------------------------
/src/old/fig/Poisson2D_Dvc.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/Poisson2D_Dvc.pdf
--------------------------------------------------------------------------------
/src/old/fig/Poisson2D_Dvc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/Poisson2D_Dvc.png
--------------------------------------------------------------------------------
/src/old/fig/Poisson2D_Dvc_contour1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/Poisson2D_Dvc_contour1.pdf
--------------------------------------------------------------------------------
/src/old/fig/Poisson2D_Dvc_contour1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/Poisson2D_Dvc_contour1.png
--------------------------------------------------------------------------------
/src/old/fig/Poisson2D_Dvc_flux_x.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/Poisson2D_Dvc_flux_x.pdf
--------------------------------------------------------------------------------
/src/old/fig/Poisson2D_Dvc_flux_x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/Poisson2D_Dvc_flux_x.png
--------------------------------------------------------------------------------
/src/old/fig/Poisson2D_Dvc_mesh1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/Poisson2D_Dvc_mesh1.pdf
--------------------------------------------------------------------------------
/src/old/fig/Poisson2D_Dvc_mesh1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/Poisson2D_Dvc_mesh1.png
--------------------------------------------------------------------------------
/src/old/fig/Poisson2D_Dvc_surf1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/Poisson2D_Dvc_surf1.pdf
--------------------------------------------------------------------------------
/src/old/fig/Poisson2D_Dvc_surf1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/Poisson2D_Dvc_surf1.png
--------------------------------------------------------------------------------
/src/old/fig/Poisson2D_Dvc_surfmesh1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/Poisson2D_Dvc_surfmesh1.pdf
--------------------------------------------------------------------------------
/src/old/fig/Poisson2D_Dvc_surfmesh1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/Poisson2D_Dvc_surfmesh1.png
--------------------------------------------------------------------------------
/src/old/fig/beam1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/beam1.pdf
--------------------------------------------------------------------------------
/src/old/fig/beam1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/beam1.png
--------------------------------------------------------------------------------
/src/old/fig/beam2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/beam2.pdf
--------------------------------------------------------------------------------
/src/old/fig/beam2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/beam2.png
--------------------------------------------------------------------------------
/src/old/fig/cube3D_quad_sol.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/cube3D_quad_sol.pdf
--------------------------------------------------------------------------------
/src/old/fig/cube3D_quad_sol.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/cube3D_quad_sol.png
--------------------------------------------------------------------------------
/src/old/fig/cube3D_quad_sol_contours.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/cube3D_quad_sol_contours.pdf
--------------------------------------------------------------------------------
/src/old/fig/cube3D_quad_sol_contours.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/cube3D_quad_sol_contours.png
--------------------------------------------------------------------------------
/src/old/fig/daynight.fig:
--------------------------------------------------------------------------------
1 | #FIG 3.2 Produced by xfig version 3.2.5
2 | Landscape
3 | Center
4 | Metric
5 | A4
6 | 100.00
7 | Single
8 | -2
9 | 1200 2
10 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
11 | 0 0 1.00 60.00 120.00
12 | 2070 2250 7695 2250
13 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
14 | 2250 2250 6300 2250 6300 6300 2250 6300 2250 2250
15 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
16 | 0 0 1.00 60.00 120.00
17 | 4275 2250 4275 1440
18 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
19 | 3600 3375 4950 3375 4950 4275 3600 4275 3600 3375
20 | 2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 1 1 2
21 | 0 0 1.00 60.00 120.00
22 | 0 0 1.00 60.00 120.00
23 | 2250 7200 6300 7200
24 | 2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 1 1 2
25 | 0 0 1.00 60.00 120.00
26 | 0 0 1.00 60.00 120.00
27 | 8100 2250 8100 6345
28 | 4 0 0 50 -1 0 12 0.0000 2 210 2085 6390 4230 $\\partial u/\\partial n = 0$\001
29 | 4 0 0 50 -1 0 12 0.0000 2 210 2085 1260 4230 $\\partial u/\\partial n = 0$\001
30 | 4 0 0 50 -1 0 12 0.0000 2 210 315 3870 1665 $y$\001
31 | 4 0 0 50 -1 0 12 0.0000 2 180 315 7380 2475 $x$\001
32 | 4 0 0 50 -1 0 12 0.0000 2 210 3120 4365 2115 $T_0(t)= T_R + T_A\\sin(\\omega t)$\001
33 | 4 0 0 50 -1 0 12 0.0000 2 180 360 8145 3555 $D$\001
34 | 4 0 0 50 -1 0 12 0.0000 2 180 405 4185 7425 $W$\001
35 | 4 0 0 50 -1 0 12 0.0000 2 210 1785 4005 3870 $\\kappa\\ll \\kappa_0$\001
36 | 4 0 0 50 -1 0 12 0.0000 2 210 1950 4050 5220 $\\varrho, c, \\kappa_0$\001
37 | 4 0 0 50 -1 0 12 0.0000 2 210 2085 3915 6615 $\\partial u/\\partial n = 0$\001
38 |
--------------------------------------------------------------------------------
/src/old/fig/daynight.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/daynight.pdf
--------------------------------------------------------------------------------
/src/old/fig/daynight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/daynight.png
--------------------------------------------------------------------------------
/src/old/fig/daynight.pstex_t:
--------------------------------------------------------------------------------
1 | \begin{picture}(0,0)%
2 | \includegraphics{daynight.pstex}%
3 | \end{picture}%
4 | \setlength{\unitlength}{4144sp}%
5 | %
6 | \begingroup\makeatletter\ifx\SetFigFontNFSS\undefined%
7 | \gdef\SetFigFontNFSS#1#2#3#4#5{%
8 | \reset@font\fontsize{#1}{#2pt}%
9 | \fontfamily{#3}\fontseries{#4}\fontshape{#5}%
10 | \selectfont}%
11 | \fi\endgroup%
12 | \begin{picture}(6915,6066)(1246,-6655)
13 | \put(6391,-3391){\makebox(0,0)[lb]{\smash{{\SetFigFontNFSS{12}{14.4}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$\partial u/\partial n = 0$}%
14 | }}}}
15 | \put(1261,-3391){\makebox(0,0)[lb]{\smash{{\SetFigFontNFSS{12}{14.4}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$\partial u/\partial n = 0$}%
16 | }}}}
17 | \put(3871,-826){\makebox(0,0)[lb]{\smash{{\SetFigFontNFSS{12}{14.4}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$y$}%
18 | }}}}
19 | \put(7381,-1636){\makebox(0,0)[lb]{\smash{{\SetFigFontNFSS{12}{14.4}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$x$}%
20 | }}}}
21 | \put(4366,-1276){\makebox(0,0)[lb]{\smash{{\SetFigFontNFSS{12}{14.4}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$T_0(t)= T_R + T_A\sin(\omega t)$}%
22 | }}}}
23 | \put(8146,-2716){\makebox(0,0)[lb]{\smash{{\SetFigFontNFSS{12}{14.4}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$D$}%
24 | }}}}
25 | \put(4186,-6586){\makebox(0,0)[lb]{\smash{{\SetFigFontNFSS{12}{14.4}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$W$}%
26 | }}}}
27 | \put(4006,-3031){\makebox(0,0)[lb]{\smash{{\SetFigFontNFSS{12}{14.4}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$\kappa\ll \kappa_0$}%
28 | }}}}
29 | \put(4051,-4381){\makebox(0,0)[lb]{\smash{{\SetFigFontNFSS{12}{14.4}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$\varrho, c, \kappa_0$}%
30 | }}}}
31 | \put(3916,-5776){\makebox(0,0)[lb]{\smash{{\SetFigFontNFSS{12}{14.4}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$\partial u/\partial n = 0$}%
32 | }}}}
33 | \end{picture}%
34 |
--------------------------------------------------------------------------------
/src/old/fig/daynight.tex:
--------------------------------------------------------------------------------
1 | \documentclass{article}
2 | \usepackage{epsfig}
3 | \usepackage{color}
4 | \setlength{\textwidth}{100cm}
5 | \setlength{\textheight}{100cm}
6 | \begin{document}
7 | \pagestyle{empty}
8 | \input{daynight.pstex_t}
9 | \end{document}
10 |
--------------------------------------------------------------------------------
/src/old/fig/diffu_A_factors_BE.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/diffu_A_factors_BE.pdf
--------------------------------------------------------------------------------
/src/old/fig/diffu_A_factors_BE.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/diffu_A_factors_BE.png
--------------------------------------------------------------------------------
/src/old/fig/diffu_A_factors_CN.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/diffu_A_factors_CN.pdf
--------------------------------------------------------------------------------
/src/old/fig/diffu_A_factors_CN.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/diffu_A_factors_CN.png
--------------------------------------------------------------------------------
/src/old/fig/diffu_A_factors_fine_FE.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/diffu_A_factors_fine_FE.pdf
--------------------------------------------------------------------------------
/src/old/fig/diffu_A_factors_fine_FE.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/diffu_A_factors_fine_FE.png
--------------------------------------------------------------------------------
/src/old/fig/diffusion0_paraview_animation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/diffusion0_paraview_animation.png
--------------------------------------------------------------------------------
/src/old/fig/ex1_gradu.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/ex1_gradu.pdf
--------------------------------------------------------------------------------
/src/old/fig/ex1_gradu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/ex1_gradu.png
--------------------------------------------------------------------------------
/src/old/fig/ex1_mesh.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/ex1_mesh.pdf
--------------------------------------------------------------------------------
/src/old/fig/ex1_mesh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/ex1_mesh.png
--------------------------------------------------------------------------------
/src/old/fig/ex1_u.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/ex1_u.pdf
--------------------------------------------------------------------------------
/src/old/fig/ex1_u.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/ex1_u.png
--------------------------------------------------------------------------------
/src/old/fig/gui_poisson1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/gui_poisson1.png
--------------------------------------------------------------------------------
/src/old/fig/gui_poisson2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/gui_poisson2.png
--------------------------------------------------------------------------------
/src/old/fig/guifig_view1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/guifig_view1.png
--------------------------------------------------------------------------------
/src/old/fig/guifig_view1.tiff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/guifig_view1.tiff
--------------------------------------------------------------------------------
/src/old/fig/guifig_view_dolfin_krylov_solver.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/guifig_view_dolfin_krylov_solver.png
--------------------------------------------------------------------------------
/src/old/fig/guifig_view_dolfin_krylov_solver.tiff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/guifig_view_dolfin_krylov_solver.tiff
--------------------------------------------------------------------------------
/src/old/fig/guifig_view_results1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/guifig_view_results1.png
--------------------------------------------------------------------------------
/src/old/fig/guifig_view_results1.tiff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/guifig_view_results1.tiff
--------------------------------------------------------------------------------
/src/old/fig/guifig_view_results1_bootstrap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/guifig_view_results1_bootstrap.png
--------------------------------------------------------------------------------
/src/old/fig/guifig_view_results1_bootstrap.tiff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/guifig_view_results1_bootstrap.tiff
--------------------------------------------------------------------------------
/src/old/fig/hollow_cylinder.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/hollow_cylinder.pdf
--------------------------------------------------------------------------------
/src/old/fig/hollow_cylinder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/hollow_cylinder.png
--------------------------------------------------------------------------------
/src/old/fig/layered_medium_2.py:
--------------------------------------------------------------------------------
1 | from pysketcher import *
2 | from numpy import exp, linspace
3 |
4 | W = 10.
5 | H = 10.
6 | a = [0, 5, 10]
7 |
8 | drawing_tool.set_coordinate_system(xmin=-1, xmax=W+1,
9 | ymin=-1, ymax=H+1,
10 | axis=False)
11 | drawing_tool.set_linecolor('black')
12 | drawing_tool.set_fontsize(24)
13 |
14 | layers = {'layer%d' % i: Line((0,a[i]), (W,a[i]))
15 | for i in range(len(a))}
16 | symbols_q = {'Omega_k%d' % i: Text(r'$\Omega_%d$: $k_%d$' % (i, i),
17 | (W/2,0.5*(a[i]+a[i+1])))
18 | for i in range(len(a)-1)}
19 |
20 | sides ={'left': Line((0,0), (0,H)), 'right': Line((W,0), (W,H))}
21 | d = sides.copy()
22 | d.update(layers)
23 | d.update(symbols_q)
24 | fig = Composition(d)
25 |
26 | fig.draw()
27 | drawing_tool.display()
28 | drawing_tool.savefig('tmp2')
29 |
30 | raw_input()
31 |
--------------------------------------------------------------------------------
/src/old/fig/layers.fig:
--------------------------------------------------------------------------------
1 | #FIG 3.2 Produced by xfig version 3.2.5b
2 | Landscape
3 | Center
4 | Metric
5 | A4
6 | 100.00
7 | Single
8 | -2
9 | 1200 2
10 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
11 | 0 0 1.00 60.00 120.00
12 | 900 6750 6525 6750
13 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
14 | 900 2925 4725 2925 4725 6750
15 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
16 | 2340 6750 2340 2925
17 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
18 | 1755 6750 1755 2925
19 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
20 | 4005 6750 4005 2925
21 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
22 | 0 0 1.00 60.00 120.00
23 | 900 6795 900 1350
24 | 4 0 0 50 -1 0 12 0.0000 2 195 2040 2160 2565 $\\partial u/\\partial n = 0$\001
25 | 4 0 0 50 -1 0 12 0.0000 2 195 2040 2160 7155 $\\partial u/\\partial n = 0$\001
26 | 4 0 0 50 -1 0 12 0.0000 2 165 525 180 4770 $u=0$\001
27 | 4 0 0 50 -1 0 12 0.0000 2 165 525 4905 4770 $u=1$\001
28 | 4 0 0 50 -1 0 12 0.0000 2 195 1050 4185 3735 $\\Omega_3$\001
29 | 4 0 0 50 -1 0 12 0.0000 2 195 1050 3015 3735 $\\Omega_2$\001
30 | 4 0 0 50 -1 0 12 0.0000 2 195 1050 1935 3735 $\\Omega_1$\001
31 | 4 0 0 50 -1 0 12 0.0000 2 180 525 1935 4140 $k_1$\001
32 | 4 0 0 50 -1 0 12 0.0000 2 195 1050 1170 3735 $\\Omega_0$\001
33 | 4 0 0 50 -1 0 12 0.0000 2 180 525 6210 6975 $x_0$\001
34 | 4 0 0 50 -1 0 12 0.0000 2 180 525 1170 4140 $k_0$\001
35 | 4 0 0 50 -1 0 12 0.0000 2 180 525 3015 4140 $k_2$\001
36 | 4 0 0 50 -1 0 12 0.0000 2 180 525 4185 4140 $k_3$\001
37 | 4 0 0 50 -1 0 12 0.0000 2 180 525 540 1710 $x_1$\001
38 |
--------------------------------------------------------------------------------
/src/old/fig/layers.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/layers.pdf
--------------------------------------------------------------------------------
/src/old/fig/layers.sh:
--------------------------------------------------------------------------------
1 | # receipe: http://www.qscitech.info/blog-entries/LaTeX-in-your-figures-with-XFig-shudders-.html
2 |
3 | xfig -specialtext -latexfonts -startlatexFont default layers.fig
4 | # write latex text as straight default text with $...$
5 | # export to combined PS/LaTeX format
6 |
7 | # copy tex file (like layers.tex) to some file, go into it and inset the right
8 | # filename (layers.pstex_t)
9 | latex layers.tex
10 | # make EPS figure out of the xfig figure:
11 | dvips -E layers.dvi -o layers.eps
12 | # check layers.eps - you probably need to adjust the placement of $...$ text
13 | # include layers.eps in the latex document
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/old/fig/layers.tex:
--------------------------------------------------------------------------------
1 | \documentclass{article}
2 | \usepackage{epsfig}
3 | \usepackage{color}
4 | \setlength{\textwidth}{100cm}
5 | \setlength{\textheight}{100cm}
6 | \begin{document}
7 | \pagestyle{empty}
8 | \input{layers.pstex_t}
9 | \end{document}
10 |
--------------------------------------------------------------------------------
/src/old/fig/membrane_curveplot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/membrane_curveplot.pdf
--------------------------------------------------------------------------------
/src/old/fig/membrane_curveplot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/membrane_curveplot.png
--------------------------------------------------------------------------------
/src/old/fig/membrane_curveplot_new.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/membrane_curveplot_new.pdf
--------------------------------------------------------------------------------
/src/old/fig/membrane_curveplot_new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/membrane_curveplot_new.png
--------------------------------------------------------------------------------
/src/old/fig/membrane_deflection.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/membrane_deflection.pdf
--------------------------------------------------------------------------------
/src/old/fig/membrane_deflection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/membrane_deflection.png
--------------------------------------------------------------------------------
/src/old/fig/membrane_fenics_viz.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/membrane_fenics_viz.pdf
--------------------------------------------------------------------------------
/src/old/fig/membrane_fenics_viz.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/membrane_fenics_viz.png
--------------------------------------------------------------------------------
/src/old/fig/membrane_waxis.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/membrane_waxis.pdf
--------------------------------------------------------------------------------
/src/old/fig/membrane_waxis.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/membrane_waxis.png
--------------------------------------------------------------------------------
/src/old/fig/paraview_animation_buttons.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/paraview_animation_buttons.png
--------------------------------------------------------------------------------
/src/old/fig/paraview_membrane.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/paraview_membrane.pdf
--------------------------------------------------------------------------------
/src/old/fig/paraview_membrane.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/paraview_membrane.png
--------------------------------------------------------------------------------
/src/old/fig/paraview_membrane2_3D.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/paraview_membrane2_3D.pdf
--------------------------------------------------------------------------------
/src/old/fig/paraview_membrane2_3D.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/paraview_membrane2_3D.png
--------------------------------------------------------------------------------
/src/old/fig/paraview_membrane3.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/paraview_membrane3.pdf
--------------------------------------------------------------------------------
/src/old/fig/paraview_membrane3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/paraview_membrane3.png
--------------------------------------------------------------------------------
/src/old/fig/paraview_membrane3b.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/paraview_membrane3b.pdf
--------------------------------------------------------------------------------
/src/old/fig/paraview_membrane3b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/paraview_membrane3b.png
--------------------------------------------------------------------------------
/src/old/fig/paraview_show_center_button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/paraview_show_center_button.png
--------------------------------------------------------------------------------
/src/old/fig/poisson0_paraview.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/poisson0_paraview.pdf
--------------------------------------------------------------------------------
/src/old/fig/poisson0_paraview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/poisson0_paraview.png
--------------------------------------------------------------------------------
/src/old/fig/poisson_fsin.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/poisson_fsin.pdf
--------------------------------------------------------------------------------
/src/old/fig/poisson_fsin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/poisson_fsin.png
--------------------------------------------------------------------------------
/src/old/fig/poisson_vc_structmesh.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/poisson_vc_structmesh.pdf
--------------------------------------------------------------------------------
/src/old/fig/poisson_vc_structmesh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/poisson_vc_structmesh.png
--------------------------------------------------------------------------------
/src/old/fig/reaction_system_u1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/reaction_system_u1.png
--------------------------------------------------------------------------------
/src/old/fig/reaction_system_u2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/reaction_system_u2.png
--------------------------------------------------------------------------------
/src/old/fig/reaction_system_u3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/reaction_system_u3.png
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer1.pdf
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer1.png
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer1.py:
--------------------------------------------------------------------------------
1 | """Heat conduction problems."""
2 |
3 | from pysketcher import *
4 |
5 | drawing_tool.set_coordinate_system(
6 | xmin=-0.5, xmax=1.5, ymin=-0.5, ymax=1.5, axis=False)
7 |
8 | drawing_tool.set_linecolor('black')
9 |
10 | domain = Rectangle((0,0), 1, 1)
11 | subdomain = Rectangle((0.3, 0.3), 0.4, 0.4)
12 | text1 = Text('$u=1$', (-0.2,0.5), alignment='left')
13 | text2 = Text('$u=0$', (1.2,0.5), alignment='right')
14 | text3 = Text(r'$\partial u/\partial n=0$', (0.5, 1.05), alignment='center')
15 | text4 = Text(r'$\partial u/\partial n=0$', (0.5, -0.1), alignment='center')
16 |
17 | fig1 = Composition({
18 | 'domain': domain,
19 | 'x=0': text1, 'x=1': text2, 'y=1': text3, 'y=0': text4,
20 | })
21 |
22 | fig1.draw()
23 | drawing_tool.display()
24 | drawing_tool.savefig('tmp1')
25 |
26 | drawing_tool.erase()
27 | fig1['subdomain'] = subdomain
28 | fig1['x=1'] = Text(r'$\partial u/\partial n = 0$',
29 | (1.3,0.5), alignment='right')
30 |
31 | fig1.draw()
32 | drawing_tool.savefig('tmp2')
33 |
34 | raw_input()
35 |
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer1_BE20.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer1_BE20.pdf
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer1_BE20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer1_BE20.png
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer1_CN20.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer1_CN20.pdf
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer1_CN20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer1_CN20.png
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer1_sketch.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer1_sketch.pdf
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer1_sketch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer1_sketch.png
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer2_CN20.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer2_CN20.pdf
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer2_CN20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer2_CN20.png
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer2_sketch.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer2_sketch.pdf
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer2_sketch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer2_sketch.png
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer3.py:
--------------------------------------------------------------------------------
1 | """Heat conduction problems."""
2 |
3 | from pysketcher import *
4 |
5 | drawing_tool.set_coordinate_system(
6 | xmin=-0.3, xmax=1.5, ymin=-0.5, ymax=1.3, axis=False)
7 |
8 | drawing_tool.set_linecolor('black')
9 |
10 | text1 = Text(r'$u=U_s + A\sin wt$', (0.5,1.05), alignment='center')
11 | text2 = Text(r'$\frac{\partial u}{\partial n}=0$', (-0.17, 0.5), alignment='left')
12 | text3 = Text(r'$\frac{\partial u}{\partial n}=0$', (1.1, 0.5), alignment='left')
13 | text4 = Text(r'$\frac{\partial u}{\partial n}=0$', (0.5, -0.1), alignment='center')
14 |
15 | import numpy as np
16 | x = np.linspace(-0.1, 1.1, 101)
17 | y = 1.15 + 0.025*np.sin(2*np.pi/0.2*x)
18 |
19 | fig1 = Composition({
20 | 'domain': Rectangle((0,0), 1, 1),
21 | 'subdomain': Rectangle((0.3, 0.3), 0.4, 0.4),
22 | 'y=1': text1, 'x=0': text2, 'x=1': text3, 'y=0': text4,
23 | 'sine': Curve(x,y),
24 | })
25 |
26 | fig1.draw()
27 | drawing_tool.savefig('tmp3')
28 |
29 | fig1['subdomain'] = Rectangle((0.3,0.5), 0.4, 0.4)
30 | fig1['y=1'] = Text(r'$u= \sin 2t$', (0.5,1.05), alignment='center')
31 | drawing_tool.erase()
32 | fig1.draw()
33 | drawing_tool.savefig('tmp4')
34 |
35 |
36 | """
37 | text1 = Text(r'$u= \sin 2t$', (0.08,1.05), alignment='center')
38 | text2 = Text(r'$\frac{\partial u}{\partial n}=0$', (-0.2, 0.5), alignment='left')
39 | text3 = Text(r'$\frac{\partial u}{\partial n}=0$', (0.2, 0.5), alignment='left')
40 | text4 = Text(r'$\frac{\partial u}{\partial n}=0$', (0.08, -0.1), alignment='center')
41 |
42 | x = np.linspace(-0.1, 0.167+0.1, 101)
43 | y = 1.15 + 0.025*np.sin(2*np.pi/0.1*x)
44 |
45 | fig2 = Composition({
46 | 'domain': Rectangle((0,0), 0.167, 1),
47 | 'subdomain': Rectangle((0.3*0.167, 0.3), 0.4*0.167, 0.4),
48 | 'x=0': text1, 'x=1': text2, 'y=1': text3, 'y=0': text4,
49 | 'sine': Curve(x,y),
50 | })
51 | """
52 |
53 | raw_input()
54 |
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer3_CN20.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer3_CN20.pdf
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer3_CN20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer3_CN20.png
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer3_scaling_sketch.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer3_scaling_sketch.pdf
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer3_scaling_sketch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer3_scaling_sketch.png
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer3_sketch.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer3_sketch.pdf
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer3_sketch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer3_sketch.png
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer4.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer4.pdf
--------------------------------------------------------------------------------
/src/old/fig/thermal_layer4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/thermal_layer4.png
--------------------------------------------------------------------------------
/src/old/fig/two_domains.fig:
--------------------------------------------------------------------------------
1 | #FIG 3.2 Produced by xfig version 3.2.5
2 | Landscape
3 | Center
4 | Metric
5 | A4
6 | 100.00
7 | Single
8 | -2
9 | 1200 2
10 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
11 | 0 0 1.00 60.00 120.00
12 | 900 6795 900 1350
13 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
14 | 0 0 1.00 60.00 120.00
15 | 900 6750 6525 6750
16 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
17 | 900 2925 4725 2925 4725 6750
18 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
19 | 900 4860 4725 4860
20 | 4 0 0 50 -1 0 24 0.0000 0 195 210 6300 7065 x\001
21 | 4 0 0 50 -1 0 24 0.0000 0 300 180 585 1440 y\001
22 | 4 0 0 50 -1 0 24 0.0000 0 345 1335 2250 7200 du/dn=0\001
23 | 4 0 0 50 -1 0 24 0.0000 0 345 1335 2250 2700 du/dn=0\001
24 | 4 0 0 50 -1 0 24 0.0000 0 270 810 2430 4050 Om1\001
25 | 4 0 0 50 -1 0 24 0.0000 0 270 810 2475 6030 Om0\001
26 | 4 0 0 50 -1 0 24 0.0000 0 270 615 180 4995 u=0\001
27 | 4 0 0 50 -1 0 24 0.0000 0 270 615 4860 4950 u=1\001
28 |
--------------------------------------------------------------------------------
/src/old/fig/two_domains.latex:
--------------------------------------------------------------------------------
1 | \setlength{\unitlength}{4144sp}%
2 | %
3 | \begingroup\makeatletter\ifx\SetFigFontNFSS\undefined%
4 | \gdef\SetFigFontNFSS#1#2#3#4#5{%
5 | \reset@font\fontsize{#1}{#2pt}%
6 | \fontfamily{#3}\fontseries{#4}\fontshape{#5}%
7 | \selectfont}%
8 | \fi\endgroup%
9 | \begin{picture}(6372,6030)(166,-6376)
10 | \thinlines
11 | {\color[rgb]{0,0,0}\put(901,-5956){\vector( 0, 1){5445}}
12 | }%
13 | {\color[rgb]{0,0,0}\put(901,-5911){\vector( 1, 0){5625}}
14 | }%
15 | {\color[rgb]{0,0,0}\put(901,-2086){\line( 1, 0){3825}}
16 | \put(4726,-2086){\line( 0,-1){3825}}
17 | }%
18 | {\color[rgb]{0,0,0}\put(901,-4021){\line( 1, 0){3825}}
19 | }%
20 | \put(6301,-6226){\makebox(0,0)[lb]{\smash{{\SetFigFontNFSS{20}{24.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}x}%
21 | }}}}
22 | \put(586,-601){\makebox(0,0)[lb]{\smash{{\SetFigFontNFSS{20}{24.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}y}%
23 | }}}}
24 | \put(2251,-6361){\makebox(0,0)[lb]{\smash{{\SetFigFontNFSS{20}{24.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}du/dn=0}%
25 | }}}}
26 | \put(2251,-1861){\makebox(0,0)[lb]{\smash{{\SetFigFontNFSS{20}{24.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}du/dn=0}%
27 | }}}}
28 | \put(2431,-3211){\makebox(0,0)[lb]{\smash{{\SetFigFontNFSS{20}{24.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}Om1}%
29 | }}}}
30 | \put(2476,-5191){\makebox(0,0)[lb]{\smash{{\SetFigFontNFSS{20}{24.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}Om0}%
31 | }}}}
32 | \put(181,-4156){\makebox(0,0)[lb]{\smash{{\SetFigFontNFSS{20}{24.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}u=0}%
33 | }}}}
34 | \put(4861,-4111){\makebox(0,0)[lb]{\smash{{\SetFigFontNFSS{20}{24.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}u=1}%
35 | }}}}
36 | \end{picture}%
37 |
--------------------------------------------------------------------------------
/src/old/fig/welding3D.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/welding3D.pdf
--------------------------------------------------------------------------------
/src/old/fig/welding3D.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/welding3D.png
--------------------------------------------------------------------------------
/src/old/fig/welding_gamma2000_temp.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/welding_gamma2000_temp.pdf
--------------------------------------------------------------------------------
/src/old/fig/welding_gamma2000_temp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/fig/welding_gamma2000_temp.png
--------------------------------------------------------------------------------
/src/old/mov/diffusion0.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/diffusion0.ogg
--------------------------------------------------------------------------------
/src/old/mov/thermal_layer1/movie.flv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/thermal_layer1/movie.flv
--------------------------------------------------------------------------------
/src/old/mov/thermal_layer1/movie.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/thermal_layer1/movie.mp4
--------------------------------------------------------------------------------
/src/old/mov/thermal_layer1/movie.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/thermal_layer1/movie.ogg
--------------------------------------------------------------------------------
/src/old/mov/thermal_layer1/movie.webm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/thermal_layer1/movie.webm
--------------------------------------------------------------------------------
/src/old/mov/thermal_layer2/movie.flv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/thermal_layer2/movie.flv
--------------------------------------------------------------------------------
/src/old/mov/thermal_layer2/movie.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/thermal_layer2/movie.mp4
--------------------------------------------------------------------------------
/src/old/mov/thermal_layer2/movie.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/thermal_layer2/movie.ogg
--------------------------------------------------------------------------------
/src/old/mov/thermal_layer2/movie.webm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/thermal_layer2/movie.webm
--------------------------------------------------------------------------------
/src/old/mov/thermal_layer3/movie.flv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/thermal_layer3/movie.flv
--------------------------------------------------------------------------------
/src/old/mov/thermal_layer3/movie.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/thermal_layer3/movie.mp4
--------------------------------------------------------------------------------
/src/old/mov/thermal_layer3/movie.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/thermal_layer3/movie.ogg
--------------------------------------------------------------------------------
/src/old/mov/thermal_layer3/movie.webm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/thermal_layer3/movie.webm
--------------------------------------------------------------------------------
/src/old/mov/thermal_layer3/paraview.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/thermal_layer3/paraview.ogg
--------------------------------------------------------------------------------
/src/old/mov/thermal_layer4/movie.flv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/thermal_layer4/movie.flv
--------------------------------------------------------------------------------
/src/old/mov/thermal_layer4/movie.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/thermal_layer4/movie.mp4
--------------------------------------------------------------------------------
/src/old/mov/thermal_layer4/movie.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/thermal_layer4/movie.ogg
--------------------------------------------------------------------------------
/src/old/mov/thermal_layer4/movie.webm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/thermal_layer4/movie.webm
--------------------------------------------------------------------------------
/src/old/mov/welding/welding_gamma01_3D.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/welding/welding_gamma01_3D.ogg
--------------------------------------------------------------------------------
/src/old/mov/welding/welding_gamma1_2D.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/welding/welding_gamma1_2D.ogg
--------------------------------------------------------------------------------
/src/old/mov/welding/welding_gamma1_3D.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/welding/welding_gamma1_3D.ogg
--------------------------------------------------------------------------------
/src/old/mov/welding/welding_gamma2000_3D.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/welding/welding_gamma2000_3D.ogg
--------------------------------------------------------------------------------
/src/old/mov/welding/welding_gamma30_3D.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/old/mov/welding/welding_gamma30_3D.ogg
--------------------------------------------------------------------------------
/src/scripts/clean.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #rm -f automake_sphinx.py # not used here, see make.sh
3 | doconce clean
4 | rm -rf ftut*.pdf fenics_tutorial*.pdf automake* papers.bib newcommands.tex
5 |
--------------------------------------------------------------------------------
/src/scripts/install.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # This script installs all required packages for building the book.
4 |
5 | sudo apt-get update
6 |
7 | # Install basic packages
8 | sudo apt-get install \
9 | git mercurial texlive texlive-latex-extra ispell
10 |
11 | # Install Chinese LaTeX
12 | sudo apt-get install texlive-lang-chinese
13 |
14 | # Install standard Python packages
15 | sudo apt-get install \
16 | python-future python-mako python-lxml python-sphinx python-pip ipython
17 |
18 | # Install extra Python packages
19 | sudo pip2 install git+https://github.com/hplgit/doconce.git
20 | sudo pip2 install git+https://github.com/hplgit/preprocess.git
21 | sudo pip2 install hg+https://bitbucket.org/logg/publish
22 | sudo pip2 install python-Levenshtein
23 |
--------------------------------------------------------------------------------
/src/scripts/make_notebooks.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -x
3 |
4 | function system {
5 | "$@"
6 | if [ $? -ne 0 ]; then
7 | echo "make.sh: unsuccessful command $@"
8 | echo "abort!"
9 | exit 1
10 | fi
11 | }
12 |
13 | EXV=True
14 |
15 | system preprocess -DFORMAT=html newcommands.p.tex > newcommands.tex
16 | filenames='poisson0 membrane0 diffusion0'
17 | for filename in $filenames; do
18 | doconce format ipynb $filename --encoding=utf-8 EXV=$EXV
19 | done
20 |
21 | # Publish in doc/pub
22 | dest=../pub
23 | cp *.ipynb $dest
24 |
--------------------------------------------------------------------------------
/src/scripts/number_src_files.py:
--------------------------------------------------------------------------------
1 | """Copy src files with logical names to numbered src files.
2 | The files are published in the directory ../pub/python.
3 | """
4 |
5 | # Note the following issues:
6 | #
7 | # 1. Running this script requires tmp_preprocess__ftut1.do.txt, which
8 | # in turn requires building the book, which in turn requires
9 | # mako_code.txt, which should be generated by this script... :-)
10 | # So some bootstrapping is needed. Add lines 'foo': 'bar') manually
11 | # to make_code.txt, then build the book, then run this script and
12 | # udpate mako_code.txt.
13 | #
14 | # 2. The source files are only copied to pub when running this script
15 | # and it is not integrated with the build system.
16 |
17 | import commands, re
18 |
19 | # Find all references to Python programs
20 | cmd = r"""grep -o -h -E 'prog\[".*?"\]' tmp_preprocess__ftut1.do.txt"""
21 | status, output = commands.getstatusoutput(cmd)
22 |
23 | # Extract filenames from references
24 | filenames = []
25 | for line in output.splitlines():
26 | names = re.findall(r'prog\["(.*?)"\]', line)
27 | print names
28 | [filenames.append(f) for f in names if f not in filenames]
29 |
30 | print filenames
31 |
32 | # Generate mapping from logical to numbered filenames
33 | counter = 1
34 | prog = []
35 | for filename in filenames:
36 | new_filename = 'ft%02d_%s' % (counter, filename)
37 | print filename, '-->', new_filename
38 | counter += 1
39 | prog.append((filename, new_filename))
40 |
41 | # Copy source files
42 | for filename, new_filename in prog:
43 | cmd = 'cp vol1/python/%s.py ../pub/python/vol1/%s.py' % (filename, new_filename)
44 | status, output = commands.getstatusoutput(cmd)
45 |
46 | # Write prog to mako_code.txt
47 | print
48 | print 'Stick this into mako_code.txt:'
49 | print
50 | rows = []
51 | for (filename, new_filename) in prog:
52 | rows.append("'%s': '%s'" % (filename, new_filename))
53 | print 'prog = {'
54 | print ',\n'.join(rows)
55 | print '}'
56 |
--------------------------------------------------------------------------------
/src/scripts/publish.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | rsync -avz --delete ../pub/ fenics-web@fenicsproject.org:/home/fenics-web/pub/tutorial/
4 |
--------------------------------------------------------------------------------
/src/scripts/rsync_git.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """
3 | Sync two directory trees with rsync and perform corresponding
4 | git operations (add or rm).
5 | Skip files listed in $HOME/1/.rsyncexclude.
6 |
7 | Usage: rsync_git.py from-dir to-dir
8 | Example: rsync_git.py src-mychap $HOME/repos/pub/mybook/src/mychap
9 |
10 | The from-dir is the source and the to-dir is the destination
11 | (e.g. a public directory where resources are exposed).
12 | The script must be run from a dir within the repo of to-dir.
13 | """
14 |
15 | # Typical rsync output:
16 | """
17 | sending incremental file list
18 | deleting decay7.py
19 | decay_TULL.py
20 |
21 | sent 675 bytes received 34 bytes 1418.00 bytes/sec
22 | total size is 94788 speedup is 133.69
23 | """
24 |
25 | import commands, os, sys
26 |
27 | from_ = sys.argv[1]
28 | to_ = sys.argv[2]
29 | cmd = 'rsync -rtDvz -u -e ssh -b --exclude-from=$HOME/1/.rsyncexclude --suffix=.rsync~ --delete --force %s/ %s' % (from_, to_)
30 | print cmd
31 | failure, output = commands.getstatusoutput(cmd)
32 | print output
33 |
34 | delete = []
35 | add = []
36 | for line in output.splitlines():
37 | relevant_line = True
38 | for text in 'sending incremental file list', \
39 | 'sent ', 'total size is':
40 | if line.startswith(text):
41 | relevant_line = False
42 | if relevant_line and line != '':
43 | if line.startswith('deleting'):
44 | delete.append(line.split()[1])
45 | else:
46 | add.append(line.strip())
47 |
48 | print delete
49 | print add
50 |
51 | for filename in delete:
52 | option = '-rf' if os.path.isdir('%s/%s' % (to_, filename)) else '-f'
53 | cmd = 'git rm %s %s/%s' % (option, to_, filename)
54 | print cmd
55 | os.system(cmd)
56 | for filename in add:
57 | cmd = 'git add %s/%s' % (to_, filename)
58 | print cmd
59 | os.system(cmd)
60 |
--------------------------------------------------------------------------------
/src/src/clean.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | rm -rf *.vtu *.pvd *.pdf *.png *.pyc __pycache__ tmp* *~ *.mat Results*
3 |
--------------------------------------------------------------------------------
/src/src/concentric_cylinders.py:
--------------------------------------------------------------------------------
1 | from dolfin import *
2 | import mshr
3 |
4 | # Parameters for geometry
5 | a = 0.04
6 | b = a + 0.004
7 | c = a + 0.01
8 | L = 0.5
9 |
10 | # Define cylinders
11 | inner = mshr.CSGCGALDomain3D(mshr.Cylinder(Point(0, 0, 0), Point(0, 0, L), a, a))
12 | mid = mshr.CSGCGALDomain3D(mshr.Cylinder(Point(0, 0, 0), Point(0, 0, L), b, b))
13 | outer = mshr.CSGCGALDomain3D(mshr.Cylinder(Point(0, 0, 0), Point(0, 0, L), c, c))
14 |
15 | generator = mshr.TetgenMeshGenerator3D()
16 | generator.parameters["preserve_surface"] = True
17 | generator.parameters["mesh_resolution"] = 16.
18 |
19 | # Mesh inner cylinder
20 | inner_mesh = generator.generate(inner)
21 |
22 |
23 | # Mesh mid part
24 | mid_mesh = generator.generate(mshr.CSGCGALDomain3D(mid-inner))
25 |
26 | # Mesh outer part
27 | outer_mesh = generator.generate(mshr.CSGCGALDomain3D(outer-mid))
28 |
29 | # Glue together inner and mid mesh
30 | inner_mid_mesh = mshr.DolfinMeshUtils.merge_meshes(inner_mesh, mid_mesh)
31 |
32 | # Glue outer and inner/mid
33 | the_entire_domain = mshr.DolfinMeshUtils.merge_meshes(inner_mid_mesh, outer_mesh)
34 |
35 | # Save to file
36 | File('pipe_mesh.pvd') << the_entire_domain
37 |
38 | plot(the_entire_domain, interactive=True)
39 |
--------------------------------------------------------------------------------
/src/src/convection_diffusion.py:
--------------------------------------------------------------------------------
1 | """
2 | FEniCS tutorial demo program: Convection-diffusion in a cylinder
3 | with particular focus on mesh generation, subdomains and boundary
4 | conditions.
5 |
6 | -div(lmbda*grad(u)) + div(c*beta*u) = f
7 | """
8 |
9 | from __future__ import print_function
10 | from fenics import *
11 | from mshr import *
12 |
13 | # Parameters for geometry
14 | a = 0.04
15 | b = a + 0.004
16 | c = a + 0.01
17 | L = 0.5
18 |
19 | # Define cylinders
20 | cylinder_a = Cylinder(Point(0, 0, 0), Point(0, 0, L), a, a)
21 | cylinder_b = Cylinder(Point(0, 0, 0), Point(0, 0, L), b, b)
22 | cylinder_c = Cylinder(Point(0, 0, 0), Point(0, 0, L), c, c)
23 |
24 | # Define domain and set subdomains
25 | domain = cylinder_c
26 | domain.set_subdomain(1, cylinder_b)
27 | domain.set_subdomain(2, cylinder_a)
28 |
29 | # Generate mesh
30 | mesh = generate_mesh(domain, 16)
31 |
32 | xmlfile = File('pipe.xml')
33 | xmlfile << mesh
34 |
35 | vtkfile = File('pipe.pvd')
36 | vtkfile << mesh
37 |
--------------------------------------------------------------------------------
/src/src/gui/clean.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Clean up files that can be regenerated
3 | rm -rf uploads/ templates/ static/ controller.py model.py *.pyc *~ clean.sh
--------------------------------------------------------------------------------
/src/src/gui/noweb/controller_noweb.py:
--------------------------------------------------------------------------------
1 | import os
2 | from compute_noweb import compute_noweb as compute_function # changed
3 |
4 | # Pool object (must be imported before model)
5 | from compute_noweb import define_pool as pool_function
6 | pool = pool_function()
7 |
8 | # Can define other default values in a file: --poolfile name
9 | from parampool.pool.UI import set_defaults_from_file
10 | pool = set_defaults_from_file(pool)
11 | # Can override default values on the command line
12 | from parampool.pool.UI import set_values_from_command_line
13 | pool = set_values_from_command_line(pool)
14 |
15 | # Removed everything with Flask
16 |
17 | def compute(pool):
18 | """
19 | Generic function for calling compute_function with values
20 | taken from the pool object.
21 | Return the output from the compute_function.
22 | """
23 |
24 | # compute_function must have only one positional argument
25 | # named pool
26 | import inspect
27 | arg_names = inspect.getargspec(compute_function).args
28 | if len(arg_names) == 1 and arg_names[0] == "pool":
29 | result = compute_function(pool)
30 | else:
31 | raise TypeError('%s(%s) can only have one argument named "pool"'
32 | % (compute_function.__name__, ', '.join(arg_names)))
33 | return result
34 |
35 | if __name__ == '__main__':
36 | result = compute_function(pool) # Add
37 |
38 | # Dump pool to file for use with --poolfile .tmp_pool.dat
39 | from parampool.pool.UI import write_poolfile
40 | write_poolfile(pool, '.tmp_pool.dat')
41 |
--------------------------------------------------------------------------------
/src/src/gui/web/controller.py:
--------------------------------------------------------------------------------
1 | import os
2 | from compute import compute as compute_function
3 |
4 | # Pool object (must be imported before model)
5 | from compute import define_pool as pool_function
6 | pool = pool_function()
7 |
8 | # Can define other default values in a file: --poolfile name
9 | from parampool.pool.UI import set_defaults_from_file
10 | pool = set_defaults_from_file(pool)
11 | # Can override default values on the command line
12 | from parampool.pool.UI import set_values_from_command_line
13 | pool = set_values_from_command_line(pool)
14 |
15 | from flask import Flask, render_template, request
16 | from model import Compute
17 |
18 | # Application object
19 | app = Flask(__name__)
20 |
21 | # Path to the web application
22 | @app.route('/', methods=['GET', 'POST'])
23 | def index():
24 | form = Compute(request.form)
25 | if request.method == 'POST': # and form.validate():
26 |
27 | # Send data to Pool object
28 | for field in form:
29 | if field.name not in request.files:
30 | name = field.description
31 | value = field.data
32 | data_item = pool.set_value(name, value)
33 |
34 | result = compute(pool)
35 |
36 | else:
37 | result = None
38 |
39 | return render_template("view.html", form=form, result=result)
40 |
41 |
42 | def compute(pool):
43 | """
44 | Generic function for calling compute_function with values
45 | taken from the pool object.
46 | Return the output from the compute_function.
47 | """
48 |
49 | # compute_function must have only one positional argument
50 | # named pool
51 | import inspect
52 | arg_names = inspect.getargspec(compute_function).args
53 | if len(arg_names) == 1 and arg_names[0] == "pool":
54 | result = compute_function(pool)
55 | else:
56 | raise TypeError('%s(%s) can only have one argument named "pool"'
57 | % (compute_function.__name__, ', '.join(arg_names)))
58 | return result
59 |
60 | if __name__ == '__main__':
61 | app.run(debug=True)
62 |
63 | # Dump pool to file for use with --poolfile .tmp_pool.dat
64 | from parampool.pool.UI import write_poolfile
65 | write_poolfile(pool, '.tmp_pool.dat')
66 |
--------------------------------------------------------------------------------
/src/src/gui/web/generate.py:
--------------------------------------------------------------------------------
1 | from parampool.generator.flask import generate
2 | from compute import compute, define_pool
3 |
4 | generate(compute, pool_function=define_pool, MathJax=True)
5 |
--------------------------------------------------------------------------------
/src/src/gui/web/static/dtree.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/dtree.css
--------------------------------------------------------------------------------
/src/src/gui/web/static/dtree.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/dtree.js
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/base.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/base.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/cd.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/cd.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/empty.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/empty.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/folder.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/folder.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/folderopen.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/folderopen.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/globe.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/globe.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/imgfolder.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/imgfolder.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/join.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/join.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/joinbottom.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/joinbottom.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/line.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/line.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/minus.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/minus.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/minusbottom.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/minusbottom.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/musicfolder.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/musicfolder.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/nolines_minus.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/nolines_minus.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/nolines_plus.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/nolines_plus.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/page.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/page.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/plus.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/plus.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/plusbottom.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/plusbottom.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/question.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/question.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/img/trash.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/img/trash.gif
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/Nx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/Nx.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/Ny.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/Ny.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/allow_extrapolation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/allow_extrapolation.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/dof_ordering_library.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/dof_ordering_library.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/cache_dir.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/cache_dir.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/convert_exceptions_to_warnings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/convert_exceptions_to_warnings.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/cpp_optimize.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/cpp_optimize.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/cpp_optimize_flags.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/cpp_optimize_flags.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/epsilon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/epsilon.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/error_control.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/error_control.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/form_postfix.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/form_postfix.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/format.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/format.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/log_level.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/log_level.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/log_prefix.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/log_prefix.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/name.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/name.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/no-evaluate_basis_derivatives.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/no-evaluate_basis_derivatives.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/optimize.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/optimize.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/output_dir.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/output_dir.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/precision.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/precision.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/quadrature_degree.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/quadrature_degree.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/quadrature_rule.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/quadrature_rule.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/representation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/representation.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/restrict_keyword.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/restrict_keyword.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/split.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/form_compiler/split.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/ghost_mode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/ghost_mode.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/graph_coloring_library.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/graph_coloring_library.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/absolute_tolerance.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/absolute_tolerance.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/divergence_limit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/divergence_limit.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/error_on_nonconvergence.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/error_on_nonconvergence.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/gmres/restart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/gmres/restart.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/maximum_iterations.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/maximum_iterations.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/monitor_convergence.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/monitor_convergence.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/nonzero_initial_guess.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/nonzero_initial_guess.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/preconditioner/ilu/fill_level.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/preconditioner/ilu/fill_level.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/preconditioner/report.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/preconditioner/report.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/preconditioner/schwarz/overlap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/preconditioner/schwarz/overlap.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/preconditioner/shift_nonzero.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/preconditioner/shift_nonzero.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/preconditioner/structure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/preconditioner/structure.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/relative_tolerance.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/relative_tolerance.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/report.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/krylov_solver/report.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/linear_algebra_backend.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/linear_algebra_backend.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/lu_solver/report.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/lu_solver/report.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/lu_solver/reuse_factorization.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/lu_solver/reuse_factorization.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/lu_solver/same_nonzero_pattern.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/lu_solver/same_nonzero_pattern.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/lu_solver/symmetric.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/lu_solver/symmetric.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/lu_solver/verbose.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/lu_solver/verbose.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/mesh_partitioner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/mesh_partitioner.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/num_threads.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/num_threads.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/partitioning_approach.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/partitioning_approach.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/print_mpi_thread_support_level.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/print_mpi_thread_support_level.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/refinement_algorithm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/refinement_algorithm.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/relative_line_width.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/relative_line_width.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/reorder_cells_gps.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/reorder_cells_gps.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/reorder_dofs_serial.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/reorder_dofs_serial.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/reorder_vertices_gps.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/reorder_vertices_gps.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/std_out_all_processes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/std_out_all_processes.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/timer_prefix.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/timer_prefix.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/use_petsc_signal_handler.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/use_petsc_signal_handler.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/dolfin/warn_on_xml_file_size.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/dolfin/warn_on_xml_file_size.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/element_degree.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/element_degree.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/f.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/f.png
--------------------------------------------------------------------------------
/src/src/gui/web/static/latex/Main_menu/u0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hplgit/fenics-tutorial/bf8120cb448f244df18871ee305f4b9c463896cf/src/src/gui/web/static/latex/Main_menu/u0.png
--------------------------------------------------------------------------------
/src/src/heat2.py:
--------------------------------------------------------------------------------
1 | """
2 | FEniCS tutorial demo program: Diffusion equation with Dirichlet
3 | conditions and a solution that will be exact at all nodes on
4 | a uniform mesh.
5 | Difference from heat.py: A (coeff.matrix) is assembled
6 | only once.
7 | """
8 |
9 | from __future__ import print_function
10 | from fenics import *
11 | import numpy as np
12 |
13 | # Create mesh and define function space
14 | nx = ny = 4
15 | mesh = UnitSquareMesh(nx, ny)
16 | V = FunctionSpace(mesh, 'P', 1)
17 |
18 | # Define boundary conditions
19 | alpha = 3; beta = 1.2
20 | u0 = Expression('1 + x[0]*x[0] + alpha*x[1]*x[1] + beta*t',
21 | alpha=alpha, beta=beta, t=0)
22 |
23 | def boundary(x, on_boundary):
24 | return on_boundary
25 |
26 | bc = DirichletBC(V, u0, boundary)
27 |
28 | # Initial condition
29 | u_1 = interpolate(u0, V)
30 | #project(u0, V) # will not result in exact solution at the nodes!
31 |
32 | dt = 0.3 # time step
33 |
34 | # Define variational problem
35 | u = TrialFunction(V)
36 | v = TestFunction(V)
37 | f = Constant(beta - 2 - 2*alpha)
38 | a = u*v*dx + dt*dot(grad(u), grad(v))*dx
39 | L = (u_1 + dt*f)*v*dx
40 |
41 | A = assemble(a) # assemble only once, before the time stepping
42 | b = None # necessary for memory saving assemeble call
43 |
44 | # Compute solution
45 | u = Function(V) # the unknown at a new time level
46 | T = 1.9 # total simulation time
47 | t = dt
48 | while t <= T:
49 | print('time =', t)
50 | b = assemble(L, tensor=b)
51 | u0.t = t
52 | bc.apply(A, b)
53 | solve(A, u.vector(), b)
54 |
55 | # Verify
56 | u_e = interpolate(u0, V)
57 | error = np.abs(u_e.vector().array() -
58 | u.vector().array()).max()
59 | print('error, t=%.2f: %-10.3g' % (t, error))
60 |
61 | t += dt
62 | u_1.assign(u)
63 |
--------------------------------------------------------------------------------
/src/src/make_moviefiles.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -x
3 | if [ $# -ge 1 ]; then
4 | name=$1
5 | else
6 | name="tmp_%04d.png"
7 | fi
8 | if [ $# -ge 2 ]; then
9 | fps=$2
10 | else
11 | fps=25
12 | fi
13 | prog=ffmpeg
14 |
15 | # Make movies in modern web friendly formats
16 | rm -f movie.flv movie.mp4 movie.webm movie.ogg
17 | $prog -i $name -r $fps -vcodec flv movie.flv
18 | $prog -i $name -r $fps -vcodec libx264 movie.mp4
19 | $prog -i $name -r $fps -vcodec libvpx movie.webm
20 | $prog -i $name -r $fps -vcodec libtheora movie.ogg
21 |
--------------------------------------------------------------------------------
/src/src/modules/setup.py:
--------------------------------------------------------------------------------
1 | from distutils.core import setup
2 | name = 'BoxField'
3 | setup(name=name,
4 | version='1.0',
5 | author='Hans Petter Langtangen ',
6 | py_modules=[name],
7 | #scripts=[name + '.py'],
8 | )
9 |
--------------------------------------------------------------------------------
/src/vol1/fundamentals.do.txt:
--------------------------------------------------------------------------------
1 | ========= Fundamentals: Solving the Poisson equation =========
2 | label{ch:fundamentals}
3 |
4 | !bquote
5 | The goal of this chapter is to show how the Poisson equation, the
6 | most basic of all PDEs, can be quickly solved with a few lines
7 | of FEniCS code. We introduce the most
8 | fundamental FEniCS objects such as `Mesh`, `Function`,
9 | `FunctionSpace`, `TrialFunction`,
10 | and `TestFunction`, and learn how to write a basic PDE solver,
11 | including how to formulate the mathematical variational problem,
12 | apply boundary conditions, call the FEniCS solver, and plot
13 | the solution.
14 | !equote
15 |
16 | # #include "fundamentals_poisson.do.txt"
17 |
18 | !split
19 | # #include "fundamentals_membrane.do.txt"
20 |
--------------------------------------------------------------------------------
/src/vol1/gallery.do.txt:
--------------------------------------------------------------------------------
1 | ========= A Gallery of finite element solvers =========
2 | label{ch:gallery}
3 |
4 | !bquote
5 | The goal of this chapter is to demonstrate how a range of important
6 | PDEs from science and engineering can be quickly solved with a few
7 | lines of FEniCS code. We start with the heat equation and continue
8 | with a nonlinear Poisson equation, the equations for linear
9 | elasticity, the Navier--Stokes equations, and finally look at how to
10 | solve systems of nonlinear advection--diffusion--reaction
11 | equations. These problems illustrate how to solve time-dependent
12 | problems, nonlinear problems, vector-valued problems, and systems of
13 | PDEs. For each problem, we derive the variational formulation and
14 | express the problem in Python in a way that closely resembles the
15 | mathematics.
16 | !equote
17 |
18 | # #include "gallery_heat_equation.do.txt"
19 |
20 | !split
21 | # #include "gallery_nlpoisson.do.txt"
22 |
23 | !split
24 | # #include "gallery_elasticity.do.txt"
25 |
26 | !split
27 | # #include "gallery_navier_stokes.do.txt"
28 |
29 | !split
30 | # #include "gallery_reaction_system.do.txt"
31 |
--------------------------------------------------------------------------------
/src/vol1/preface.do.txt:
--------------------------------------------------------------------------------
1 | ========= Preface =========
2 |
3 | This book gives a concise and gentle introduction to finite element
4 | programming in Python based on the popular FEniCS software library.
5 | FEniCS can be programmed in both C++ and Python, but this tutorial
6 | focuses exclusively on Python programming, since this is the simplest
7 | and most effective approach for beginners. After having digested the
8 | examples in this tutorial, the reader should be able to learn more
9 | from the FEniCS documentation, the numerous demo programs that come
10 | with the software, and the comprehensive FEniCS book *Automated
11 | Solution of Differential Equations by the Finite Element Method*
12 | cite{FEniCS}. This tutorial is a further development of the opening
13 | chapter in cite{FEniCS}.
14 |
15 | We thank Johan Hake, Kent-Andre Mardal, and Kristian Valen-Sendstad
16 | for many helpful discussions during the preparation of the first
17 | version of this tutorial for the FEniCS book cite{FEniCS}. We are
18 | particularly thankful to Professor Douglas Arnold for very valuable
19 | feedback on early versions of the text. Øystein Sørensen pointed out
20 | numerous typos and contributed with many helpful comments. Many errors
21 | and typos were also reported by Mauricio Angeles, Ida Drøsdal,
22 | Miroslav Kuchta, Hans Ekkehard Plesser, Marie Rognes, Hans Joachim
23 | Scroll, Glenn Terje Lines, Simon Funke, Matthew Moelter, and Magne
24 | Nordaas. Ekkehard Ellmann as well as two anonymous reviewers provided
25 | a series of suggestions and improvements. Special thanks go to
26 | Benjamin Kehlet for all his work with the `mshr` tool and for quickly
27 | implementing our requests for this tutorial.
28 |
29 | Comments and corrections can be reported as *issues* for the
30 | "Git repository of this book":
31 | "https://github.com/hplgit/fenics-tutorial/",
32 | or via email
33 | to `logg@chalmers.se`.
34 |
35 | # #if FORMAT in ("latex", "pdflatex")
36 | \vspace{1cm}
37 |
38 | \noindent
39 | {\it Oslo and Smögen, November 2016} \hfill {\it Hans Petter Langtangen, Anders Logg}
40 | # #endif
41 |
--------------------------------------------------------------------------------
/src/vol1/python/elasticity.py:
--------------------------------------------------------------------------------
1 | """
2 | FEniCS tutorial demo program: Linear elastic problem.
3 |
4 | -div(sigma(u)) = f
5 |
6 | The model is used to simulate an elastic beam clamped at
7 | its left end and deformed under its own weight.
8 | """
9 |
10 | from __future__ import print_function
11 | from fenics import *
12 |
13 | # Scaled variables
14 | L = 1; W = 0.2
15 | mu = 1
16 | rho = 1
17 | delta = W/L
18 | gamma = 0.4*delta**2
19 | beta = 1.25
20 | lambda_ = beta
21 | g = gamma
22 |
23 | # Create mesh and define function space
24 | mesh = BoxMesh(Point(0, 0, 0), Point(L, W, W), 10, 3, 3)
25 | V = VectorFunctionSpace(mesh, 'P', 1)
26 |
27 | # Define boundary condition
28 | tol = 1E-14
29 |
30 | def clamped_boundary(x, on_boundary):
31 | return on_boundary and x[0] < tol
32 |
33 | bc = DirichletBC(V, Constant((0, 0, 0)), clamped_boundary)
34 |
35 | # Define strain and stress
36 |
37 | def epsilon(u):
38 | return 0.5*(nabla_grad(u) + nabla_grad(u).T)
39 | #return sym(nabla_grad(u))
40 |
41 | def sigma(u):
42 | return lambda_*nabla_div(u)*Identity(d) + 2*mu*epsilon(u)
43 |
44 | # Define variational problem
45 | u = TrialFunction(V)
46 | d = u.geometric_dimension() # space dimension
47 | v = TestFunction(V)
48 | f = Constant((0, 0, -rho*g))
49 | T = Constant((0, 0, 0))
50 | a = inner(sigma(u), epsilon(v))*dx
51 | L = dot(f, v)*dx + dot(T, v)*ds
52 |
53 | # Compute solution
54 | u = Function(V)
55 | solve(a == L, u, bc)
56 |
57 | # Plot solution
58 | plot(u, title='Displacement', mode='displacement')
59 |
60 | # Plot stress
61 | s = sigma(u) - (1./3)*tr(sigma(u))*Identity(d) # deviatoric stress
62 | von_Mises = sqrt(3./2*inner(s, s))
63 | V = FunctionSpace(mesh, 'P', 1)
64 | von_Mises = project(von_Mises, V)
65 | plot(von_Mises, title='Stress intensity')
66 |
67 | # Compute magnitude of displacement
68 | u_magnitude = sqrt(dot(u, u))
69 | u_magnitude = project(u_magnitude, V)
70 | plot(u_magnitude, 'Displacement magnitude')
71 | print('min/max u:',
72 | u_magnitude.vector().array().min(),
73 | u_magnitude.vector().array().max())
74 |
75 | # Save solution to file in VTK format
76 | File('elasticity/displacement.pvd') << u
77 | File('elasticity/von_mises.pvd') << von_Mises
78 | File('elasticity/magnitude.pvd') << u_magnitude
79 |
80 | # Hold plot
81 | interactive()
82 |
--------------------------------------------------------------------------------
/src/vol1/python/heat.py:
--------------------------------------------------------------------------------
1 | """
2 | FEniCS tutorial demo program: Heat equation with Dirichlet conditions.
3 | Test problem is chosen to give an exact solution at all nodes of the mesh.
4 |
5 | u'= Laplace(u) + f in the unit square
6 | u = u_D on the boundary
7 | u = u_0 at t = 0
8 |
9 | u = 1 + x^2 + alpha*y^2 + \beta*t
10 | f = beta - 2 - 2*alpha
11 | """
12 |
13 | from __future__ import print_function
14 | from fenics import *
15 | import numpy as np
16 |
17 | T = 2.0 # final time
18 | num_steps = 10 # number of time steps
19 | dt = T / num_steps # time step size
20 | alpha = 3 # parameter alpha
21 | beta = 1.2 # parameter beta
22 |
23 | # Create mesh and define function space
24 | nx = ny = 8
25 | mesh = UnitSquareMesh(nx, ny)
26 | V = FunctionSpace(mesh, 'P', 1)
27 |
28 | # Define boundary condition
29 | u_D = Expression('1 + x[0]*x[0] + alpha*x[1]*x[1] + beta*t',
30 | degree=2, alpha=alpha, beta=beta, t=0)
31 |
32 | def boundary(x, on_boundary):
33 | return on_boundary
34 |
35 | bc = DirichletBC(V, u_D, boundary)
36 |
37 | # Define initial value
38 | u_n = interpolate(u_D, V)
39 | #u_n = project(u_D, V)
40 |
41 | # Define variational problem
42 | u = TrialFunction(V)
43 | v = TestFunction(V)
44 | f = Constant(beta - 2 - 2*alpha)
45 |
46 | F = u*v*dx + dt*dot(grad(u), grad(v))*dx - (u_n + dt*f)*v*dx
47 | a, L = lhs(F), rhs(F)
48 |
49 | # Time-stepping
50 | u = Function(V)
51 | t = 0
52 | for n in range(num_steps):
53 |
54 | # Update current time
55 | t += dt
56 | u_D.t = t
57 |
58 | # Compute solution
59 | solve(a == L, u, bc)
60 |
61 | # Plot solution
62 | plot(u)
63 |
64 | # Compute error at vertices
65 | u_e = interpolate(u_D, V)
66 | error = np.abs(u_e.vector().array() - u.vector().array()).max()
67 | print('t = %.2f: error = %.3g' % (t, error))
68 |
69 | # Update previous solution
70 | u_n.assign(u)
71 |
72 | # Hold plot
73 | interactive()
74 |
--------------------------------------------------------------------------------
/src/vol1/python/heat_gaussian.py:
--------------------------------------------------------------------------------
1 | """
2 | FEniCS tutorial demo program: Diffusion of a Gaussian hill.
3 |
4 | u'= Laplace(u) + f in a square domain
5 | u = u_D on the boundary
6 | u = u_0 at t = 0
7 |
8 | u_D = f = 0
9 |
10 | The initial condition u_0 is chosen as a Gaussian hill.
11 | """
12 |
13 | from __future__ import print_function
14 | from fenics import *
15 | import time
16 |
17 | T = 2.0 # final time
18 | num_steps = 50 # number of time steps
19 | dt = T / num_steps # time step size
20 |
21 | # Create mesh and define function space
22 | nx = ny = 30
23 | mesh = RectangleMesh(Point(-2, -2), Point(2, 2), nx, ny)
24 | V = FunctionSpace(mesh, 'P', 1)
25 |
26 | # Define boundary condition
27 | def boundary(x, on_boundary):
28 | return on_boundary
29 |
30 | bc = DirichletBC(V, Constant(0), boundary)
31 |
32 | # Define initial value
33 | u_0 = Expression('exp(-a*pow(x[0], 2) - a*pow(x[1], 2))',
34 | degree=2, a=5)
35 | u_n = interpolate(u_0, V)
36 |
37 | # Define variational problem
38 | u = TrialFunction(V)
39 | v = TestFunction(V)
40 | f = Constant(0)
41 |
42 | F = u*v*dx + dt*dot(grad(u), grad(v))*dx - (u_n + dt*f)*v*dx
43 | a, L = lhs(F), rhs(F)
44 |
45 | # Create VTK file for saving solution
46 | vtkfile = File('heat_gaussian/solution.pvd')
47 |
48 | # Time-stepping
49 | u = Function(V)
50 | t = 0
51 | for n in range(num_steps):
52 |
53 | # Update current time
54 | t += dt
55 |
56 | # Compute solution
57 | solve(a == L, u, bc)
58 |
59 | # Save to file and plot solution
60 | vtkfile << (u, t)
61 | plot(u)
62 |
63 | # Update previous solution
64 | u_n.assign(u)
65 |
66 | # Hold plot
67 | interactive()
68 |
--------------------------------------------------------------------------------
/src/vol1/python/poisson.py:
--------------------------------------------------------------------------------
1 | """
2 | FEniCS tutorial demo program: Poisson equation with Dirichlet conditions.
3 | Test problem is chosen to give an exact solution at all nodes of the mesh.
4 |
5 | -Laplace(u) = f in the unit square
6 | u = u_D on the boundary
7 |
8 | u_D = 1 + x^2 + 2y^2
9 | f = -6
10 | """
11 |
12 | from __future__ import print_function
13 | from fenics import *
14 | import matplotlib.pyplot as plt
15 |
16 | # Create mesh and define function space
17 | mesh = UnitSquareMesh(8, 8)
18 | V = FunctionSpace(mesh, 'P', 1)
19 |
20 | # Define boundary condition
21 | u_D = Expression('1 + x[0]*x[0] + 2*x[1]*x[1]', degree=2)
22 |
23 | def boundary(x, on_boundary):
24 | return on_boundary
25 |
26 | bc = DirichletBC(V, u_D, boundary)
27 |
28 | # Define variational problem
29 | u = TrialFunction(V)
30 | v = TestFunction(V)
31 | f = Constant(-6.0)
32 | a = dot(grad(u), grad(v))*dx
33 | L = f*v*dx
34 |
35 | # Compute solution
36 | u = Function(V)
37 | solve(a == L, u, bc)
38 |
39 | # Plot solution and mesh
40 | plot(u)
41 | plot(mesh)
42 |
43 | # Save solution to file in VTK format
44 | vtkfile = File('poisson/solution.pvd')
45 | vtkfile << u
46 |
47 | # Compute error in L2 norm
48 | error_L2 = errornorm(u_D, u, 'L2')
49 |
50 | # Compute maximum error at vertices
51 | vertex_values_u_D = u_D.compute_vertex_values(mesh)
52 | vertex_values_u = u.compute_vertex_values(mesh)
53 | import numpy as np
54 | error_max = np.max(np.abs(vertex_values_u_D - vertex_values_u))
55 |
56 | # Print errors
57 | print('error_L2 =', error_L2)
58 | print('error_max =', error_max)
59 |
60 | # Hold plot
61 | plt.show()
62 |
--------------------------------------------------------------------------------
/src/vol1/python/poisson_membrane.py:
--------------------------------------------------------------------------------
1 | """
2 | FEniCS tutorial demo program: Deflection of a membrane.
3 |
4 | -Laplace(w) = p in the unit circle
5 | w = 0 on the boundary
6 |
7 | The load p is a Gaussian function centered at (0, 0.6).
8 | """
9 |
10 | from __future__ import print_function
11 | from fenics import *
12 | from mshr import *
13 | import numpy as np
14 |
15 | # Create mesh and define function space
16 | domain = Circle(Point(0, 0), 1)
17 | mesh = generate_mesh(domain, 64)
18 | V = FunctionSpace(mesh, 'P', 2)
19 |
20 | # Define boundary condition
21 | w_D = Constant(0)
22 |
23 | def boundary(x, on_boundary):
24 | return on_boundary
25 |
26 | bc = DirichletBC(V, w_D, boundary)
27 |
28 | # Define load
29 | beta = 8
30 | R0 = 0.6
31 | p = Expression('4*exp(-pow(beta, 2)*(pow(x[0], 2) + pow(x[1] - R0, 2)))',
32 | degree=1, beta=beta, R0=R0)
33 |
34 | # Define variational problem
35 | w = TrialFunction(V)
36 | v = TestFunction(V)
37 | a = dot(grad(w), grad(v))*dx
38 | L = p*v*dx
39 |
40 | # Compute solution
41 | w = Function(V)
42 | solve(a == L, w, bc)
43 |
44 | # Plot solution
45 | p = interpolate(p, V)
46 | plot(w, title='Deflection')
47 | plot(p, title='Load')
48 |
49 | # Save solution to file in VTK format
50 | vtkfile_w = File('poisson_membrane/deflection.pvd')
51 | vtkfile_w << w
52 | vtkfile_p = File('poisson_membrane/load.pvd')
53 | vtkfile_p << p
54 |
55 | # Curve plot along x = 0 comparing p and w
56 | import numpy as np
57 | import matplotlib.pyplot as plt
58 | tol = 0.001 # avoid hitting points outside the domain
59 | y = np.linspace(-1 + tol, 1 - tol, 101)
60 | points = [(0, y_) for y_ in y] # 2D points
61 | w_line = np.array([w(point) for point in points])
62 | p_line = np.array([p(point) for point in points])
63 | plt.plot(y, 50*w_line, 'k', linewidth=2) # magnify w
64 | plt.plot(y, p_line, 'b--', linewidth=2)
65 | plt.grid(True)
66 | plt.xlabel('$y$')
67 | plt.legend(['Deflection ($\\times 50$)', 'Load'], loc='upper left')
68 | plt.savefig('poisson_membrane/curves.pdf')
69 | plt.savefig('poisson_membrane/curves.png')
70 |
71 | # Hold plots
72 | interactive()
73 | plt.show()
74 |
--------------------------------------------------------------------------------
/src/vol1/python/poisson_nonlinear.py:
--------------------------------------------------------------------------------
1 | """
2 | FEniCS tutorial demo program: Nonlinear Poisson equation.
3 |
4 | -div(q(u)*grad(u)) = f in the unit square.
5 | u = u_D on the boundary.
6 | """
7 |
8 | from __future__ import print_function
9 |
10 | # Warning: from fenics import * will import both `sym` and
11 | # `q` from FEniCS. We therefore import FEniCS first and then
12 | # overwrite these objects.
13 | from fenics import *
14 |
15 | def q(u):
16 | "Return nonlinear coefficient"
17 | return 1 + u**2
18 |
19 | # Use SymPy to compute f from the manufactured solution u
20 | import sympy as sym
21 | x, y = sym.symbols('x[0], x[1]')
22 | u = 1 + x + 2*y
23 | f = - sym.diff(q(u)*sym.diff(u, x), x) - sym.diff(q(u)*sym.diff(u, y), y)
24 | f = sym.simplify(f)
25 | u_code = sym.printing.ccode(u)
26 | f_code = sym.printing.ccode(f)
27 | print('u =', u_code)
28 | print('f =', f_code)
29 |
30 | # Create mesh and define function space
31 | mesh = UnitSquareMesh(8, 8)
32 | V = FunctionSpace(mesh, 'P', 1)
33 |
34 | # Define boundary condition
35 | u_D = Expression(u_code, degree=2)
36 |
37 | def boundary(x, on_boundary):
38 | return on_boundary
39 |
40 | bc = DirichletBC(V, u_D, boundary)
41 |
42 | # Define variational problem
43 | u = Function(V) # Note: not TrialFunction!
44 | v = TestFunction(V)
45 | f = Expression(f_code, degree=2)
46 | F = q(u)*dot(grad(u), grad(v))*dx - f*v*dx
47 |
48 | # Compute solution
49 | solve(F == 0, u, bc)
50 |
51 | # Plot solution
52 | plot(u)
53 |
54 | # Compute maximum error at vertices. This computation illustrates
55 | # an alternative to using compute_vertex_values as in poisson.py.
56 | u_e = interpolate(u_D, V)
57 | import numpy as np
58 | error_max = np.abs(u_e.vector().array() - u.vector().array()).max()
59 | print('error_max = ', error_max)
60 |
61 | # Hold plot
62 | interactive()
63 |
--------------------------------------------------------------------------------
/src/vol2/notes.txt:
--------------------------------------------------------------------------------
1 | Chapters
2 |
3 | Nonlinear problems, advanced setting of parameters etc as referred
4 | to in volume 1 at end of nonlinear Poisson section.
5 |
--------------------------------------------------------------------------------