Esempio n. 1
0
def main():
    ## parameters
    dir_in = '/usr/local/home/yl8bc/duannas/'
    filename_in_grid = 'nozzle_grid_test.h5'
    filename_outlet = 'Test_Incompact3d/HLB_Nozzle/AcousticZgrid_k500.dat'
    ## output
    dir_out = '../../data/nozzle/'
    filename_out = 'nozzle_grid_test_try1'
    ## BELOW NO PARAMS ARE DEFINED
    tstart = time.time()

    ## Read grid(uniform)
    grid, vars_name = IO_util.read_hdf5(dir_out + filename_in_grid)
    u = grid['x']
    v = grid['z']
    dset, zones_name, vars_name = util_tp.read_tp(dir_in + filename_outlet)
    data_outlet, nodemap = util_tp.read_tp_zone(dset, 'SubZone', vars_name)

    ## intersections
    nx, ny = u.shape
    v[-1, :] = v[-1, -1] * normalized_flipped(data_outlet['z'], ny)
    u, v = gridgen.cm_gridgen.gridgen_checker(u, v)

    print 'Checker done. Elapsed time: %f' % (time.time() - tstart)

    ## Write grid
    grid['x'] = u
    grid['z'] = v
    IO_util.write_hdf5(dir_out + filename_out, grid)
Esempio n. 2
0
def main():
    dir_in = '/usr/local/home/yl8bc/duannas/yl8bc/data/cone/run3_polar/REST/'
    filename_in_grid = 'grid.h5'
    stencilsize = 6
    bc = [0, 0, 1, 1, 0, 1]
    ## end params

    ## read grid
    grid_in = IO_util.read_hdf5(dir_in + filename_in_grid)
    x = grid_in['x']
    y = grid_in['y']
    z = grid_in['z']
    ny, nx, nz = x.shape

    ## extend grid
    x, y, z = util_f.mod_metrics.extend_grid(x, y, z, stencilsize)

    ## compute grid der
    grid_derivative = util_f.mod_metrics.compute_grid_derivative(
        x, y, z, ny, nx, nz, stencilsize, bc)
    grid_derivative = grid_derivative[:, (1, 0, 2), :, :, :]

    ## condition gridder
    grid_derivative[(0, 2), 1, :, :, :] = 0.
    grid_derivative[1, (0, 2), :, :, :] = 0.
    grid_derivative = np.repeat(
        grid_derivative[:, :,
                        stencilsize + ny / 2:stencilsize + ny / 2 + 1, :, :],
        grid_derivative.shape[2],
        axis=2)
    grid_derivative[:, 1, :2, :, :] = 0.
    grid_derivative[:, 1, -2:, :, :] = 0.

    ## out
    grid_out = {'dxdi':grid_derivative[0,0,:,:,:], \
                'dxdj':grid_derivative[0,1,:,:,:], \
                'dxdk':grid_derivative[0,2,:,:,:], \
                'dydi':grid_derivative[1,0,:,:,:], \
                'dydj':grid_derivative[1,1,:,:,:], \
                'dydk':grid_derivative[1,2,:,:,:], \
                'dzdi':grid_derivative[2,0,:,:,:], \
                'dzdj':grid_derivative[2,1,:,:,:], \
                'dzdk':grid_derivative[2,2,:,:,:]}
    IO_util.write_hdf5(dir_in + 'gridDerivative_f.h5', grid_out)
    #x[:] = stretch_tanh(x, 2., type='left')
    return

if __name__ == '__main__':
    ###---parameters----###
    # Files required to start interpolation
    # "filename_fluent": old file that contains Fluent data in .dat format
    shape = (32, 100, 140)
    dir_in = '../../data/grids/'
    filename_in = 'cone_grid_flat_part2.h5'
    # Files generated by the program
    dir_out = '/usr/local/home/yl8bc/duannas/yl8bc/data/cone/run3_polar/REST/' 
    filename_out = 'grid'

    ## stack those grids
    grid_in, names = IO_util.read_hdf5(dir_in+filename_in)
    
    ## 
    x0 = grid_in['x'][0,0]
    xm = grid_in['x'][-1,0]
    dist_bot = grid_in['x'][:,0].copy()
    distribution = np.linspace(x0, xm, grid_in['x'].shape[0])
    #distribution =  grid_in['x'][:,0]
    #stretch_func(distribution)
    
    ## interp by distribution
    for key,var in grid_in.iteritems():
        for n in range(0, grid_in['x'].shape[1]):
            grid_in[key][:,n] = np.interp( distribution, dist_bot, var[:,n])
    
    ## intep to new shape
