forked from idaholab/moose
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added PostprocessorInterface to InitialConditionBase
- Added PostprocessorInterface to InitialConditionBase - Added overloads for InitialConditionBase::getPostprocessorValue and InitialConditionBase::getPostprocessorValueByName that add the post-processor name to the user object dependency list - Tested correct dependency resolution of both new overloads - Added news entry Closes idaholab#17692
- Loading branch information
1 parent
1c0d1c1
commit 7478c55
Showing
8 changed files
with
161 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
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
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
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,29 @@ | ||
//* 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 "InitialCondition.h" | ||
|
||
/** | ||
* This initial condition takes values from post-processor values. | ||
*/ | ||
class PostprocessorIC : public InitialCondition | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
PostprocessorIC(const InputParameters & parameters); | ||
|
||
virtual Real value(const Point & p) override; | ||
|
||
protected: | ||
const PostprocessorValue & _pp1; | ||
const PostprocessorValue & _pp2; | ||
}; |
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,34 @@ | ||
//* 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 "PostprocessorIC.h" | ||
|
||
registerMooseObject("MooseTestApp", PostprocessorIC); | ||
|
||
InputParameters | ||
PostprocessorIC::validParams() | ||
{ | ||
InputParameters params = InitialCondition::validParams(); | ||
params.addClassDescription("This initial condition takes values from post-processor values."); | ||
params.addRequiredParam<PostprocessorName>("pp1", "Name of first test post-processor"); | ||
return params; | ||
} | ||
|
||
PostprocessorIC::PostprocessorIC(const InputParameters & parameters) | ||
: InitialCondition(parameters), | ||
_pp1(getPostprocessorValue("pp1")), | ||
_pp2(getPostprocessorValueByName("pp2")) | ||
{ | ||
} | ||
|
||
Real | ||
PostprocessorIC::value(const Point & /*p*/) | ||
{ | ||
return _pp1 + _pp2; | ||
} |
3 changes: 3 additions & 0 deletions
3
test/tests/ics/postprocessor_interface/gold/postprocessor_interface_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,3 @@ | ||
time,integral_pp,pp2,test_var_pp | ||
0,34,6,40 | ||
1,34,6,40 |
66 changes: 66 additions & 0 deletions
66
test/tests/ics/postprocessor_interface/postprocessor_interface.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,66 @@ | ||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 1 | ||
xmin = 0 | ||
xmax = 10 | ||
nx = 10 | ||
[] | ||
|
||
[Functions] | ||
# The integral of this function is 2*3 + 3*6 + 5*2 = 34 | ||
[test_fn] | ||
type = PiecewiseConstant | ||
axis = x | ||
x = '0 2 5' | ||
y = '3 6 2' | ||
[] | ||
[] | ||
|
||
[Postprocessors] | ||
[integral_pp] | ||
type = FunctionElementIntegral | ||
function = test_fn | ||
execute_on = 'INITIAL' | ||
[] | ||
[pp2] | ||
type = FunctionValuePostprocessor | ||
function = 6 | ||
execute_on = 'INITIAL' | ||
[] | ||
[] | ||
|
||
[AuxVariables] | ||
[test_var] | ||
order = CONSTANT | ||
family = MONOMIAL | ||
[] | ||
[] | ||
|
||
[ICs] | ||
[test_var_ic] | ||
type = PostprocessorIC | ||
variable = test_var | ||
pp1 = integral_pp | ||
[] | ||
[] | ||
|
||
[Problem] | ||
solve = false | ||
[] | ||
|
||
[Executioner] | ||
type = Steady | ||
[] | ||
|
||
[Postprocessors] | ||
# This PP should have the sum of the other two PPs: 34 + 6 = 40 | ||
[test_var_pp] | ||
type = ElementAverageValue | ||
variable = test_var | ||
execute_on = 'INITIAL' | ||
[] | ||
[] | ||
|
||
[Outputs] | ||
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,11 @@ | ||
[Tests] | ||
[test] | ||
type = CSVDiff | ||
input = 'postprocessor_interface.i' | ||
csvdiff = 'postprocessor_interface_out.csv' | ||
|
||
requirement = 'MOOSE shall allow initial conditions to retrieve post-processor values.' | ||
design = '/InitialCondition.md /PostprocessorInterface.md' | ||
issues = '#17692' | ||
[] | ||
[] |