CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Installation (https://www.cfd-online.com/Forums/openfoam-installation/)
-   -   Multiple OpenFOAM versions on one machine (https://www.cfd-online.com/Forums/openfoam-installation/96253-multiple-openfoam-versions-one-machine.html)

eric.m.tridas January 17, 2012 10:43

Multiple OpenFOAM versions on one machine
 
Hey Foamers,

I've been running OF-2.0.1 on my Ubuntu 11.04 machine and want to try out some of the solvers that were made for OF-1.6-ext at the same time. I installed 2.0.1 using a precompiled package.

Will I have problems being able to run both versions at the same time? How can I ensure that the application I wish to run will be from the desired OF version? If I download the solvers and compile them without compiling OF-1.6-ext will I run into issues?

Thanks for your input.

-Eric

alquimista January 17, 2012 11:06

It was discussed before in this forum I'm not sure if this is the optimal way but you can run different OpenFOAM executables adding that lines in your $HOME/.bashrc file, for example (change your paths and versions):

alias startFoamGPU='source /opt/openfoam201GPU/etc/bashrc'
alias startFoam='source /opt/openfoam201/etc/bashrc'
alias startFoam210='source /opt/OpenFOAM-2.1.0/etc/bashrc'

So when you want to use OpenFOAM type in the console: startFoamGPU, startFoam or startFoam210.

Be sure that the WM_PROJECT_DIR environment variable present in the bashrc of your OpenFOAM directory was right.

Also delete previous PATH environment variables in $HOME/.bashrc, something like:

source /opt/OpenFOAM-2.1.0/etc/bashrc

Quote:

Will I have problems being able to run both versions at the same time?
You will run the solver that you specified.

Quote:

How can I ensure that the application I wish to run will be from the desired OF version?
There are several ways, check the environment variable FOAM_SOLVERS before run the case (echo $FOAM_SOLVERS)

eric.m.tridas January 17, 2012 12:03

Thanks for your reply alquimista. That was exactly what I was looking for.

wyldckat January 17, 2012 15:10

Greetings to all!

For future reference, you can also check a blog post of mine: Advanced tips for working with the OpenFOAM shell environment
There is still more to be written, but I haven't had the time and inspiration to write more about it.

Best regards,
Bruno

curiosity September 24, 2012 13:12

Hi, I have the same problem that Eric (I have installed OF 2.0.1 and 2.1.0 and I canīt run cases in 2.1.0) but I canīt follow Alquimistaīs indications.

I canīt find the route /opt/OpenFOAM-2.1.0/etc/bashrc

I canīt execute the command startFoam in my console neither... Any help please?

Thanks

Regards,

alquimista September 24, 2012 13:52

Hi couriosity,

You should locate the OpenFOAM paths first. Try to find directly in your folders the different version of OpenFOAM that you want to use. If you have problems and you used the rpm package you can find informstion about the installation in the official webpage.

The aliases won't work if the bashrc files doesn't exist. So, for example try to open first each bashrc of OpenFOAM to be sure about that.

Post more information if you have problems or you are not confortable in linux environments.

Regards.

PD: you can find also interesting the information provided by wyldckat


Quote:

Originally Posted by curiosity (Post 383371)
Hi, I have the same problem that Eric (I have installed OF 2.0.1 and 2.1.0 and I canīt run cases in 2.1.0) but I canīt follow Alquimistaīs indications.

I canīt find the route /opt/OpenFOAM-2.1.0/etc/bashrc

I canīt execute the command startFoam in my console neither... Any help please?

Thanks

Regards,


curiosity September 25, 2012 11:28

Hi,

Thanks for your response. I got it ^^

Mojtaba.a July 5, 2013 05:19

1 Attachment(s)
Hi Guys and thank you for your guidance,

I am also trying to have multiple OF version on a single machines but There have been a strange behavior of aliases while running them.

I am trying to use both OF version 2.1.1 and OF version 1.6-ext. As you have mentioned I have added aliases for both OF version in my ~/bashrc file:

Quote:

alias OF16ext='. $HOME/OpenFOAM/OpenFOAM-1.6-ext/etc/bashrc'
alias OF211='. $HOME/OpenFOAM/OpenFOAM-2.1.1/etc/bashrc'
Well at first, when I log into my account, it is all fine. I type

Quote:

OF16ext
and everything is normal. I use OF v1.6-ext. Then I type

Quote:

OF211
and again everything is fine and I use OF v2.1.1. But ! now when I want to switch back into OF v 1.6-ext I do have some problems. I type

Quote:

OF16ext
but unfortunately not all my environment variables set to OF v1.6-ext. For instance now when I type

Quote:

$WN_THIRD_PARTY_DIR
it shows me the third party dir of OF v 2.1.1 and not OF v 1.6-ext.

But strangely some of other environment variables are OK, like

Quote:

WM_PROJECT_DIR
I have attached bashrc files located in etc dir of both versions. I don't know why in bashrc file of OF v1.6ext sourcing statement format is different. it has a format like this:

Quote:

: ${WM_THIRD_PARTY_DIR=$WM_PROJECT_DIR/ThirdParty}; export WM_THIRD_PARTY_DIR
and when I change it into:

Quote:

export WM_THIRD_PARTY_DIR=$WM_PROJECT_DIR/ThirdParty
it works just fine. is there any new bashrc file for 1.6ext that I am not aware of?

Thank you
Mojtaba

elvis July 5, 2013 09:30

Hi,

try to add those "unset" Variable prior you call bashrc to your ./bashrc

alias OF16ext='unset FOAM_INST_DIR;unset WM_PROJECT_USER_DIR;unset WM_THIRD_PARTY_DIR;source ...../OpenFOAM-1.6-ext/etc/bashrc'

alias myOF20='unset FOAM..., .../bashrc'

Mojtaba.a July 6, 2013 09:12

Quote:

Originally Posted by elvis (Post 438007)
Hi,

try to add those "unset" Variable prior you call bashrc to your ./bashrc

alias OF16ext='unset FOAM_INST_DIR;unset WM_PROJECT_USER_DIR;unset WM_THIRD_PARTY_DIR;source ...../OpenFOAM-1.6-ext/etc/bashrc'

alias myOF20='unset FOAM..., .../bashrc'

Thank you elvis,
So I have got to see which variables are working and which is not, one by one? and them unset them before bashrc.

P.S: unfortunately it didn't work. It just works when I define them and export them one by one. is there any alternative?

wyldckat July 7, 2013 05:17

Greetings to all!

Quote:

Originally Posted by Mojtaba.a (Post 438128)
P.S: unfortunately it didn't work. It just works when I define them and export them one by one. is there any alternative?

First of all, I suggest you read this blog post of mine: Advanced tips for working with the OpenFOAM shell environment ;)

So, in light of that blog post, there are a few alternatives:
  • Always use independent terminal windows/tabs for each version/variant of OpenFOAM.
  • When changing from OpenFOAM 2.x to 1.6-ext, you can use the command wmUNSET for unloading most of the environment variables.
  • When changing 1.6-ext to 2.x... I'll let you figure it out ;)
    But I'll give a hint: while using the 2.x environment, run:
    Code:

    alias wmUNSET
Best regards,
Bruno

Mojtaba.a July 7, 2013 13:43

Quote:

Originally Posted by Mojtaba.a (Post 438128)
P.S: unfortunately it didn't work. It just works when I define them and export them one by one. is there any alternative?

Well I think this worked, I was wrong maybe. Thank you elvis.

Quote:

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


First of all, I suggest you read this blog post of mine: Advanced tips for working with the OpenFOAM shell environment ;)

