|
[Sponsors] |
February 6, 2017, 03:26 |
[SOLVED] How to pause a simulation
|
#1 |
New Member
Anders Simonsen
Join Date: Sep 2013
Posts: 18
Rep Power: 13 |
RESOLVED!
Hi. Do anyone know any way to pause a simulation through UDF's? The pause should be around 10 second. I'm using ANSYS Fluent 18.0. I'm running my code in parallel, and I've tried to make a while-loop on the host, but this requires a lot of computational power, which is not acceptable for my application, as other calculation are executed externally in other programs in the pause-time. Kind regards Anders I figured it out - I simply had to sleep/pause on all nodes+host: http://imgur.com/2kZegMK Correct: Code:
#include "udf.h" #include <stdlib.h> DEFINE_ON_DEMAND(WaitPause) { Message("Start..."); sleep(10); Message("stop!\n"); } Code:
#include "udf.h" #include <stdlib.h> DEFINE_ON_DEMAND(WaitPause) { #if !RP_NODE Message("Start..."); sleep(10); Message("stop!\n"); #endif } Last edited by ASimonsen; February 6, 2017 at 10:25. Reason: Resolved the problem |
|
February 6, 2017, 11:10 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Although your solution does what you want, and is probably the easiest, it is not the nicest solution.
You stop the simulation for 10 seconds to let another program do a calculation. But what if, for some reason, the other program takes 11 seconds to produce a result? Or does it take 1 second to calculate it, and do you wait 9 extra seconds just in case? A better way is to send a signal between Fluent and the external program, to tell each other whose turn it is. The signal can be many things, but I think a file is easiest to code. If the file exists, Fluent should wait, if the file does not exist, Fluent should run. In Pseudo-code: Fluent should do: Code:
[after a time step] fsignal=fopen("signal.txt","w");fclose(fsignal); while (file_exists("signal.txt")) { /* do nothing */ } [continue with the next time step] Code:
while (!file_exists("signal.txt")) { /* do nothing */ } do_the_things_you_need_done(); repeat_this_code; As long as your (ASimonsen's) simulation does what you want, just keep it the way it is. I put the text above mainly for somebody else in the future that has a similar question and ends up on this page. |
|
February 6, 2017, 11:35 |
|
#3 |
New Member
Anders Simonsen
Join Date: Sep 2013
Posts: 18
Rep Power: 13 |
Hi pakk
Thanks for your reply. The 10s pause was only an example, and it'll be implemented differently. Both programs are allowed to be paused at the same time, but I'll limit this "downtime" to 1s by implementing it as: Fluent: Code:
while (1) { FileExists <- "Check for file existence - fopen("File.txt","r") or something." if (FileExists) break; sleep(1); } // Do 5-20 Fluent iterations and return to the above. Anders |
|
Tags |
pause, sleep, wait |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to pause a transient simulation and resume without time step advancement? | aleisia | Main CFD Forum | 33 | June 12, 2017 12:41 |
Simulation of high pressure diesel injector - all phases compressible with cavitation | fivos | CFX | 4 | July 30, 2015 07:48 |
mass flow rate issue in supersonic nozzle simulation | xkang | FLUENT | 0 | July 31, 2014 17:06 |
Simulation of a complex wing in solidworks flow simulation | niels1900 | FloEFD, FloWorks & FloTHERM | 6 | April 20, 2011 11:44 |
Continuous vs interrupted simulation | sega | OpenFOAM Running, Solving & CFD | 4 | November 3, 2008 15:29 |