forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test that uses setData() ref idaholab#14220
- Loading branch information
Showing
5 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#pragma once | ||
|
||
#include "PiecewiseLinearBase.h" | ||
|
||
class HardCodedPiecewiseLinearFunction : public PiecewiseLinearBase | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
HardCodedPiecewiseLinearFunction(const InputParameters & parameters); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#include "HardCodedPiecewiseLinearFunction.h" | ||
|
||
registerMooseObject("MooseTestApp", HardCodedPiecewiseLinearFunction); | ||
|
||
InputParameters | ||
HardCodedPiecewiseLinearFunction::validParams() | ||
{ | ||
InputParameters params = PiecewiseLinearBase::validParams(); | ||
params.set<std::vector<Real>>("xy_data") = {}; // Avoids error in base class constructor | ||
params.addClassDescription("Class to test using setData() to set xy data in a Piecewise function"); | ||
return params; | ||
} | ||
|
||
HardCodedPiecewiseLinearFunction::HardCodedPiecewiseLinearFunction(const InputParameters & parameters) : PiecewiseLinearBase(parameters) | ||
{ | ||
const std::vector<Real> x = {0, 1, 2}; | ||
const std::vector<Real> y = {3, 1, 6}; | ||
setData(x, y); | ||
} |
5 changes: 5 additions & 0 deletions
5
test/tests/functions/hardcoded_piecewise_linear/gold/hardcoded_piecewise_linear_out.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
time,end1_pp | ||
0.5,2 | ||
1,1 | ||
1.5,3.5 | ||
2,6 |
57 changes: 57 additions & 0 deletions
57
test/tests/functions/hardcoded_piecewise_linear/hardcoded_piecewise_linear.i
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# This test ensures that hardcoded_function returns the expected | ||
# time-dependent values. The HardCodedPiecewiseLinearFunction is | ||
# a test object whose purpose is to ensure that the setData() method | ||
# can be used in Piecewise functions to directly set the xy data. | ||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 1 | ||
xmin = 0 | ||
xmax = 1 | ||
nx = 1 | ||
[] | ||
|
||
[Problem] | ||
solve = false | ||
[] | ||
|
||
[AuxVariables] | ||
[funcval] | ||
[] | ||
[] | ||
|
||
[AuxKernels] | ||
[funcval] | ||
type = FunctionAux | ||
variable = funcval | ||
function = hardcoded_function | ||
execute_on = 'initial timestep_end' | ||
[] | ||
[] | ||
|
||
|
||
[Functions] | ||
[hardcoded_function] | ||
type = HardCodedPiecewiseLinearFunction | ||
[] | ||
[] | ||
|
||
[Postprocessors] | ||
[end1_pp] | ||
type = ElementalVariableValue | ||
variable = funcval | ||
elementid = 0 | ||
execute_on = 'initial timestep_end' | ||
[../] | ||
[] | ||
|
||
[Executioner] | ||
type = Transient | ||
dt = 0.5 | ||
end_time = 2 | ||
[] | ||
|
||
[Outputs] | ||
execute_on = 'timestep_end' | ||
exodus = false | ||
csv = true | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[Tests] | ||
design = 'PiecewiseLinear.md' | ||
[./steady] | ||
type = 'CSVDiff' | ||
input = 'hardcoded_piecewise_linear.i' | ||
exodiff = 'hardcoded_piecewise_linear_out.csv' | ||
requirement = "The Function system shall allow for piecewise functions to directly set the xy data internally" | ||
issues = '#14220' | ||
[../] | ||
[] |