Skip to content

Commit 18da9ec

Browse files
committed
Make it work via splitting ugh
1 parent f6c82fb commit 18da9ec

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

test/mismip_test.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def run_simulation(ny: int):
105105
a = Constant(0.3)
106106

107107
# Make the initial thickness
108-
h_0 = firedrake.Function(Q).assign(Constant(100.0))
108+
h_initial = firedrake.Function(Q).assign(Constant(100.0))
109109

110110
# Fluidity of ice in yr⁻¹ MPa⁻³
111111
A = Constant(20.0)
@@ -144,7 +144,7 @@ def run_simulation(ny: int):
144144
Lx = Constant(lx)
145145
u_expr = firedrake.as_vector((δu * x[0] / Lx, 0))
146146
z.sub(0).interpolate(u_expr)
147-
z.sub(3).assign(h_0)
147+
z.sub(3).assign(h_initial)
148148
u, M, τ, h = firedrake.split(z)
149149
s = max_value(b + h, (1 - ρ_I / ρ_W) * h)
150150

@@ -159,7 +159,7 @@ def run_simulation(ny: int):
159159
"membrane_stress": M,
160160
"basal_stress": τ,
161161
"thickness": h,
162-
"surface": max_value(b + h, (1 - ρ_I / ρ_W) * h),
162+
"surface": s, #max_value(b + h, (1 - ρ_I / ρ_W) * h),
163163
"floating": f,
164164
}
165165

@@ -175,7 +175,7 @@ def run_simulation(ny: int):
175175

176176
sparams = {
177177
"solver_parameters": {
178-
"snes_monitor": None,
178+
#"snes_monitor": None,
179179
"snes_type": "newtonls",
180180
"snes_max_it": 200,
181181
"snes_linesearch_type": "nleqerr",
@@ -190,32 +190,36 @@ def run_simulation(ny: int):
190190
H = Constant(500.0)
191191

192192
v, N, σ, η = firedrake.TestFunctions(Z)
193+
z_0 = z.copy(deepcopy=True)
194+
u_0, M_0, τ_0, h_0 = firedrake.split(z_0)
193195

194196
F_momentum = form_momentum_balance((u, M, τ), (v, N, σ), h, s, f, H, α, rheo1, rheo3)
195197
F_mass = (h - h_0) * η * dx
196198
F = F_momentum + F_mass
197199
problem = firedrake.NonlinearVariationalProblem(F, z, **pparams, bcs=bcs)
198-
solver = firedrake.NonlinearVariationalSolver(problem, **sparams)
200+
momentum_solver = firedrake.NonlinearVariationalSolver(problem, **sparams)
199201

200202
num_continuation_steps = 5
201203
for r in np.linspace(0.0, 1.0, num_continuation_steps):
202204
n.assign((1 - r) + r * glen_flow_law)
203205
m.assign((1 - r) + r * weertman_sliding_law)
204-
solver.solve()
206+
momentum_solver.solve()
205207

206208
print("Time-dependent solve")
207209
F_mass = mass_balance(
208210
thickness=h,
209211
velocity=u,
210212
accumulation=a,
211-
thickness_inflow=h_0,
213+
thickness_inflow=h_initial,
212214
test_function=η,
213215
)
214216

215217
t = Constant(0.0)
216-
timestep = 1.0
218+
timestep = 2.0
217219
dt = Constant(timestep)
218-
F = F_momentum + F_mass
220+
F_dummy = (
221+
inner(u - u_0, v) * dx + inner(M - M_0, N) * dx + inner(τ - τ_0, σ) * dx
222+
)
219223

220224
lower = firedrake.Function(Z)
221225
upper = firedrake.Function(Z)
@@ -226,10 +230,16 @@ def run_simulation(ny: int):
226230
params = {
227231
"solver_parameters": {
228232
"snes_monitor": None,
233+
"snes_converged_reason": None,
234+
#"snes_linesearch_monitor": None,
229235
"snes_type": "vinewtonrsls",
230-
"snes_max_it": 200,
231-
"snes_linesearch_type": "nleqerr",
232-
"ksp_type": "gmres",
236+
"snes_max_it": 50,
237+
#"snes_atol": 2e-6,
238+
"snes_stol": 1e-15,
239+
#"snes_convergence_test": "skip",
240+
"snes_linesearch_type": "l2",
241+
"snes_linesearch_max_it": 5,
242+
"ksp_type": "preonly",
233243
"pc_type": "lu",
234244
"pc_factor_mat_solver_type": "mumps",
235245
},

0 commit comments

Comments
 (0)