Thread Previous • Date Previous • Date Next • Thread Next |
Kristian Oelgaard wrote:
On 6 July 2010 14:52, Patrick Riesen <priesen@xxxxxxxxxxxxxxx> wrote:Kristian Oelgaard wrote:On 6 July 2010 14:07, Patrick Riesen <priesen@xxxxxxxxxxxxxxx> wrote:Garth N. Wells wrote:On 06/07/10 13:25, Patrick Riesen wrote:hello, i want to take the gradient of a coefficient with respect to some other quantity than the spatial coordinates (i.e. some other coefficient). i tried to construct a custom operator derived from diff() and the SpatialCoordinate/Derivative classes in ufl but after some point beyond my knowledge it always gets evaluated to zero by FFC then stops compiling with FFC : division by zero! does somebody of you experts know an approach to this?Did you try using 'variable'? � �. . . � �v �= variable(v) � �f �= v*v � �df = diff(f, v)yes, but if f is a coefficient and not an expression of v, this won't work, i.e., f = Coefficient(element) f = variable(f) v = SpatialCoordinates(cell) v = variable(v) df = diff(f, v) will end up as Type Zero, although this is equivalent to grad(f). that's the one case, and it v = Coefficient(element) as well, it will also be zero. if would be nice if where not zero :-)The first example I get although I don't know why it does not work at the moment, but it could be a bug. The second case where v is a coefficient I don't get. If f(x) = x**2, then df/dy = 0, I think that makes sense.yes, but if f is a coefficient, i.e., it is a eulerian quantity f=f(x), and df/dx is the spatial gradient, ufl computes this from either grad(f) or f.dx(i) or Dx(f,i). but the vector of spatial coordinates x is hidden in ufl. i would like to do something like f.dx(v[i]), i.e. compute df_i/dv_j where v represents some other coordinates, possibly given by another coefficient?My bad for choosing 'x' in my example. The point I was trying to make is simply that if UFL does not know that a given expression depend on a variable, then taking derivatives w.r.t. this variable will always turn out zero: f(v) = 5*v --> d_f/d_foo = 0. Did you take a look at the blueprint I linked to?
yes, if it got it correctly i would define dfdX = Function(element) f = Function(element, gradient=dfdX)and dfdX must come from another form, where i have other spatial coordinates (say X, ).
i don't know how x (the spatial coordinates) are represented in ufl, but if they are somehow indexed and acessible, one could define a new Grad(f, X[i]) / f.dx(X[i]) , where the partial derivative of f is computed with respect to component X[i] instead of spatial variable component i as in f.dx(i).
patrick
KristianPerhaps whatyou want (or is trying to do) is described in this blueprint? https://blueprints.launchpad.net/ufl/+spec/function-derivatoves KristianpatrickGarthmany thanks and best regards, patrick _______________________________________________ Mailing list: https://launchpad.net/~ufl Post to : ufl@xxxxxxxxxxxxxxxxxxx Unsubscribe : https://launchpad.net/~ufl More help : https://help.launchpad.net/ListHelp_______________________________________________ Mailing list: https://launchpad.net/~ufl Post to � � : ufl@xxxxxxxxxxxxxxxxxxx Unsubscribe : https://launchpad.net/~ufl More help � : https://help.launchpad.net/ListHelp_______________________________________________ Mailing list: https://launchpad.net/~ufl Post to : ufl@xxxxxxxxxxxxxxxxxxx Unsubscribe : https://launchpad.net/~ufl More help : https://help.launchpad.net/ListHelp
Thread Previous • Date Previous • Date Next • Thread Next |