require "common"

if referenceRun == false then
  require "refParams"
else
  function refFunction()
    return 0
  end
end
-- Musubi configuration file. 
-- This is a LUA script.

-- Simulation name
mesh = 'mesh/' -- Mesh information
ebug = {debugMode = true, debugFiles = true}
simulation_name = 'channelRefine'
identify = {label = idLabel, layout='d2q9'}

-- Time step settigs
tmax =   nIters    -- total iteration number
interval = tmax/10
tRamping = tmax/20
time = {useIterations = true,
        min = 1, max = tmax, interval = interval }

fluid = { --#omega_ramping = { predefined='smooth', min_factor = 0.7, max_factor=1, from_time=0, to_time=tRamping}, 
       omega = omega, 
       rho0 = 1.0 }

-- Initial condition 
initial_condition = { density = 1.0, 
                      velocityX = 0.0,
                      velocityY = 0.0,
                      velocityZ = 0.0 }
-- Boundary conditions
boundary_condition = {  
{ label = 'west', 
  kind = 'inlet_ubb', 
  velocityX = { kind = 'combined',
                transient= {
                  predefined='smooth', 
                  min_factor = 0.0, 
                  max_factor=1.0, 
                  from_time=0, 
                  to_time=tRamping}, 
                spatial = {
                  predefined='parabol', 
                  shape = { 
                    kind = 'canoND', 
                    object = {
                      origin = {-0.5*length, -(height-0.5*dx)*0.5, 0.0},
                      vec = {0.0, height-0.5*dx, 0.0} 
                      } 
                   }
                  ,amplitude = u_in 
              }         
	      },
   velocityY = 0.0, velocityZ = 0.0},
{ label = 'east',
   kind = 'outlet_pab',
   density =  1.0}, 
{ label = 'north', 
   kind = 'wall' },
{ label = 'south', 
   kind = 'wall' },
 }

if useObstacle ==true then
  table.insert( boundary_condition, 
{ label = 'sphere', 
   kind = 'wall' } )
 end

-- Output settings
utput = { active = true, -- VTK output activated?
  folder = './output/'..label..'_l'..level,     -- Output location
  vtk = false,             -- VTK output activated?
  wss = true, 
  --dumpGhosts = true,
  time = {min = tmax, max = tmax, interval = interval}
}

-- Tracking              
tracking = {{
  label = label..'_probePressure_l'..level, 
 variable = {'density'}, 
 shape = {kind = 'canoND', object = {origin ={0.0,0.,0.} } },
 time = {min = 1, max = -1, interval = 5},
  format = 'ascii', folder = './tracking/'      
 }, 
{
  label = label..'_velX_l'..level, 
 variable = {'velocity', 'shearstress'}, 
 shape = {kind = 'canoND', object = {origin ={ 0.0,-height*0.5,0.}, vec={0., height, 0.}, segments = 2*nElemsMax } },
 time = {min = tmax, max = -1, interval = interval},
  format = 'asciiSpatial'      , folder = './tracking/'      
 },
{
  label = label..'_pressCutY_l'..level, 
 variable = {'density'}, 
 shape = {kind = 'canoND', 
          object = {
            origin ={0., -height*0.5,0.,0.}, 
            vec={0., height, 0.}, 
            segments = 2*nElemsMax } },
 time = {min = tmax, max = -1, interval = interval},
  format = 'asciiSpatial'      , folder = './tracking/'      
 }
,
{
  label = label..'_pressCutX_l'..level..'_om_'..omega, 
 variable = {'density', 'shearstress'}, 
 shape = {kind = 'canoND', 
          object = {
              origin ={-length*0.5,0.,0.}, 
              vec={length, 0., 0.}, 
              segments = 2*nElemsMax } 
          },
 time = {min = tmax, max = -1, interval = interval},
  format = 'asciiSpatial'      , folder = './tracking/'      
 }, {
  -- tracking object for getting the error in terms of the l2norm
  label = label..'_hvs_l'..level, 
  variable = { 
     {'density'}, 
     {'velocity'}, {'wss'}},
  --reduction = {operation = 'sum', variable = {'difference'}},
  shape = {kind = 'all'},
  time = {min = tmax, max = tmax, interval = interval},
  format = 'harvester',
  folder = './hvs/'
 },} 
test = {
{
  -- tracking object for getting the error in terms of the l2norm
  label = label..'_error_l'..level, 
  variable = { 
     {'density'}, 
     {name = 'spacetime', ncomponents = 1, spacetime = refFunction},
     {name = 'difference', ncomponents = 1, dep = {'density', 'spacetime'} }},
  reduction = {'l2norm','l2norm','l2norm' },
  --reduction = {operation = 'sum', variable = {'difference'}},
  shape = {kind = 'canoND', object = {origin ={-0.5*length,0.,0.}, 
           vec = {length, 0.0, 0.0}, segments = 10*nElemsMax } },
  time = {min = tmax, max = -1, interval = 1},
  format = 'ascii',
  folder = './tracking/'
 },
  
 }
