Hello,
after much trying I figured I need your help.
I managed to calculate the scalar field variable using sfepy
field = Field.from_args('fu', np.float64, 'scalar', omega,
space='H1', poly_space_base='lagrange', approx_order=2)
u = FieldVariable('u', 'unknown', field)
...
I can evaluate it at arbitrary points using probes or directly:
p = zeros((500,2))
p[:,0] = linspace(-10,10,500)
u.evaluate_at(p)
Now I need the gradient, I don't want the average cell value
as I am using it to integrate particle path through the field.
This is what I tried:
vecfield = Field.from_args('fgradu', field.dtype, 'vector',
field.region, space=field.space, poly_space_base=field.poly_space_base,
approx_order=field.approx_order)
gradu = FieldVariable('gradu', 'parameter', vecfield,
primary_var_name='(set-to-None)')
from sfepy.discrete.fem.geometry_element import geometry_data
gdata = geometry_data['2_3']
nc = len(gdata.coors)
ivn = Integral('ivn', 'custom', gdata.coors, [gdata.volume / nc] * nc)
d = u.evaluate('grad', integral=i)
gradu.set_data_from_qp(d, i)
Now I can use gradu.evaluate_at(p), however it is not precise.
Even (u.evaluate_at(x+dx)-u.evaluate_at(x))/dx is better.
I suspect some interpolation is still going on. I thought the special
Integral I got from one of the examples was supposed to eliminate the
interpolation. Where is the catch?
Thanks for help
Jozef