← Back to team overview

ufl team mailing list archive

Re: rot and curl

 

On Apr 25 2009, Anders Logg wrote:

On Sat, Apr 25, 2009 at 11:40:35AM +0200, Martin Sandve Alnæs wrote:
I've verified the curl vs wikipedia and defined rot as the z-component
of the curl of the 2D vector operand embedded in 3D. Is that right?


rot is just a synonym for curl. For simplicity, I would remove rot.

ez = (0, 0, 1)
u = (u0, u1)
rot(u) =  ez . (nabla x (u0, u1, 0))

    def curl(self, o, a):
        # o = curl a = "cross(nabla, a)"
        def c(i, j):
            return a[j].dx(i) - a[i].dx(j)
        return as_vector((c(1,2), c(2,0), c(0,1)))

    def rot(self, o, a):
        # o = rot a = "cross(nabla, (a0, a1, 0))[2]"
        def c(i, j):
            return a[j].dx(i) - a[i].dx(j)
        return c(0,1)


What about

    def curl(self, o, a):
        # o = curl a = "cross(nabla, a)"
        def c(i, j):
            return a[j].dx(i) - a[i].dx(j)
        if a.d == 2:   # whatever the function is for the dimension
            return c(0,1)
else if a.s == 3; return as_vector((c(1,2), c(2,0), c(0,1)))
        else:
erorr . . . .
Garth


Martin

It looks correct, but shouldn't there be some dimension check?

Maybe rot can be implemented directly as

    def rot(self, o, a):
        return curl(as_vector([a[0], a[1], 0]))[2]

?





Follow ups

References