So, in light of that blog post, there are a few alternatives:
  • Always use independent terminal windows/tabs for each version/variant of OpenFOAM.
  • When changing from OpenFOAM 2.x to 1.6-ext, you can use the command wmUNSET for unloading most of the environment variables.
  • When changing 1.6-ext to 2.x... I'll let you figure it out ;)
    But I'll give a hint: while using the 2.x environment, run:
    Code:

    alias wmUNSET
Best regards,
Bruno

Thank you Bruno for another useful post.
Well this is interesting, I hadn't mentioned the file unset.sh before.
The description in the file says:
"Clear as many OpenFOAM environment settings as possible"

That's exactly what I needed, But there is a question I have, I couldn't understand the difference between "wmUNSET" and "alias wmUNSET".

I think they both do the same for me, am I wrong about this?

wyldckat July 7, 2013 14:23

Hi Mojtaba,
  • wmUNSET - is the command that exists only because it was created as an alias.
  • alias wmUNSET - tells you what the alias "wmUNSET" actually does.
  • And last but not least, the following command will create an alias named "variable" that does "real commands":
    Code:

    alias variable='real commands'
    :)
For more information about the command alias:
Code:

man alias
About the command alias in general: http://en.wikipedia.org/wiki/Alias_%28command%29

Best regards,
Bruno

