Quoting LUK ShunTim <[EMAIL PROTECTED]>:
>
> Can you explain what do the arguments in mfd.eval('[0, x[1]*x[1]/1000]')
> in this line
>
> b1.set('param', 'M', mfd, mfd.eval('[0, x[1]*x[1]/1000]'))
It evaluates the vector field [0, x^2/1000] on the mesh_fem mfd. There is no
magic in the eval function, its source code is really short:
def eval(self, expression):
"""interpolate an expression on the (lagrangian) MeshFem.
Examples:
mf.eval('x[0]*x[1]') interpolates the function 'x*y'
mf.eval('[x[0],x[1]]') interpolates the vector field '[x,y]'
"""
P=self.dof_nodes()
nbd = P.shape[1];
if not self.is_lagrangian:
raise RuntimeError('cannot eval on a non-Lagragian MeshFem')
if self.qdim() != 1:
raise RuntimeError('only works (for now) with qdim == 1')
x=P[:,0]; r=numarray.array(eval(expression))
Z=numarray.zeros(r.shape + (nbd,),'d')
for i in range(0,nbd):
x=P[:,i]
Z[...,i]=eval(expression)
return Z
> Does MeshFem.eval() requires a numarray array argument?
No, it is just a string expression that is dynamically evaluated for each dof
node. For vector fields, just enclose the expression in brackets.
--
Julien
_______________________________________________
Getfem-users mailing list
[email protected]
https://mail.gna.org/listinfo/getfem-users