|
[Sponsors] |
December 10, 2020, 11:56 |
Defining stop criteria within solver
|
#1 |
Member
Join Date: Feb 2020
Posts: 90
Rep Power: 6 |
Hello to all,
I am using the solver pimpleFoam in openFoam v7 to do some calculations. After I achieve convergence of the main fields I would like to solve another equation. So, I place the following: Code:
if (pimple.finalPimpleIter()) { bool switch_solver(true); label counter(0); while (switch_solver) { #include "solveMyEquation.H" //has the solve statement inside counter+=1; if (counter==3) { switch_solver=false; } } } This works fine but I would like to end the loop by a predefined value of the residuals and not the number of cycles. Something like: Code:
while (residue > myPredefinedResidue) { #include "solveMyEquation.H" } Does anyone know how to do this? Best regards Last edited by Shibi; December 11, 2020 at 08:22. |
|
December 11, 2020, 16:02 |
|
#2 |
Member
Join Date: Feb 2020
Posts: 90
Rep Power: 6 |
Update:
in solve statement within #include "solveMyEquation.H" I made Code:
SymmTensor<scalar> Residue_ = solve(MyEquation).initialResidual(); Code:
counter+=1; SymmTensor<scalar> tolerance_ (1e-05,1e-05,1e-05,1e-05,1e-05,1e-05); scalar checkConvergence_(1); forAll(Residue_,i) { checkConvergence_*=pos( tolerance_[i]-Residue_[i]); } if (checkConvergence_>0) { switch_solver=false; // if checkConvergence_ is positive, all multiplications will result in the value 1 and the residue is smaller than the tolerance } else { switch_solver=true; } // If solver takes more than 3 iteration to converge, leave the loop if ( counter==3) { end_orientation_loop=false; } It does the first pimple cycle and everything is Ok. During the 2nd cycle, I get the following error: Code:
--> FOAM FATAL ERROR: index 3 out of range 0 ... 2 From function void Foam::UList<T>::checkIndex(Foam::label) const [with T = Foam::SolverPerformance<Foam::SymmTensor<double> >; Foam::label = int] in file /home/pc/OpenFOAM/OpenFOAM-7/src/OpenFOAM/lnInclude/UListI.H at line 106. Any suggestions on what to do? |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Unsteady Restart Divergence | pro_ | SU2 | 6 | May 20, 2020 15:17 |
Hybrid discretisation - blend factor | gcoopermax | CFX | 5 | September 23, 2016 08:05 |
Quarter Burner mesh with periosic condition | SamCanuck | FLUENT | 2 | August 31, 2011 11:34 |
Working directory via command line | Luiz | CFX | 4 | March 6, 2011 20:02 |
Setting a B.C using UserFortran in 4.3 | tokai | CFX | 10 | July 17, 2001 16:25 |