From e04d483128d0f25872ac96810de0692acf1708e7 Mon Sep 17 00:00:00 2001 From: "Joshua E. Hansel" Date: Thu, 31 Aug 2023 09:09:01 -0500 Subject: [PATCH] Fixed sync_times_object in Output Closes #25368 --- framework/src/outputs/Output.C | 26 ++++++++---- .../doc/content/newsletter/2023/2023_08.md | 2 + .../gold/sync_times_object_out.csv | 4 ++ .../sync_times_object/sync_times_object.i | 42 +++++++++++++++++++ test/tests/outputs/sync_times_object/tests | 18 ++++++++ 5 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 test/tests/outputs/sync_times_object/gold/sync_times_object_out.csv create mode 100644 test/tests/outputs/sync_times_object/sync_times_object.i create mode 100644 test/tests/outputs/sync_times_object/tests diff --git a/framework/src/outputs/Output.C b/framework/src/outputs/Output.C index 2f1632062749..489f938bafc6 100644 --- a/framework/src/outputs/Output.C +++ b/framework/src/outputs/Output.C @@ -185,11 +185,18 @@ Output::Output(const InputParameters & parameters) _sync_times.insert(pwb_olf->domain(i)); } - // Check that the sync times were retrieved as expected - if (_sync_times_object && - (isParamValid("output_limiting_function") || isParamSetByUser("sync_times"))) - paramError("sync_times_object", - "Only one method of specifying sync times is supported at a time"); + // Get sync times from Times object if using + if (_sync_times_object) + { + if (isParamValid("output_limiting_function") || isParamSetByUser("sync_times")) + paramError("sync_times_object", + "Only one method of specifying sync times is supported at a time"); + else + // Sync times for the time steppers are taken from the output warehouse. The output warehouse + // takes sync times from the output objects immediately after the object is constructed. Hence + // we must ensure that we set the `_sync_times` in the constructor + _sync_times = _sync_times_object->getUniqueTimes(); + } } void @@ -252,9 +259,14 @@ Output::onInterval() if (_sync_only) output = false; - // Update sync times if a sync time object is in use if (_sync_times_object) - _sync_times = _sync_times_object->getUniqueTimes(); + { + const auto & sync_times = _sync_times_object->getUniqueTimes(); + if (sync_times != _sync_times) + mooseError("The provided sync times object has changing time values. Only static time " + "values are supported since time steppers take sync times from the output " + "warehouse which determines its sync times at output construction time."); + } // If sync times are not skipped, return true if the current time is a sync_time if (_sync_times.find(_time) != _sync_times.end()) diff --git a/modules/doc/content/newsletter/2023/2023_08.md b/modules/doc/content/newsletter/2023/2023_08.md index 277982283fa0..c96aaeb279f6 100644 --- a/modules/doc/content/newsletter/2023/2023_08.md +++ b/modules/doc/content/newsletter/2023/2023_08.md @@ -90,3 +90,5 @@ with their respective parameter. - Disclaimers were added to the [SideDiffusiveFluxAverage.md] and [DiffusionFluxAux.md] documentation to warn the user that the diffusive flux calculated by these postprocessing tools are only exact if the diffusive flux discretization is the same between the user's kernels and these tools. +- The parameter [!param](/Outputs/CSV/sync_times_object) in outputs was not forcing + solution to occur at these times, which has been fixed. diff --git a/test/tests/outputs/sync_times_object/gold/sync_times_object_out.csv b/test/tests/outputs/sync_times_object/gold/sync_times_object_out.csv new file mode 100644 index 000000000000..6a6c06322ce5 --- /dev/null +++ b/test/tests/outputs/sync_times_object/gold/sync_times_object_out.csv @@ -0,0 +1,4 @@ +time,current_time +1.1,1.1 +1.5,1.5 +2.3,2.3 diff --git a/test/tests/outputs/sync_times_object/sync_times_object.i b/test/tests/outputs/sync_times_object/sync_times_object.i new file mode 100644 index 000000000000..18e3708b37d5 --- /dev/null +++ b/test/tests/outputs/sync_times_object/sync_times_object.i @@ -0,0 +1,42 @@ +[Mesh] + type = GeneratedMesh + dim = 1 + nx = 1 +[] + +[Postprocessors] + [current_time] + type = TimePostprocessor + execute_on = 'INITIAL TIMESTEP_END' + [] +[] + +[Problem] + solve = false +[] + +[Executioner] + type = Transient + dt = 1 + end_time = 5 +[] + +[Times] + [input_times] + type = InputTimes + times = '1.1 1.5 2.3' + [] + # For the error-check test + [simulation_times] + type = SimulationTimes + [] +[] + +[Outputs] + [out] + type = CSV + sync_only = true + sync_times_object = input_times + execute_reporters_on = 'NONE' + [] +[] diff --git a/test/tests/outputs/sync_times_object/tests b/test/tests/outputs/sync_times_object/tests new file mode 100644 index 000000000000..1475b578629f --- /dev/null +++ b/test/tests/outputs/sync_times_object/tests @@ -0,0 +1,18 @@ +[Tests] + issues = '#25368' + design = 'syntax/Outputs/index.md' + + [sync_times_object] + type = CSVDiff + input = 'sync_times_object.i' + csvdiff = 'sync_times_object_out.csv' + requirement = "The system shall allow output to occur at times provided by a times object." + [] + [sync_times_object_changing_times] + type = RunException + input = 'sync_times_object.i' + cli_args = "Outputs/out/sync_times_object=simulation_times" + expect_err = 'The provided sync times object has changing time values. Only static time values are supported' + requirement = "The system shall report an error if output is specified to use a times object with changing times." + [] +[]