sfepy/sfepy — Issue #40: unify passing extra arguments to BC, material, and region functions
Author: rc
Created: 2012-01-30 10:24:34+00:00
State: open

Current situation:
material:
1. via 'extraArgs' in input - function is given by name only
2. via extraMatArgs keyword argument passed to ProblemDefinition.timeUpdate()

bc: passing a global variable as keyword argument to BC function in input -
function is given by name only

region: (nodes by function mode...)
1. positional arguments after the obligatory x, y, z in input - function
is given with arguments
2. same as bc may also work (not tested)

Examples and proposals will come later.

Migrated from http://code.google.com/p/sfepy/issues/detail?id=36

earlier comments

robert.cimrman said, at 2008-12-17T15:32:54.000Z:

Instead of the "hackish" way of giving the function by its name (string) let's put in
the proper function instance:

---
def f( standard_args ):
pass

material_1 = {
...
'function' = f,
...
}
---

in case one needs some extra arguments:

---
some_extra_args = ...

def f( standard_args, **some_extra_args ):
pass

material_1 = {
...
'function' = lambda standard_args: f( standard_args, **some_extra_args ),
...
}
---

The only exception would be when defining the regions:

region_1 = {
'name' : 'Inlet',
'select' : 'nodes by cinc( x, y, z, 0 )',
}

could be replaced by:

functions = {
'cinc_0' : lambda x, y, z: cinc( x, y, z, 0 ),
}

region_1 = {
'name' : 'Inlet',
'select' : 'nodes by cinc_0',
}

Note that having the new keyword 'functions' works for all the other cases (BC,
materials, ...) too.

robert.cimrman said, at 2009-09-03T14:53:26.000Z:

Implemented using the 'functions' keyword. See tests/test_functions.py for syntax.