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

Running subfolder applications in Allrun

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 8, 2021, 15:29
Default
  #1
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 670
Rep Power: 14
Tobermory will become famous soon enough
Maybe I am being stupid (I am tired), but I am struggling to see what your code is doing. First up, take this line:

Code:
if surfaceConvert rotor.stl rotor_scaled.stl -clean -scale 0.01 > /dev/null 2>&1 > log.surfaceConvert
you start by running the utility surfaceConvert, and then redirect the output into /dev/null, ie throw it away. Fine. You then redirect stderr to stdout, with 2>&1, which throws away any error messages as well. Okay. Then you are redirecting stdout again to the log file ... I don't think that you mean to redirect stdout twice - perhaps the following part
Code:
> /dev/null
can be deleted?

Also, as discussed, if you want to see the log file data from each time surfaceConvert is run, you want to change the line into something like the following:
Code:
if surfaceConvert rotor.stl rotor_scaled.stl -clean -scale 0.01 >> log.surfaceConvert  2>&1
The other bit that is puzzling me is the purpose of the if commands. As written, the argument of the if command in first bit of code above is true if surfaceConvert outputs any text, and false if no text is output. For example, the code:

Code:
if ls; then echo "true"; else echo "false"; fi
echoes "true". Is that what you want? Why do you need the if's?
Tobermory is offline   Reply With Quote

Old   March 9, 2021, 13:46
Default
  #2
New Member
 
Santi Parera
Join Date: Jul 2019
Location: BARCELONA
Posts: 25
Rep Power: 6
Kalabagh is on a distinguished road
Quote:
Originally Posted by Tobermory View Post
Maybe I am being stupid (I am tired), but I am struggling to see what your code is doing. First up, take this line:

Code:
if surfaceConvert rotor.stl rotor_scaled.stl -clean -scale 0.01 > /dev/null 2>&1 > log.surfaceConvert
you start by running the utility surfaceConvert, and then redirect the output into /dev/null, ie throw it away. Fine. You then redirect stderr to stdout, with 2>&1, which throws away any error messages as well. Okay. Then you are redirecting stdout again to the log file ... I don't think that you mean to redirect stdout twice - perhaps the following part
Code:
> /dev/null
can be deleted?

Also, as discussed, if you want to see the log file data from each time surfaceConvert is run, you want to change the line into something like the following:
Code:
if surfaceConvert rotor.stl rotor_scaled.stl -clean -scale 0.01 >> log.surfaceConvert  2>&1
The other bit that is puzzling me is the purpose of the if commands. As written, the argument of the if command in first bit of code above is true if surfaceConvert outputs any text, and false if no text is output. For example, the code:

Code:
if ls; then echo "true"; else echo "false"; fi
echoes "true". Is that what you want? Why do you need the if's?

Thank you so much, now it works well.


One thing I do not understand is that if I navigate to the installation directory of OpenFOAM I can see that "surfaceConvert", "blockMesh" and "rotateMesh" are applications. Now why I have to execute blockMesh with "runApplication" and not with surfaceConvert??


This is the code I have now:
Code:
#!/bin/sh
cd ${0%/*} || exit 1    # Run from this directory

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

# - scaling

cd constant/triSurface/
surfaceConvert ROTOR.stl ROTOR_SCALED.stl -clean -scale 0.01 >> log.surfaceConvert 2>&1
surfaceConvert TURBINA.stl TURBINA_SCALED.stl -clean -scale 0.01 >> log.surfaceConvert 2>&1
surfaceConvert REACTOR.stl REACTOR_SCALED.stl -clean -scale 0.01 >> log.surfaceConvert 2>&1

# - meshing

cd ../..
cd system/
m4 blockMeshDict.m4 > blockMeshDict
cd ..
runApplication blockMesh >> log.blockMesh 2>&1
runApplication rotateMesh  '(0 0 1)' '(0 1 0)' >> log.rotateMesh 2>&1
What happens is that everything goes well till blockMesh. The mesh is not done as the log informs that "blockMesh already run on ...directory, remove log file to re-run".


This also happens with "rotateMesh"
Kalabagh is offline   Reply With Quote

Old   March 9, 2021, 15:18
Default
  #3
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 670
Rep Power: 14
Tobermory will become famous soon enough
Quote:
Thank you so much, now it works well.
Excellent!

Quote:
One thing I do not understand is that if I navigate to the installation directory of OpenFOAM I can see that "surfaceConvert", "blockMesh" and "rotateMesh" are applications. Now why I have to execute blockMesh with "runApplication" and not with surfaceConvert??
You can certainly ignore runApplication, and just run directly as per your script. I tend to use runApplication because it automatically generates me a log file for that application, and I find it is quite compact coding and easy to read ... no other advantage though. You can find the coding for runApplication in $WM_PROJECT_DIR/bin/tools/RunFunctions, if you want to see the detail.

Quote:
This is the code I have now:
Looks good. As a fine-tuning tweak, you could change
Code:
surfaceConvert ROTOR.stl ROTOR_SCALED.stl -clean -scale 0.01 >> log.surfaceConvert 2>&1
to
Code:
surfaceConvert ROTOR.stl ROTOR_SCALED.stl -clean -scale 0.01 > log.surfaceConvert 2>&1
so that the first time you run surfaceConvert you overwrite the previous version of the logfile, but for the 2nd and 3rd times you will append.

Quote:
What happens is that everything goes well till blockMesh. The mesh is not done as the log informs that "blockMesh already run on ...directory, remove log file to re-run". This also happens with "rotateMesh"
Try add a -overwrite flag to the runApplication or delete the log.blockMesh file - it is complaining that you have already got a set of results from the application (eg blockMesh) there already, so you need to tell it that you want to overwrite it ... it's a safety feature I guess. Also, runApplication already dumps the output into a logfile that is called log.{applicationName}, so you can just write:
Code:
runApplication -overwrite blockMesh
and same for rotateMesh.

Good luck my friend!
Tobermory is offline   Reply With Quote

Reply

Tags
allrun, directory, surfaceconvert


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
Hypersonic Sim (running at Mach 7): floating point exception has occurred bungusbeefcake STAR-CCM+ 10 March 31, 2015 06:59
CFX11 + Fortran compiler ? Mohan CFX 20 March 30, 2011 18:56
Suse10 FoamX problem frank178 OpenFOAM Installation 6 January 14, 2010 04:18
Statically Compiling OpenFOAM Issues herzfeldd OpenFOAM Installation 21 January 6, 2009 09:38
Kubuntu uses dash breaks All scripts in tutorials platopus OpenFOAM Bugs 8 April 15, 2008 07:52


All times are GMT -4. The time now is 19:27.