forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
demonstrate action controllable parameters with a test idaholab#22069
- Loading branch information
Showing
10 changed files
with
196 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//* 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 "Control.h" | ||
|
||
class Function; | ||
|
||
class RealVectorFunctionControl : public Control | ||
{ | ||
public: | ||
/** | ||
* Class constructor | ||
* @param parameters Input parameters for this Control object | ||
*/ | ||
static InputParameters validParams(); | ||
|
||
RealVectorFunctionControl(const InputParameters & parameters); | ||
|
||
virtual void execute() override; | ||
|
||
private: | ||
/// The function to execute | ||
const Function & _function; | ||
}; |
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,43 @@ | ||
//* 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 | ||
|
||
// MOOSE includes | ||
#include "RealVectorFunctionControl.h" | ||
#include "Function.h" | ||
|
||
registerMooseObject("MooseTestApp", RealVectorFunctionControl); | ||
|
||
InputParameters | ||
RealVectorFunctionControl::validParams() | ||
{ | ||
InputParameters params = Control::validParams(); | ||
params.addClassDescription("Sets all component a 'RealEigenVector' input parameters to the value " | ||
"of a provided function."); | ||
params.addRequiredParam<FunctionName>( | ||
"function", "The function to use for controlling the specified parameter."); | ||
params.addRequiredParam<std::string>( | ||
"parameter", | ||
"The input parameter(s) to control. Specify a single parameter name and all " | ||
"parameters in all objects matching the name will be updated"); | ||
return params; | ||
} | ||
|
||
RealVectorFunctionControl::RealVectorFunctionControl(const InputParameters & parameters) | ||
: Control(parameters), _function(getFunction("function")) | ||
{ | ||
} | ||
|
||
void | ||
RealVectorFunctionControl::execute() | ||
{ | ||
Real value = _function.value(_t); | ||
auto cname = getParam<std::string>("parameter"); | ||
unsigned int ncomp = getControllableValueByName<RealEigenVector>(cname).size(); | ||
setControllableValueByName<RealEigenVector>(cname, RealEigenVector::Constant(ncomp, value)); | ||
} |
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,41 @@ | ||
[Mesh] | ||
[gmg] | ||
type = GeneratedMeshGenerator | ||
dim = 2 | ||
nx = 3 | ||
ny = 3 | ||
[] | ||
[] | ||
|
||
[Testing/LotsOfDiffusion/lots] | ||
number = 10 | ||
array = true | ||
n_components = 4 | ||
diffusion_coefficients = '1 1 1 1' | ||
add_reaction = true | ||
[] | ||
|
||
[Functions] | ||
[dc] | ||
type = ParsedFunction | ||
value = t+1 | ||
[] | ||
[] | ||
|
||
[Controls] | ||
[setdc] | ||
type = RealVectorFunctionControl | ||
function = dc | ||
parameter = Testing/LotsOfDiffusion/lots/diffusion_coefficients | ||
execute_on = timestep_begin | ||
[] | ||
[] | ||
|
||
[Executioner] | ||
type = Transient | ||
num_steps = 10 | ||
[] | ||
|
||
[Outputs] | ||
exodus = true | ||
[] |
Binary file not shown.
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] | ||
[test] | ||
type = Exodiff | ||
input = action_control_test.i | ||
exodiff = action_control_test_out.e | ||
issues = '#22068' | ||
design = 'syntax/Controls/index.md' | ||
requirement = "The Control system shall include a means to control input parameters added by MOOSE action systems." | ||
[] | ||
[] |
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 |
---|---|---|
|
@@ -23,4 +23,5 @@ | |
|
||
[Testing/LotsOfDiffusion/vars] | ||
number = 10 | ||
diffusion_coefficients = '1 1' | ||
[] |
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 |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
[./LotsOfDiffusion] | ||
[./vars] | ||
number = 1 | ||
diffusion_coefficients = 1 | ||
[../] | ||
[../] | ||
[] |
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