from util import IO_util, util_interp
import numpy as np

if __name__ == '__main__':
    ##---params --##
    shape = (512, 128)
    dir_in = './InitBody/'
    filename_delta = 'BL.dat'
    ##
    dir_out = '../../data/grids/'
    filename_in_grid = 'cone_grid_parabolic_part2.h5'
    filename_out = 'cone_para_part2'
    ##---params end----##
    
    ## Input
    grid_in, names = IO_util.read_hdf5(dir_out+filename_in_grid)
    delta = np.loadtxt(dir_in+filename_delta)
    
    ## assess delta
    dist = np.linspace( grid_in['z'][0,0], grid_in['z'][0,-1], shape[1] )
    for i in range(shape[0]):
        grid_in['z'][i,:] = np.interp( 
    

    ## output
    IO_util.write_hdf5(dir_out+filename_out, grid_new)

    
    
Esempio n. 5
0
    start_over = True
    if start_over:
        #IC
        idx_left, u[0,:],v[0,:] = gridgen.cm_gridgen.init_index(choice_left, shape[1], 1)
        idx_right, u[-1,:],v[-1,:] = gridgen.cm_gridgen.init_index(choice_right, shape[1], 1)
        idx_bottom, u[:,0],v[:,0] = gridgen.cm_gridgen.init_index(choice_bottom, shape[0], 1)
        idx_top, u[:,-1],v[:,-1] = gridgen.cm_gridgen.init_index(choice_top, shape[0], 1)
        u,v = gridgen.cm_gridgen.init_tfi(u, v)
        grid = {'x':u, 'y':v}
        IO_util.write_hdf5(dir_out+filename_output_hdf5, grid)
    else:
        idx_left = np.load('idx_left.npy')
        idx_right = np.load('idx_right.npy')
        idx_bottom = np.load('idx_bottom.npy')
        idx_top = np.load('idx_top.npy')
        grid, vars_name = IO_util.read_hdf5(dir_out+filename_output_hdf5+'.h5')
        u = grid['x']
        v = grid['y']

    iloop = True
    while iloop:

        u,v,idx_left,idx_right,idx_bottom,idx_top,iconverge = gridgen.cm_gridgen.compute_grid(u,v,idx_left,idx_right,
                                                                                              idx_bottom,idx_top,
                                                                                              choice_left,choice_right,
                                                                                              choice_bottom,choice_top, 1e-8, .0, 100,
                                                                                              np.array([0,0,0,0],dtype=int),
                                                                                              np.array([0,0,0,0],dtype=int))
        #iconverge = 1
        np.save('idx_left', idx_left)
        np.save('idx_right', idx_right)
from scipy import interpolate

if __name__ == '__main__':
    ##---params --##
    shape = (2, 100, 140)
    dir_in_old = '/usr/local/home/yl8bc/duannas/yl8bc/data/cone/run6_release/REST/'#'./InitBody/'
    filename_grid_old = 'grid.h5'
    filename_data_old = 'flowdata_00200000.h5'
    dir_in_new = '/usr/local/home/yl8bc/duannas/yl8bc/data/cone/'
    filename_grid_new = 'cone_grid_flat_part2.h5'
    ## out
    dir_out = '/usr/local/home/yl8bc/duannas/yl8bc/data/cone/run7_2d/REST/'
    #filename_out =
    ##---params end----##
    ## read data/grid 
    grid_old = IO_util.read_hdf5(dir_in_old+filename_grid_old)
    data_old = IO_util.read_hdf5(dir_in_old+filename_data_old)
    grid_new = IO_util.read_hdf5(dir_in_new+filename_grid_new)
   
    grid_old = {'x':grid_old['x'], 'z':grid_old['z']}
    
    ## get IC
    data_new = util_interp.structured_interp(grid_old, data_old, grid_new, robust=True, method='linear')
    data_new.update(grid_new)
    
    ## distribution 
    x0 = data_new['x'][0,0]
    xm = data_new['x'][-1,0]
    dist_old = data_new['x'][:,0].copy()
    dist_new = np.linspace(x0, xm, data_new['x'].shape[0])
Esempio n. 7
0
def main():
    ###params###

    mrange = range(1, 99, 1)
    mmax = len(mrange)
    nmax = 75

    dir_in = '/usr/local/home/yl8bc/data_local/cone/run3_Col_native/REST/'
    filename_in_grid = 'grid.h5'
    filename_in_data = 'flowdata_00024000.h5'
    ## files output:
    dir_out = '/usr/local/home/yl8bc/yl8bc/data/cone/FLUENT/'
    filename_out_profiles = 'profiles_dns_GCL'
    filename_out_integrals = 'integrals_dns_GCL'
    ##--below no param is defined--##
    tstart = time.time()
    keys_change = {
        'X': 'x',
        'Y': 'z',
        'X Velocity': 'uave',
        'Y Velocity': 'wave',
        'Pressure': 'pave',
        'Density': 'rhoave',
        'Temperature': 'tave'
    }
    grid_keys = ['x', 'z']

    ## read grid and data
    grid = IO_util.read_hdf5(dir_in + filename_in_grid)
    data = IO_util.read_hdf5(dir_in + filename_in_data)
    print('Data read. Time elapsed: %f secs' % (time.time() - tstart))

    ## slice
    data.update(grid)
    data.pop('time')
    sdata = util_data.structured_data(data, ['y', 'x', 'z'])
    sdata = sdata.slice_data(0, 0)

    ## wall normal profiles
    profiles_out = sdata.get_wall_normal_profiles('right', mrange, nmax)

    ## integral
    delta = np.zeros(mmax)
    delta_star = np.zeros(mmax)
    theta = np.zeros(mmax)
    for n in range(mmax):
        wd = profiles_out['wd'][n, :]
        x = profiles_out['x'][n, :]
        z = profiles_out['z'][n, :]
        u = profiles_out['u'][n, :]
        w = profiles_out['w'][n, :]
        rho = util_flow.get_rho(profiles_out['p'][n, :],
                                profiles_out['T'][n, :])
        up = util_flow.get_up_2d(u, w, x, z)
        delta[n] = util_flow.get_delta(wd, up)
        delta_star[n] = util_flow.get_delta_star(wd, up, rho)
        theta[n] = util_flow.get_theta(wd, up, rho)

    int_out = {}
    int_out['x'] = profiles_out['x'][:, 0]
    int_out['z'] = profiles_out['z'][:, 0]
    int_out['delta'] = delta
    int_out['delta*'] = delta_star
    int_out['theta'] = theta

    ## out
    IO_util.write_hdf5(dir_out + filename_out_profiles, profiles_out)
    IO_util.write_hdf5(dir_out + filename_out_integrals, int_out)
def main():
    ###---parameters----###
    shape0 = (32, 256)  #(i,k)(this is only used in orthogonal gridgen)
    shape1 = (96, 256)
    shape_out = (16, 100, 140)  #(j,i,k)(this is FINAL SHAPE)
    xl = -30.e-4  # (xl,yl) is top-left point of whole domain
    yl = .12
    # skip options(skip gridgen)
    skip_shock = False
    skip_freestream = False
    # Files required to start interpolation
    dir_in = './InitBody/'
    filename_in_body = 'ConeSurfGeometry.dat'
    filename_in_shock = 'ConeShockGeometry.dat'
    dir_IC = '/usr/local/home/yl8bc/yl8bc/data/cone/run7_Col_2d/REST/'
    filename_in_grid_IC = 'grid.h5'
    filename_in_data_IC = 'flowdata_00050000.h5'

    # Files generated by the program
    dir_out = '/usr/local/home/yl8bc/duannas/yl8bc/data/cone/run11_GCL/REST/'
    filename_out_shock = 'cone_grid_flat_shock.h5'
    filename_out_freestream = 'cone_grid_flat_freestream.h5'
    filename_out_full = 'grid.h5'
    filename_out_IC = 'flowdata_00000000.h5'
    filename_out_gd = 'gridDerivative_f.h5'
    filename_out_mi = 'metric_identities_f.h5'
    ###---no parameters below---#

    if skip_shock:
        grid_tmp = IO_util.read_hdf5(dir_out + filename_out_shock)
        u_s = grid_tmp['x']
        v_s = grid_tmp['z']
    else:
        ## define wall
        body = np.loadtxt(dir_in + filename_in_body, skiprows=2)
        #poly = np.polyfit(body[21:35,0], body[21:35,1], 10)
        #body[21:35,1] = np.polyval(poly, body[21:35,0])
        ## define shock
        shock = np.loadtxt(dir_in + filename_in_shock, skiprows=2)
        ## compute shock part
        u_s, v_s = flat_shock.gridgen(shape0, body, shock,
                                      dir_out + filename_out_shock)

    ## compute full grid
    if skip_freestream:
        grid_tmp = IO_util.read_hdf5(dir_out + filename_out_freestream)
        u_f = grid_tmp['x']
        v_f = grid_tmp['z']
    else:
        u_f, v_f = flat_freestream.gridgen(shape1[0], xl, yl, u_s, v_s,
                                           dir_out + filename_out_freestream)

    ## combine grids
    u, v = flat_combined.gridgen(u_f, v_f, u_s, v_s, shape1[0] - 8, shape1[0])
    grid_out = {'x': u, 'z': v}

    ## IC
    grid_IC = IO_util.read_hdf5(dir_IC + filename_in_grid_IC)
    data_IC = IO_util.read_hdf5(dir_IC + filename_in_data_IC)
    data_out = IC_by_interp.ICgen(grid_IC, data_IC, grid_out)

    ## reshape in 2d
    grid_out = reshape.reshape_by_index(shape_out[1:], grid_out)
    data_out = reshape.reshape_by_index(shape_out[1:], data_out)

    ## redistribute
    slc_axis = np.s_[:, 0]
    dist_old = grid_out['x'][slc_axis].copy()
    pdist_new = dist.pdist(dist_old[0], dist_old[-1], dist_old.shape[0])
    dist_new = pdist_new.tanh(2.5, type='right')
    grid_out = reshape.redistribute(dist_new, dist_old, grid_out)
    data_out = reshape.redistribute(dist_new, dist_old, data_out)

    ## expand
    grid_out = reshape.expand_spanwise(shape_out[0],
                                       grid_out,
                                       dim_new=1,
                                       span_name='y')
    data_out = reshape.expand_spanwise(shape_out[0], data_out, dim_new=1)

    ## polar treatment
    grid_out['z'] = shift.Colonius_shift(grid_out['z'], 2)

    ## regulate
    slc_body = np.s_[-1, :, :]
    data_out['v'][:] = 0.
    data_out['T'][slc_body] = 400.

    ## inlet
    data_inlet = {
        key: data_out[key][0:1, :, :]
        for key in ['T', 'p', 'u', 'v', 'w']
    }

    # RANS
    data_inlet['p'][:] = 6878.1
    data_inlet['u'][:] = 1508.7
    data_inlet['v'][:] = 0.
    data_inlet['w'][:] = 0.
    data_inlet['T'][:] = 202.08

    ## ducros
    #    ducros = sensor.ducros(data_out['u'], data_out['v'], data_out['w'], grid_out, \
    #                           u_inf=1508., delta_in = 0.125)
    #    dist_old = grid_out['x'][:,0,0].copy()
    #    dist_new = dist.ptrans(dist_old).expo(.5, 50)
    #    grid_out = reshape.redistribute(dist_new, dist_old, grid_out, dim=0)
    #    data_out = reshape.redistribute(dist_new, dist_old, data_out, dim=0)

    ## metrICs
    grid_tmp, grid_derivative = m_gd.analytically_2d(grid_out,
                                                     bc_g=[0, 0, 0, 0, 0, 0],
                                                     bc_gd=[0, 0, 1, 1, 0, 1])
    #grid_tmp, grid_derivative = m_gd.native(grid_out, bc_g=[0,0,0,0,0,0], bc_gd=[1,1, 0,0, 0,1])

    mm, Ji = m_mm.compute_mesh_metrics(grid_derivative)
    I = m_mm.compute_metric_identities(mm, Ji)

    ## transpose
    grid_out = {
        key: np.swapaxes(value, 0, 1)
        for key, value in grid_out.items()
    }
    data_out = {
        key: np.swapaxes(value, 0, 1)
        for key, value in data_out.items()
    }
    data_inlet = {
        key: np.swapaxes(value, 0, 1)
        for key, value in data_inlet.items()
    }

    grid_derivative = np.swapaxes(grid_derivative, 2, 3)
    mm = np.swapaxes(mm, 2, 3)
    I = np.swapaxes(I, 1, 2)
    ducros = np.swapaxes(ducros, 0, 1)

    ## time
    IC_by_interp.add_time(data_out)

    ## out
    IO_util.write_hdf5(dir_out + filename_out_full, grid_out)
    IO_util.write_hdf5(dir_out + filename_out_IC, data_out)
    grid_derivative = m_gd.pack_grid_derivative(grid_derivative)
    IO_util.write_hdf5(dir_out + filename_out_gd, grid_derivative)
    I = m_mm.pack_metric_identities(I)
    IO_util.write_hdf5(dir_out + filename_out_mi, I)
    IO_util.write_hdf5(dir_out + 'inlet', data_inlet)
    data_out.update(grid_out)
    data_out.update(grid_derivative)
    data_out.update({'ducros': ducros})
    IO_util.write_hdf5(dir_out + 'vis', data_out)
Esempio n. 9
0
from util import util_cyl, IO_util

## params
dir_in = '../'  # directory in
filename_in_grid = 'grid.h5'
filename_in_data = 'flowdata_00000000.h5'
dir_out = './'  # directory out
filename_out_grid = 'grid.h5'
filename_out_data = 'flowdata_00000000.h5'
if_cart_to_cyl = True  # if converting cartesian to cylidrical? set True/False
## end params

## read files
grid = IO_util.read_hdf5(dir_in + filename_in_grid)
data = IO_util.read_hdf5(dir_in + filename_in_data)

## convert
if if_cart_to_cyl:
    x, y, z = util_cyl.coord_cart_to_cyl(grid['x'], grid['y'], grid['z'])
    u, v, w = util_cyl.vel_cart_to_cyl(data['u'], data['v'], data['w'], x, y,
                                       z)
else:
    x, y, z = util_cyl.coord_cyl_to_cart(grid['x'], grid['y'], grid['z'])
    u, v, w = util_cyl.vel_cyl_to_cart(data['u'], data['v'], data['w'],
                                       grid['x'], grid['y'], grid['z'])

##out
grid['x'] = x
grid['y'] = y
grid['z'] = z
data['u'] = u
def main():
    '''
    Note:
        The boundary thickness calculation relies on a clear profile  that converges. current code cannot intelligently tell which wall normal profile is "perfect". Thus boundary layer thickness might yield to poor quality if the profile is badly extracted.
    '''
    ###params##
    mrange = range(100, 300, 100)  ## along the wall at which index to extract
    nmax = 75  ## along wall normal direction how many nodes to extract
    fluid_type = 'nitrogen'

    dir_in = './'
    filename_in_data = 'structured_tec.plt'
    is_in_tecplot = True  # Input is of tecplot format ??? False to be HDF5, True to be Tecplot format

    ## files output---------------------------------!
    dir_out = './'
    filename_out_profiles = 'profiles'
    filename_out_integrals = 'integrals'
    ## names of variables---------------------------!
    name_x = 'X'  # name of these variables!
    name_z = 'Y'
    name_u = 'u'
    name_w = 'w'
    name_p = 'p'
    name_T = 'T'
    ## --------------------------------------
    keys_change = {name_x: 'x', name_z: 'z'}
    grid_keys = ['x', 'z']
    ## end params

    tstart = time.time()
    ## read grid and data
    if is_in_tecplot:
        data = util_tp.read_tp(dir_in + filename_in_data, order='F')
        data = next(iter(data.values()))
    else:
        data = IO_util.read_hdf5(dir_in + filename_in_data)
    print('Data read. Time elapsed: %f secs' % (time.time() - tstart))

    ## slice
    data = util_data.change_dict(data, keys_change=keys_change)
    sdata = util_data.structured_data(data, grid_keys)

    ## wall normal profiles
    profiles_out = sdata.get_wall_normal_profiles('top', mrange, nmax)

    ## integral
    mmax = len(mrange)
    delta = np.zeros(mmax)
    delta_star = np.zeros(mmax)
    theta = np.zeros(mmax)
    tauw = np.zeros(mmax)
    utau = np.zeros(mmax)
    ztau = np.zeros(mmax)
    for n in range(mmax):
        wd = profiles_out['wd'][n, :]
        x = profiles_out['x'][n, :]
        z = profiles_out['z'][n, :]
        u = profiles_out[name_u][n, :]
        w = profiles_out[name_w][n, :]
        p = profiles_out[name_p][n, :]
        T = profiles_out[name_T][n, :]

        rho = util_flow.get_rho(profiles_out[name_p][n, :],
                                profiles_out[name_T][n, :],
                                fluid_type=fluid_type)
        up = util_flow.get_up_2d(u, w, x, z)
        delta[n] = util_flow.get_delta(wd, up)
        delta_star[n] = util_flow.get_delta_star(wd, up, rho)
        theta[n] = util_flow.get_theta(wd, up, rho)
        mu = util_flow.get_mu_Sutherland(T[0], fluid_type=fluid_type)
        tauw[n] = np.abs(mu * up[1] / wd[1])
        utau[n] = np.sqrt(tauw[n] / rho[0])
        ztau[n] = mu / rho[0] / utau[n]

    int_out = {}
    int_out['x'] = profiles_out['x'][:, 0]
    int_out['z'] = profiles_out['z'][:, 0]
    int_out['delta'] = delta
    int_out['delta*'] = delta_star
    int_out['theta'] = theta
    int_out['tauw'] = tauw
    int_out['utau'] = utau
    int_out['ztau'] = ztau

    ## out
    IO_util.write_hdf5(dir_out + filename_out_profiles, profiles_out)
    IO_util.write_hdf5(dir_out + filename_out_integrals, int_out)
    IO_util.write_ascii_point(dir_out + filename_out_profiles, profiles_out)
    IO_util.write_ascii_point(dir_out + filename_out_integrals, int_out)
Esempio n. 11
0
def main():
    ###---parameters----###
    shape0 = (32, 256)  #(i,k)
    shape1 = (96, 256)
    shape_out = (16, 100, 140)  #(j,i,k)
    xl = -30.e-4
    yl = .12
    # skip options
    skip_shock = True  #False
    skip_freestream = True  #False
    # Files required to start interpolation
    dir_in = './InitBody/'
    filename_in_body = 'ConeSurfGeometry.dat'
    filename_in_shock = 'ConeShockGeometry.dat'
    dir_IC = '/usr/local/home/yl8bc/yl8bc/data/cone/run9/REST/'
    filename_in_grid_IC = 'grid.h5'
    filename_in_data_IC = 'flowdata_00100000.h5'

    # Files generated by the program
    dir_out = '/usr/local/home/yl8bc/duannas/yl8bc/data/cone/run7_2d_Lele/REST/'
    filename_out_shock = 'cone_grid_flat_shock.h5'
    filename_out_freestream = 'cone_grid_flat_freestream.h5'
    filename_out_full = 'grid.h5'
    filename_out_IC = 'flowdata_00000000.h5'
    filename_out_gd = 'gridDerivative_f.h5'
    ###---no parameters below---#

    if skip_shock:
        grid_tmp = IO_util.read_hdf5(dir_out + filename_out_shock)
        u_s = grid_tmp['x']
        v_s = grid_tmp['z']
    else:
        ## define wall
        body = np.loadtxt(dir_in + filename_in_body, skiprows=2)
        ## define shock
        shock = np.loadtxt(dir_in + filename_in_shock, skiprows=2)
        ## compute shock part
        u_s, v_s = flat_shock.gridgen(shape0, body, shock,
                                      dir_out + filename_out_shock)

    ## compute full grid
    if skip_freestream:
        grid_tmp = IO_util.read_hdf5(dir_out + filename_out_freestream)
        u_f = grid_tmp['x']
        v_f = grid_tmp['z']
    else:
        u_f, v_f = flat_freestream.gridgen(shape1[0], xl, yl, u_s, v_s,
                                           dir_out + filename_out_freestream)

    ## combine grids
    u, v = flat_combined.gridgen(u_f, v_f, u_s, v_s, shape1[0] - 8, shape1[0])
    grid_out = {'x': u, 'z': v}

    ## IC
    grid_IC = IO_util.read_hdf5(dir_IC + filename_in_grid_IC)
    data_IC = IO_util.read_hdf5(dir_IC + filename_in_data_IC)
    data_out = IC_by_interp.ICgen(grid_IC, data_IC, grid_out)

    ## reshape
    grid_out = reshape.reshape_by_index(shape_out[1:], grid_out)
    data_out = reshape.reshape_by_index(shape_out[1:], data_out)

    ## redistribute
    slc_axis = np.s_[:, 0]
    dist_old = grid_out['x'][slc_axis].copy()
    pdist_new = dist.pdist(dist_old[0], dist_old[-1], dist_old.shape[0])
    dist_new = pdist_new.tanh(1.5, type='right')
    grid_out = reshape.redistribute(dist_new, dist_old, grid_out)
    data_out = reshape.redistribute(dist_new, dist_old, data_out)

    ## expand
    grid_out = reshape.expand_spanwise(shape_out[0], grid_out, span_name='y')
    data_out = reshape.expand_spanwise(shape_out[0], data_out)

    ## polar treatment
    #grid_out['z'] = shift.Colonius_shift(grid_out['z'], 2)

    ## regulate
    slc_body = np.s_[:, -1, :]
    data_out['v'][:] = 0.
    data_out['T'][slc_body] = 400.

    ## time
    IC_by_interp.add_time(data_out)

    ## inlet
    data_inlet = {
        key: data_out[key][:, 0:1, :]
        for key in ['T', 'p', 'u', 'v', 'w']
    }

    # RANS
    data_inlet['p'][:] = 6878.1
    data_inlet['u'][:] = 1508.7  #570.
    data_inlet['v'][:] = 0.
    data_inlet['w'][:] = 0.
    data_inlet['T'][:] = 202.08

    ## metrICs
    grid_tmp, grid_derivative = m_gd.analytically_2d(grid_out,
                                                     bc_g=[0, 0, 0, 0, 1, 0],
                                                     bc_gd=[0, 0, 1, 1, 0, 1])

    ## out
    IO_util.write_hdf5(dir_out + filename_out_full, grid_out)
    IO_util.write_hdf5(dir_out + 'ghost', grid_tmp)
    IO_util.write_hdf5(dir_out + filename_out_IC, data_out)
    grid_derivative = m_gd.pack_grid_derivative(grid_derivative)
    IO_util.write_hdf5(dir_out + filename_out_gd, grid_derivative)
    IO_util.write_hdf5(dir_out + 'inlet', data_inlet)
    data_out.update(grid_tmp)
    data_out.update(grid_derivative)
    IO_util.write_hdf5(dir_out + 'vis', data_out)
Esempio n. 12
0
                                       ['pave', 'p2', 'tauw', 'delta'],
                                       order='F')
        tauw = 0.5 * (stat_in['tauw'][:, 0] + stat_in['tauw'][:, -1])
        delta = 0.5 * (stat_in['delta'][:, 0] + stat_in['delta'][:, -1])

    ##  calculation
    stat_out = {}
    stat_out['prms'] = np.sqrt(np.abs(stat_in['p2'] - stat_in['pave']**2))
    prms_tauw_vs_x = stat_out['prms'][:, index_k_vs_x] / tauw
    #
    prms_tauw_vs_z = np.mean(stat_out['prms'][ibe:ien, :] /
                             tauw[ibe:ien, np.newaxis],
                             axis=0)

    ##  read grid atg walls
    grid, gridname = IO_util.read_hdf5(dir_in + filename_grid,
                                       vars_name=['x', 'z'])
    x = grid['x'][:, 0]
    z = np.mean(grid['z'][ibe:ien, :] / delta[ibe:ien, np.newaxis], axis=0)

    ##  plots
    fig, axe = plt.subplots(1, 1)
    axe.plot(x, prms_tauw_vs_x)
    util_plot.labels(axe, 'x/m', r'$p_{rms}/\tau_{w}$')
    util_plot.title(axe, r'$p_{rms}/\tau_{w}$ along k = %d' % index_k_vs_x)
    fig.savefig(dir_out + 'prms_tauw_vs_x.png')
    fig, axe = plt.subplots(1, 1)
    axe.plot(z, prms_tauw_vs_z)
    util_plot.labels(axe, r'$z/\delta$', r'$p_{rms}/\tau_{w}$')
    util_plot.title(axe,
                    r'$p_{rms}/\tau_{w}$ in window i = %d~%d' % (ibe, ien))
    fig.savefig(dir_out + 'prms_tauw_vs_z.png')