CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Installation (https://www.cfd-online.com/Forums/openfoam-installation/)
-   -   [OpenFOAM.org] Installing OpenFOAM 2.3 on Ubuntu 18.04 (https://www.cfd-online.com/Forums/openfoam-installation/202905-installing-openfoam-2-3-ubuntu-18-04-a.html)

Joe1best June 11, 2018 15:34

Installing OpenFOAM 2.3 on Ubuntu 18.04
 
Hi guys,



I am fairly new to OpenFOAM and I just started a research project with my university. I took on a project that uses OpenFOAM to simulate some fluid dynamics. The previous student who worked on this used OpenFOAM 2.3 along with some python wrapper to generate the necessary 0, constant, system files,etc. I am just wondering if there is a way to install OpenFOAM 2.3 on my Ubuntu 18.04 ? All the tutorial that I found work for older versions of Ubuntu like 16.04 and older. I even tried those and as expected, they did not work...



Thanks !

u2berggeist June 26, 2018 12:49

I've been able to get the OpenFOAM working on Ubuntu 18.04 via the Docker fine. That's with 1712 (I'm not sure what the conversion from the X.X version system to the XXXX versioning system is), though you can probably find a Docker with the version you're looking for?


I'm as much of a newbie (probably more) as you are, so I might be steering you in the wrong direction, but I figured I'd let you know that I've gotten OF to work on 18.04.

charryzzz August 13, 2018 11:46

I am working on it, but it does not work yet. :-(

wyldckat August 17, 2018 13:30

Greetings to all!

Sorry for the late reply, but I simply was not able to look into the forum questions until now.

Please find the requested installation instructions here: https://openfoamwiki.net/index.php/I...u#Ubuntu_18.04

Best regards,
Bruno

charryzzz August 18, 2018 11:18

1 Attachment(s)
Thank you for your time.
I have tried this method, but failed to compile the of 2.3.1 on Ubuntu 18.04. The log is attached ( since the file size is too big, only the beginning is uploadded)

Quote:

Originally Posted by wyldckat (Post 703014)
Greetings to all!

Sorry for the late reply, but I simply was not able to look into the forum questions until now.

Please find the requested installation instructions here: https://openfoamwiki.net/index.php/I...u#Ubuntu_18.04

Best regards,
Bruno

Thank you for your time.
I have tried this method, but failed to compile the of 2.3.1 on Ubuntu 18.04. The log is attached ( since the file size is too big, only the beginning is uploadded)

wyldckat August 18, 2018 18:58

Quick post:
  • This is very strange... are you certain you installed the packages listed in step #3?
  • Are you using Ubuntu 18.04 via Windows 10 WSL? Namely the one installed through the Microsoft Store?
  • Either way, please install the package "libc6-dev" as well, by running the following command:
    Code:

    sudo apt-get install libc6-dev
    It should solve the very first error, which affects everything else.

charryzzz August 19, 2018 00:06

5 Attachment(s)
Quote:

Originally Posted by wyldckat (Post 703097)
Quick post:
  • This is very strange... are you certain you installed the packages listed in step #3?
  • Are you using Ubuntu 18.04 via Windows 10 WSL? Namely the one installed through the Microsoft Store?
  • Either way, please install the package "libc6-dev" as well, by running the following command:
    Code:

    sudo apt-get install libc6-dev
    It should solve the very first error, which affects everything else.

  • I am sure that I have installed all the packages by running
    Code:

    apt-get install build-essential cmake flex bison zlib1g-dev qt4-dev-tools libqt4-dev libqtwebkit-dev gnuplot \
    libreadline-dev libncurses5-dev libxt-dev libopenmpi-dev openmpi-bin libboost-system-dev libboost-thread-dev libgmp-dev \
    libmpfr-dev python python-dev libcgal-dev gcc-5 g++-5

  • NO, I am using Ubuntu 18.04 Desktop (Ubuntu 18.04.1 LTS)
  • I have already installed the newest verison of libc6-dev (2.27-3ubuntu1) and it still shows the same error, please see the attachment.

charryzzz August 19, 2018 02:32

Quote:

Originally Posted by charryzzz (Post 703109)
  • I am sure that I have installed all the packages by running
    Code:

    apt-get install build-essential cmake flex bison zlib1g-dev qt4-dev-tools libqt4-dev libqtwebkit-dev gnuplot \
    libreadline-dev libncurses5-dev libxt-dev libopenmpi-dev openmpi-bin libboost-system-dev libboost-thread-dev libgmp-dev \
    libmpfr-dev python python-dev libcgal-dev gcc-5 g++-5

  • NO, I am using Ubuntu 18.04 Desktop (Ubuntu 18.04.1 LTS)
  • I have already installed the newest verison of libc6-dev (2.27-3ubuntu1) and it still shows the same error, please see the attachment.

It seems to be an "isnan error" and I have found a solution.

To modify src/conversion/ensight/part/ensightPart.H

After line 63
Code:

// Static data memebers
static const List<word> elemTypes_;

add the following content

Code:

// wrapper for isnan, namely C99 or C++11
inline bool isnan(const scalar value) const
{
#ifndef isnan
return std::isnan(value);
#else
return ::isnan(value);
#endif
}


wyldckat August 20, 2018 13:51

Greetings charryzzz,

The fix you proposed for "isnan" would not solve this issue as indicated in the log files:
Code:

gcc -m32  -Wall -O3  -fPIC dirToString.c -o /home/charry/OpenFOAM/OpenFOAM-2.3.1/wmake/platforms/linuxGcc/dirToString
In file included from dirToString.c:43:0:
/usr/include/stdio.h:27:36: fatal error: bits/libc-header-start.h: No such file or directory
 #include <bits/libc-header-start.h>

But from this line and others, it's possible to see that I had made a mistake in the order of export commands for "WM_CC" and "WM_CXX" in step #8, because the line in the output above starts with gcc instead of gcc-5.

The problem was that since I had written this:
Code:

export WM_CC='gcc-5'
export WM_CXX='g++-5'
source $HOME/OpenFOAM/OpenFOAM-2.3.1/etc/bashrc WM_NCOMPPROCS=4 WM_MPLIB=SYSTEMOPENMPI

Meant that "WM_CC" and "WM_CXX" were redefined when sourcing "etc/bashrc" back to the default:
Code:

export WM_CC='gcc'
export WM_CXX='g++'

I've now corrected to this in that step #8:
Code:

source $HOME/OpenFOAM/OpenFOAM-2.3.1/etc/bashrc WM_NCOMPPROCS=4 WM_MPLIB=SYSTEMOPENMPI
export WM_CC='gcc-5'
export WM_CXX='g++-5'


As for the fix you proposed, my guess is that you had started a new terminal and ran of231. This means that the following command was called when you started a new terminal:
Code:

source $HOME/OpenFOAM/OpenFOAM-2.3.1/etc/bashrc WM_NCOMPPROCS=4 WM_MPLIB=SYSTEMOPENMPI; export WM_CC=gcc-5; export WM_CXX=g++-5
hence now using GCC version 5 instead of version 7.


However, I'm not certain why you needed the fix for "isnan", because the library inside which you made that change, did not require that fix in the test build that I did while writing the instructions. That fix would only have been necessary if g++ 7 (part of GCC) was being used, which in the second build attempt that you did, I believe you were already using g++ 5.

For example, in the log file of my build, I got this:
Code:

SOURCE=ensight/part/ensightPart.C ;  g++-5 -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/home/ofuser/OpenFOAM/OpenFOAM-2.3.1/src/fileFormats/lnInclude -I/home/ofuser/OpenFOAM/OpenFOAM-2.3.1/src/finiteVolume/lnInclude -I/home/ofuser/OpenFOAM/OpenFOAM-2.3.1/src/meshTools/lnInclude -IlnInclude -I. -I/home/ofuser/OpenFOAM/OpenFOAM-2.3.1/src/OpenFOAM/lnInclude -I/home/ofuser/OpenFOAM/OpenFOAM-2.3.1/src/OSspecific/POSIX/lnInclude  -fPIC -c $SOURCE -o Make/linux64GccDPOpt/ensightPart.o
notice that it starts with:
Code:

SOURCE=ensight/part/ensightPart.C ;  g++-5
which gave me no errors.
Only when I replace g++-5 with g++, do I get this error:
Code:

ensight/part/ensightPart.C: In member function ‘bool Foam::ensightPart::isFieldDefined(const Foam::List<double>&) const’:
ensight/part/ensightPart.C:54:39: error: ‘isnan’ was not declared in this scope
            if (id >= field.size() || isnan(field[id]))
                                      ^~~~~

Therefore, there shouldn't be a need to add the "isnan" fix to the instructions at https://openfoamwiki.net/index.php/I...u#Ubuntu_18.04 - given that GCC 5 is the version being used to build it.

Best regards,
Bruno

charryzzz August 21, 2018 23:23

Greetings Bruno
You are right! I have installed openfoam 2.3.1 on ubuntu 18.04 successfully according to your newest instructions.
Thank you :-)

Daniel_Khazaei August 23, 2018 15:42

I have compiled OpenFOAM 2.3.0 including paraview 4.1.0 successfully on the Ubuntu 18.04 based on the instruction provided for the 16.04! just needed to install gcc 5.5 accroding to this guide: (side by side with gcc 7.3 and selecting gcc5 before compiling)

https://gist.github.com/application2...cf9f56315a2d91

also needed to add these two lines in Make/options to get foamyQuadMesh and foamyHexyMesh compiled:

Code:

EXE_LIBS = \
    $(CGAL_LIBS) \
    -lextrude2DMesh \
    -lextrudeModel \
    -lcv2DMesh \
    -lconformalVoronoiMesh \
    -lmeshTools \
    -lsurfMesh \
    -ledgeMesh \
    -ltriSurface \
    -ldynamicMesh \
    -ldecompositionMethods \
    -L$(FOAM_LIBBIN)/dummy -lptscotchDecomp \
    -lsampling \
    -lpthread \
    -lboost_thread \

    -lfileFormats


wyldckat August 23, 2018 16:20

Greetings Daniel,

Many thanks for sharing!

Although now I am a bit confused... when did you start to try to build OpenFOAM 2.3.0 on Ubuntu 18.04? I ask this because I had added a section for it here https://openfoamwiki.net/index.php/I...u#Ubuntu_18.04 - on the 17th of August 2018... so perhaps you had started your build before that?

Which leads me to the following question: Would it be preferable that I copy the complete instructions from the page for 2.3.1 to 2.3.0, instead of providing the wiki link?

Best regards,
Bruno

Daniel_Khazaei August 23, 2018 17:17

Quote:

Originally Posted by wyldckat (Post 703731)
Greetings Daniel,

Many thanks for sharing!

Although now I am a bit confused... when did you start to try to build OpenFOAM 2.3.0 on Ubuntu 18.04? I ask this because I had added a section for it here https://openfoamwiki.net/index.php/I...u#Ubuntu_18.04 - on the 17th of August 2018... so perhaps you had started your build before that?

Which leads me to the following question: Would it be preferable that I copy the complete instructions from the page for 2.3.1 to 2.3.0, instead of providing the wiki link?

Best regards,
Bruno

Dear Bruno,
I have compiled it a month ago when I decided to upgrade to ubuntu 18.04 from 16.04! The first reasonable thing to do was to follow 16.04 instruction step by step and it didn't failed me...

after the step involving the installation of the necessary packages, I did as follow:

Code:

sudo apt-get update
sudo apt-get install gcc-snapshot -y
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7
sudo apt-get install gcc-5 g++-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5

then selecting gcc5:
Code:

sudo update-alternatives --config gcc
also qt4 is needed:
Code:

sudo apt-get install qt4-default
actually I made aliases in bashrc to choose between different gcc and qt:
Code:

alias selectGCC='sudo update-alternatives --config gcc'
alias selectQt4='sudo apt-get install qt4-default'
alias selectQt5='sudo apt-get install qt5-default'

default cmake from ubuntu installation is used (3.10.2).

Quote:

Originally Posted by wyldckat (Post 703731)
Which leads me to the following question: Would it be preferable that I copy the complete instructions from the page for 2.3.1 to 2.3.0, instead of providing the wiki link?

Sorry but I haven't tried the instruction for OpenFOAM 2.3.1 with 2.3.0, so can comment here!

I can only confirm that the instruction for 16.04 in this page:

https://openfoamwiki.net/index.php/I...M-2.3.0/Ubuntu

is completely applicable to 18.04 with the above mentioned modifications!

Furthermore, the instruction for swak4Foam is also working on ubuntu 18.04:

https://openfoamwiki.net/index.php/I...2.2.0_to_3.0.x


Regards,

wyldckat August 24, 2018 13:46

Hi Daniel,

Many thanks for writing down the steps you've used! And I'm very glad that swak4Foam builds without problems with those instructions.

I have a few improvement suggestions to the steps that you have:
  • You can switch between Qt versions by using the environment flag "QT_SELECT", for example:
    Code:

    export QT_SELECT=qt4
    export QT_SELECT=qt5

  • In steps #7 and #8 on the recent instructions for building OpenFOAM 2.3.1 on Ubuntu 18.04, you can tell OpenFOAM to use GCC 5 by using two tricks:
    1. Change the compiler names on the rules file:
      Code:

      sed -i -e 's/gcc/\$(WM_CC)/' OpenFOAM-2.3.1/wmake/rules/linux64Gcc/c
      sed -i -e 's/g++/\$(WM_CXX)/' OpenFOAM-2.3.1/wmake/rules/linux64Gcc/c++

      So that it uses environment variables instead of hard-coded names.
    2. Then after sourcing OpenFOAM's shell environment, you can redefine said environment variables, namely:
      Code:

      export WM_CC='gcc-5'
      export WM_CXX='g++-5'

    This way you don't need to change the default compiler for the whole Ubuntu installation ;)
Best regards,
Bruno

aparangement December 27, 2020 08:22

I followed the guide of

https://openfoamwiki.net/index.php/I...u#Ubuntu_18.04

and successfully installed of230 and paraview on ubuntu18.04.5, without any issue, thanks a lot!!

wangchengan2003 August 5, 2021 22:21

Dear Bruno,
Have you tried to install openfoam 2.3 on ubuntu 20.04? I follow wiki https://openfoamwiki.net/index.php/I...u#Ubuntu_18.04
But it does not work. Could you give me some ideas?



Best regards,


Chengan


All times are GMT -4. The time now is 01:33.