qreal and double

Discussion about building and installing Elmer
Post Reply
hazelsct
Posts: 153
Joined: 05 Oct 2009, 17:02
Location: Boston, MA, USA
Contact:

qreal and double

Post by hazelsct »

Hi,

The ElmerGUI code makes the assumption in several places that qreal is the same as double. On little-endian ARM systems (EABI), this is not the case: qreal is a float. I've already committed a small patch to SVN fixing this in twod/renderarea.cpp but other issues came up which the more extensive attached patch fixes just to the point where it builds on that platform. (One part of the fix uses a neat C++ polymorphism technique by Phil Endecott...)

The main lesson here for future coding is that although it's easy to cast from float to double, arrays can't cast like that, which was the origin of these errors. It's tempting to consider writing much of the GUI code in terms of qreals rather than doubles, but I don't think it's worth the effort.

ARM is not necessarily a high-priority platform for Elmer -- until it has decent double-precision performance, nobody is going to run FEA solvers on it. On the other hand, it could well be used in low-cost thin clients which might run the GUI and post-processor, so it would be good to keep it compiling well. Each time I build for Debian, I'll get immediate feedback from the ARM auto-build machine, and can fix compilation errors as needed.

-Adam
Attachments
arm-qt-casting.patch
Patch required to build when qreal != double, e.g. ARM EABI
(4.6 KiB) Downloaded 326 times
Post Reply