CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Installation

[OpenFOAM.org] How change OpenFoam run directory

Register Blogs Community New Posts Updated Threads Search

Like Tree13Likes
  • 2 Post By alexeym
  • 1 Post By Gallienus
  • 4 Post By wyldckat
  • 3 Post By time-
  • 1 Post By Wowbagger
  • 2 Post By reverseila

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 18, 2019, 01:49
Unhappy How change OpenFoam run directory
  #1
New Member
 
John
Join Date: Nov 2013
Location: USA
Posts: 22
Rep Power: 13
Gallienus is on a distinguished road
Installed OpenFoam 6 on an Ubuntu Linux v 18.04 system. OF installation went nicely but need to change the OpenFoam run directory from the default setup to something different.

I imagine this means changing an Environment variable somewhere as well as creating the new directories. I'm aware that OF uses a directory structure to save cases and variables.

There is an old thread from 2011 on this same topic but those solutions don't work.

Thanks very much for any help.
Gallienus is offline   Reply With Quote

Old   March 18, 2019, 05:29
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Hope, I got your question right. There is FOAM_RUN environment variable, which by default points to $WM_PROJECT_USER_DIR/run (and alias run just do 'cd $FOAM_RUN').

So, a) you can set this variable to whatever value you like, b) keep your cases wherever you like, ignoring FOAM_RUN variable.
Gallienus and reverseila like this.
alexeym is offline   Reply With Quote

Old   March 18, 2019, 14:00
Default need to find envir variable to change run directory
  #3
New Member
 
John
Join Date: Nov 2013
Location: USA
Posts: 22
Rep Power: 13
Gallienus is on a distinguished road

Hi & thanks for your reply.

I know how to find my Openfoam run directory, the issue is to change it.

Apparently the setup configured my OF for multiple users but I'm the only one on this laptop, thus I don't want a very convoluted directory structure.

I was able to find other OpenFOAM environment variables in the file: /opt/openfoam6/etc/bashrc
but these were for the installation directory which I do not want or need to change.

This is the only line that discusses user settings in bashrc

# Location of user files
# ~~~~~~~~~~~~~~~~~~~~~~
export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION

However, this does not change the run location.
Wowbagger likes this.
Gallienus is offline   Reply With Quote

Old   March 18, 2019, 21:57
Default
  #4
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quick/simple answer: In your file "~/.bashrc", right after the line:
Code:
source  /opt/openfoam6/etc/bashrc
add the following line:
Code:
export FOAM_RUN=$HOME/myRunFolder
where you can change the name "myRunFolder" to whatever you want.

This does not need any changes inside the folder "/opt/openfoam6" and will work without problems when you need to rely on the variable "FOAM_RUN".
__________________
wyldckat is offline   Reply With Quote

Old   March 19, 2019, 04:57
Default
  #5
New Member
 
Mattia
Join Date: May 2018
Location: Novara - Italy
Posts: 29
Rep Power: 8
time- is on a distinguished road
Quote:
Originally Posted by Gallienus View Post

Hi & thanks for your reply.

I know how to find my Openfoam run directory, the issue is to change it.

Apparently the setup configured my OF for multiple users but I'm the only one on this laptop, thus I don't want a very convoluted directory structure.

I was able to find other OpenFOAM environment variables in the file: /opt/openfoam6/etc/bashrc
but these were for the installation directory which I do not want or need to change.

This is the only line that discusses user settings in bashrc

# Location of user files
# ~~~~~~~~~~~~~~~~~~~~~~
export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION

However, this does not change the run location.
Hi,
if you check OpenFOAM's etc README.md file you'll see:

Code:
OpenFOAM Configuration
----------------------

The main OpenFOAM settings are located in the parent `etc/` directory.
Both POSIX (bash, dash,...) and csh shells are supported.
To configure OpenFOAM, source either the `etc/bashrc` or the
`etc/cshrc` file, as appropriate for your shell.

These source the following files in the `config.sh/` or
`config.csh/` directories:

* `setup` : finalize setup of OpenFOAM environment (called by bashrc,cshrc)
* `settings` : core settings
* `aliases` : aliases for interactive shells
* `unset` : sourced to clear as many OpenFOAM environment settings as possible
* `mpi` : MPI communications library settings
* `paraview` : application settings for ParaView
* `scotch` : application settings for compiling against scotch
* `metis` : application settings for compiling against metis

The `config.*/example` directories contain additional example configuration
files for the corresponding shell:

* `compiler` : an example of fine tuning ThirdParty compiler settings
* `openmpi` : an example of fine tuning openmpi settings for OpenFOAM
* `paraview` : an example of chaining to the standard config/paraview
   with a different ParaView_VERSION
* `prefs`: an example of supplying alternative site-defined settings
When you source the rc file, other files are sourced as well. Those files are inside etc/config.sh/ folder and it's usefull to understand them.

For example $FOAM_RUN is defined inside "settings" file.

