thegooglecodearchive / sfepy

Automatically exported from code.google.com/p/sfepy
0 stars 0 forks source link

unify passing extra arguments to BC, material, and region functions #36

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by robert.c...@gmail.com on 7 May 2008 at 10:07

GoogleCodeExporter commented 9 years ago
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.

Original comment by robert.c...@gmail.com on 17 Dec 2008 at 3:32

GoogleCodeExporter commented 9 years ago
Implemented using the 'functions' keyword. See tests/test_functions.py for 
syntax.

Original comment by robert.c...@gmail.com on 3 Sep 2009 at 2:53

GoogleCodeExporter commented 9 years ago
Migrated to http://github.com/sfepy/sfepy/issues/40

Original comment by robert.c...@gmail.com on 30 Jan 2012 at 10:24