def adaptive(rootdir, norm, ref, file, inifile="blob-convection.ini"):
    dirsx = glob.glob(rootdir)
    e, Nb, eps_list, Jmax_list, compression_list = [], [], [], [], []
    if len(dirsx) == 0:
        raise ValueError('no data')

    for d in dirsx:
        eps = wt.get_ini_parameter(d + "/" + inifile, "Blocks", "eps")
        Jmax = wt.get_ini_parameter(d + "/" + inifile,
                                    "Blocks",
                                    "max_treelevel",
                                    dtype=np.int32)
        eps_list.append(eps)
        Jmax_list.append(Jmax)

        fpath = d + "/" + file
        fpath_sparse = d + "/" + file.replace("-dense", "")
        if (os.path.isfile(fpath)):
            # compute error
            field, box, dx, X = wt.to_dense_grid(fpath)
            err = np.linalg.norm(field - ref, ord=norm) / np.linalg.norm(
                ref, ord=norm)
            e.append(err)
            print("rel error: %f" % err)
            if (os.path.isfile(fpath_sparse)):
                Nbl_sparse = sum(
                    wt.block_level_distribution_file(fpath_sparse))
                Nbl_dense = sum(wt.block_level_distribution_file(fpath))
                compression_list.append(Nbl_sparse / Nbl_dense)

    return e, Jmax_list, eps_list, compression_list
def adaptive(rootdir, norm, ref, file, inifile="blob-convection.ini"):
    dirsx = glob.glob(rootdir)
    e, Nb, eps_list, Jmax_list, compression_list = [], [], [], [], []
    if len(dirsx) == 0:
        raise ValueError('no data')

    for d in dirsx:
        eps = wt.get_ini_parameter(d + "/" + inifile, "Blocks", "eps")
        Jmax = wt.get_ini_parameter(d + "/" + inifile,
                                    "Blocks",
                                    "max_treelevel",
                                    dtype=np.int32)
        eps_list.append(eps)
        Jmax_list.append(Jmax)

        fpath = d + "/" + file
        fpath_sparse = d + "/" + file.replace("-dense", "")
        if (os.path.isfile(fpath)):
            # compute error
            err = wt.wabbit_error_vs_wabbit(fpath, ref, norm=norm)
            e.append(err)
            if (os.path.isfile(fpath_sparse)):
                Nbl_sparse = sum(
                    wt.block_level_distribution_file(fpath_sparse))
                Nbl_dense = sum(wt.block_level_distribution_file(fpath))
                compression_list.append(Nbl_sparse / Nbl_dense)

    return e, Jmax_list, eps_list, compression_list
def err_equidist(rootdir, norm, ref, file, inifile="blob-convection.ini"):
    dirsx = glob.glob(rootdir)
    e, Jmax_list = [], []
    if len(dirsx) == 0:
        raise ValueError('no data')

    for d in dirsx:
        Jmax = wt.get_ini_parameter(d + "/" + inifile,
                                    "Blocks",
                                    "max_treelevel",
                                    dtype=np.int32)
        Jmax_list.append(Jmax)

        fpath = d + "/" + file
        fpath_ref = d + "/" + ref

        if (os.path.isfile(fpath)):
            # compute error
            err = wt.wabbit_error_vs_wabbit(fpath, fpath_ref, norm=norm)
            e.append(err)

    return e, Jmax_list
def err_equidist(rootdir, norm, ref, file, inifile="blob-convection.ini"):
    dirsx = glob.glob(rootdir)
    e, Jmax_list = [], []
    if len(dirsx) == 0:
        raise ValueError('no data')

    for d in dirsx:
        Jmax = wt.get_ini_parameter(d + "/" + inifile,
                                    "Blocks",
                                    "max_treelevel",
                                    dtype=np.int32)
        Jmax_list.append(Jmax)

        fpath = d + "/" + file

        if (os.path.isfile(fpath)):
            # compute error
            field, box, dx, X = wt.to_dense_grid(fpath)
            err = np.linalg.norm(field - ref, ord=norm) / np.linalg.norm(
                ref, ord=norm)
            e.append(err)
            print("rel error: %f" % err)

    return e, Jmax_list