Code:
export FOAM_ETC="$WM_PROJECT_DIR/etc"
export FOAM_APP="$WM_PROJECT_DIR/applications"
export FOAM_SRC="$WM_PROJECT_DIR/src"
export FOAM_TUTORIALS="$WM_PROJECT_DIR/tutorials"
export FOAM_UTILITIES="$WM_PROJECT_DIR/applications/utilities"
export FOAM_SOLVERS="$WM_PROJECT_DIR/applications/solvers"
export FOAM_RUN="$WM_PROJECT_USER_DIR/run"
Anyways wyldckat hint is perfectly correct and I suggest you to keep it simple and not to mess with OF config if you don't know exactly what you are doing.

I posted just to clearify how that works.

Bye
Gallienus, brianIRE and Wowbagger like this.
time- is offline   Reply With Quote

Old   August 12, 2021, 13:07
Default
  #6
Member
 
Wowbagger's Avatar
 
Michael S.
Join Date: May 2020
Location: Hamburg, Germany
Posts: 53
Rep Power: 6
Wowbagger is on a distinguished road
Send a message via Skype™ to Wowbagger
Quote:
Originally Posted by wyldckat View Post
Quick/simple answer: In your file "~/.bashrc", right after the line:
Code:
source  /opt/openfoam6/etc/bashrc
add the following line:
Code:
export FOAM_RUN=$HOME/myRunFolder
where you can change the name "myRunFolder" to whatever you want.

This does not need any changes inside the folder "/opt/openfoam6" and will work without problems when you need to rely on the variable "FOAM_RUN".

I want to change my "run" folder to an external HDD and tried this in some various ways but it seems it does not work that easy outside from $HOME.

I tried to do this in Linux Mint but I am just another beginner at Linux.

Is there a similar easy way to change it to "/media/..." as in this description?


Best regards
Michael
Wowbagger is offline   Reply With Quote

Old   August 13, 2021, 07:53
Default
  #7
Member
 
Wowbagger's Avatar
 
Michael S.
Join Date: May 2020
Location: Hamburg, Germany
Posts: 53
Rep Power: 6
Wowbagger is on a distinguished road
Send a message via Skype™ to Wowbagger
...well, seems that all I needed was still here.

I changed the bashrc file as mentioned in the thread:


Code:
# Location of user files
# ~~~~~~~~~~~~~~~~~~~~~~
# export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
export WM_PROJECT_USER_DIR=/media/michel/DATEN/CFD/OF9
Created the run folder into that directory:


media/michel/DATEN/CFD/OF9/run


Works.
Thanks to your posts in before. Maybe this helps some other users.

Regards
Michael
mgvelasquez likes this.
Wowbagger is offline   Reply With Quote

Old   September 15, 2021, 15:48
Default
  #8
New Member
 
Cheng Chen
Join Date: Apr 2020
Posts: 1
Rep Power: 0
CchcC is on a distinguished road
I don’t know if this is the version/system difference or not, but I couldn’t find the line in bashrc under the home folder(found in wyldckat’s reply). Instead I found line in bashrc under the ~/OpenFOAM/OpenFOAM-x.x/etc/
CchcC is offline   Reply With Quote

Old   September 25, 2021, 11:45
Default
  #9
Member
 
Ali B.
Join Date: Mar 2020
Location: abzrg.github.io
Posts: 44
Rep Power: 6
reverseila is on a distinguished road
Quote:
Originally Posted by CchcC View Post
I don’t know if this is the version/system difference or not, but I couldn’t find the line in bashrc under the home folder(found in wyldckat’s reply). Instead I found line in bashrc under the ~/OpenFOAM/OpenFOAM-x.x/etc/
You can find any variable/setting/pattern with grep. For example, to find the occurrences of “FOAM_RUN” environment variable, you can issue the following (usually settings are in “etc” directory, so run this command in that directory),

Code:
grep -R 'FOAM_RUN='
  • -R: recursively search in the current directory in all the files
  • =: because an environment variable is immediately proceeds with an equal sign

Note that on some very old version of grep, you should supply the directory to search:

Code:
grep -R 'FOAM_RUN=' $WM_PROJECT_DIR/etc
CchcC and Wowbagger like this.

Last edited by reverseila; September 26, 2021 at 10:37.
reverseila is offline   Reply With Quote

Reply

Tags
change run directory


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[swak4Foam] funkyDoCalc with OF2.3 massflow NiFl OpenFOAM Community Contributions 14 November 25, 2020 04:30
[waves2Foam] Waves2Foam Related Topics ngj OpenFOAM Community Contributions 660 August 20, 2018 13:39
How to contribute to the community of OpenFOAM users and to the OpenFOAM technology wyldckat OpenFOAM 17 November 10, 2017 16:54
Working directory via command line Luiz CFX 4 March 6, 2011 21:02
Compiling OpenFOAM13 on AMD64 with Redhat Enterprise mbeaudoin OpenFOAM Installation 20 June 17, 2008 07:43


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