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

changing OF171 to single precision

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 31, 2011, 18:47
Default changing OF171 to single precision
  #1
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16
ozzythewise is on a distinguished road
Hi all,

I'm pretty sure this is a really easy thing to do but I want to change openfoam171 from double precision to single precision. Looking around it shows how to do it for OF 1.3 (here: http://openfoamwiki.net/index.php/Ho...on_of_OpenFOAM) but I'm not sure how I would do it for 171.

Thanks!
Jeff
ozzythewise is offline   Reply With Quote

Old   May 31, 2011, 20:17
Default
  #2
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16
ozzythewise is on a distinguished road
I tried changing the line in ~/opt/openfoam171/etc/bashrc that reads:
Code:
# WM_PRECISION_OPTION = DP | SP
: ${WM_PRECISION_OPTION:=DP}; export WM_PRECISION_OPTION
to
Code:
# WM_PRECISION_OPTION = DP | SP
: ${WM_PRECISION_OPTION:=SP}; export WM_PRECISION_OPTION
And then I went to ~/opt/openfoam171/ and executed
Code:
sudo ./Allwmake
but I got an error that read:
Code:
Error: Current directory is not $WM_PROJECT_DIR
    The environment variable are not consistent with the installation.
    Check the OpenFOAM entries in your dot-files and source them.
even though i definitely am in $WM_PROJECT_DIR. Any help on this one?

Thanks
Jeff
ozzythewise is offline   Reply With Quote

Old   June 1, 2011, 02:11
Default
  #3
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas will become famous soon enough
yes, you cant just change the variables and expect the shell to know about them without sourcing it.

if you open a new window and type icoFoam, I would expect the command not be found, which
means that the SP version does not exist yet, so you can compile it with Allwmake
niklas is offline   Reply With Quote

Old   June 1, 2011, 09:24
Default
  #4
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16
ozzythewise is on a distinguished road
Yeah that is exactly what happened. So then how would I go about changing to single precision?

J
ozzythewise is offline   Reply With Quote

Old   June 1, 2011, 09:44
Default
  #5
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
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
Greetings to both!

@ozzythewise: I suggest you resort to OF voodoo - run the following commands in your terminal that has a working OpenFOAM environment:
Code:
foam
wmSP
./Allwmake > make.log 2>&1
You can track the building process in another terminal window, by running:
Code:
tail -F make.log
Oh, about those two voodoo commands:
  • foam: does cd to OpenFOAM's project folder.
  • wmSP: re-sources the environment as SP
  • To learn about more aliases made by default on OpenFOAM, see the aliases.sh script on OpenFOAM's etc folder.

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   June 1, 2011, 10:24
Default
  #6
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16
ozzythewise is on a distinguished road
Hi Bruno,

When I run the command
Code:
./Allwmake > make.log 2>&1
I get the following error:
Code:
Error: Current directory in not $WM_PROJECT_DIR
The environment variable are not consistent with the installation.
Check the OpenFOAM entries in your dot-files and source them.
However, when I check $PWD and $WM_PROJECT_DIR they are both identical, any idea what is going on here?

Thanks
Jeff
ozzythewise is offline   Reply With Quote

Old   June 1, 2011, 11:42
Default
  #7
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
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
Hi Jeff,

Mmm, I have the vague idea I already tripped on that issue before.

OK, easiest way to isolate-and-conquer the problem is to edit Allwmake and after the first line add:
Code:
set -x
Run Allwmake again as before and see where it croaks .

I've got a hunch you either have a contaminated environment, or something is amiss on the file system.

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   June 2, 2011, 10:51
Default
  #8
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16
ozzythewise is on a distinguished road
Okay this is weird.

Well first off when I tried what you wrote I got the following error:
Code:
bash: make.log: Permission denied
even though I used sudo. Secondly when I tried just executing Allwmake without outputting to a log file I got the following error:
Code:
+ cd .
+ [ /opt/openfoam171 !=  ]
+ echo Error: Current directory is not $WM_PROJECT_DIR
Error: Current directory is not $WM_PROJECT_DIR
+ echo     The environment variable are not consistent with the installation.
    The environment variable are not consistent with the installation.
+ echo     Check the OpenFOAM entries in your dot-files and source them.
    Check the OpenFOAM entries in your dot-files and source them.
+ exit 1
Which seems to be the same flavour of error message as before, and yet slightly different. What's your take?

Thanks,
Jeff
ozzythewise is offline   Reply With Quote

Old   June 2, 2011, 10:53
Default
  #9
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16
ozzythewise is on a distinguished road
Wait, reading the 2nd line of the longer error message I just put up, does that mean that $WM_PROJECT_DIR isn't being set at all (hence it's blank in that line?). The code for Allwmake reads:
Code:
if [ "$PWD" != "$WM_PROJECT_DIR" ]
then
    echo "Error: Current directory is not \$WM_PROJECT_DIR"
    echo "    The environment variable are not consistent with the installation."
    echo "    Check the OpenFOAM entries in your dot-files and source them."
    exit 1
