1
"This demo illustrate basic plotting."
3
__author__ = "Anders Logg (logg@simula.no)"
4
__date__ = "2007-05-29 -- 2008-12-07"
5
__copyright__ = "Copyright (C) 2007-2008 Anders Logg"
6
__license__ = "GNU LGPL Version 2.1"
13
# Read and plot mesh from file
14
mesh = Mesh("dolfin-2.xml.gz")
17
# Decide which demos to run
19
demos = [int(sys.argv[-1])]
23
# Have some fun with the mesh
32
coordinates = mesh.coordinates()
33
original = coordinates.copy()
37
if X < H or X > 1.0 - H:
39
if Y < H or Y > 1.0 - H:
44
for j in xrange(mesh.numVertices()):
46
r = sqrt((x - X)**2 + (y - Y)**2)
48
coordinates[j] = [X + (r/R)**2*(x - X), Y + (r/R)**2*(y - Y)]
52
for j in xrange(mesh.numVertices()):
53
coordinates[j] = original[j]
55
# Plot scalar function
57
V = FunctionSpace(mesh, "CG", 1)
58
f = Function(V, "t * 100 * exp(-10.0 * (pow(x[0] - t, 2) + pow(x[1] - t, 2)))")
62
plot(f, rescale=True, title="Scalar function")
64
# Plot vector function
66
mesh = UnitSquare(16, 16)
67
V = VectorFunctionSpace(mesh, "CG", 1)
68
f = Function(V, ("-(x[1] - t)*exp(-10.0*(pow(x[0] - t, 2) + pow(x[1] - t, 2)))",
69
" (x[0] - t)*exp(-10.0*(pow(x[0] - t, 2) + pow(x[1] - t, 2)))"))
73
plot(f, rescale=True, title="Vector function")
77
mesh = UnitSquare(10, 10)
78
V = VectorFunctionSpace(mesh, "CG", 1)
79
f = Function(V, ("-(x[1] - t)*exp(-10.0*(pow(x[0] - t, 2) + pow(x[1] - t, 2)))",
80
" (x[0] - t)*exp(-10.0*(pow(x[0] - t, 2) + pow(x[1] - t, 2)))"))
91
plot(f, eval_pts=pts, rescale=True, title="Vector function")
94
# plot(f,eval_pts=pts)