Example #1
0
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.0, Solution(dom))
mask = Vector(0.0, Solution(dom))
#
#  in subduction zone:
#

if DIM == 2:
    S = numpy.array([0.0, 0.0])
    X0 = [bb[0][0], bb[1][1]]
    dd = [-cos(ALPHA), -sin(ALPHA)]
else:
    S = numpy.array([sin(STRIKE), cos(STRIKE), 0.0])
    X0 = [bb[0][0], bb[1][0], bb[2][1]]
Example #2
0
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]]
Example #3
0
    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")
Example #4
0
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,max_iter=max_iter,verbose=verbose,useUzawa=useUzawa)
  
Example #5
0
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,
Example #6
0
#
#   velocity constraints:
#
x=dom.getX()
x0=x[0]
v=DIRECTION*V0/2*(1.-2*(sup(x0)-x0)/(sup(x0)-inf(x0)))*unitVector(0,DIM)
fixed_v_mask=(whereZero(x0-inf(x0))+whereZero(x0-sup(x0)))*unitVector(0,DIM)  + \
             whereZero(x[DIM-1])*unitVector(DIM-1,DIM)
if DIM==3: fixed_v_mask+=(whereZero(x[1])+whereZero(x[1]-L))*unitVector(1,DIM)

p=Scalar(0.,ReducedSolution(dom))
gamma_dot=sqrt(2.)*length(deviatoric(symmetric(grad(v))))
tau=0.
tau_lsup=0

flow=StokesProblemCartesian(dom)
flow.setTolerance(1.e-5)

while n<1:

  print("========= Time step %d ======="%( n+1,))
  m=0
  dtau_lsup =1.
  while dtau_lsup > TOL * tau_lsup:
     print("--- iteration step %d ---- "%m)
     if n==0 and m==0:
        eta_top=ETA_TOP
     else:
        tau_Y=clip(c*cos(friction_angle)+p*sin(friction_angle), minval=0.)
        eta_top=clip(safeDiv(tau_Y,gamma_dot),maxval=ETA_TOP)
        print("eta_top=",eta_top)
x = dom.getX()
x0 = x[0]
v = DIRECTION * V0 / 2 * (1. - 2 * (sup(x0) - x0) /
                          (sup(x0) - inf(x0))) * unitVector(0, DIM)
fixed_v_mask=(whereZero(x0-inf(x0))+whereZero(x0-sup(x0)))*unitVector(0,DIM)  + \
             whereZero(x[DIM-1])*unitVector(DIM-1,DIM)
if DIM == 3:
    fixed_v_mask += (whereZero(x[1]) + whereZero(x[1] - L)) * unitVector(
        1, DIM)

p = Scalar(0., ReducedSolution(dom))
gamma_dot = sqrt(2.) * length(deviatoric(symmetric(grad(v))))
tau = 0.
tau_lsup = 0

flow = StokesProblemCartesian(dom)
flow.setTolerance(1.e-5)

while n < 1:

    print("========= Time step %d =======" % (n + 1, ))
    m = 0
    dtau_lsup = 1.
    while dtau_lsup > TOL * tau_lsup:
        print("--- iteration step %d ---- " % m)
        if n == 0 and m == 0:
            eta_top = ETA_TOP
        else:
            tau_Y = clip(c * cos(friction_angle) + p * sin(friction_angle),
                         minval=0.)
            eta_top = clip(safeDiv(tau_Y, gamma_dot), maxval=ETA_TOP)