sfepy.base.conf module

Problem description file handling.

Notes

Short syntax: key is suffixed with ‘__<number>’ to prevent collisions with long syntax keys -> both cases can be used in a single input.

class sfepy.base.conf.ProblemConf(define_dict, funmod=None, filename=None, required=None, other=None, verbose=True, override=None, setup=True)[source]

Problem configuration, corresponding to an input (problem description file). It validates the input using lists of required and other keywords that have to/can appear in the input. Default keyword lists can be obtained by sfepy.base.conf.get_standard_keywords().

ProblemConf instance is used to construct a Problem instance via Problem.from_conf(conf).

add_missing(conf)[source]

Add missing values from another problem configuration.

Missing keys/values are added also to values that are dictionaries.

Parameters:
confProblemConf instance

The other configuration.

edit(key, newval)[source]
static from_dict(dict_, funmod, required=None, other=None, verbose=True, override=None, setup=True)[source]
static from_file(filename, required=None, other=None, verbose=True, define_args=None, override=None, setup=True)[source]

Loads the problem definition from a file.

The filename can either contain plain definitions, or it can contain the define() function, in which case it will be called to return the input definitions.

The job of the define() function is to return a dictionary of parameters. How the dictionary is constructed is not our business, but the usual way is to simply have a function define() along these lines in the input file:

def define():
    options = {
        'save_eig_vectors' : None,
        'eigen_solver' : 'eigen1',
    }
    region_2 = {
        'name' : 'Surface',
        'select' : 'nodes of surface',
    }
    return locals()

Optionally, the define() function can accept additional arguments that should be defined using the define_args tuple or dictionary.

static from_file_and_options(filename, options, required=None, other=None, verbose=True, define_args=None, setup=True)[source]

Utility function, a wrapper around ProblemConf.from_file() with possible override taken from options.

static from_module(module, required=None, other=None, verbose=True, override=None, setup=True)[source]
get_function(name)[source]

Get a function object given its name.

It can be either in ProblemConf.funmod, or a ProblemConf attribute directly.

Parameters:
namestr or function or None

The function name or directly the function.

Returns:
funfunction or None

The required function, or None if name was None.

get_item_by_name(key, item_name)[source]

Return item with name item_name in configuration group given by key.

get_raw(key=None)[source]
setup(define_dict=None, funmod=None, filename=None, required=None, other=None)[source]
transform_input()[source]
transform_input_trivial()[source]

Trivial input transformations.

update_conf(conf)[source]

Update configuration by values in another problem configuration.

Values that are dictionaries are updated in-place by dict.update().

Parameters:
confProblemConf instance

The other configuration.

validate(required=None, other=None)[source]
sfepy.base.conf.dict_from_options(options)[source]

Return a dictionary that can be used to construct/override a ProblemConf instance based on options.

See --conf and --options options of the simple.py script.

sfepy.base.conf.dict_from_string(string, allow_tuple=False, free_word=False)[source]

Parse string and return a dictionary that can be used to construct/override a ProblemConf instance.

sfepy.base.conf.get_standard_keywords()[source]
sfepy.base.conf.transform_conditions(adict, prefix)[source]
sfepy.base.conf.transform_dgebcs(adict)[source]
sfepy.base.conf.transform_dgepbcs(adict)[source]
sfepy.base.conf.transform_ebcs(adict)[source]
sfepy.base.conf.transform_epbcs(adict, prefix='epbc')[source]
sfepy.base.conf.transform_fields(adict)[source]
sfepy.base.conf.transform_functions(adict)[source]
sfepy.base.conf.transform_ics(adict)[source]
sfepy.base.conf.transform_integrals(adict)[source]
sfepy.base.conf.transform_lcbcs(adict)[source]
sfepy.base.conf.transform_materials(adict)[source]
sfepy.base.conf.transform_regions(adict)[source]
sfepy.base.conf.transform_solvers(adict)[source]
sfepy.base.conf.transform_to_i_struct_1(adict)[source]
sfepy.base.conf.transform_to_struct_01(adict)[source]
sfepy.base.conf.transform_to_struct_1(adict)[source]
sfepy.base.conf.transform_to_struct_10(adict)[source]
sfepy.base.conf.transform_variables(adict)[source]
sfepy.base.conf.tuple_to_conf(name, vals, order)[source]

Convert a configuration tuple vals into a Struct named name, with attribute names given in and ordered by order.

Items in order at indices outside the length of vals are ignored.