Y = Vector(0.0, Function(mesh)) Y[1] = -rho * g #element spacing h = Lsup(mesh.getSize()) #boundary conditions for slip at base boundary_cond = whereZero(coordinates[1]) * [0.0, 1.0] + whereZero( coordinates[0]) * [1.0, 0.0] #velocity and pressure vectors velocity = Vector(0.0, Solution(mesh)) pressure = Scalar(0.0, ReducedSolution(mesh)) #Stokes Cartesian solution = StokesProblemCartesian(mesh) solution.setTolerance(tolerance) while t <= t_end: print(" ----- Time step = %s -----" % (t)) print("Time = %s seconds" % (time)) solution.initialize(fixed_u_mask=boundary_cond, eta=eta, f=Y) velocity, pressure = solution.solve(velocity, pressure, max_iter=max_iter, verbose=verbose, usePCG=True) print("Max velocity =", Lsup(velocity), "m/s")
STRIKE = 10 * U.DEG DIP = 30 * U.DEG N = 1 # boudary layer control g = 9.81 * U.m / U.sec**2 # # derived values # dom = ReadMesh(MESHFILE) DIM = dom.getDim() bb = boundingBox(dom) LX = bb[0][1] - bb[0][0] if DIM == 3: LY = bb[1][1] - bb[1][0] DEPTH = bb[DIM - 1][1] - bb[DIM - 1][0] sc = StokesProblemCartesian(dom) x = dom.getX() # v = Vector(0., Solution(dom)) mask = Vector(0., Solution(dom)) # # in subduction zone: # if DIM == 2: S = numpy.array([0., 0.]) X0 = [bb[0][0], bb[1][1]] dd = [-cos(ALPHA), -sin(ALPHA)] else: S = numpy.array([sin(STRIKE), cos(STRIKE), 0.]) X0 = [bb[0][0], bb[1][0], bb[2][1]]
velocity = Vector(0.0, ContinuousFunction(mesh)) pressure = Scalar(0.0, ContinuousFunction(mesh)) Y = Vector(0.0, Function(mesh)) #define initial interface between fluids xx = mesh.getX()[0] yy = mesh.getX()[1] func = Scalar(0.0, ContinuousFunction(mesh)) h_interface = Scalar(0.0, ContinuousFunction(mesh)) h_interface = h_interface + (0.02 * cos(math.pi * xx / l0) + 0.2) func = yy - h_interface func_new = func.interpolate(ReducedSolution(mesh)) #Stokes Cartesian solution = StokesProblemCartesian(mesh, debug=True) solution.setTolerance(TOL) #level set levelset = LevelSet(mesh, func_new, reinit_max, reinit_each, tolerance, smooth) while t_step <= t_step_end: #update density and viscosity rho = levelset.update_parameter(rho1, rho2) eta = levelset.update_parameter(eta1, eta2) #get velocity and pressure of fluid Y[1] = -rho * g solution.initialize(fixed_u_mask=b_c, eta=eta, f=Y) velocity, pressure = solution.solve(velocity, pressure,