CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

openFoam run functions, runApplication, getApplication

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

Like Tree12Likes
  • 8 Post By wyldckat
  • 2 Post By wyldckat
  • 2 Post By wyldckat

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 22, 2015, 12:30
Default openFoam run functions, runApplication, getApplication
  #1
Member
 
Hassan
Join Date: Oct 2012
Location: Iran
Posts: 63
Rep Power: 13
luckycfd is on a distinguished road
Hello all,
I want to use my own solver 'interPhaseChangeFoam_0' in a case by its tutorial 'Allrun' script. The script is shown below:
Code:
 #!/bin/sh
 cd ${0%/*} || exit 1    # run from this directory
 # Source tutorial run functions
 . $WM_PROJECT_DIR/bin/tools/RunFunctions
 # copy bullet surface from resources folder
 cp $FOAM_TUTORIALS/resources/geometry/bullet.stl.gz constant/triSurface/
 # Generate the base block mesh
 runApplication blockMesh
 # Generate the snappy mesh
 runApplication snappyHexMesh -overwrite
 # Run the solver
 runApplication `getApplication`
For this reason, I edit the file system/controlDict of the case so the application is changed from interPhaseChangeFoam to interPhaseChangeFoam_0.
But after this, the script can,t access to my own solver then can not run. How can I configure this script or file system/controlDict to right accessing the new solver by keeping its original key words 'runApplication' and 'getApplication'?

Best regards,
Hassan
luckycfd is offline   Reply With Quote

Old   February 22, 2015, 13:00
Default
  #2
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 Hassan,

No, no, no... don't call your solver that!
For better or for worse, the shell function "getApplication" was not designed to allow names with numbers and characters in them. It was designed with the naming convention used by the solvers and utilities in OpenFOAM, namely to use normal names, like "simpleFoam" and "rhoPimpleFoam" (I know, not very normal, but spaces are prohibited in C/C++ names for variables).

This to say that you should name your solver something like "interPhaseChangeFoamZero".

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   February 22, 2015, 13:42
Default
  #3
Member
 
Hassan
Join Date: Oct 2012
Location: Iran
Posts: 63
Rep Power: 13
luckycfd is on a distinguished road
Hi
Thanks Bruno for your clear answer. Now, how can I discover openfoam conventions like this?
luckycfd is offline   Reply With Quote

Old   February 22, 2015, 14:22
Default
  #4
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
Quote:
Originally Posted by luckycfd View Post
Now, how can I discover openfoam conventions like this?
A bit by trial an error, as well as getting a feeling by how the OpenFOAM source code is... uhm... coded.

Then there's this page: http://www.openfoam.org/contrib/code-style.php
You can get there through this link path:
------

edit: The updated links are:
vortex_shedding and qutadah.r like this.

Last edited by wyldckat; April 16, 2018 at 19:34. Reason: see "edit:"
wyldckat is offline   Reply With Quote

Old   October 19, 2015, 02:46
Default
  #5
Member
 
Join Date: Jul 2014
Posts: 39
Rep Power: 11
PicklER is on a distinguished road
Hi Bruno

Thank you for your answer. Is there a way to obtain the 0 (zero) that the solver returns when it is done executing? For example (in the shell script):

Code:
#!/bin/sh
cd ${0%/*} || exit 1    # run from this directory

# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions

application=`getApplication`

runApplication blockMesh
runApplication setFields
result = runApplication $application
echo $result

# ----------------------------------------------------------------- end-of-file
This does not work (novice at shell scripting). I want the variable result to be equal to 0 (for a default solver). The reason for this is that I want to run the solver multiple times with a for loop in the shell script and the condition to end the loop will be the value (int) returned by the solver.

Kind regards
PicklER is offline   Reply With Quote

Old   October 22, 2015, 17:29
Default
  #6
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
Quick answer: Google:
Code:
bash script get error code
2nd hit: http://tldp.org/LDP/abs/html/exit-status.html

Try this:
Code:
runApplication $application
result=$?
echo $result
vsammartano and betterglobe like this.
wyldckat is offline   Reply With Quote

Old   October 22, 2015, 17:49
Talking
  #7
Member
 
Join Date: Jul 2014
Posts: 39
Rep Power: 11
PicklER is on a distinguished road
Hi Bruno

Thank you for your amswer. I found that solution this morning. Did not xpect it to be that simple. Will defintely improve my Google before I post a question.
PicklER 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
Frequently Asked Questions about Installing OpenFOAM wyldckat OpenFOAM Installation 3 November 14, 2023 12:58
How to run OpenFoam using openMP. bravikanth OpenFOAM Running, Solving & CFD 12 June 20, 2016 11:11
Suggestion for a new sub-forum at OpenFOAM's Forum wyldckat Site Help, Feedback & Discussions 20 October 28, 2014 10:04
Unable to run a case with OpenFOAM 1.6-ext that works with OpenFOAM 2.3.0 Jiricbeng OpenFOAM Running, Solving & CFD 15 May 21, 2014 04:52
New OpenFOAM Forum Structure jola OpenFOAM 2 October 19, 2011 07:55


All times are GMT -4. The time now is 00:56.