View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0004158 | OpenFOAM | Contribution | public | 2024-10-01 08:01 | 2024-10-01 09:42 |
Reporter | cgoessni | Assigned To | henry | ||
Priority | low | Severity | minor | Reproducibility | always |
Status | closed | Resolution | suspended | ||
Product Version | dev | ||||
Summary | 0004158: wrong check in adjustDeltaT() in Time.C would lead e.g. to missed meshToMesh timings | ||||
Description | The fix that I proposed in https://bugs.openfoam.org/view.php?id=4157 was slightly flawed. It did not consider float => int rounding errors, leading to label(nSteps) == 0 for nSteps slightly below 1. | ||||
Steps To Reproduce | Run incompressibleFluid/movingCone. The logfile leading to the first meshToMesh mapping reads as: Courant Number mean: 0.0569563 max: 0.494397 deltaT = 3.99701e-06 Time = 0.001496s PIMPLE: Iteration 1 DICPCG: Solving for cellMotionUx, Initial residual = 3.36653e-07, Final residual = 6.16238e-09, No Iterations 8 GAMG: Solving for pcorr, Initial residual = 1, Final residual = 0.0118018, No Iterations 5 DILUPBiCGStab: Solving for Ux, Initial residual = 0.00124333, Final residual = 9.92029e-07, No Iterations 1 DILUPBiCGStab: Solving for Uy, Initial residual = 0.0023504, Final residual = 2.0371e-06, No Iterations 1 DILUPBiCGStab: Solving for Uz, Initial residual = 0.0140534, Final residual = 1.38885e-05, No Iterations 1 GAMG: Solving for p, Initial residual = 0.00242521, Final residual = 3.89385e-07, No Iterations 7 time step continuity errors : sum local = 9.49261e-11, global = 1.94566e-11 PIMPLE: Iteration 2 DILUPBiCGStab: Solving for Ux, Initial residual = 2.01153e-05, Final residual = 2.6716e-08, No Iterations 1 DILUPBiCGStab: Solving for Uy, Initial residual = 1.47274e-05, Final residual = 3.79699e-08, No Iterations 1 DILUPBiCGStab: Solving for Uz, Initial residual = 0.000500498, Final residual = 1.38235e-08, No Iterations 1 GAMG: Solving for p, Initial residual = 0.00173992, Final residual = 9.50013e-07, No Iterations 5 time step continuity errors : sum local = 2.31651e-10, global = 4.38565e-11, cumulative = 1.11121e-08 ExecutionTime = 7.11 s ClockTime = 8 s Courant Number mean: 0.0569724 max: 0.49454 deltaT = 4.04114e-06 Time = 0.00150004s PIMPLE: Iteration 1 DICPCG: Solving for cellMotionUx, Initial residual = 3.36324e-07, Final residual = 6.09221e-09, No Iterations 8 GAMG: Solving for pcorr, Initial residual = 1, Final residual = 0.0118423, No Iterations 5 DILUPBiCGStab: Solving for Ux, Initial residual = 0.00125623, Final residual = 1.0223e-06, No Iterations 1 DILUPBiCGStab: Solving for Uy, Initial residual = 0.00237763, Final residual = 2.10229e-06, No Iterations 1 DILUPBiCGStab: Solving for Uz, Initial residual = 0.0136349, Final residual = 1.48114e-05, No Iterations 1 GAMG: Solving for p, Initial residual = 0.00364312, Final residual = 3.8061e-07, No Iterations 7 time step continuity errors : sum local = 9.46339e-11, global = 1.93497e-11 PIMPLE: Iteration 2 DILUPBiCGStab: Solving for Ux, Initial residual = 2.06023e-05, Final residual = 2.80523e-08, No Iterations 1 DILUPBiCGStab: Solving for Uy, Initial residual = 1.50962e-05, Final residual = 3.64753e-08, No Iterations 1 DILUPBiCGStab: Solving for Uz, Initial residual = 0.000531966, Final residual = 1.40346e-08, No Iterations 1 GAMG: Solving for p, Initial residual = 0.00178745, Final residual = 9.37538e-07, No Iterations 5 time step continuity errors : sum local = 2.33074e-10, global = 4.24015e-11, cumulative = 1.11545e-08 ExecutionTime = 7.16 s ClockTime = 8 s Courant Number mean: 0.0576184 max: 0.500159 Mapping to mesh time 0.0015 Creating cellsToCells between source mesh and target mesh region0 using intersection cellsToCells: Calculating couplings between 1690 source cells and 1580 target cells Overlapping volume = 1.73613e-09 8058 couplings calculated in 0.39s Creating patchToPatch between source patch internal and target patch internal using intersection Notice that Time = 0.00150004s, not Time = 0.0015s as expected. This happens due to nSteps in Time.C:adjustDeltaT() being slightly below one, thus, label(nSteps) == 0. While this seems only a minor issue in this tutorial case, this leads to missed meshToMesh mappings for our engine simulations. | ||||
Additional Information | I attached a diff that corrects the behaviour. It moves the check to a separate if () clause, after the conversion to label has happened. This should be the most robust way to ensure that nStepsToNextWrite is not zero, if ever 0.99 is changed, the check proposed in the diff would consider that already. | ||||
Tags | No tags attached. | ||||
|
adjustDeltaT.diff2..txt (917 bytes)
diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index b2682d0..0d8f603 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -95,14 +95,18 @@ void Foam::Time::adjustDeltaT() const scalar nSteps = timeToNextAction/deltaT_; - // Ensure nSteps larger than 0 and nStepsToNextWrite does not overflow - if (label(nSteps) > 0 && nSteps < labelMax) + // Ensure nStepsToNextWrite does not overflow + if (nSteps < labelMax) { // Allow the time-step to increase by up to 1% // to accommodate the next write time before splitting const label nStepsToNextWrite = label(nSteps + 0.99); - deltaT_ = timeToNextAction/nStepsToNextWrite; + // Ensure that nStepsToNextWrite is larger than 0 + if (nStepsToNextWrite > 0) + { + deltaT_ = timeToNextAction/nStepsToNextWrite; + } } } |
|
To be discussed directly with the user. |
Date Modified | Username | Field | Change |
---|---|---|---|
2024-10-01 08:01 | cgoessni | New Issue | |
2024-10-01 08:01 | cgoessni | File Added: adjustDeltaT.diff2..txt | |
2024-10-01 09:42 | henry | Assigned To | => henry |
2024-10-01 09:42 | henry | Status | new => closed |
2024-10-01 09:42 | henry | Resolution | open => suspended |
2024-10-01 09:42 | henry | Note Added: 0013420 |