-
Notifications
You must be signed in to change notification settings - Fork 0
/
compressive.py
58 lines (47 loc) · 1.37 KB
/
compressive.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from firedrake import *
Lx = 0.1
Ly = 10.
ref_level = 3
deg = 2
#mesh = UnitIcosahedralSphereMesh(ref_level, degree=deg)
mesh = UnitOctahedralSphereMesh(ref_level, degree=deg, hemisphere="north")
Xn = mesh.coordinates
V = VectorFunctionSpace(mesh, "CG", deg)
K = FunctionSpace(mesh, "CG", deg)
Xs = Function(V)
Xbcs = Function(V).assign(Xn)
mesh.init_cell_orientations(Xn)
nu = TestFunction(V)
W = MixedFunctionSpace((V,K))
w = Function(W)
Xnp, kappa = split(w)
eta, chi = TestFunctions(W)
nu = CellNormal(mesh)
Dt = 0.01
dt = Constant(Dt)
F = (
inner(Xnp - Xn, chi*nu) - dt*kappa*chi +
inner(kappa*nu, eta) + inner(grad(Xnp), grad(eta))
)*dx
bcs = [DirichletBC(W[0], Xbcs, "on_boundary")]
prob = NonlinearVariationalProblem(F, w, bcs=bcs)
solver = NonlinearVariationalSolver(prob,
solver_parameters=
{'mat_type': 'aij',
'snes_linesearch_type':'basic',
"snes_monitor":True,
'ksp_type': 'preonly',
'pc_type': 'lu'})
T = 0.5
t = 0.
file = File('curvatureflow.pvd')
Xs.assign(Xn)
file.write(Xs)
while t < T - Dt/2:
print(t)
t += Dt
solver.solve()
X_out, kappa_out = w.split()
mesh.coordinates.assign(X_out)
Xs.assign(X_out)
file.write(Xs)