Exemplo n.º 1
0
        # enter the smallest wavenumber represented by this spectrum
        wn1 = 15  #determined here from cbc spectrum properties

        #------------------------------------------------------------------------------
        # END USER INPUT
        #------------------------------------------------------------------------------
        t0 = time.time()

        if use_threads:
            u, v, w = isoturbo.generate_isotropic_turbulence(
                lx, ly, lz, nx, ny, nz, nmodes, wn1, cbc_specf, False, False,
                FileFormats.FLAT)
        else:
            u, v, w = isoturb.generate_isotropic_turbulence(
                lx, ly, lz, nx, ny, nz, nmodes, wn1,
                cbc_specf)  # this doesnt support file formats yet

        t1 = time.time()
        times[i, j] = t1 - t0
        print 'it took me ', t1 - t0, ' s to generate the isotropic turbulence.'

        # verify that the generated velocities fit the spectrum
        knyquist, wavenumbers, tkespec = compute_tke_spectrum(
            u, v, w, lx, ly, lz, False)

        # analyze how well we fit the input spectrum
        espec = cbc_specf(kcbc)  # compute the cbc original spec

        #find index of nyquist limit
        idx = (np.where(wavenumbers == knyquist)[0][0]) - 1
Exemplo n.º 2
0
# determine the maximum wave number that can be represented on this grid.
# see wnn below
dx = lx / nx
dy = ly / ny
dz = lz / nz

t0 = time.time()
if use_threads:
    u, v, w = isoturbo.generate_isotropic_turbulence(patches, lx, ly, lz, nx,
                                                     ny, nz, nmodes, wn1,
                                                     whichspec)
elif use_cuda:
    u, v, w = cudaturbo.generate_isotropic_turbulence(lx, ly, lz, nx, ny, nz,
                                                      nmodes, wn1, whichspec)
else:
    u, v, w = isoturb.generate_isotropic_turbulence(lx, ly, lz, nx, ny, nz,
                                                    nmodes, wn1, whichspec)
t1 = time.time()
elapsed_time = t1 - t0
print('it took me ', elapsed_time, 's to generate the isotropic turbulence.')

if enableIO:
    if use_threads:
        isoio.writefileparallel(u, v, w, dx, dy, dz, fileformat)
    else:
        isoio.writefile('u_' + fileappend + '.txt', 'x', dx, dy, dz, u,
                        fileformat)
        isoio.writefile('v_' + fileappend + '.txt', 'y', dx, dy, dz, v,
                        fileformat)
        isoio.writefile('w_' + fileappend + '.txt', 'z', dx, dy, dz, w,
                        fileformat)