示例#1
0
import libspud
print libspud.__file__

libspud.load_options('test.flml')

libspud.print_options()

print libspud.number_of_children('/geometry')
print libspud.get_child_name('geometry', 0)

print libspud.option_count('/problem_type')
print libspud.have_option('/problem_type')

print libspud.get_option_type('/geometry/dimension')
print libspud.get_option_type('/problem_type')

print libspud.get_option_rank('/geometry/dimension')
print libspud.get_option_rank(
    '/physical_parameters/gravity/vector_field::GravityDirection/prescribed/value/constant'
)

print libspud.get_option_shape('/geometry/dimension')
print libspud.get_option_shape('/problem_type')

print libspud.get_option('/problem_type')
print libspud.get_option('/geometry/dimension')
libspud.set_option('/geometry/dimension', 3)
print libspud.get_option('/geometry/dimension')

list_path = '/material_phase::Material1/scalar_field::MaterialVolumeFraction/prognostic/boundary_conditions::LetNoOneLeave/surface_ids'
print libspud.get_option_shape(list_path)
import libspud

libspud.load_options('test.flml')

#libspud.print_options()

assert libspud.get_option('/timestepping/timestep') == 0.025

assert libspud.get_number_of_children('/geometry') == 5
assert libspud.get_child_name('geometry', 0) == "dimension"

assert libspud.option_count('/problem_type') == 1
assert libspud.have_option('/problem_type')

assert libspud.get_option_type('/geometry/dimension') is int
assert libspud.get_option_type('/problem_type') is str

assert libspud.get_option_rank('/geometry/dimension') == 0
assert libspud.get_option_rank(
    '/physical_parameters/gravity/vector_field::GravityDirection/prescribed/value/constant'
) == 1

assert libspud.get_option_shape('/geometry/dimension') == (-1, -1)
assert libspud.get_option_shape('/problem_type')[0] > 1
assert libspud.get_option_shape('/problem_type')[1] == -1

assert libspud.get_option('/problem_type') == "multimaterial"
assert libspud.get_option('/geometry/dimension') == 2
libspud.set_option('/geometry/dimension', 3)

assert libspud.get_option('/geometry/dimension') == 3
示例#3
0
def gen_flmls(params, template_dir, output_dir, paths, names, verbose):

    import types

    # get flml file from template_dir - first one we come across
    # If you have more in there, tough.
    full_flml = glob.glob(os.path.join(template_dir, '*.flml'))[0]
    # strip to the filename only
    flml = os.path.basename(full_flml)

    f = open(os.path.join(output_dir, 'runs', "directory_listing.csv"), "w")
    # append data to directory listing file
    line = "Directory number"
    for n in names:
        line = line + "," + n

    line = line + "\n"
    f.write(line)

    # loop over paramas
    # create a new directory, with a unqiue number, starting from 1
    # This makes it easier to use in an array job on CX1
    dir_num = 1
    for p_set in params:
        if (verbose):
            print "Processing " + str(dir_num)

        # copy contents from template folder to directory number
        dirname = os.path.join(output_dir, 'runs', str(dir_num))
        if (os.path.exists(os.path.join(dirname))):
            shutil.rmtree(dirname)
        shutil.copytree(template_dir, dirname)

        # open FLML file
        output_file = os.path.join(dirname, flml)
        # This load the data into the memory of the libspud library
        libspud.load_options(output_file)

        i = 0
        for path in paths:
            path = path.strip()
            # get type
            path_type = libspud.get_option_type(path)
            path_rank = libspud.get_option_rank(path)
            path_shape = libspud.get_option_shape(path)
            if (path_type is float and path_rank == 0):
                libspud.set_option(path, float(p_set[i]))
            elif (path_rank == 1 and path_type is float):
                value = eval(p_set[i])
                val = list(map(float, value))
                libspud.set_option(path, val)
            elif (path_rank == 2 and path_type is float):
                value = eval(p_set[i])
                val = []
                for row in value:
                    val.append(list(map(float, row)))
                libspud.set_option(path, val)

            i = i + 1

        # save file
        libspud.write_options(output_file)

        # append data to directory listing file
        line = str(dir_num)
        for p in p_set:
            # quoting the params so csv parsers can get the columns right
            line = line + "," + '"' + str(p) + '"'
        line = line + "\n"
        f.write(line)

        dir_num += 1

    f.close()
示例#4
0
import libspud

