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

[OpenFOAM.com] Installing OpenFOAM on secondary drive

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 21, 2020, 18:37
Default Installing OpenFOAM on secondary drive
  #1
New Member
 
Join Date: Jun 2020
Posts: 4
Rep Power: 5
CronusX is on a distinguished road
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.
CronusX is offline   Reply With Quote

Old   June 21, 2020, 20:49
Default
  #2
New Member
 
bestucan's Avatar
 
Tu Can
Join Date: Jul 2017
Location: China
Posts: 16
Rep Power: 8
bestucan is on a distinguished road
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'
bestucan is offline   Reply With Quote

Old   June 23, 2020, 00:10
Default
  #3
New Member
 
Join Date: Jun 2020
Posts: 4
Rep Power: 5
CronusX is on a distinguished road
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.
CronusX is offline   Reply With Quote

Old   June 25, 2020, 02:18
Default
  #4
New Member
 
Join Date: May 2020
Posts: 21
Rep Power: 5
SSG_NJ is on a distinguished road
Quote:
Originally Posted by CronusX View Post
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 is offline   Reply With Quote

Old   June 25, 2020, 05:04
Default
  #5
New Member
 
Join Date: May 2020
Posts: 21
Rep Power: 5
SSG_NJ is on a distinguished road
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!
SSG_NJ is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
[OpenFOAM.com] Installing OpenFOAM on secondary drive CronusX OpenFOAM Installation 0 June 21, 2020 16:14
OpenFOAM course for beginners Jibran OpenFOAM Announcements from Other Sources 2 November 4, 2019 08:51
[Other] Basic questions about OpenFOAM cluster running and installing Fauster OpenFOAM Installation 0 May 25, 2018 15:00
OpenFOAM Training Jan-Jul 2017, Virtual, London, Houston, Berlin CFDFoundation OpenFOAM Announcements from Other Sources 0 January 4, 2017 06:15
OpenFOAM Training Jan-Apr 2017, Virtual, London, Houston, Berlin cfd.direct OpenFOAM Announcements from Other Sources 0 September 21, 2016 11:50


All times are GMT -4. The time now is 10:28.