jiatangwang February 4, 2014 05:24

how to set environment variables of ThirdPartys corresponding to the OpemFOAMs ??
 
Quote:

Originally Posted by alquimista (Post 339765)
It was discussed before in this forum I'm not sure if this is the optimal way but you can run different OpenFOAM executables adding that lines in your $HOME/.bashrc file, for example (change your paths and versions):

alias startFoamGPU='source /opt/openfoam201GPU/etc/bashrc'
alias startFoam='source /opt/openfoam201/etc/bashrc'
alias startFoam210='source /opt/OpenFOAM-2.1.0/etc/bashrc'

So when you want to use OpenFOAM type in the console: startFoamGPU, startFoam or startFoam210.

Be sure that the WM_PROJECT_DIR environment variable present in the bashrc of your OpenFOAM directory was right.

Also delete previous PATH environment variables in $HOME/.bashrc, something like:

source /opt/OpenFOAM-2.1.0/etc/bashrc



You will run the solver that you specified.



There are several ways, check the environment variable FOAM_SOLVERS before run the case (echo $FOAM_SOLVERS)


Hi,

Currently I am struggling with the post-processing with multi-version of OpenFOAM on my ubuntu 12.04.
Actually I have installed the version of OpenFOAM 2.2.1 and ThirdParty 2.2.1. But I also need the OpemFOAM 2.1.1 and 1.6-ext . When I use the paraFoam in these cases of various versions, I meet a block like this,

FATAL ERROR: ParaView reader module libraries do not exist

Please build the reader module before continuing:
cd $FOAM_UTILITIES/postProcessing/graphics/PV3Readers
./Allwclean
./Allwmake

So my question is how to set environment variables of ThirdPartys corresponding to the OpemFOAMs ??

Best wishes,

Jiatang

wyldckat February 4, 2014 14:22

Greetings Jiatang,

If you can provide more information on how you installed each version of OpenFOAM, it'll will be easier to help you.

Best regards,
Bruno

jiatangwang February 5, 2014 04:01

my different version of OpenFOAM installation
 
2 Attachment(s)
Quote:

Originally Posted by wyldckat (Post 473411)
Greetings Jiatang,

If you can provide more information on how you installed each version of OpenFOAM, it'll will be easier to help you.

Best regards,
Bruno


Hi,Brun,

In the beginning I installed OpenFOAM 2.2.1, corresponding post-processing ThirdParty 2.2.1 as well on my ubuntu 12.04, and they are all in the $HOME/user/OpenFOAM fold direction. As my aim is to use the CFDEM coupling, but also need simulation in OpenFOAM individually, so I installed the required package called LIGGGHTS and CFDEM in the $HOME/user direction. The OpenFOAM as well as CFDEM coupling can work smoothly.

