|
[Sponsors] |
May 6, 2011, 06:17 |
systemCall for defined time steps
|
#1 |
New Member
Peter Canfield
Join Date: Mar 2009
Posts: 16
Rep Power: 17 |
I have been looking for a way to modify the alpha field during a simulation and stumbled across systemCall. It allows you to execute functions at the end of an iteration step, at a write interval and/or at the end of the simulation. I would like to be able to specify explicitly at which time steps the desired functions should be executed. Maybe someone has had some experience with systemCall and help me out?
Thanks in advance n.b. I am using OF 1.7.x Last edited by canfield; May 6, 2011 at 08:23. |
|
May 6, 2011, 15:13 |
|
#2 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings Peter,
Does this page help: Tip Function Object systemCall @ openfoamwiki.net ? Best regards, Bruno
__________________
|
|
May 6, 2011, 17:26 |
|
#3 |
New Member
Peter Canfield
Join Date: Mar 2009
Posts: 16
Rep Power: 17 |
Thanks for the link, Bruno. Unfortunately, I had already scoured that page for additional information and haven't got any further. It basically says what i posted initially; a function can be called either before an iteration, before a write interval, or just before the end of the simulation. I would like to be able to use systemCall between write intervals, but not as often as every iteration.
Other hints would be very welcome! Peter |
|
May 7, 2011, 04:39 |
|
#4 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi Peter,
OK, now read again the chapter: Usage Description Back when I first wrote that page, I didn't fully test all of it's options... Either way, the new information sums up to using these options together: Code:
outputControl timeStep; outputInterval 2; Quote:
I've also fixed the other sibling page "Tip Function Object writeRegisteredObject", in which I had wrongly categorized outputInterval but now it's fixed. Best regards, Bruno
__________________
Last edited by wyldckat; May 7, 2011 at 04:43. Reason: see "edit:" |
||
May 7, 2011, 04:54 |
|
#5 |
New Member
Peter Canfield
Join Date: Mar 2009
Posts: 16
Rep Power: 17 |
Bruno, you are amazing! This is indeed very good news. Thank you for opening my eyes to that option.
All the best |
|
June 9, 2011, 10:47 |
Function "executeCalls"
|
#6 |
Member
Matthias Hettel
Join Date: Apr 2011
Location: Karlsruhe, Germany
Posts: 31
Rep Power: 15 |
Hello Bruno,
thanks for the helpful informations about the system calls. This tool is very helpful for me, because I want to call a fortran Program externally. I tried the approach given in the wiki page to test the availability: functions { sysCall { type systemCall; functionObjectLibs ( "libsystemCall.so" ); executeCalls 1("echo Execute system call before time iteration is done"); endCalls 1("echo Finishing up with a system call, which is seems to be before the write call..."); writeCalls 2("echo Writing to file call" "ls -l"); outputControl outputTime; } } It works ... but the command "executeCalls 1" shows NO echo line on the terminal ! The other comand lines work properly. Maybe this has something to do with my version ? I use version 1.7.1. Thanks in advance Matthi |
|
June 9, 2011, 17:15 |
|
#7 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi Matthias and welcome to the forum!
Well, you could have said which solver you were using But I suspect the issue you're seeing is quite simple and I'm going to quote with bold letters on the two critical words: Quote:
Best regards, Bruno
__________________
|
||
June 10, 2011, 04:15 |
|
#8 |
Member
Matthias Hettel
Join Date: Apr 2011
Location: Karlsruhe, Germany
Posts: 31
Rep Power: 15 |
Hello Bruno,
thanks a lot for the fast answer. You`re completely right. I should read all items more carefully. I tried it with the solver rhoSimpleFoam (steady state) and therefore it didn`t work. I thought about my approach again and I will try to call the external Fortran program and several system calls (copy of files and so on) directly inside the solver. This gives me more freedom to position and handle the calls. But nevertheless the option of using your functions in controldict is a very valuable tool. Thank you again Greetings Matthias |
|
June 10, 2011, 13:58 |
|
#9 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi Matthias,
Quote:
But indeed, an option for any iterations, not just time iterations, would be a nice feature. I wonder if I that option already exists and I didn't see it... Best regards, Bruno
__________________
|
||
June 10, 2011, 14:53 |
|
#10 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hello again Matthias,
Hold on, something is amiss... I just ran the tutorial tutorials/compressible/rhoPorousSimpleFoam/angledDuctImplicit with the example from the wiki page and it showed me this: Code:
Starting time loop Time = 1 DILUPBiCG: Solving for h, Initial residual = 0.567508, Final residual = 0.021675, No Iterations 2 GAMG: Solving for p, Initial residual = 1, Final residual = 0.04149, No Iterations 6 time step continuity errors : sum local = 5.65325, global = -0.302944, cumulative = -0.302944 rho max/min : 1.22254 1.1863 smoothSolver: Solving for epsilon, Initial residual = 0.178745, Final residual = 0.00240625, No Iterations 2 smoothSolver: Solving for k, Initial residual = 1, Final residual = 0.0389567, No Iterations 2 ExecutionTime = 0.27 s ClockTime = 1 s Execute system call before time iteration is done Time = 2 DILUPBiCG: Solving for h, Initial residual = 1, Final residual = 0.0359937, No Iterations 2 GAMG: Solving for p, Initial residual = 0.409515, Final residual = 0.019402, No Iterations 4 time step continuity errors : sum local = 11.5033, global = -1.95711, cumulative = -2.26005 rho max/min : 1.58949 1.1863 smoothSolver: Solving for epsilon, Initial residual = 0.0863096, Final residual = 0.00417895, No Iterations 4 smoothSolver: Solving for k, Initial residual = 0.291302, Final residual = 0.0239134, No Iterations 4 ExecutionTime = 0.44 s ClockTime = 1 s Execute system call before time iteration is done Time = 3 DILUPBiCG: Solving for h, Initial residual = 0.927538, Final residual = 0.041592, No Iterations 2 (...) That solver should be very similar to rhoSimpleFoam, so it should work as intended! And I also just tested tutorials/stressAnalysis/solidDisplacementFoam/plateHole, which seems to be a strict iteration only solver and it showed this: Code:
Calculating displacement field Iteration: 1 GAMG: Solving for Dx, Initial residual = 1, Final residual = 0.47337, No Iterations 2 GAMG: Solving for Dy, Initial residual = 0, Final residual = 0, No Iterations 0 ExecutionTime = 0.02 s ClockTime = 0 s Execute system call before time iteration is done Iteration: 2 GAMG: Solving for Dx, Initial residual = 0.0217996, Final residual = 0.00712496, No Iterations 1 GAMG: Solving for Dy, Initial residual = 1, Final residual = 0.443501, No Iterations 1 ExecutionTime = 0.03 s ClockTime = 0 s Execute system call before time iteration is done Iteration: 3 Sooo... something is not right! I think it should have worked as intended for you as well! Best regards, Bruno
__________________
|
|
June 15, 2011, 10:37 |
|
#11 |
Member
Matthias Hettel
Join Date: Apr 2011
Location: Karlsruhe, Germany
Posts: 31
Rep Power: 15 |
Hi Bruno,
sorry for my late answer. I was out of office. Thanks or your effort. I tried it again with rhoSimpleFoam and maybe I solved the secret. Here my entry in controldict: functions { sysCall { type systemCall; functionObjectLibs ( "libsystemCall.so" ); executeCalls 1("echo Execute system call before time iteration is done"); endCalls 1("echo Finishing up with a system call, which is seems to be before the write call..."); outputControl outputTime; } } Here the output for only ONE iteration (this is what I did last week): Starting time loop Time = 3611 smoothSolver: Solving for Ux, Initial residual = 0.0171106, Final residual = 0.000317189, No Iterations 2 smoothSolver: Solving for Uy, Initial residual = 0.074749, Final residual = 0.00156304, No Iterations 2 smoothSolver: Solving for Uz, Initial residual = 0.02481, Final residual = 0.00060317, No Iterations 2 DILUPBiCG: Solving for h, Initial residual = 0.0148062, Final residual = 0.00114063, No Iterations 4 GAMG: Solving for p, Initial residual = 0.81745, Final residual = 0.0212307, No Iterations 2 time step continuity errors : sum local = 1.91384, global = -0.00727263, cumulative = -0.00727263 rho max/min : 1.15865 1.15098 ExecutionTime = 9.37 s ClockTime = 12 s Finishing up with a system call, which is seems to be before the write call... End THE SENTENCE IS NOT HERE ! Here the output for TWO iterations: Starting time loop Time = 3612 smoothSolver: Solving for Ux, Initial residual = 0.0143379, Final residual = 0.000299003, No Iterations 2 smoothSolver: Solving for Uy, Initial residual = 0.0575645, Final residual = 0.00140563, No Iterations 2 smoothSolver: Solving for Uz, Initial residual = 0.0187994, Final residual = 0.000524105, No Iterations 2 DILUPBiCG: Solving for h, Initial residual = 0.0147228, Final residual = 0.000794698, No Iterations 4 GAMG: Solving for p, Initial residual = 0.85305, Final residual = 0.0210801, No Iterations 2 time step continuity errors : sum local = 2.05708, global = -0.00686541, cumulative = -0.00686541 rho max/min : 1.15865 1.15098 ExecutionTime = 10.07 s ClockTime = 12 s Execute system call before time iteration is done Time = 3613 smoothSolver: Solving for Ux, Initial residual = 0.0115322, Final residual = 0.000258155, No Iterations 2 smoothSolver: Solving for Uy, Initial residual = 0.0431911, Final residual = 0.0011706, No Iterations 2 smoothSolver: Solving for Uz, Initial residual = 0.0140338, Final residual = 0.000416262, No Iterations 2 DILUPBiCG: Solving for h, Initial residual = 0.0110091, Final residual = 0.000334477, No Iterations 4 GAMG: Solving for p, Initial residual = 0.840982, Final residual = 0.0209793, No Iterations 2 time step continuity errors : sum local = 2.13375, global = -0.00501545, cumulative = -0.0118809 rho max/min : 1.15865 1.15098 ExecutionTime = 15.11 s ClockTime = 19 s Finishing up with a system call, which is seems to be before the write call... End Here you can find the message just right befor the second time information is written. A little bit strange, but it seems, that it works not right for only on iteration. I will not investigate it furthermore, because I search for another way. If it works, I will post it here. Many Greetings Matthias |
|
June 15, 2011, 16:57 |
|
#12 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi Matthias,
Ah, now I understand the logic behind this function object:
Edit: OK, I'm a bit slow today... You needed it to run after writing the fields. Mmm, then you need writeCalls, not either one of the other two! Best regards, Bruno
__________________
Last edited by wyldckat; June 15, 2011 at 17:01. Reason: see "Edit:" |
|
November 23, 2012, 13:53 |
|
#13 |
Senior Member
Canakkale Dardanelspor
Join Date: Aug 2012
Posts: 135
Rep Power: 14 |
Hi,
I also try to use systemCall to couple an external executable file with OpenFOAM ( a small C++ code which also reads and writes some text files inside the case file). However, I receive this error: Code:
sh: 1: ./cwind: Permission denied Code:
allowSystemOperations : Allowing user-supplied system call operations My systemCall function in the controlDict is as follows: Code:
functions { sysCall { type systemCall; functionObjectLibs ( "libsystemCall.so" ); executeCalls 1( "./cwind" ); endCalls 0(); writeCalls 0(); outputControl timeStep; outputInterval 1; } } During that time, if I could find an answer I will post its explanation. Many thanks in advance and millions espresso. |
|
November 23, 2012, 14:07 |
|
#14 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
- cwind is not executable - the current working directory is different than what you're expecting and the shell doesn't even find the util
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
November 23, 2012, 14:39 |
|
#15 |
Senior Member
Canakkale Dardanelspor
Join Date: Aug 2012
Posts: 135
Rep Power: 14 |
Hi,
Thanks for your answer. I think you are right. I also consider what you said beforehand and tried to solve it. Even though I am not an expert on Linux, it is obvious that the problem stems from the OS itself. I have made the changes in the following: 1. I edited "sudoers" file in order to eliminate the OS functionality which asks password for any execution of any C++ executable script. a. First, select editor by inputting the following command in the terminal: Code:
sudo select-editor c. Third, launch editor by inputting the following command in the terminal Code:
sudo visudo Code:
%admin ALL = NOPASSWD: ALL 2. In the case folder, please also pay attention to the "folder access". Some does not let the user to create or delete files inside a folder. So, make sure that everything is appropriate in the folder "Permissions" properties. I expected everything would be fine; but, I observed that I have had issues and systemCall didn't work properly. 3. Then I realized that there is no gap between the execution of the external program and OpenFOAM solver - the relevant time iteration. Hence, I have modified the systemCall accordingly by adding 1 second between the start of execution of the external program and OpenFOAM time step: Code:
functions { sysCall { type systemCall; functionObjectLibs ( "libsystemCall.so" ); executeCalls 1( "./cwind" ); endCalls 0(); writeCalls 1("sleep 1"); outputControl timeStep; outputInterval 1; } } And thanks a lot to Bruno, without the Wiki page which is his product and Bernhard for the "sleep 1" tip in the forum somewhere, I would not end up with the coupling. Millions Turkish coffee. |
|
November 23, 2012, 16:43 |
|
#16 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
November 23, 2012, 18:40 |
|
#17 |
Senior Member
Canakkale Dardanelspor
Join Date: Aug 2012
Posts: 135
Rep Power: 14 |
The problem seems to be solved now. I also checked from the shell whether the external program works or not and it worked well. Now, considering your message, I will reconsider the reason behind why it did not work properly.
|
|
November 27, 2012, 10:43 |
|
#18 |
Member
Matthias Hettel
Join Date: Apr 2011
Location: Karlsruhe, Germany
Posts: 31
Rep Power: 15 |
Hi,
I also don`t understand the problem fully. But anyway, there is another possibility to launch an external program or to use system calls. This might be easier than defining an own function. If you want to call a programm named "test" in a routine you can use: system(./test); If the program is NOT in the case folder, then you have to change the directory. E.G. the program is in the subfolder "system". The you could use the command: system("cd system; ./test; cd .."); Hope this helps. Greetings Matthi |
|
July 31, 2017, 10:51 |
|
#19 |
New Member
dario
Join Date: Dec 2016
Posts: 24
Rep Power: 10 |
Hi all,
is there a way to add systemCall to an application (a solver for example)? |
|
July 31, 2017, 12:03 |
|
#20 |
Member
Matthias Hettel
Join Date: Apr 2011
Location: Karlsruhe, Germany
Posts: 31
Rep Power: 15 |
Hi dario,
have you read the last post from me just upon your question? The answer should be found there. Greetings Matthias |
|
Tags |
systemcall |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
calculation diverge after continue to run | zhajingjing | OpenFOAM | 0 | April 28, 2010 05:35 |
Time Steps gets smaller and smaller | titio | OpenFOAM Running, Solving & CFD | 1 | July 22, 2009 09:19 |
Time steps - Large Eddy - LES | Gernot | FLUENT | 0 | September 14, 2005 12:54 |
Number of time steps in fluent 4-NT | Newbie | FLUENT | 0 | March 24, 2001 14:44 |
unsteady calcs in FLUENT | Sanjay Padhiar | Main CFD Forum | 1 | March 31, 1999 13:32 |