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.com] Installing OpenFOAM on secondary drive (https://www.cfd-online.com/Forums/openfoam-installation/228155-installing-openfoam-secondary-drive.html)

CronusX June 21, 2020 18:37

Installing OpenFOAM on secondary drive
 
I'm installing OpenFOAM via Ubuntu Bash for Windows.

Instead of installing OpenFOAM on the C: drive, I want to install it on my F: drive (secondary hard drive).

I thought I was manipulating the instructions on openFOAM's website properly, but evidently now because when I try to do the test of the cravity tutorial I get the error.

Code:

Command 'blockMesh' not found, but can be installed with:
sudo apt install openFOAM.

Here are the steps I ran to istall openFOAM on my F: drive based on modifications to the install instructions on OpenFOAMs site. I would appreciate any feedback on where I went wrong.

Copied .tgz to bash-environment f drive folder OpenFOAM

Code:

cp -ar /mnt/c/Users/<USER>/Downloads/OpenFOAM-v1912-windows10.tgz /mnt/f/OpenFOAM
Untar'd the install file

Code:

sudo tar -xvzf  OpenFOAM-v1912-windows10.tgz -C /mnt/e/OpenFOAM
sudo chown -R mnt/f/OpenFOAM

Set the OpenFOAM working environment

Code:

echo "source /mnt/f/OpenFOAM/OpenFOAM/OpenFOAM-v1912/etc/bashrc" >> ~/.bashrc
source ~/.bashrc

I'm guessing it has to do with how I did the working environment. I'm not fluent in Linux so yeah let me know what I messed up here.

Thanks.

bestucan June 21, 2020 20:49

that's a shortcoming of OpenFOAM. not easy to change install path.

cause it's install path is written down in script as environment variable.

here is my step(first step already change install path. Second step could change path which OpenFOAM used to generate file and something else.):


1. replace "$HOME" with "$path/to/where/I/want" in etc/bashrc. here is my change log. (Just look the line start with "+" and "-")
Code:

diff --git a/etc/bashrc b/etc/bashrc
index 7e7423522..383dde079 100644
--- a/etc/bashrc
+++ b/etc/bashrc
@@ -44,7 +44,7 @@ export WM_PROJECT_VERSION=dev
 #
 [ "$BASH" -o "$ZSH_NAME" ] && \
 export FOAM_INST_DIR=$(cd $(dirname ${BASH_SOURCE:-$0})/../.. && pwd -P) || \
-export FOAM_INST_DIR=$HOME/$WM_PROJECT
+export FOAM_INST_DIR=$HOME/opt/$WM_PROJECT
 # export FOAM_INST_DIR=~$WM_PROJECT
 # export FOAM_INST_DIR=/opt/$WM_PROJECT
 # export FOAM_INST_DIR=/usr/local/$WM_PROJECT
@@ -105,7 +105,7 @@ export FOAM_SIGFPE=
 
 # The old dirs to be cleaned from the environment variables
 foamOldDirs="$WM_PROJECT_DIR $WM_THIRD_PARTY_DIR \
-    $HOME/$WM_PROJECT/$USER $FOAM_USER_APPBIN $FOAM_USER_LIBBIN \
+    $HOME/opt/$WM_PROJECT/$USER $FOAM_USER_APPBIN $FOAM_USER_LIBBIN \
    $WM_PROJECT_SITE $FOAM_SITE_APPBIN $FOAM_SITE_LIBBIN"
 
 # Location of installation
@@ -149,7 +149,8 @@ fi
 
 # Location of user files
 # ~~~~~~~~~~~~~~~~~~~~~~
-export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
+export WM_PROJECT_USER_DIR=$HOME/opt/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
+source $FOAM_INST_DIR/my_environment/$USER-$WM_PROJECT_VERSION
 
 # Source initialization functions
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2. add a script to reset and add environment. the change log above also record the sentence
Code:

source $FOAM_INST_DIR/my_environment/$USER-$WM_PROJECT_VERSION
that's not complex if you don't use environment variable (start with "$").
in my PC, it is
Code:

source home/user/opt/my_environment/user-dev
IMPORTANT: the script must be put at a special location: following
Code:

-export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
 +export WM_PROJECT_USER_DIR=$HOME/opt/$WM_PROJECT/$USER-$WM_PROJECT_VERSION

and here is the script
Code:

export WM_PROJECT_USER_DIR=$HOME/Documents/openfoam/$USER-$WM_PROJECT_VERSION
export WM_PROJECT_USER_CODE_DIR=$HOME/Documents/code/C/openfoam/$USER-$WM_PROJECT_VERSION

#-------------------------------------------------------------------------------
export FOAM_USER_SRC=$WM_PROJECT_USER_CODE_DIR/src;
#-------------------------------------------------------------------------------
export FOAM_USER_APP=$WM_PROJECT_USER_CODE_DIR/applications;
export FOAM_USER_SOLVERS=$WM_PROJECT_USER_CODE_DIR/applications/solvers;
export FOAM_USER_UTILITIES=$WM_PROJECT_USER_CODE_DIR/applications/utilities;
#-------------------------------------------------------------------------------
export FOAM_USER_TUTORIALS=$WM_PROJECT_USER_DIR/run/tutorials


alias msrc='cd $FOAM_USER_SRC'
#-------------------------------------------------------------------------------
alias mapp='cd $FOAM_USER_APP'
alias msol='cd $FOAM_USER_SOLVERS'
alias mutil='cd $FOAM_USER_UTILITIES'
#-------------------------------------------------------------------------------
alias mtut='cd $FOAM_USER_TUTORIALS'


alias mappb='cd $FOAM_USER_APPBIN'
alias mlibb='cd $FOAM_USER_LIBBIN'


CronusX June 23, 2020 00:10

Thanks, bestucan.

It was actually much easier than that. I pointed the install at the secondary drive, but my main bashrc was wrong.

After making the adjustments and having that grab the source from my secondary drive, the program works fine.

Thanks for the suggestion though.

SSG_NJ June 25, 2020 02:18

Quote:

Originally Posted by CronusX (Post 775641)
Thanks, bestucan.

It was actually much easier than that. I pointed the install at the secondary drive, but my main bashrc was wrong.

After making the adjustments and having that grab the source from my secondary drive, the program works fine.

Thanks for the suggestion though.

Hi, I am finding to difficult to install OpenFOAM on a secondary drive.
I run Windows 10 with WSL enabled and have Ubuntu installed via the MS Store.

After untarring the .tar file on the secondary drive, I did change the default location on the bashrc file to:

source /mnt/h/OF/OpenFOAM/OpenFOAM-v1912/etc/bashrc

(OF is the folder containing the OpenFOAM untarred)

I get an error message when I run 'blockMesh' command:

command 'blockMesh' not found, but can be installed with:
sudo apt install openfoam

Please help.

SSG_NJ June 25, 2020 05:04

Looks like I fixed my issue by myself too. I had forgotten to use "chown" command, and I fixed the location of my bashrc file back into the 'etc' folder.

Then it worked!


All times are GMT -4. The time now is 15:37.