|
[Sponsors] |
how to stop the solver from continuing the solution |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 21, 2021, 15:55 |
how to stop the solver from continuing the solution
|
#1 |
New Member
Hamed Hoorijani
Join Date: May 2019
Location: Gent, Belgium
Posts: 23
Rep Power: 7 |
Hi everyone
I'm doing research on adding state-space trajectory and hopefully use it to speeding up the solution. At some point in the "while (runTime.run())" loop, I need to define a condition and tell the algorithm if the condition is satisfied stops the solution, and read some data. I'm having a hard time finding how should I tell the algorithm to stop the solution. Is there a specific function to do so? or stop a specific parameter to terminate the solution? I'll be grateful if you could guide me. Thanks |
|
July 21, 2021, 16:42 |
|
#2 | |
Member
Join Date: Mar 2021
Posts: 39
Rep Power: 5 |
Quote:
Hi, Will this be helpful? https://www.openfoam.com/documentati...e-control.html Last edited by trailer; July 21, 2021 at 18:51. |
||
July 22, 2021, 16:56 |
|
#3 |
New Member
Hamed Hoorijani
Join Date: May 2019
Location: Gent, Belgium
Posts: 23
Rep Power: 7 |
Hi,
Thanks a lot for your reply. That actually helped a lot, Thanks. But what I'm looking for is a way to stop the solution inside the solver. I want to define my condition inside the solver's source code and then I could continue my work from there. I want to write this function object's code inside the solver, so I could stop the solution without crashing the job and I could do other calculations. what I don't know is what parameter or function should I stop or call to do inside the source code? |
|
July 22, 2021, 19:42 |
|
#4 | |
Member
Join Date: Mar 2021
Posts: 39
Rep Power: 5 |
Quote:
Code:
bool exitFlag (false); label iterationCounter (0); label maxNumberOfIterations (5); // Set this to some number you feel confortable with while ( (!exitFlag) && (iterationCounter < maxNumberOfIterations) ) { // Calculations go in here iterationCounter += 1; if (myConvergenceCriteriaHasBeenReached) { exitFlag = true; } if( (iterationCounter == maxNumberOfIterations) && (!exitFlag) ) { Info << "Solver did not converge in: " << iterationCounter << " iterations " << endl; } } |
||
July 23, 2021, 08:03 |
|
#5 |
New Member
Hamed Hoorijani
Join Date: May 2019
Location: Gent, Belgium
Posts: 23
Rep Power: 7 |
Thanks for your reply
Yes, That's actually what I'm looking for. Thank you. but can I use it as : Code:
while ((runTime.run()) && (!exitFlag)) Instead of using the (iterationCounter < maxNumberOfIterations) I use the runTime.run() of the solver? |
|
July 24, 2021, 19:11 |
|
#6 | |
Member
Join Date: Mar 2021
Posts: 39
Rep Power: 5 |
Quote:
Just a note, I do not know if you need to do any changes to run this in parallel! |
||
July 25, 2021, 14:09 |
|
#7 |
New Member
Hamed Hoorijani
Join Date: May 2019
Location: Gent, Belgium
Posts: 23
Rep Power: 7 |
Thanks for the warning, I don't know about this code I haven't used the bool type variable in my codes.
I added other mathematical functions to OpenFOAM's solvers and it didn't bothered me as long as I wrote them using "foam" namespace. MPI and parallelization wasn't a problem so far for me. |
|
Tags |
openfoam 7, programming |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
foam-extend-4.1 release | hjasak | OpenFOAM Announcements from Other Sources | 19 | July 16, 2021 06:02 |
Buoyancy-driven flow eclipsed by solver noise? | JayDeeUU | OpenFOAM Running, Solving & CFD | 0 | March 7, 2021 17:53 |
SU2 7.0.7 Built on CentOS 7, parallel computation pyscript mpi exit error? | EternalSeekerX | SU2 | 3 | October 9, 2020 19:28 |
Working directory via command line | Luiz | CFX | 4 | March 6, 2011 21:02 |
IcoFoam parallel woes | msrinath80 | OpenFOAM Running, Solving & CFD | 9 | July 22, 2007 03:58 |