But I shared some code related to my research field, which codes are compatible with OpenFOAM 2.1.1 and OenFOAM 1.6-ext version.

During the OpenFOAM 2.2.1, ThirdParty 2.2.1 LIGGGHTS and CFDEM installation I followed the attached steps file "1#-installation"

Followed the same instruction "1#-installation" to install OpenFOAM 2.1.1. Also corresponding ThirdParty 2.1.1 have been complied. At the same time I want to let OpenFOAM 2.1.x coupling with DEM, so I tried OpenFOAM 2.1.x as well.

Followed the instruction
http://openfoamwiki.net/index.php/In...1.6-ext/Ubuntu
to install OpenFOAM 1.6-ext.

Now I can use the different version of OpenFOAM except OpenFOAM 1.6-ext because some errors when I tried to compile the OF using the command "./Allwmake"

When I use the post-processing of OpenFOAM 2.1.1, after the command "paraFoam", a block is as follows,

FATAL ERROR: ParaView reader module libraries do not exist

**************************************
Please build the reader module before continuing:
cd $FOAM_UTILITIES/postProcessing/graphics/PV3Readers
./Allwclean
./Allwmake
*********************************
Attached you can find my .bashrc file and the "1#-installation"

Thank you.

Best wishes,

jiatang

wyldckat February 11, 2014 16:55

Hi Jiatang,

Sorry for taking so long to answer to you, but I haven't managed to get enough time to answer questions here on the forum.

First, I advise you to change the last big part of your "~/.bashrc" file to this:
Code:

#================================================#
function cfdem_environment()
{
  export WM_NCOMPPROCS=4

  #- source cfdem env vars
  export CFDEM_VERSION=PUBLIC
  export CFDEM_PROJECT_DIR=$HOME/CFDEM/CFDEMcoupling-$CFDEM_VERSION-$WM_PROJECT_VERSION
  export CFDEM_SRC_DIR=$CFDEM_PROJECT_DIR/src/lagrangian/cfdemParticle
  export CFDEM_SOLVER_DIR=$CFDEM_PROJECT_DIR/applications/solvers
  export CFDEM_DOC_DIR=$CFDEM_PROJECT_DIR/doc
  export CFDEM_UT_DIR=$CFDEM_PROJECT_DIR/applications/utilities
  export CFDEM_TUT_DIR=$CFDEM_PROJECT_DIR/tutorials
  export CFDEM_PROJECT_USER_DIR=$HOME/CFDEM/$LOGNAME-$CFDEM_VERSION-$WM_PROJECT_VERSION
  export CFDEM_bashrc=$CFDEM_SRC_DIR/etc/bashrc
  export CFDEM_LIGGGHTS_SRC_DIR=$HOME/LIGGGHTS/LIGGGHTS-PUBLIC/src
  export CFDEM_LIGGGHTS_MAKEFILE_NAME=fedora_fpic
  export CFDEM_LPP_DIR=$HOME/LIGGGHTS/LPP/src
  export CFDEM_PIZZA_DIR=$HOME/LIGGGHTS/PIZZA/pizza-11Sep13/src
  source $CFDEM_bashrc
}
#================================================#

## OPENFOAM ###
alias of221='[ -n "$WM_PROJECT_DIR" ] && source $HOME/OpenFOAM/OpenFOAM-2.2.1/etc/config/unset.sh; source $HOME/OpenFOAM/OpenFOAM-2.2.1/etc/bashrc; cfdem_environment'

alias of21x='[ -n "$WM_PROJECT_DIR" ] && source $HOME/OpenFOAM/OpenFOAM-2.2.1/etc/config/unset.sh; source $HOME/OpenFOAM/OpenFOAM-2.1.x/etc/bashrc; cfdem_environment'

