\(\require{physics}\)

クエット流れ

package.cpath = "../fantom_libraries/Release/?.dll;" .. package.cpath
require("fantom")
require("writer")

-- basic parameters
case_name              = "couette"
total_count            = 6000
save_interval          = 300
dx                     = 1.0
dy                     = 1.0
dt                     = 100.0
fantom.Parameter_THETA = 0.5
num_threads            = 4
z_spacing              = 0.02

-- z coordinate
dz    = fantom.VectorDouble(50)
for i = 0, dz:size()-1 do
  dz[i]=z_spacing
end

-- creating geometry files
fg  = io.open("geom.txt", "w")
fxr = io.open("xrfm.txt", "w")
fyr = io.open("yrfm.txt", "w")
fg:write ("0.0\n")
fxr:write("1\n")
fyr:write("1\n")
fg:close()
fxr:close()
fyr:close()

-- objects
 water_body   = fantom.WaterBody(dx, dy, dz, "geom.txt", "xrfm.txt", "yrfm.txt", false, true)
diffusion    = fantom.VerticalDiffusionHorizontalVelocityBottomNonslip()
txt_writer   = writer.TextWriter(water_body, case_name)

-- settings
water_body:set_num_threads(num_threads) 
water_body:set_var("u",  0.0)
water_body:set_var("v",  0.0)
water_body:set_var("w",  0.0)

-- forcing function
function wall_drag(water_body)
  for i=0,water_body:vertical_face_columns():size()-1 do
    local column = water_body:vertical_face_columns()[i]
    if column:direction()==fantom.Parameter.WEST_EAST then
      k = column:original_components():size()-1 -- top face
      local wall_velocity = 1.0
      local dz            = z_spacing
      local velocity      = column:get_face(k):velocity():value().present
      local D             = 1.0E-06
      column:get_face(k):velocity():add_increment(1.0/(0.5*dz)/dz*D*(wall_velocity-velocity))
    end
  end
end

-- time marching
for counter = 0, total_count do
  time = dt*counter
  water_body:construct_box_variables()  
  print("----- count = ", counter)
  if counter % save_interval == 0 then
    txt_writer:write(time, counter)
  end
  wall_drag(water_body)
  water_body :update_explicit_terms(dt)
  diffusion:apply(water_body, dt)
end