else:
    dir = args.directory

if dir[-1] is not '/':
    dir = dir + '/'

#------------------------------------------------------------------------------
# look for the ini file, this gives us the information at what time the run is done
if args.paramsfile is None:
    l = glob.glob(dir + '*.ini')
    inifile = l[0]
else:
    inifile = args.paramsfile

#------------------------------------------------------------------------------
if not os.path.isfile(dir + 'timesteps_info.t'):
    raise ValueError("The file timesteps_info.t has not been found here.")

# load the data file
d = insect_tools.load_t_file(dir + 'timesteps_info.t', verbose=False)

# final time to reach according to paramsfile
T = wabbit_tools.get_ini_parameter(inifile, 'Time', 'time_max', float)

if d[-1, 0] >= 0.99 * T:
    # run is done
    print('0   (The simulation is done!)')
    sys.exit(0)
else:
    print('1   (The simulation is not yet complete!)')
    sys.exit(1)
示例#6
0
    print("program           = %s%s%s" %
          (bcolors.OKBLUE, progfile, bcolors.ENDC))
    print("paramsfile        = %s%s%s" %
          (bcolors.OKBLUE, paramsfile, bcolors.ENDC))
    print("memory in call    = %s%2.2f%s GB (%s%2.2f%s GB/core)" %
          (bcolors.OKBLUE, memory, bcolors.ENDC, bcolors.OKBLUE, memory / ncpu,
           bcolors.ENDC))
    print("max memory        = %s%i%s GB" %
          (bcolors.OKBLUE, maxmem, bcolors.ENDC))
    print("max memory (safe) = %s%i%s GB" %
          (bcolors.OKBLUE, maxmem - 5.0, bcolors.ENDC))
    print("ncpu              = %s%i%s" % (bcolors.OKBLUE, ncpu, bcolors.ENDC))
    print("wtime (jobfile)   = %s%i%s sec (%2.2f hours)" %
          (bcolors.OKBLUE, wtime, bcolors.ENDC, wtime / 3600.0))
    wtime_ini = wabbit_tools.get_ini_parameter(paramsfile, "Time",
                                               "walltime_max", float)
    # hours to seconds
    wtime_ini *= 3600.0
    print("wtime (inifile)   = %s%i%s sec (%2.2f hours)" %
          (bcolors.OKBLUE, wtime_ini, bcolors.ENDC, wtime_ini / 3600.0))

    if auto_resub:
        print('RESUBMISSION      : %sAutomatic resubmission is ACTIVE%s' %
              (bcolors.WARNING, bcolors.ENDC))
    else:
        print(
            'RESUBMISSION      : %sAutomatic resubmission is DEACTIVTÀTED!!%s'
            % (bcolors.WARNING, bcolors.ENDC))

    if memory >= 0.98 * maxmem:
        print('Memory check      : %sEXCEEDED%s' %
示例#7
0
# load the data file
d = insect_tools.load_t_file(dir + 'performance.t', verbose=verbose)

# if we consider only a few time steps, we discard the others:
if args.first_n_time_steps is not None:
    d = d[0:args.first_n_time_steps + 1, :]

# if we consider only a few time steps, we discard the others:
if args.last_m_time_steps is not None:
    d = d[-args.last_m_time_steps:, :]

# figure out how many RHS evaluatins we do per time step
method = wabbit_tools.get_ini_parameter(inifile,
                                        'Time',
                                        'time_step_method',
                                        str,
                                        default="RungeKuttaGeneric")

# default is one (even though that might be wrong...)
nrhs = 1

if method == "RungeKuttaGeneric":
    # this is not always true, but most of the time (butcher_tableau)
    nrhs = 4.0
elif method == "RungeKuttaChebychev":
    nrhs = wabbit_tools.get_ini_parameter(inifile, 'Time', 's', float)

# if we perform more than one dt on the same grid, this must be taken into account as well
N_dt_per_grid = wabbit_tools.get_ini_parameter(inifile,
                                               'Blocks',
示例#8
0
    print("program           = %s%s%s" %
          (bcolors.OKBLUE, progfile, bcolors.ENDC))
    print("paramsfile        = %s%s%s" %
          (bcolors.OKBLUE, paramsfile, bcolors.ENDC))
    print("memory in call    = %s%2.2f%s GB (%s%2.2f%s GB/core)" %
          (bcolors.OKBLUE, memory, bcolors.ENDC, bcolors.OKBLUE, memory / ncpu,
           bcolors.ENDC))
    print("max memory        = %s%i%s GB" %
          (bcolors.OKBLUE, maxmem, bcolors.ENDC))
    print("max memory (safe) = %s%i%s GB" %
          (bcolors.OKBLUE, maxmem - 5.0, bcolors.ENDC))
    print("ncpu              = %s%i%s" % (bcolors.OKBLUE, ncpu, bcolors.ENDC))
    print("wtime (jobfile)   = %s%i%s sec (%2.2f hours)" %
          (bcolors.OKBLUE, wtime, bcolors.ENDC, wtime / 3600.0))
    wtime_ini = wabbit_tools.get_ini_parameter(paramsfile, "Time",
                                               "walltime_max", float)
    # hours to seconds
    wtime_ini *= 3600.0
    print("wtime (inifile)   = %s%i%s sec (%2.2f hours)" %
          (bcolors.OKBLUE, wtime_ini, bcolors.ENDC, wtime_ini / 3600.0))

    if auto_resub:
        print('RESUBMISSION      : %sAutomatic resubmission is ACTIVE%s' %
              (bcolors.WARNING, bcolors.ENDC))
    else:
        print(
            'RESUBMISSION      : %sAutomatic resubmission is DEACTIVTÀTED!!%s'
            % (bcolors.WARNING, bcolors.ENDC))

    if memory >= 0.98 * maxmem:
        print('Memory check      : %sEXCEEDED%s' %
示例#9
0
    help='Value for N_tau (default: 20.0)',
    default=20.0,
)

args = parser.parse_args()

file = args.file[0]
K_eta = args.Keta[0]
Ntau = args.Ntau

print("K_eta=%f N_tau=%f" % (K_eta, Ntau))

import wabbit_tools

Bs = wabbit_tools.get_ini_parameter(file,
                                    'Blocks',
                                    'number_block_nodes',
                                    vector=True)
Jmax = wabbit_tools.get_ini_parameter(file, 'Blocks', 'max_treelevel')
L = wabbit_tools.get_ini_parameter(file, 'Domain', 'domain_size', vector=True)
nu = wabbit_tools.get_ini_parameter(file, 'ACM-new', 'nu')

dx = L[0] * (2**-Jmax) / (Bs[0] - 1)

C_eta = (K_eta * dx)**2 / nu

import os
command = "replace_ini_value.py " + file + " VPM C_eta %e" % (C_eta)
os.system(command)

use_sponge = wabbit_tools.get_ini_parameter(file,
                                            'Sponge',
示例#10
0
    inifile = args.paramsfile

# load the data file
d = insect_tools.load_t_file(dir + 'performance.t', verbose=verbose)

tstart = d[0, 0]
tnow = d[-1, 0]
# how many time steps did we already do?
nt_now = d.shape[0]
nt = min(20, nt_now)

if verbose:
    print("We found and extract the final time in the simulation from: " +
          inifile)

T = wabbit_tools.get_ini_parameter(inifile, 'Time', 'time_max', float)
bs = wabbit_tools.get_ini_parameter(inifile,
                                    'Blocks',
                                    'number_block_nodes',
                                    int,
                                    vector=True)
dim = wabbit_tools.get_ini_parameter(inifile, 'Domain', 'dim', int)

if len(bs) == 1:
    npoints = (bs - 1)**dim
else:
    npoints = np.product(bs)

# how long did this run run already
runtime = sum(d[:, 2]) / 3600