alias of16ext='[ -n "$WM_PROJECT_DIR" ] && source $HOME/OpenFOAM/OpenFOAM-2.2.1/etc/config/unset.sh; source $HOME/OpenFOAM/OpenFOAM-1.6-ext/etc/bashrc; cfdem_environment'

alias of211='[ -n "$WM_PROJECT_DIR" ] && source $HOME/OpenFOAM/OpenFOAM-2.2.1/etc/config/unset.sh; source $HOME/OpenFOAM/OpenFOAM-2.1.1/etc/bashrc; cfdem_environment'
## OPENFOAM ###

alias lpp="python $HOME/LIGGGHTS/LPP/src/lpp.py"
alias pizza="python -i $HOME/LIGGGHTS/PIZZA/pizza-11Sep13/src/pizza.py"

What this suggestion enables you to do is this:
  1. The CFDEM environment is initialized only when it's truly needed, namely after the OpenFOAM environment has been started. It does this by relying on a shell function: http://www.cyberciti.biz/faq/bash-sh...tion-examples/
  2. Have a more clean shell environment, by relying on the "unset.sh" bash script that OpenFOAM 2.x has got. The suggestion is hard-coded to the one in 2.2.1, because it's the more recent one. Although it will give some warnings when starting the environment for 1.6-ext.
  3. This should avoid the collision of independent ParaView installations, one per OpenFOAM version.
Honestly, this usually isn't necessary, because the easiest procedure is to have only one OpenFOAM environment working per terminal window or tab, precisely because it's very complicated to keep the shell environment clean after using OpenFOAM.


Now, as I suggested, start 4 terminal windows or tabs and on each one run only one of the alias commands; in other words, on each terminal run:
  1. Terminal 1:
    Code:

    of221
  2. Terminal 2:
    Code:

    of211
  3. Terminal 3:
    Code:

    of21x
  4. Terminal 4:
    Code:

    of16ext
Then on each terminal, run:
Code:

which paraview
If the path given by the command above is different for all of them, and each one is pointing to their respective ThirdParty folder, then run on each terminal these commands:
Code:

cd $FOAM_UTILITIES/postProcessing/graphics/PV3Readers
./Allwclean
./Allwmake

If any of the above is different from the expected results, let me know.

Best regards,
Bruno

jiatangwang February 13, 2014 04:19

Multiple OpenFOAM versions on one machine
 
Hi Bruno,
A few days before, I installed a Praraview in the /home/ directory but not depend on the each version of OpenFOAM called ThirdyParty. Actually I can use the command "paraFoam" when I run the case in OpenFOAM 221. And in others version of OpenFOAM I can use the command "touch caseneme.OpenFOAM", then use "paraview" to view the results of runung case.

New I follow the advice you give me above. Changed the .bashrc fill environment. After that use the command you supplied, and each results are as follows in every terminal,

In OenFOAM 2.2.1 terminal,
Code:

>>of221
>>which paraview
/home/jt/OpenFOAM/ThirdParty-2.2.1/platforms/linux64Gcc/paraview-3.12.0/bin/paraview

In OenFOAM 2.1.1 terminal,
Code:

>>of211
bash: /home/jt/CFDEM/CFDEMcoupling-PUBLIC-2.1.1/src/lagrangian/cfdemParticle/etc/bashrc: No such file or directory
>>which paraview
/usr/bin/paraview

In OenFOAM 2.1.x terminal,
Code:

>>of21x
bash: /home/jt/CFDEM/CFDEMcoupling-PUBLIC-2.1.x/src/lagrangian/cfdemParticle/etc/bashrc: No such file or directory
>>which paraview
/usr/bin/paraview

In OpenFOAM 1.6ext terminal,
Code:

>>of16ext
bash: /home/jt/CFDEM/CFDEMcoupling-PUBLIC-1.6-ext/src/lagrangian/cfdemParticle/etc/bashrc: No such file or directory
>>which paraview
/usr/bin/paraview

