View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0004198 | OpenFOAM | Bug | public | 2025-01-02 22:45 | 2025-01-10 10:36 |
Reporter | jtriesch | Assigned To | will | ||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | resolved | Resolution | fixed | ||
Platform | Linux | OS | Ubuntu | OS Version | 24.04 |
Product Version | 12 | ||||
Fixed in Version | dev | ||||
Summary | 0004198: fieldAverage function object periodic restart possibly inconsistent | ||||
Description | If I understand correctly, under certain conditions, the periodic restart may be inconsistent for a number of iterations. Specifically, when a simulation run is restarted, the periodIndex_ is always initialized to 1. This may be inconsistent with the current time, as the evaluation in fieldAverage.C:137 restarts the averaging until periodIndex_ matches the correct condition. | ||||
Additional Information | A suggested fix could conditionally re-evaluate the value in fieldAverage.C Foam::functionObjects::fieldPhaseAverage::read(), following line 223 in the if conditional: const scalar currentTime = time_.value(); periodIndex_ = ceil(currentTime/restartPeriod_); | ||||
Tags | No tags attached. | ||||
|
I think the way to do this would be to put write the period index into the "props" dictionary and read it back out on restart. Regardless, if you want this looked at you'll need to provide a means to reproduce the issue. I.e., a case that can be run from a single Allrun script that demonstrates the problem. Note https://bugs.openfoam.org/rules.php : " An issue report therefore must include the following: ... A clear set of instructions that reproduces the issue, including key files, if required." |
|
As this is quite generic I thought it would be obvious to reproduce the mentioned behavior. I hope the following is more clear. Applying the following steps subsequently should do: 1. Running the original "incompressibleFluid/cavity" tutorial. 2. Replacing the original controlDict by the attached file (with fieldAverage function object) and continuing the run for another 2 s. Debugging with gdb it can be observed that a restart and period index increment is falsely spawn from fieldAverage.C:137 for the first 10 iterations. Subsequently, no restart correctly takes place until the next 1 s is completed. I think writing/reading the period index is suboptimal as it does not take into account the case when fieldAverage is enabled later during a simulation run (and not from the start). My suggested fix would correctly handle this as well. Alternatively, one could e.g. conditionally loop through all previous period indexes. controlDict (1,602 bytes)
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 12 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { format ascii; class dictionary; location "system"; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // application foamRun; solver incompressibleFluid; startFrom latestTime; startTime 0; stopAt endTime; endTime 12; deltaT 0.005; writeControl timeStep; writeInterval 100; purgeWrite 0; writeFormat ascii; writePrecision 6; writeCompression off; timeFormat general; timePrecision 6; runTimeModifiable true; functions { fieldAverage1 { type fieldAverage; libs ("libfieldFunctionObjects.so"); log true; enabled true; writeControl writeTime; restartOnOutput false; restartOnRestart false; periodicRestart true; restartPeriod 1; fields ( p { mean on; prime2Mean off; base time; } ); } } // ************************************************************************* // |
|
That is more clear, yes, though it is still not a case that can be run from a single Allrun script. Unless you make the process of reproducing the issue and verifying the fix unambiguous and relatively efficient then future bug reports relating to niche settings will result in those settings being deleted rather than fixed. It may seem obvious to you, but if it is not obvious to us then your bug just won't get fixed. So I'd advise giving as much help as you can. As for the fix. I don't think we need a periodIndex at all. If we are rounding (ceil- or /floor-ing) the time divided by the restart period, then we can work out if we are at a restarting time without any additional state. Fix to dev here: https://github.com/OpenFOAM/OpenFOAM-dev/commit/f66950891843ce3becc330f3d745480361ada4f3 I think that fixes it. But again, we don't actually have a consistent reference case that we are both using to reproduce and verify this. So I'm not 100% sure. Fingers crossed. Open another report if its still wrong. With a case this time, or I'll just close it. |
Date Modified | Username | Field | Change |
---|---|---|---|
2025-01-02 22:45 | jtriesch | New Issue | |
2025-01-03 11:24 | will | Note Added: 0013501 | |
2025-01-03 11:24 | will | Note Edited: 0013501 | |
2025-01-03 11:25 | will | Note Edited: 0013501 | |
2025-01-03 11:25 | will | Note Edited: 0013501 | |
2025-01-03 11:27 | will | Note Edited: 0013501 | |
2025-01-03 11:27 | will | Note Edited: 0013501 | |
2025-01-03 11:29 | will | Note Edited: 0013501 | |
2025-01-03 11:29 | will | Note Edited: 0013501 | |
2025-01-03 20:08 | jtriesch | Note Added: 0013502 | |
2025-01-03 20:08 | jtriesch | File Added: controlDict | |
2025-01-10 10:36 | will | Assigned To | => will |
2025-01-10 10:36 | will | Status | new => resolved |
2025-01-10 10:36 | will | Resolution | open => fixed |
2025-01-10 10:36 | will | Fixed in Version | => dev |
2025-01-10 10:36 | will | Note Added: 0013503 | |
2025-01-10 10:36 | will | Note Edited: 0013503 |