Exemple #1
0
    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")
Exemple #2
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)
  
  #update the interface
Exemple #3
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)
     eta_eff=eta_top*(1-mask_visc) + ETA_BOTTOM*mask_visc
Exemple #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,
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)