fi
so it looks like $PWD is reading the correct directory, that is /opt/openfoam171 but $WM_PROJECT_DIR is empty. If so, how do I fix this?
ozzythewise is offline   Reply With Quote

Old   June 4, 2011, 08:07
Default
  #10
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
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
Hi Jeff,

Ah HA! You omitted crucial information You are trying to change your system installed OpenFOAM, which requires administrative powers, namely using "sudo" or "su -". This changes the ball game!

OK, the easiest thing for you to do is this, always as normal user:
  1. Run:
    Code:
    sudo -R o+w /opt/openfoam171
    This will give permissions to all users who aren't root to write on OpenFOAM's folder.
  2. Now do this, without sudo:
    Code:
    foam
    wmSP
    ./Allwmake > make.log 2>&1
  3. After the goose is cooked, check if all is working as intended. When you have confirmed this, run:
    Code:
    sudo -R o-w /opt/openfoam171
    This will restore the writing restriction to the folder and its contents.
--------------
Edit: I forgot about "chmod":
Point 1:
Code:
sudo chmod -R o+w /opt/openfoam171
Point 3:
Code:
sudo chmod -R o-w /opt/openfoam171
--------------

Since you're on Ubuntu (or so I guess):
Quote:
Originally Posted by wyldckat View Post
This is a command line that will install most of the necessary (and some possibly unnecessary) packages for building OpenFOAM and ParaView:
Code:
sudo apt-get install binutils-dev flex bison git-core   build-essential python-dev libreadline5-dev wget zlib1g-dev cmake   libpng12-dev libxt-dev libxi-dev libxrender-dev libxrandr-dev   libxcursor-dev libxinerama-dev libfreetype6-dev libfontconfig1-dev   libglib2.0-dev freeglut3-dev libqt4-dev qt4-dev-tools
Right now I'm not 100% on which packages are truly needed for you, so if I'm not mistaken:
Code:
sudo apt-get install binutils-dev flex bison build-essential zlib1g-dev libglib2.0-dev
Best regards,
Bruno
__________________

Last edited by wyldckat; June 4, 2011 at 13:53. Reason: forgot about "chmod"
wyldckat is offline   Reply With Quote

