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 authored and oanaoana committed Nov 7, 2023
1 parent a9b9ad4 commit 8a5f978
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 7 deletions.
26 changes: 19 additions & 7 deletions framework/src/outputs/Output.C
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down
2 changes: 2 additions & 0 deletions modules/doc/content/newsletter/2023/2023_08.md
Expand Up @@ -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.
@@ -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 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."
[]
[]

0 comments on commit 8a5f978

Please sign in to comment.