# to increase model resolution, increase refine (refine = 2 doubles resolution)

refine = 1

nt = 7000*refine # Number of timesteps
nx1 = 600*refine+1 # number of grid point in left block
nx2 = 600*refine+1 # number of grid point in right block
nx = nx1+nx2 # total for x coordinates
nby0 = 200*refine+1 # for 000 and 100 blocks

fault_surface = 51.
fault_bottom = 42.
surf_height = 10.

[x1, y1, x2, y2, block000_length, block100_length] = read_surface_data(nx1, nx2, fault_bottom,
                                                                       fault_surface, surf_height)
p = fdfault.problem('normalfault')

# set rk and fd order
p.set_rkorder(4)
p.set_sbporder(4)

# set time step info
p.set_nt(nt)
p.set_cfl(0.3)
p.set_ninfo(100*refine)

# set number of blocks and coordinate information
p.set_nblocks((2,1,1))
p.set_nx_block(([nx1, nx2], [nby0], [1]))
plt.rc('font', **font)
plt.rc('text', usetex=True)

#-------- Grid set up and import surface data ----------
refine = mesh.refine
nt = mesh.nt * refine  # Number of timesteps
nx1 = mesh.nx1 * refine + 1  # number of grid point in left block
nx2 = mesh.nx2 * refine + 1  # number of grid point in right block
nx = nx1 + nx2  # total for x coordinates
nby0 = mesh.nby0 * refine + 1  # for 000 and 100 blocks
nby1 = mesh.nby1 * refine + 1  # for 000 and 100 blocks
ny = nby0 + nby1

[x1, y1, x2, y2, block010_length,
 block110_length] = read_surface_data(nx1, nx2)

import pickle
mydict = {'x1': x1, 'x2': x2, 'y1': y1 - 70, 'y2': y2 - 70}
output = open('surface.pkl', 'wb')

surf_height = max([max(y1), max(y2)])

arg = str(50)
problem_name = 'longterm_' + arg

p = fdfault.problem(problem_name)
# set rk and fd order
p.set_rkorder(4)
p.set_sbporder(4)
from get_stress import lithostatic_stress
import mesh as mesh
import matplotlib.pyplot as plt


#-------- Grid set up and import surface data ----------
refine = mesh.refine
nt = mesh.nt*refine # Number of timesteps
nx1 = mesh.nx1*refine+1 # number of grid point in left block
nx2 = mesh.nx2*refine+1 # number of grid point in right block
nx = nx1+nx2 # total for x coordinates
nby0 = mesh.nby0*refine+1 # for 000 and 100 blocks
nby1 = mesh.nby1*refine+1 # for 000 and 100 blocks
ny = nby0 + nby1

[x1, y1, x2, y2, block010_length, block110_length] = read_surface_data(nx1, nx2)

surf_height = max([max(y1), max(y2)])

problem_name = 'litho_deep_initial'
p = fdfault.problem(problem_name)
# set rk and fd order
p.set_rkorder(4)
p.set_sbporder(4)

# set time step info
p.set_nt(nt)
p.set_cfl(0.3)
p.set_ninfo(100*refine)

# set number of blocks and coordinate information