mrklein / openfoam-os-x

Patches for OpenFOAM(R) to build it on OS X
93 stars 33 forks source link

Compilation Error on Catalina #50

Closed BrushXue closed 4 years ago

BrushXue commented 4 years ago

Hello,

I was installing OpenFOAM-7-0ebbff061 following your tutorial and got an error:

primitives/quaternion/quaternion.C:129:12: error: call to 'pow' is ambiguous
return pow(magQ, power)*exp(powq);

My system information

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.15.3
BuildVersion:   19D76
$ clang++ --version
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin19.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

3rd party:

$ brew list --versions
boost 1.72.0
cgal 5.0.2
eigen 3.3.7
gcc 9.2.0_3
gmp 6.2.0
hwloc 2.1.0
icu4c 64.2
isl 0.22.1
libevent 2.1.11_1
libmpc 1.1.0
metis 5.1.0
mpfr 4.0.2
open-mpi 4.0.3
openssl@1.1 1.1.1d
parmgridgen 0.0.2
scotch 6.0.4_1

Is my software version too new?

BrushXue commented 4 years ago

I managed to fix this error by changing it to

return std::pow(magQ, power)*exp(powq);

Then here comes the second similar error:

extrudeModel/extrudeModel.C:82:18: error: call to 'pow' is ambiguous
(1.0-pow(expansionRatio_, layer))

It is not possible to manually fix all pow() functions in OpenFOAM. How should I fix all of them?

mrklein commented 4 years ago

Hi,

I will try to reproduce the error and either correct the patch or demand additional information.

No, you should not substitute pow with std::pow everywhere, since usually it should be Foam::pow.

mrklein commented 4 years ago

@BrushXue unfortunately I was not able to reproduce your error. I have tried with two different clangs: one from CL Tools, one from Xcode. Both compile OpenFOAM-7 without any difficulties.

Could you run xcrun c++ --version instead of clang++ --version?

BrushXue commented 4 years ago
$ xcrun c++ --version
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin19.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
mrklein commented 4 years ago

Could you add more context around errors? I.e. could you post your build log file (or just a part around errors).

BrushXue commented 4 years ago

I forgot to mention that I used WM_LABEL_SIZE=64(with metis64 and scotch64 you provided). Is that a problem for mac to compile with 64bit label? I'm attaching the log file. log.txt

mrklein commented 4 years ago

Quite a significant addition. In fact, I have not tested 64-bit label builds for a long time, they can be broken. According to the log, you have attached, there are certain missing definitions. I will take a look and update the patch as necessary.

BrushXue commented 4 years ago

I'm testing it with 32bit label. Seems like it will go through so there must be something broken with 64bit integers.

EDIT: I was able to compile almost everything on 32bit, except for this one.

wmake MGridGenGamgAgglomeration
wmakeLnIncludeAll: running wmakeLnInclude on dependent libraries:
    wmakeLnInclude error: base directory EXE_INC does not exist
    wmakeLnInclude error: base directory += does not exist
    wmakeLnInclude error: base directory /MGridGen/Lib/ does not exist
    wmakeLnInclude error: base directory EXE_INC does not exist
    wmakeLnInclude error: base directory += does not exist
    wmakeLnInclude error: base directory /MGridGen/IMlib/ does not exist
mrklein commented 4 years ago

Hi,

If you need this to be fixed ASAP, then you can use attached patch to add necessary bits to Scalar. Or you can wait till I update patch in the repository. Below is the attached patch, basically it adds pow functions with scalar and int64_t.

diff --git a/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H b/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H
index 86e5484b5..5852ef13a 100644
--- a/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H
+++ b/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H
@@ -100,6 +100,10 @@ MAXMINPOW(Scalar, Scalar, int)
 MAXMINPOW(Scalar, int, Scalar)
 MAXMINPOW(Scalar, Scalar, long)
 MAXMINPOW(Scalar, long, Scalar)
+#if defined(darwin64) && WM_LABEL_SIZE == 64
+MAXMINPOW(Scalar, Scalar, int64_t)
+MAXMINPOW(Scalar, int64_t, Scalar)
+#endif
 MAXMINPOW(Scalar, Scalar, float)
 MAXMINPOW(Scalar, float, Scalar)

diff --git a/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H b/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H
index f427b0109..582116e68 100644
--- a/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H
+++ b/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H
@@ -98,6 +98,10 @@ inline double pow(const type1 s, const type2 e)   \
 MAXMINPOW(Scalar, Scalar, Scalar)
 MAXMINPOW(Scalar, Scalar, int)
 MAXMINPOW(Scalar, int, Scalar)
+#if defined(darwin64) && WM_LABEL_SIZE == 64
+MAXMINPOW(Scalar, Scalar, int64_t)
+MAXMINPOW(Scalar, int64_t, Scalar)
+#endif
 MAXMINPOW(Scalar, Scalar, long)
 MAXMINPOW(Scalar, long, Scalar)

diff --git a/src/OpenFOAM/primitives/Scalar/longDoubleScalar/longDoubleScalar.H b/src/OpenFOAM/primitives/Scalar/longDoubleScalar/longDoubleScalar.H
index d2a5ff849..a82a28509 100644
--- a/src/OpenFOAM/primitives/Scalar/longDoubleScalar/longDoubleScalar.H
+++ b/src/OpenFOAM/primitives/Scalar/longDoubleScalar/longDoubleScalar.H
@@ -105,6 +105,10 @@ inline double pow(const type1 s, const type2 e)   \
 MAXMINPOW(Scalar, Scalar, Scalar)
 MAXMINPOW(Scalar, Scalar, int)
 MAXMINPOW(Scalar, int, Scalar)
+#if defined(darwin64) && WM_LABEL_SIZE == 64
+MAXMINPOW(Scalar, Scalar, int64_t)
+MAXMINPOW(Scalar, int64_t, Scalar)
+#endif
 MAXMINPOW(Scalar, Scalar, long)
 MAXMINPOW(Scalar, long, Scalar)
 MAXMINPOW(Scalar, Scalar, float)
diff --git a/src/fvAgglomerationMethods/Allwmake b/src/fvAgglomerationMethods/Allwmake
index 48abdf020..c7d4ff303 100755
--- a/src/fvAgglomerationMethods/Allwmake
+++ b/src/fvAgglomerationMethods/Allwmake
@@ -7,7 +7,8 @@ cd ${0%/*} || exit 1    # Run from this directory
 if [ "$(uname -s)" = "Darwin" ]
 then
     [ -e "/usr/local/opt/parmgridgen/lib/libmgrid.a" -a \
-        "$WM_LABEL_SIZE" -ne "64" ] \
+        "$WM_LABEL_SIZE" -ne "64" -a \
+        "$WM_PRECISION_OPTION" != "LP" ] \
         && wmake $targetType MGridGenGamgAgglomeration
 elif [ -e "$FOAM_LIBBIN/libMGridGen.so" ]
 then

pow.patch.gz

BrushXue commented 4 years ago

Thanks for the patch. It works like a charm!