|
[Sponsors] |
May 31, 2011, 18:47 |
changing OF171 to single precision
|
#1 |
Senior Member
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16 |
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 |
|
May 31, 2011, 20:17 |
|
#2 |
Senior Member
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16 |
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 Code:
# WM_PRECISION_OPTION = DP | SP : ${WM_PRECISION_OPTION:=SP}; export WM_PRECISION_OPTION Code:
sudo ./Allwmake 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. Thanks Jeff |
|
June 1, 2011, 02:11 |
|
#3 |
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29 |
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 |
|
June 1, 2011, 09:24 |
|
#4 |
Senior Member
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16 |
Yeah that is exactly what happened. So then how would I go about changing to single precision?
J |
|
June 1, 2011, 09:44 |
|
#5 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
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 Code:
tail -F make.log
Best regards, Bruno
__________________
|
|
June 1, 2011, 10:24 |
|
#6 |
Senior Member
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16 |
Hi Bruno,
When I run the command Code:
./Allwmake > make.log 2>&1 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. Thanks Jeff |
|
June 1, 2011, 11:42 |
|
#7 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
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 I've got a hunch you either have a contaminated environment, or something is amiss on the file system. Best regards, Bruno
__________________
|
|
June 2, 2011, 10:51 |
|
#8 |
Senior Member
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16 |
Okay this is weird.
Well first off when I tried what you wrote I got the following error: Code:
bash: make.log: Permission denied 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 Thanks, Jeff |
|
June 2, 2011, 10:53 |
|
#9 |
Senior Member
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16 |
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 |
|
June 4, 2011, 08:07 |
|
#10 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
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:
Edit: I forgot about "chmod": Point 1: Code:
sudo chmod -R o+w /opt/openfoam171 Code:
sudo chmod -R o-w /opt/openfoam171 Since you're on Ubuntu (or so I guess): Quote:
Code:
sudo apt-get install binutils-dev flex bison build-essential zlib1g-dev libglib2.0-dev Bruno
__________________
Last edited by wyldckat; June 4, 2011 at 13:53. Reason: forgot about "chmod" |
||
June 4, 2011, 12:01 |
|
#11 |
Senior Member
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16 |
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 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 ... Thanks |
|
June 4, 2011, 12:37 |
|
#12 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
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 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". |
|
June 4, 2011, 12:59 |
|
#13 |
Senior Member
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16 |
Hi,
When I tried your last code I got the following error: Code:
chown: invalid user: `o+w' Code:
sudo chmod o+w /opt/openfoam171 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 Code:
: ${WM_PRECISION_OPTION:=DP}; Thanks by the way for all your help J |
|
June 4, 2011, 13:45 |
|
#14 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
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
__________________
|
|
June 4, 2011, 14:12 |
|
#15 |
Senior Member
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16 |
Sorry, I'm confused. Do I need to manually edit the /opt/openfoam171/etc bashrc file to read:
Code:
: ${WM_PRECISION_OPTION:=SP}; Code:
foam wmSP ./Allwmake make.log 2>&1 |
|
June 4, 2011, 14:58 |
|
#16 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
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):
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 Bruno
__________________
|
|
June 4, 2011, 16:46 |
|
#17 |
Senior Member
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16 |
YEAHHHH got it!
Code:
echo $WM_OPTIONS linux64GccSPOpt 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 |
|
June 4, 2011, 18:36 |
|
#18 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
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 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
__________________
|
|
|
|
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 |