Ah, yes, I misinterpreted the e-16 values, of course this is zero.
Thank you very much!
Quinta-feira, 16 de Maio de 2013 16:46:56 UTC+1, Robert Cimrman escreveu:
The following works for me:
def Def_Sigma(ts,coors,region=None):
x = coors[:,0]
y = coors[:,1]
#val = x*y
val = nm.ones_like(x)
return val
Maybe run postproc.py with the "-b" option to see colorbars with data ranges:
sfepy: cell vectors Grad_S at [ 0. 0. 0.]
sfepy: range: -8.88e-16 8.88e-16 l2 norm range: 0.00e+00 9.93e-16
The values are machine-precision zeros.
r.
On 05/16/2013 05:00 PM, dj....@gmx.de wrote:
> Assigning values 0 to the variable S in my example leads to a calculation
> of a gradient of S = 0 everywhere which is correct.
> But assigning other constant values (like 1) leads to different results for
> the gradient of S, not 0 although it should also be.
> Just wondered if it has to do with the evaluating function: gradS =
> pb.evaluate('ev_grad.i2.Omega(S)', S=vv, mode='el_avg') ?
>
> Thx
> Djamil
>
>
>
> Quinta-feira, 16 de Maio de 2013 12:15:07 UTC+1, dj....@gmx.de escreveu:
>>
>> Thanks Robert! Works fine.
>> :)
>>
>> Quinta-feira, 16 de Maio de 2013 11:31:26 UTC+1, Robert Cimrman escreveu:
>>>
>>> On 05/16/2013 11:22 AM, dj....@gmx.de wrote:
>>>> Dear Robert,
>>>> you are right, the parameter S is not used in the equations, so I would
>>>> have to define it. I tried it without success. Do you have an example
>>> how
>>>> to define it correctly in the postproc-function?
>>>> I add the code below which gives the mentioned error (argument S not
>>>> found). It's using the rectangle_fine_tri.mesh.
>>>
>>> It can be easily created in this way:
>>>
>>> vv = pb.create_variables('S')['S']
>>> vv.time_update(None, pb.functions)
>>> gradS = pb.evaluate('ev_grad.i2.Omega(S)', S=vv, mode='el_avg')
>>> out['Grad_S'] = Struct(name='output_S', mode='cell', data=gradS,
>>> dofs=None)
>>>
>>> The example file works after adding the first two lines into the
>>> post_process()
>>> function (notice the modification of the third line!).
>>>
>>> Cheers,
>>> r.
>>>
>>>> Thanks
>>>> Djamil
>>>>
>>>> Quarta-feira, 15 de Maio de 2013 21:42:37 UTC+1, Robert Cimrman
>>> escreveu:
>>>>>
>>>>> Hi!
>>>>>
>>>>> On 05/15/2013 04:46 PM, dj....@gmx.de <javascript:> wrote:
>>>>>> Dear sfepy group,
>>>>>>
>>>>>> I defined a parameter field S and tried to use a function to assign
>>>>> certain
>>>>>> values to the parameter depending of the coordinates.
>>>>>> Like this (simplified):
>>>>>>
>>>>>> variable_7 = {
>>>>>> 'name' : 'S',
>>>>>> 'kind' : 'parameter field',
>>>>>> 'field' : 'pressure',
>>>>>> 'like' : None,
>>>>>> 'special' : {'setter' : 'Def_Sigma'},
>>>>>> }
>>>>>>
>>>>>> def Def_Sigma(ts,coors,region=None):
>>>>>> x = coors[:,0]
>>>>>> y = coors[:,1]
>>>>>> val = x*y*10
>>>>>> return val
>>>>>>
>>>>>> The field is:
>>>>>>
>>>>>> field_1 = {
>>>>>> 'name' : 'pressure',
>>>>>> 'dtype' : nm.float64,
>>>>>> 'shape' : (1,),
>>>>>> 'region' : 'Omega',
>>>>>> 'approx_order' : '1',
>>>>>> }
>>>>>>
>>>>>> When I try to calculate the gradient of the parameter S field in a
>>>>>> post-process-hook I always get an error:
>>>>>>
>>>>>> def post_process(out, pb, state, extend=False):
>>>>>> from sfepy.base.base import Struct
>>>>>>
>>>>>> div = pb.evaluate('ev_grad.i2.Omega(S)',mode='el_avg')
>>>>>> out['Grad_S'] = Struct(name='output_data', mode='cell',
>>> data=div,
>>>>>> dofs=None)
>>>>>>
>>>>>> return out
>>>>>>
>>>>>> The error is:
>>>>>> Argument S not found.
>>>>>
>>>>> Is the variable S used in the equations (like, e.g. in [1])? If not,
>>> it is
>>>>> not
>>>>> created/set by the solver at all. In that case, you would have to
>>> create
>>>>> it
>>>>> manually in the post_process() function.
>>>>>
>>>>> Anyway, it would help if you send a complete file (preferably using
>>> one of
>>>>> the
>>>>> sfepy meshes), so that I could run it.
>>>>>
>>>>> r.
>>>>>
>>>>> [1]
>>>>>
>>> http://sfepy.org/doc-devel/examples/thermo_elasticity/ thermo_elasticity.html
>>>>>
>>>>
>>>
>>>
>