Additionally, In OpenFOAM 221, I run the command,
Code:

cd $FOAM_UTILITIES/postProcessing/graphics/PV3Readers 
./Allwclean
./Allwmake

After that , command "which paraview", the path of paraview is still in the corresponding ThirdParty files showed above.
And in others version of OpenFOAM, I use the command,
Code:

cd $FOAM_UTILITIES/postProcessing/graphics/PV3Readers
./Allwclean
./Allwmake

The path of paraview are in the /usr/bin/paraview

It is strange that I can use the command "paraFoam" directly when I run the case in OpenFOAM 16ext to view the results of running case.

Now the conclusion is that I can use each version of OpenFOAM, and view the results of running case even though some times I need to transfer the results to .OpenFOAM file using command 'touch casename.OpenFOAM' and then "paraview". So this situation is not too bad. If you cant solve the problem do not worry. But if you can it is better.

My question is that I cant use the CFDEM coupling in each version (only can be used in OpenFOAM 2.2.1). I do not know If you can give me some advice.
I really need to use the OpenFOAM 21x and Open16ext on my computer.

Thanks for your help.

Best wishes,

Jiatang Wang

babakflame February 15, 2014 00:41

Greetings Bruno

Many thanks for your valuable hints about installing different versions of O.F. on one machine and also the blog you have written (advanced tips).:):)

I have O.F. 2.2.x on my $HOME/OpenFOAM directory and my operating system is ubuntu 12.10. I want to install O.F. 2.1.0 in my $HOME/OpenFOAM directory too.

I think I am familiar with alias methodology now. However, before starting my installation there is a question remained in my mind.:confused:

What about paraview? I mean do I need to just download and build O.F. 2.1.0 and use the alias methodology and then my earlier paraview (3.12.0) installed with O.F. 2.2.x will be used automatically for 2.1.0 too ?

Or should I install paraview along with O.F.2.1.0 (which is my second O.F.), too?


Regards
Bobi

wyldckat February 15, 2014 11:09

Greetings to all!

@Jiatang: My advice is to have separate installations of CFDEM, one per OpenFOAM version. I say this because for each version, you might need different code bases of CFDEM. In other words, it might be best to follow the installation instructions for CFDEM, once per OpenFOAM version.

Nonetheless, if you want to use the same one in all of them, try this:
Code:

cd $HOME/CFDEM/
ln -s CFDEMcoupling-PUBLIC-2.2.1 CFDEMcoupling-PUBLIC-2.1.1
ln -s CFDEMcoupling-PUBLIC-2.2.1 CFDEMcoupling-PUBLIC-2.1.x
ln -s CFDEMcoupling-PUBLIC-2.2.1 CFDEMcoupling-PUBLIC-1.6-ext

It will create symbolic links to the same folder, for the folder names that are missing.


Since you have one ParaView in the Linux Distribution, then add this alias to your "~/.bashrc" file:
Code:

alias paraFoamB='(touch case.foam && paraview --data=case.foam)'
The next time you start a new terminal, you can now using this command:
Code:

paraFoamB
It will create the file "case.foam" and open it, therefore using the built-in OpenFOAM reader.

The other possibility is to use this alias:
Code:

alias paraFoam221='([ -n "$WM_PROJECT_DIR" ] && source $HOME/OpenFOAM/OpenFOAM-2.2.1/etc/config/unset.sh; source $HOME/OpenFOAM/OpenFOAM-2.2.1/etc/bashrc; $WM_PROJECT_DIR/bin/paraFoam)'
Then after a new terminal is started, you are able to run the same ParaView version from OpenFOAM 2.2.1 from any command line, by running:
Code:

paraFoam221
________________________________________________

@Bobi: The instructions I wrote above for Jiatang, namely regarding "paraFoam221", should also work for you :)

Best regards,
Bruno


All times are GMT -4. The time now is 09:41.