|
[Sponsors] |
April 30, 2019, 20:36 |
|
#21 |
Senior Member
Brett
Join Date: May 2013
Posts: 217
Rep Power: 14 |
yep. The script is called "batch.sh" still. this is the command line:
AUBD501827@L19AU-32823 /cygdrive/c/OpenFOAM/18.10/AUBD501827-dev/run $ chmod +x batch.sh AUBD501827@L19AU-32823 /cygdrive/c/OpenFOAM/18.10/AUBD501827-dev/run $ ./batch.sh ./batch.sh: line 4: syntax error near unexpected token `$'\r'' '/batch.sh: line 4: ` AUBD501827@L19AU-32823 /cygdrive/c/OpenFOAM/18.10/AUBD501827-dev/run $ line 4 of the script is just blank. |
|
April 30, 2019, 20:43 |
|
#22 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 15 |
Short of suggesting that that you do exactly what I suggested, I am not sure what more to add. It works fine for me. Someone else may have a better idea of what is causing the output you see. A final thought -- did you include the
Code:
#!/bin/bash Caelan |
|
April 30, 2019, 20:51 |
|
#23 |
Senior Member
Brett
Join Date: May 2013
Posts: 217
Rep Power: 14 |
Yep I've got that in.
It seems to just "stall" at the line "do". almost as if it's looking for something extra? |
|
April 30, 2019, 20:57 |
|
#24 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 15 |
Thought about the error and the path does not look familiar. How did you install openfoam?
Caelan |
|
April 30, 2019, 21:07 |
|
#25 |
Senior Member
Brett
Join Date: May 2013
Posts: 217
Rep Power: 14 |
just installed it on my machine? wasnt aware there were different ways to install it??
|
|
April 30, 2019, 21:10 |
|
#26 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 15 |
Right. What type of machine is it?
Caelan |
|
April 30, 2019, 21:14 |
|
#27 |
Senior Member
Brett
Join Date: May 2013
Posts: 217
Rep Power: 14 |
desktop PC. Running windows.
|
|
April 30, 2019, 21:20 |
|
#28 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 15 |
Well there you have it -- the script is for linux. You will need help from someone familiar with using OF for windows. Or, I bet that you could do some debugging yourself and google for windows-specific answers.
Caelan |
|
April 30, 2019, 21:43 |
|
#29 |
Senior Member
Brett
Join Date: May 2013
Posts: 217
Rep Power: 14 |
ok. I've done some digging and I can't even seem to get a basic script running. I thought I'd made the changes for windows, for example....
#!/bin/sh cd ${0%/*} || exit 1 # Run from this directory for value in {10..0..2} do echo $value done echo All done wont even run. |
|
April 30, 2019, 21:55 |
Trying to run a bash (or is it batch?) script in openfoam installed on a windows PC
|
#30 |
Senior Member
Brett
Join Date: May 2013
Posts: 217
Rep Power: 14 |
Hi foamers.
I'm trying to run a bash (or is it batch?) script in openfoam installed on a windows PC. Basically it's running different mass flow rates. I had some great help from someone but he assumed I was using linux. So the question is how do I modify it to run on windows? Code:
#!/bin/bash for value in {10..5..20} do #print case $value echo "Starting simulation $value" #copy a base case to the current case $value cp -rf att_test att_test_$value #set line number for sed to use lineNo1=32 #replace lineNo1 (line 49) in 0/U with value uniform (0 $value 0) sed -i "${lineNo1}s/.*/volumetricFlowRate $value;/" att_test_$value/0/U #enter current case directory cd att_test_$value #run solver of choice (e.g. buoyantPimpleFoam) simpleFoam > log.simpleFOAM 2>&1 & #find line starting with "Patch Pressure :" in solver log file and save value of 4th set of characters (pretty sure) press=`grep -r "Patch Pressure : " log.simpleFoam | awk '{print $4}'` #pipe saved value to data log file echo press >> log.dat cd .. done echo All done Last edited by wyldckat; May 5, 2019 at 15:52. Reason: Added [CODE][/CODE] markers |
|
May 5, 2019, 15:53 |
|
#31 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Quick questions:
__________________
|
|
May 5, 2019, 20:16 |
|
#32 |
Senior Member
Brett
Join Date: May 2013
Posts: 217
Rep Power: 14 |
OpenFoam for windows 18.1
No idea what instructions? |
|
May 6, 2019, 20:07 |
|
#33 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Quick note: I moved the last 3 posts from a separate thread to this common thread.
Quick answers: Quote:
That said, within the Windows Operating System context, a "batch file" usually refers to a file with the file extension ".bat", which uses a different scripting language from what Bash and Shell scripting usually mean on Linux/POSIX systems. Uh... looking for it online did not give any valid results, mostly because "18.1" is an unknown version. I was referring to the instructions you had followed to install OpenFOAM in your machine... OK, so after looking for your previous posts, I finally managed to make heads and tails out of this... Technically, you can run that script that you provided on your Cygwin installation, but you have to correct the line ending of the file. There is massive Wikipedia article on this topic, where you might notice the "\r" being listed here: https://en.wikipedia.org/wiki/Newline#Escape_sequences So, what you need to do to fix the problem with running the bash/shell scripts on Cygwin is to correct the line ending, which you can do by either:
|
||
May 8, 2019, 02:07 |
|
#34 |
Senior Member
Brett
Join Date: May 2013
Posts: 217
Rep Power: 14 |
Wow this is all so far over my head.
What does the /r do? I'm writing this in sublime text, saving it and then trying to run it on the OpenFoam command window with "test_script.sh" I can't even get that to work! #!/bin/bash for /l %%a in (1;1;3) do ( echo "Starting simulation $%%x" ) |
|
May 11, 2019, 09:51 |
|
#35 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
But that script is now in the Windows Batch script format, not in the Bash shell script format...
And if it's in the Windows Batch script format, you no longer need to worry about the line ending and can use the default text editing options on Windows. Oh, and you do not need the first line: Code:
#!/bin/bash |
|
September 21, 2020, 04:27 |
|
#36 | |
Senior Member
Franco
Join Date: Nov 2019
Location: Compiègne, France
Posts: 129
Rep Power: 7 |
Quote:
i am windows user too. can i asume that you are using WSL no? with a ubuntu subsystem? if that the case what you are trying to do it is easy to accomplish. first you have your casefile folder with constant, system... etc. you rename the folder baseCase. normally i would say to create an allRun file (inside the baseCase folder) for this you create a text file without extension and edit it in a text editor (recomend notePad ++) inside you copy depending on the vr of your OF (you can look in a tutorial E.G.tutorials\incompressible\pimpleFoam\RAS\elipse kkLOmega the first two lines of the allRun file. after the two lines you add the commands of the bash that you are going to use like blockMesh sanppyHex etc etc... after in the WLS you go to the folder baseCase and then from there you do “chmod 755 ./AllRun” this will make it able to be excecuted. so to recapitulate until here you have created your base case, and you can run it from your WSL command line by going inside of the baseCase folder and doing ./AllRun the modification of the U file. you go up a folder and create a file "run.sh" file by creating a text file. then you can base yourself in the example that they gave you in the third commend or you can use the run.sh file from the benchmark from here https://openfoamwiki.net/index.php/Benchmarks and modify it to change the velocity in the 0/U file (it is with the sed command) after this in the WLS you go to that folder (if you are inside baseCase folder "cd ..") and then another time “chmod 755 ./run.sh” and then you have converted run.sh in executable that it copies the baseCase folder, renames it changes the U vector file inside the new copied folder and then run the AllRun script running your case. and then creating a new copie puting the second U vector and doing the same. this should work correctly. I recommend to be attentive of the space of your disk as each time it would create a copy, so for example if you are running an steady state simulation write only the endTime. for function object I recommend you to create another topic as it is better to be easy to read that the topic stays in on subject (at least one at a time...) speaking about the subject of using the sed function, if i may, @clapointe have you already used arrays in bash for this type of template? (and calling an element of the array in the sed function). I was looking in to it as i wanted to do the same modification but with different list of values, like doing a for loop with 0 1 2 values and then call each element array inside the loop. I have not tried and want it to have any feed back about this and see if it is possible.... (as i can not try it myself right now....) best regards, franco |
||
Tags |
batch job, programming |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using Batch file in combination with the workbench | D0nT0m | CFX | 3 | February 6, 2017 06:28 |
Fluent batch command for unsteady | taekyu8 | FLUENT | 0 | January 7, 2013 16:18 |
Regarding about Fluent batch scripts | solefire | FLUENT | 3 | July 5, 2009 10:39 |
regarding about Fluent batch scripts | solefire | FLUENT | 3 | July 5, 2009 05:05 |
Running Job in Batch mode (EFD) | Nick Sessions | FloEFD, FloWorks & FloTHERM | 0 | April 16, 2008 17:44 |