Skip to content

Commit

Permalink
Move everything into fns and write driver script
Browse files Browse the repository at this point in the history
  • Loading branch information
danshapero committed Jan 9, 2024
1 parent cb8c61d commit 49dd7bf
Show file tree
Hide file tree
Showing 3 changed files with 231 additions and 191 deletions.
24 changes: 0 additions & 24 deletions demos/mismip/bed_topo.py

This file was deleted.

28 changes: 28 additions & 0 deletions demos/mismip/driver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import sys
import argparse
from icepack.meshing import triangle_to_firedrake
import mismip


# Get the command-line options.
parser = argparse.ArgumentParser()
parser.add_argument("--num-cells", type=int, default=20)
parser.add_argument("--final-time", type=float, default=2000.0)
parser.add_argument("--timestep", type=float, default=2.5)
parser.add_argument("--output", default="mismip.h5")
args = parser.parse_args()


triangle_mesh = mismip.make_initial_mesh(args.num_cells)
mesh = triangle_to_firedrake(triangle_mesh)
results = mismip.simulation(mesh, args.final_time, args.timestep)
num_steps = int(args.final_time / args.timestep)
timesteps = np.linspace(0, args.final_time, num_steps + 1)
with firedrake.CheckpointFile(args.output, "w") as chk:
for index, (u, M, τ, h) in enumerate(zip(us, Ms, τs, hs)):
chk.save_function(u, name="velocity", idx=index)
chk.save_function(M, name="membrane_stress", idx=index)
chk.save_function(τ, name="basal_stress", idx=index)
chk.save_function(h, name="thickness", idx=index)

chk.h5pyfile.create_dataset("timesteps", data=timesteps)
Loading

0 comments on commit 49dd7bf

Please sign in to comment.