Print percentage through run in stdout (in transient solvers)
Hi everyone,
I guess the title is self-explanatory. For that, one must query the following: 1. current time 2. calculate number of steps (based on the "endTime" and "deltaT") knowing these two we can do a simple calculation: Code:
percentage = current time / No. steps * 100 |
Probably best to do this as a functionObject rather than editing the solver: drop the following into a file system/printFracRun:
Code:
/*--------------------------------*- C++ -*----------------------------------*\ Code:
functions { |
Your idea is even better. No need to calculate the number of time steps, and It works like a charm! Thanks a lot!
I think the division by zero only happens when the latestTime is set and its value is the same as the endTime, meaning it only happens when one mistakenly starts a finished run. So I guess no need to be worried about it. Is it possible to change the precision with something like “setprecision(x)” (I set the writePrecision to 18, and it prints so many decimal points)? I tested Foam::setprecision(3) and std::setprecision(3) and it didn't compile, simply because they are not a member of corresponding namespaces. |
Glad that worked for you!
Quote:
Quote:
|
Okay - well, you learn something new every day! Yes - you can use the std c++ setprecision command. This seems to work:
Code:
/*--------------------------------*- C++ -*----------------------------------*\ |
Quote:
BTW, how did you find out this header file (“IOmanip.H”) should be added? |
Aaah, that was from a quick google search. The great thing about this forum is that it has been running for long enough that someone has probably had the same question as you at some stage!
Happy to help - this question caught my interest since I had wanted to do some functionObject coding last year using the simulation time, but couldn't work out how to do it at the time ... turns out it was easy all along! |
Yes, this forum is ancient :)
I believe it is possible to find them via Doxygen, not sure how to query, though. This is my first “functionObject” experience! I'm looking forward to using it for on-the-fly post-processing. |
All times are GMT -4. The time now is 04:39. |