Subject: Re: [UFL-dev] [DOLFIN-dev] complex valued functoins

From: "Garth N. Wells" <[email-masked]>
Date: Fri, 27 Feb 2009 15:03:25 +0000

Evan Lezar wrote:
> Hi
> 
> I am working on some electromagnetic problems that require I model the 
> electric field as a complex phasor.  When compiling user-defined 
> functions I get an error message.
> 
> For example, consider the following simple function:
> 
> f = Function(V, '1.0j')
> 
> 
> when calling the JIT compiler, the log shows the following error (in the 
> last couple of lines):
> 
> dolfin_compile_function_934f16b21b1210d9244eba2ba7985a9a_wrap.cxx: In 
> member function ‘virtual void 
> dolfin::function_91ee55df622466fafbf3ba887ffb745e::eval(double*, const 
> double*) const’:
> dolfin_compile_function_934f16b21b1210d9244eba2ba7985a9a_wrap.cxx:3221: 
> error: cannot convert ‘double __complex__’ to ‘double’ in assignment
> error: command 'gcc' failed with exit status 1
> 
> Does dolfin support complex valued functions?  

No.

If so, how do I go about
> getting them working?  And if not, how do I go about adding the 
> functionality.
> 

It would be a big task to make it seamless. The starting point would be 
having FFC (or soon UFL) support complex functions. I thought about this 
a few years ago but never got around to it.

UFL question: Does or will UFL support complex functions?

Garth

> Thanks
> Evan
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> DOLFIN-dev mailing list
> [email-masked]
> http://www.fenics.org/mailman/listinfo/dolfin-dev

---

From: Martin Sandve Alnæs <[email-masked]>
Date: Fri, 27 Feb 2009 16:06:28 +0100

> UFL question: Does or will UFL support complex functions?

No. And I don't think making such an addition before it has stabilised
is an option, we can't change everything everywhere simultaneously.

Martin

---

From: "Garth N. Wells" <[email-masked]>
Date: Fri, 27 Feb 2009 15:08:23 +0000

>> a few years ago but never got around to it.

Thinking about, it shouldn't be too hard to patch something together 
using mixed elements.

> is an option, we can't change everything everywhere simultaneously.

OK. Would be good for the long-term goals list.

Garth

---

From: Martin Sandve Alnæs <[email-masked]>
Date: Fri, 27 Feb 2009 16:16:26 +0100

On Fri, Feb 27, 2009 at 4:08 PM, Garth N. Wells <[email-masked]> wrote:
> Thinking about, it shouldn't be too hard to patch something together using
> mixed elements.

Won't be as user-friendly as it could be though, but perhaps you
could define e.g. complex multiplication as python functions on top.

> OK. Would be good for the long-term goals list.

Sure. I'll add it.

Martin

---

From: "Garth N. Wells" <[email-masked]>
Date: Fri, 27 Feb 2009 15:20:53 +0000

> could define e.g. complex multiplication as python functions on top.

Agree, it wouldn't be user friendly. Making it user friendly would 
require a lot of work on UFL/FFC/DOLFIN.

Garth

---

From: Evan Lezar <[email-masked]>
Date: Sat, 28 Feb 2009 10:40:24 +0200

On Fri, Feb 27, 2009 at 5:20 PM, Garth N. Wells <[email-masked]> wrote:

>>> using
> Agree, it wouldn't be user friendly. Making it user friendly would require
> a lot of work on UFL/FFC/DOLFIN.
>
> Garth
>
>
>
>
Thanks for the feedback.  I have got some ideas for an interim solution,
will give them a go and let you know what I come up with.

Evan