Robert,

My script goes attached. The function is specified in line 262, defined in line 41 and used in term t4 in line 302. 

Thanks!



On Thursday, March 31, 2016 at 1:46:43 AM UTC-5, Robert Cimrman wrote:
Hi Adolfo,

On 03/31/2016 02:02 AM, Adolfo Rodriguez wrote:
> I am trying to use a "parameter" field variable in interactive mode. What I
> am trying to do is very similar to the thermo-elaticity example, but for
> some reason I cannot make it work in interactive mode.

Note that you can set data of a variable directly in the interactive mode,
using Variable.set_data().

> In the thermo-elasticity example the parameter field variable is defined as
> follows
>
> def get_temperature_load(ts, coors, region=None):
>      """    Temperature load depends on the `x` coordinate.    """
>      x = coors[:, 0]
>      return (x - x.min())**2 - T0
>
>
> fields = {
>      'displacement': ('real', 3, 'Omega', 1),
>      'temperature': ('real', 1, 'Omega', 1),}
>
>
> variables = {
>      'u' : ('unknown field', 'displacement', 0),
>      'v' : ('test field', 'displacement', 'u'),
>      'T' : ('parameter field', 'temperature',
>             {'setter' : 'get_temperature_load'}),}
>
>
> equations = {
>      'balance_of_forces' :
>      """dw_lin_elastic.2.Omega( solid.D, v, u )     - dw_biot.2.Omega( solid.alpha, v, T )     = 0""",}
>
>
> In interactive mode this is what I am doing the following:
>
> field_p = Field.from_args('fp', nm.float64, 1, omega,
>
>                                 approx_order=order_p)
>
>
> press_load = Function('press_load',get_pressure_load)
>
> press = FieldVariable('pressure','parameter',field_p,special={'setter'
> :press_load},
>
>                            primary_var_name='(set-to-None)')
>
>
> And the corresponding term:
>
>
> t20 = Term.new('dw_laplace(matalpha.k, q, press)',
>
>                     integral, omega, matalpha=matalpha, q=q, press=press)
>
>
> But this does not work.

Could you send the code that does not work, that could be run and tried? There
might be a bug because I have never used a setter function in the interactive
mode - I use set_data() directly instead - see also FieldVariable.time_update().

r.