libspud.load_options('test.flml')

#libspud.print_options()

assert libspud.get_option('/timestepping/timestep') == 0.025

assert libspud.get_number_of_children('/geometry') == 5
assert libspud.get_child_name('geometry', 0) == "dimension"

assert libspud.option_count('/problem_type') == 1
assert libspud.have_option('/problem_type')

assert libspud.get_option_type('/geometry/dimension') is int
assert libspud.get_option_type('/problem_type') is str

assert libspud.get_option_rank('/geometry/dimension') == 0
assert libspud.get_option_rank('/physical_parameters/gravity/vector_field::GravityDirection/prescribed/value/constant') == 1

assert libspud.get_option_shape('/geometry/dimension') == (-1, -1)
assert libspud.get_option_shape('/problem_type')[0] > 1
assert libspud.get_option_shape('/problem_type')[1] == -1

assert libspud.get_option('/problem_type') == "multimaterial"
assert libspud.get_option('/geometry/dimension') == 2
libspud.set_option('/geometry/dimension', 3)


assert libspud.get_option('/geometry/dimension') == 3
示例#5
0
def gen_flmls(params, template_dir, output_dir, paths, names, verbose):

    import types

    # get flml file from template_dir - first one we come across
    # If you have more in there, tough.
    full_flml = glob.glob(os.path.join(template_dir,'*.flml'))[0]
    # strip to the filename only
    flml = os.path.basename(full_flml)

    f = open(os.path.join(output_dir,'runs',"directory_listing.csv"),"w")
    # append data to directory listing file
    line = "Directory number"
    for n in names:
        line = line+","+n

    line = line + "\n"
    f.write(line)

    # loop over paramas
    # create a new directory, with a unqiue number, starting from 1
    # This makes it easier to use in an array job on CX1
    dir_num = 1
    for p_set in params:
        if (verbose):
            print "Processing "+str(dir_num)

        # copy contents from template folder to directory number
        dirname = os.path.join(output_dir,'runs',str(dir_num))
        if (os.path.exists(os.path.join(dirname))):
            shutil.rmtree(dirname)
        shutil.copytree(template_dir,dirname)

        # open FLML file
        output_file = os.path.join(dirname,flml)
        # This load the data into the memory of the libspud library
        libspud.load_options(output_file)

        i = 0
        for path in paths:
            path = path.strip()
            # get type
            path_type = libspud.get_option_type(path)
            path_rank = libspud.get_option_rank(path)
            path_shape = libspud.get_option_shape(path)
            if (path_type is float and path_rank == 0):
                libspud.set_option(path,float(p_set[i]))
            elif (path_rank == 1 and path_type is float):
                value = eval(p_set[i])
                val = list(map(float, value))
                libspud.set_option(path,val)
            elif (path_rank == 2 and path_type is float):
                value = eval(p_set[i])
                val = []
                for row in value:
                    val.append(list(map(float, row)))
                libspud.set_option(path,val)

            i = i+1

        # save file
        libspud.write_options(output_file)
            
        # append data to directory listing file
        line = str(dir_num)
        for p in p_set:
            # quoting the params so csv parsers can get the columns right
            line = line+","+'"'+str(p)+'"'
        line = line +"\n"
        f.write(line)

        dir_num += 1


    f.close()
import libspud
print libspud.__file__

libspud.load_options('test.flml')

libspud.print_options()

print libspud.number_of_children('/geometry')
print libspud.get_child_name('geometry', 0)

print libspud.option_count('/problem_type')
print libspud.have_option('/problem_type')

print libspud.get_option_type('/geometry/dimension')
print libspud.get_option_type('/problem_type')

print libspud.get_option_rank('/geometry/dimension')
print libspud.get_option_rank('/physical_parameters/gravity/vector_field::GravityDirection/prescribed/value/constant')

print libspud.get_option_shape('/geometry/dimension')
print libspud.get_option_shape('/problem_type')

print libspud.get_option('/problem_type')
print libspud.get_option('/geometry/dimension')
libspud.set_option('/geometry/dimension', 3)
print libspud.get_option('/geometry/dimension')

list_path = '/material_phase::Material1/scalar_field::MaterialVolumeFraction/prognostic/boundary_conditions::LetNoOneLeave/surface_ids'
print libspud.get_option_shape(list_path)
print libspud.get_option_rank(list_path)
print libspud.get_option(list_path)