CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Installation (https://www.cfd-online.com/Forums/openfoam-installation/)
-   -   central installation and compiling own sources (https://www.cfd-online.com/Forums/openfoam-installation/90711-central-installation-compiling-own-sources.html)

lindstroem July 19, 2011 07:32

central installation and compiling own sources
 
Hi everybody,

I read a lot of different ways of installing OpenFOAM in a central way. But anyhow, I still can't compile my own solvers on my local machine with OF installed centrally because I don't have write permission on the central installation. Do I really need it? Or do I have to change sth in the Make/options etc?

Another question I was thinking about is: I use a Desktop and a Laptop. Both have OF installed. If I now have a personal OF-directory on a network storage could I use them for both installtions? Of course I would run the simulations locally on the machine, but the compiled sources of my own implementations would be present for the connected Computer?

Thanks for your help!
Lindstroem

wyldckat July 19, 2011 18:19

Hi Lindstroem,

Quote:

Originally Posted by lindstroem (Post 316594)
But anyhow, I still can't compile my own solvers on my local machine with OF installed centrally because I don't have write permission on the central installation. Do I really need it? Or do I have to change sth in the Make/options etc?

Have you ever read the tutorial about adding temperature to icoFoam? Here's an excerpt of the detail you are looking for:
Quote:

Originally Posted by http://openfoamwiki.net/index.php/How_to_add_temperature_to_icoFoam
Now go into the Make subdirectory and open the 'files' file with your favorite editor. Change it to read:
Code:

my_icoFoam.C

EXE = $(FOAM_USER_APPBIN)/my_icoFoam


This is also explained here: http://www.openfoam.com/docs/user/co...0-740003.2.2.3

For libraries use $(FOAM_USER_LIBBIN) ;)


________________________________

Quote:

Originally Posted by lindstroem (Post 316594)
Another question I was thinking about is: I use a Desktop and a Laptop. Both have OF installed. If I now have a personal OF-directory on a network storage could I use them for both installtions? Of course I would run the simulations locally on the machine, but the compiled sources of my own implementations would be present for the connected Computer?

Well... this is sort of a hidden feature of OpenFOAM... in other words, only those who look at the code and those who went to workshops will figure this one out:
  • You can create a file named prefs.sh where you set some of the environment variables you want to modify, such as where to look for the desired OpenFOAM.
  • This file can reside in one of the following places, with the following order of preference (copy-paste from bin/foamEtcFile):
  1. $HOME/.${WM_PROJECT:-OpenFOAM}/$version
  2. $HOME/.${WM_PROJECT:-OpenFOAM}
  3. $prefixDir/site/$version
  4. $prefixDir/site
  5. $prefixDir/openfoam$versionNum/etc <- for Debian/Ubuntu
    $prefixDir/${WM_PROJECT:-OpenFOAM}-$version/etc <- standard build
Lets see:
  • prefixDir - it's the parent folder of the bin folder where foamEtcFile resides.
  • WM_PROJECT - this variable is usually set to OpenFOAM.
Simply translating, e.g. 1.7.x it searches in these folders:
  1. ~/.OpenFOAM/1.7.x
  2. ~/.OpenFOAM/
  3. ~/OpenFOAM/OpenFOAM-1.7.x/site/1.7.x
  4. ~/OpenFOAM/OpenFOAM-1.7.x/site
  5. /opt/openfoam171/etc <- Debian/Ubuntu for 1.7.1
    ~/OpenFOAM/OpenFOAM-1.7.x/etc <- standard build
  • For more informations about prefs.sh, you can find examples here:
    • For OpenFOAM 1.6/7.x: etc/prefs.sh-EXAMPLE
    • For OpenFOAM 2.0.x: etc/config/example/prefs.sh

So, to sum up, you can create this file "~/.OpenFOAM/1.7.x/prefs.sh" and/or this one "~/.OpenFOAM/2.0.x/prefs.sh" with something like this:
Code:

export FOAM_INST_DIR=/mnt/OpenFOAM/OpenFOAM-version
export WM_PROJECT_INST_DIR=$FOAM_INST_DIR
export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION
export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION

You can change where WM_PROJECT_USER_DIR points to...


Finally, add this to your "~/.bashrc" file (don't forget to remove/comment other lines in there related to OpenFOAM, if they aren't using alias):
Code:

alias of20x='source /mnt/OpenFOAM/OpenFOAM-2.0.x/etc/bashrc'
________________________________


OK, I probably lost you somewhere... this is an easier way to do the same thing and should be compatible with both versions so add this to your "~/.bashrc" file (don't forget to remove/comment other lines in there related to OpenFOAM, if they aren't using alias):
Code:

alias of20x='export FOAM_INST_DIR=/mnt/OpenFOAM/OpenFOAM-2.0.x; source $FOAM_INST_DIR/etc/bashrc WM_PROJECT_USER_DIR=$FOAM_INST_DIR/myarea'
Then whenever you want OpenFOAM ready at your finger tips, run of20x.

I'm sorry for making things look confusing... but I think it's all explained now :D

Best regards,
Bruno

olesen July 20, 2011 03:48

Quote:

Originally Posted by wyldckat (Post 316676)
...
  • This file can reside in one of the following places, with the following order of preference (copy-paste from bin/foamEtcFile):
  1. $HOME/.${WM_PROJECT:-OpenFOAM}/$version
  2. $HOME/.${WM_PROJECT:-OpenFOAM}
  3. $prefixDir/site/$version
  4. $prefixDir/site
  5. $prefixDir/openfoam$versionNum/etc <- for Debian/Ubuntu
    $prefixDir/${WM_PROJECT:-OpenFOAM}-$version/etc <- standard build
...

For those wishing to supply site-wide solvers/libraries, the suggested location would normally be the $FOAM_SITE_APPBIN and $FOAM_SITE_LIBBIN directories. We normally compile into $FOAM_USER_APPBIN, $FOAM_USER_LIBBIN, do some testing and then use rsync to sync to the corresponding $FOAM_SITE_APPBIN and $FOAM_SITE_LIBBIN directories.

Note that these site directories are normally located below $WM_PROJECT_INST_DIR/site, but as of OpenFOAM-2.0 the env variable $WM_PROJECT_SITE can be used to specify another location as desired.

lindstroem July 20, 2011 04:35

Dear Bruno,

thanks for the very detailed and well explained answer!

Concerning the first part: Yes I did change these paths but still I got some write-permission errors. I can't post them right now, as we now installed it locally, but at least I know it should actually work as I thought. I'll try it again, when the Admin is back. Thanks for the hint!

Quote:

OK, I probably lost you somewhere...
No I'm glad you didn't! As I also work with different OF versions and use several bash-scripts I totally understood what you mean but I did not know about the possibility to give an order of preferences where he should search.

You really helped me a lot!

And thank you as well olesen for your hint!

Best regards
Lindstroem


All times are GMT -4. The time now is 06:27.