Skip to content

Commit

Permalink
Merge pull request #24695 from joseph-silberman/function_output
Browse files Browse the repository at this point in the history
added output_limiting_function parameter
  • Loading branch information
lindsayad authored Jun 24, 2023
2 parents ce4cdc7 + e45bafb commit 0e3d4f2
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 18 deletions.
4 changes: 4 additions & 0 deletions framework/include/outputs/Output.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "ReporterInterface.h"
#include "AdvancedOutputUtils.h"
#include "PerfGraphInterface.h"
#include "FunctionInterface.h"

class MooseMesh;

Expand All @@ -40,6 +41,7 @@ class Output : public MooseObject,
public Restartable,
public MeshChangedInterface,
public SetupInterface,
public FunctionInterface,
public PostprocessorInterface,
public VectorPostprocessorInterface,
public ReporterInterface,
Expand Down Expand Up @@ -136,6 +138,8 @@ class Output : public MooseObject,
*/
virtual void outputStep(const ExecFlagType & type);

const std::set<Real> & getSyncTimes() { return _sync_times; }

protected:
/**
* Overload this function with the desired output activities
Expand Down
18 changes: 18 additions & 0 deletions framework/src/outputs/Output.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "MooseUtils.h"
#include "MooseApp.h"
#include "Console.h"
#include "Function.h"
#include "PiecewiseLinear.h"

#include "libmesh/equation_systems.h"

Expand Down Expand Up @@ -50,6 +52,10 @@ Output::validParams()
params.addParam<int>("end_step", "Time step at which this output object stop operating");
params.addParam<Real>(
"time_tolerance", 1e-14, "Time tolerance utilized checking start and end times");
params.addDeprecatedParam<FunctionName>(
"output_limiting_function",
"Piecewise base function that sets sync_times",
"soon to be replaced by centralized system for managing times");

// Update the 'execute_on' input parameter for output
ExecFlagEnum & exec_enum = params.set<ExecFlagEnum>("execute_on", true);
Expand Down Expand Up @@ -90,6 +96,7 @@ Output::Output(const InputParameters & parameters)
Restartable(this, "Output"),
MeshChangedInterface(parameters),
SetupInterface(this),
FunctionInterface(this),
PostprocessorInterface(this),
VectorPostprocessorInterface(this),
ReporterInterface(this),
Expand Down Expand Up @@ -156,6 +163,17 @@ Output::Output(const InputParameters & parameters)
for (auto & me : add)
_execute_on.push_back(me);
}

if (isParamValid("output_limiting_function"))
{
const Function & olf = getFunction("output_limiting_function");
const PiecewiseBase * pwb_olf = dynamic_cast<const PiecewiseBase *>(&olf);
if (pwb_olf == nullptr)
mooseError("Function muse have a piecewise base!");

for (auto i = 0; i < pwb_olf->functionSize(); i++)
_sync_times.insert(pwb_olf->domain(i));
}
}

void
Expand Down
7 changes: 2 additions & 5 deletions framework/src/outputs/OutputWarehouse.C
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,8 @@ OutputWarehouse::addOutput(std::shared_ptr<Output> const output)
_object_names.insert(output->name());

// Insert object sync times to the global set
if (output->parameters().isParamValid("sync_times"))
{
std::vector<Real> sync_times = output->parameters().get<std::vector<Real>>("sync_times");
_sync_times.insert(sync_times.begin(), sync_times.end());
}
const std::set<Real> & sync_times = output->getSyncTimes();
_sync_times.insert(sync_times.begin(), sync_times.end());
}

bool
Expand Down
65 changes: 65 additions & 0 deletions test/tests/outputs/intervals/output_limiting_function.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
[]

[Variables]
[u]
[]
[]

[Functions]
[test_function]
type = PiecewiseLinear
x = '0.15 0.375 0.892'
y = '1 1 1'
[]
[]

[Kernels]
[diff]
type = CoefDiffusion
variable = u
coef = 0.1
[]
[time]
type = TimeDerivative
variable = u
[]
[]

[BCs]
[left]
type = DirichletBC
variable = u
boundary = left
value = 0
[]
[right]
type = DirichletBC
variable = u
boundary = right
value = 1
[]
[]

[Executioner]
type = Transient
num_steps = 15
dt = 0.1
solve_type = PJFNK
petsc_options_iname = '-pc_type -pc_hypre_type'
petsc_options_value = 'hypre boomeramg'
verbose = true
[]

[Outputs]
execute_on = 'timestep_end'
[out]
type = Exodus
output_limiting_function = test_function
sync_only = true
[]
[]
24 changes: 12 additions & 12 deletions test/tests/outputs/intervals/sync_times.i
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@
[]

[Variables]
[./u]
[../]
[u]
[]
[]

[Kernels]
[./diff]
[diff]
type = CoefDiffusion
variable = u
coef = 0.1
[../]
[./time]
[]
[time]
type = TimeDerivative
variable = u
[../]
[]
[]

[BCs]
[./left]
[left]
type = DirichletBC
variable = u
boundary = left
value = 0
[../]
[./right]
[]
[right]
type = DirichletBC
variable = u
boundary = right
value = 1
[../]
[]
[]

[Executioner]
Expand All @@ -49,9 +49,9 @@

[Outputs]
execute_on = 'timestep_end'
[./out]
[out]
type = Exodus
sync_times = '0.15 0.375 0.892'
sync_only = true
[../]
[]
[]
10 changes: 9 additions & 1 deletion test/tests/outputs/intervals/tests
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@

requirement = "The system shall support output at specific simulation times."
[]
[output_limiting_function]
type = 'Exodiff'
input = 'output_limiting_function.i'
exodiff = 'output_limiting_function_out.e'

requirement = "The system shall support output at times defined by the function."
[]
[multiple_sync_times]
# Tests the use of different sync times for outputs
type = 'Exodiff'
Expand All @@ -50,7 +57,8 @@
type = 'CSVDiff'
input = 'minimum_time_interval.i'
csvdiff = 'minimum_time_interval_out.csv'
requirement = "The system shall support specifying an minimum time difference between successive outputs."
requirement = "The system shall support specifying an minimum time difference between successive "
"outputs."
[]

[no_output]
Expand Down

0 comments on commit 0e3d4f2

Please sign in to comment.