Subject: [UFL-dev] rot and curl

From: "Garth N. Wells" <[email-masked]>
Date: Fri, 24 Apr 2009 17:16:15 +0100

Is there any particular reason why 'rot' is not implemented,

     def rot(self, o, a):
         raise NotImplementedError # FIXME

and 'curl' is,

     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))) # FIXME: Verify this

Should there be a check in curl that the vector function is in R^3?

Garth

---

From: Martin Sandve Alnæs <[email-masked]>
Date: Fri, 24 Apr 2009 22:31:22 +0200

No reason. I'll fix them.

Martin

On Fri, Apr 24, 2009 at 6:16 PM, Garth N. Wells <[email-masked]> wrote:
> _______________________________________________
> UFL-dev mailing list
> [email-masked]
> http://fenics.org/mailman/listinfo/ufl-dev
>

---

From: Martin Sandve Alnæs <[email-masked]>
Date: Sat, 25 Apr 2009 11:40:35 +0200

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?

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)

Martin

---

From: Anders Logg <[email-masked]>
Date: Sat, 25 Apr 2009 15:43:19 +0200

>             return a[j].dx(i) - a[i].dx(j)

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]

?

-- 
Anders

---

From: "Garth N. Wells" <[email-masked]>
Date: 25 Apr 2009 15:10:07 +0100

>> 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.

>>             return a[j].dx(i) - a[i].dx(j)

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

---

From: Anders Logg <[email-masked]>
Date: Sat, 25 Apr 2009 16:23:58 +0200

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

I'm used to the following notation (in pseudo-math):

  rot:  R^2 --> R
  curl: R   --> R^2
  curl: R^3 --> R^3

-- 
Anders

---

From: [email-masked]
Date: Sat, 25 Apr 2009 16:31:52 +0200 (CEST)

> I'm used to the following notation (in pseudo-math):

Agree.

Kent

---

From: "Garth N. Wells" <[email-masked]>
Date: 25 Apr 2009 15:42:56 +0100

>Agree.

Must be a Scandinavian thing. All the references I'm finding on the net say 
that curl and rot are the same.

Garth

---

From: Anders Logg <[email-masked]>
Date: Sat, 25 Apr 2009 17:01:59 +0200

On Sat, Apr 25, 2009 at 03:42:56PM +0100, Garth N. Wells wrote:
> Must be a Scandinavian thing. All the references I'm finding on the net 
> say that curl and rot are the same.

Take a look at this, page 27:

  http://www.ima.umn.edu/~arnold/papers/acta.pdf

Ragnar Winther may be Norwegian, but not Doug Arnold and Richard Falk. :-)

-- 
Anders

---

From: "Garth N. Wells" <[email-masked]>
Date: 25 Apr 2009 16:07:47 +0100

On Apr 25 2009, Anders Logg 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?
>>>>>>>
>>>>>

Not the definitive reference, but certainly heavily scrutinised,

    http://en.wikipedia.org/wiki/Curl_(mathematics)

To quote: 

"The alternative terminology "rotor" and alternative notations 
\operatorname{rot}\ \mathbf{F} and \nabla\times\mathbf{F} are often used 
(the former especially in many European countries) for "curl" and 
\operatorname{curl}\ \mathbf{F}"

Garth

---

From: Martin Sandve Alnæs <[email-masked]>
Date: Sat, 25 Apr 2009 19:16:54 +0200

> I'm used to the following notation (in pseudo-math):

So this can be defined as

nabla x (a(x,y), b(x,y), 0)
=
|  i  j  k |
| ,x ,y ,z |
|  a  b  0 |
=
(b,x - a,y) k

rot( (a,b) ) = (b,x - a,y)
(or curl)

>  curl: R   --> R^2

How is this defined?

curl( a(x,y) )
=
nabla x (0, 0, a)
=
|  i  j  k |
| ,x ,y ,z |
|  0  0  a |
=
a,y i - a,x j

?

Is this only defined in 2D so we can say curl(constant) = (0, 0)?
(That would simplify some things, but it's not the case for grad.)

>  curl: R^3 --> R^3

I don't have any opinion on the names rot and curl.
Seems like either definition is just as good to me.

Martin

---

From: "Garth N. Wells" <[email-masked]>
Date: Mon, 27 Apr 2009 11:37:00 +0100

> Seems like either definition is just as good to me.

I don't mind having curl and rot as long as they are the same thing. 
I've checked a number of books, all of which say curl and rot are the same.

Garth

---

From: Anders Logg <[email-masked]>
Date: Mon, 27 Apr 2009 13:37:45 +0200

> rot( (a,b) ) = (b,x - a,y)

Yes.

> a,y i - a,x j

Yes.

I guess we can let curl cover all three cases and then just make rot
an alias. Then everyone will be happy. The rot-curl notation will work
but it's also possible to just write curl.

-- 
Anders