Old   June 4, 2011, 12:01
Default
  #11
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16
ozzythewise is on a distinguished road
It's just one thing after another, I wish I wasn't bad with linux so that I could try and figure out what I'm doing here. When I enter
Code:
sudo -R o+w /opt/openfoam171
I get the error:
Code:
usage: sudo -h | -K | -k | -L | -V
usage: sudo -v [-AknS] [-p prompt]
usage: sudo -l[l] [-AknS] [-g groupname|#gid] [-p prompt] [-U username] [-u
            username|#uid] [-g groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-C fd] [-g groupname|#gid] [-p prompt] [-u
            username|#uid] [-g groupname|#gid] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-C fd] [-g groupname|#gid] [-p prompt] [-u
            username|#uid] file ...
So, what does this mean. What is -R suppose to do?

Thanks
ozzythewise is offline   Reply With Quote

Old   June 4, 2011, 12:37
Default
  #12
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
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
Hi Jeff,

AAaarrrg... how could I do such a mistake... I forgot about writing down the chown command It's this command:
Code:
sudo chmod -R o+w /opt/openfoam171
The -R will apply the rule recursively, namely to all child files and folders.

I certainly hope that this way you will finally be able to gets things going!

Best regards,
Bruno
__________________

Last edited by wyldckat; June 4, 2011 at 13:50. Reason: It's "chmod", not "chown".
wyldckat is offline   Reply With Quote

Old   June 4, 2011, 12:59
Default
  #13
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16
ozzythewise is on a distinguished road
Hi,

When I tried your last code I got the following error:
Code:
chown: invalid user: `o+w'
. I have also tried entering
Code:
sudo chmod o+w /opt/openfoam171
and it SEEMED to do something but then when I enter
Code:
sudo apt-get install binutils-dev flex bison git-core   build-essential python-dev libreadline5-dev wget zlib1g-dev cmake   libpng12-dev libxt-dev libxi-dev libxrender-dev libxrandr-dev   libxcursor-dev libxinerama-dev libfreetype6-dev libfontconfig1-dev   libglib2.0-dev freeglut3-dev libqt4-dev qt4-dev-tools
and trying to run icoFoam -help it cannot find the command. More importantly though is that the entre in /opt/openfoam181/etc/bashrc still reads:
Code:
: ${WM_PRECISION_OPTION:=DP};
...Thoughts?

Thanks by the way for all your help
J
ozzythewise is offline   Reply With Quote

Old   June 4, 2011, 13:45
Default
  #14
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
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
Hi Jeff,

Sorry about that again, my brain is on "weekend mode", so I'm having trouble writing down the proper commands

chmod is the command I should have written down! I'll try and not forget to fix my previous posts for future readers.

The wmSP command will only change the variable in your current environment, it will not automatically change the /opt/openfoam171/etc/bashrc file! By using wmSP, you wouldn't be restricted to only using one version for each time you edit that file!
This way you simply have to type wmSP whenever you want to use the SP version, after the OpenFOAM environment has been initialized.
If you want to run OpenFOAM in parallel, then add the wmSP command to the line after the initialization of the environment on ~/.bashrc.

Returning to DP mode will also be as easy as running wmDP.

I hope that I haven't mistyped anything on this post...

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   June 4, 2011, 14:12
Default
  #15
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16
ozzythewise is on a distinguished road
Sorry, I'm confused. Do I need to manually edit the /opt/openfoam171/etc bashrc file to read:
Code:
: ${WM_PRECISION_OPTION:=SP};
and THEN execute the commands:
Code:
foam
wmSP
./Allwmake make.log 2>&1
What I tried doing was just those codes without editing the bashrc file, I figured the wmSP line would edit that file automatically. Sorry, I'm pretty new with linux
ozzythewise is offline   Reply With Quote

Old   June 4, 2011, 14:58
Default
  #16
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
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
That the brilliance of wmSP and wmDP: No editing required!

Simply run those 3 commands and you're good to go... or so I hope, since this should have been solved about 5 posts ago


OK, let me try and give a step by step work flow, for after you've managed to build OpenFOAM in SP mode. This is assuming that you haven't edited OpenFOAM's bashrc file.

Normal serial work flow (i.e., not for running in parallel):
  1. Start a new terminal window or tab (i.e. whenever you start a new terminal).
  2. Depending on the mode you want:
    1. If you want to run in DP mode, do nothing.
    2. If you want SP mode, run:
      Code:
      wmSP
  3. Run the desired OpenFOAM commands.
  4. If for any reason you want to switch back to the other precision, run the opposite command:
    1. If already in DP mode, switch by running wmSP.
    2. If in SP mode, run wmDP.
    3. If you're not sure in which mode you are on, run:
      Code:
      echo $WM_OPTIONS
If you have to run a case in parallel and haven't followed the next steps, then do them:
  1. Edit your home .bashrc file, namely "~/.bashrc".
  2. Search the line that has this line:
    Code:
    . /opt/openfoam171/etc/bashrc
  3. Check the line after. If there isn't anything familiar or suspicious, add wmSP after it, to look like this:
    Code:
    . /opt/openfoam171/etc/bashrc
    wmSP
  4. Save the file .bashrc file.
  5. If your environment you were going to launch the parallel run on is already in SP mode, then you can proceed. If not, run wmSP before launching.
This way, when mpirun spawns the new processes, it will first start up .bashrc.
To switch back to DP mode, simply comment the line you've added to .bashrc, to look like this:
Code:
. /opt/openfoam171/etc/bashrc
#wmSP
Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   June 4, 2011, 16:46
Default
  #17
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16
ozzythewise is on a distinguished road
YEAHHHH got it!

Code:
echo $WM_OPTIONS
linux64GccSPOpt
Woot thanks man!

I'm just going to write out here the steps for anyone that comes along this thread and wants the quick and easy way to change OF171 from double precision to single precision:


______________________________________
Code:
foam
wmSP
sudo chmod -R o+w /opt/openfoam171
./Allwmake make.log 2>&1
You can now execute echo $WM_OPTIONS and you should see "linux64GccSPOpt" (note the "SP" instead of "DP"). Just a warning that the command "./Allwmake make.log 2>&1" takes a long time to run (took over an hour for me.
ozzythewise is offline   Reply With Quote

Old   June 4, 2011, 18:36
Default
  #18
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
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
Hi Jeff,

Finally! Congrats!

And I forgot to mention that you could speed up the building process if you defined WM_NCOMPPROCS to the number of your machine's processors: http://www.openfoam.com/download/source.php#x5-27000

For example, before you run Allwmake, you could run:
Code:
export WM_NCOMPPROCS=4
This ways the build process would use up to 4 processes at the same time.

Oh well... on weekends I'm a bit more slow minded than usual...

And a word of warning: SP can be faster to run on most cases, but mesh generation can get a bit troublesome, at least when running snappyHexMesh. And solvers for particles or molecule chemistry, have a tendency to get annoyed at the lack of precision

Best regards and have fun!
Bruno
__________________
wyldckat 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
Single or double precision Jonas Larsson Main CFD Forum 16 June 20, 2017 06:53
Single v.s. double precision Confused CFX 15 November 10, 2016 04:42
Single Precision and Double Precision wateraction FLUENT 1 May 27, 2011 12:16
Switch from single precision to double precision kk81 OpenFOAM Bugs 0 March 11, 2010 06:14
what's wrong about my code for 2d burgers equation morxio Main CFD Forum 3 April 27, 2007 10:38


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