Skip to content

Commit

Permalink
Fixed sync_times_object in Output
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuahansel committed Aug 31, 2023
1 parent f547de5 commit 4f7a1ed
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 6 deletions.
21 changes: 15 additions & 6 deletions framework/src/outputs/Output.C
Expand Up @@ -185,11 +185,15 @@ 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 = _sync_times_object->getUniqueTimes();
}
}

void
Expand Down Expand Up @@ -254,7 +258,12 @@ Output::onInterval()

// 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 times values. Only static time "
"values are supported at this 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())
Expand Down
@@ -0,0 +1,4 @@
time,current_time
1.1,1.1
1.5,1.5
2.3,2.3
42 changes: 42 additions & 0 deletions 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'
[]
[]
18 changes: 18 additions & 0 deletions 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 times values. Only static time values are supported at this time.'
requirement = "The system shall report an error if output is specified to use a times object with changing times."
[]
[]

0 comments on commit 4f7a1ed

Please sign in to comment.