exasim-project / FoamAdapter

GPL Adapter for the MIT licensed NeoFOAM
1 stars 0 forks source link

Compilation error #2

Closed HenningScheufler closed 2 months ago

HenningScheufler commented 5 months ago

With the following build configuration FoamAdapter does not compile:

#!/bin/bash

# Run CMake to generate the build files
# -DCMAKE_INSTALL_PREFIX=$PWD/FoamAdapter \
cmake  -S . -B build  -DCMAKE_BUILD_TYPE=Release \
        -DNEOFOAM_BUILD_TESTS=ON \
        -DKokkos_ENABLE_SERIAL=ON \
        -DKokkos_ENABLE_OPENMP=ON
        # -DKokkos_ENABLE_CUDA=ON \
        # -DKokkos_ENABLE_CUDA_CONSTEXPR=ON
        # -DKokkos_ARCH_NATIVE=ON \
        # -DKokkos_ENABLE_AGGRESSIVE_VECTORIZATION=ON

# Build the project using make
cmake --build build -j
# cmake --install build

With the following error


/home/henning/OpenFOAM/OpenFOAM-v2306/src/OpenFOAM/lnInclude/DiagonalMatrix.H:85:30: error: expected unqualified-id before ‘const’
   85 |         DiagonalMatrix<Type>(const label n, const Foam::zero);
      |                              ^~~~~
/home/henning/OpenFOAM/OpenFOAM-v2306/src/OpenFOAM/lnInclude/DiagonalMatrix.H:85:30: error: expected ‘)’ before ‘const’
   85 |         DiagonalMatrix<Type>(const label n, const Foam::zero);
      |                             ~^~~~~
      |                              )
/home/henning/OpenFOAM/OpenFOAM-v2306/src/OpenFOAM/lnInclude/DiagonalMatrix.H:88:30: error: expected unqualified-id before ‘const’
   88 |         DiagonalMatrix<Type>(const label n, const Type& val);
      |                              ^~~~~
/home/henning/OpenFOAM/OpenFOAM-v2306/src/OpenFOAM/lnInclude/DiagonalMatrix.H:88:30: error: expected ‘)’ before ‘const’
   88 |         DiagonalMatrix<Type>(const label n, const Type& val);
      |                             ~^~~~~
      |                              )
/home/henning/OpenFOAM/OpenFOAM-v2306/src/OpenFOAM/lnInclude/DiagonalMatrix.H:92:30: error: expected unqualified-id before ‘const’
   92 |         DiagonalMatrix<Type>(const Matrix<Form, Type>& mat);
      |                              ^~~~~
/home/henning/OpenFOAM/OpenFOAM-v2306/src/OpenFOAM/lnInclude/DiagonalMatrix.H:92:30: error: expected ‘)’ before ‘const’
   92 |         DiagonalMatrix<Type>(const Matrix<Form, Type>& mat);
HenningScheufler commented 5 months ago

@greole @MarcelKoch @bevanwsjones

HenningScheufler commented 4 months ago

OpenFOAM does not compile with gcc and the cpp std 20. (tested on Ubuntu 22.04)

The compiler version to compile NeoFOAM are quite high:

clang > 17.00
gcc incompatible (for non GPU compilation)

We could consider downgrading neofoam to cppstd 17. This would require only the implementation of std::span

greole commented 4 months ago

OpenFOAM does not compile with gcc and the cpp std 20. (tested on Ubuntu 22.04)

Correct me if I'm wrong but the choice for cpp 20 for NeoFOAM doens't affect the compilation of Openfoam, which should can be compiled independently with cpp 14.

The compiler version to compile NeoFOAM are quite high:

Yes that is true, but that is only the case now. Ubuntu just had a new LTS release 24.04 which ships clang 18 and gcc 10. So soon this shouldn't be an issue.

greole commented 4 months ago

For example add NeoFOAM as link target here https://github.com/exasim-project/FoamAdapter/blob/main/src/benchmarks/explicitOperators/CMakeLists.txt also have a look at: https://github.com/users/foamscience/packages/container/package/jammy-openfoam

FoamScience commented 4 months ago

Just wanted to mention that this is related to:

Clang is known for permissible syntactic constraints; but I'd prefer Gcc's way of doing things for this one. Here is a small playground to poke around this issue if you like to: https://godbolt.org/z/rcMG39Gaj

Solution:

  1. Either; we raise this with OpenFOAM devs
  2. Or just sed DiagonalMatrix.H header to remove <Type> from DiagonalMatrix<Type> (right now this works)

we see this error because FoamAdapter includes some header that includes DiagonalMatrix.H (probably dimensionSets.H)

HenningScheufler commented 4 months ago

I would prefer the solution to contact the devs to fix this issue. The other solution is not maintainable.

HenningScheufler commented 4 months ago

I opened a issue on develop github:

https://develop.openfoam.com/Development/openfoam/-/issues/3168

greole commented 4 months ago

The issue is that it is a problem with C++20 which OpenFOAM doesn't support at the moment. But yes maybe they'll fix it.

HenningScheufler commented 4 months ago

I created a fix for this issue

It only requires minor changes to 8 files

FoamScience commented 4 months ago

@HenningScheufler's patch should take care of this. But here is a fun way to solve these minor issues for future reference; that's how I did it originally to my OpenFOAM installation, there was no patch because installed from package repos 😄 Enjoy: FoamScience/openfoam-code-transformations

HenningScheufler commented 2 months ago

This is resolved with of2406