forked from idaholab/mastodon
-
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.
Create transfer for controlling layered material
(refs idaholab#107)
- Loading branch information
1 parent
7cb0e73
commit d79db77
Showing
7 changed files
with
163 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,31 @@ | ||
#ifndef LAYEREDMATERIALCONTROL_H | ||
#define LAYEREDMATERIALCONTROL_H | ||
|
||
// MOOSE includes | ||
#include "Control.h" | ||
|
||
// Forward Declarations | ||
class LayeredMaterialControl; | ||
|
||
template <> | ||
InputParameters validParams<LayeredMaterialControl>(); | ||
|
||
/** | ||
* A control for changing parameters associated with layer ids. | ||
*/ | ||
class LayeredMaterialControl : public Control | ||
{ | ||
public: | ||
LayeredMaterialControl(const InputParameters & parameters); | ||
|
||
protected: | ||
virtual void execute() override; | ||
|
||
/// The values of the parameter to control | ||
const std::vector<Real> & _current_values; | ||
|
||
/// The values to use from this control | ||
const std::vector<Real> & _control_values; | ||
}; | ||
|
||
#endif |
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,27 @@ | ||
// Mastodon includes | ||
#include "LayeredMaterialControl.h" | ||
|
||
template <> | ||
InputParameters | ||
validParams<LayeredMaterialControl>() | ||
{ | ||
InputParameters params = validParams<Control>(); | ||
params.addRequiredParam<std::string>("parameter", "The name of the parameter to control."); | ||
params.addRequiredParam<std::vector<Real>>("values", "The values to replace on the specified material object."); | ||
return params; | ||
} | ||
|
||
LayeredMaterialControl::LayeredMaterialControl(const InputParameters & parameters) | ||
: Control(parameters), | ||
_current_values(getControllableValue<std::vector<Real>>("parameter")), | ||
_control_values(getParam<std::vector<Real>>("values")) | ||
{ | ||
if (_current_values.size() != _control_values.size()) | ||
mooseError("The layer values specified in the ", name(), " Control object and the values being controlled must be the same size."); | ||
} | ||
|
||
void | ||
LayeredMaterialControl::execute() | ||
{ | ||
setControllableValue<std::vector<Real>>("parameter", _control_values); | ||
} |
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
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,84 @@ | ||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 1 | ||
nx = 2 | ||
[] | ||
|
||
[Variables] | ||
[./u] | ||
[../] | ||
[] | ||
|
||
[Kernels] | ||
[./diff] | ||
type = Diffusion | ||
variable = u | ||
[../] | ||
[] | ||
|
||
[BCs] | ||
[./left] | ||
type = DirichletBC | ||
boundary = left | ||
variable = u | ||
value = 1 | ||
[../] | ||
[./right] | ||
type = DirichletBC | ||
boundary = right | ||
variable = u | ||
value = 0 | ||
[../] | ||
[] | ||
|
||
[AuxVariables] | ||
[./layer] | ||
order = CONSTANT | ||
family = MONOMIAL | ||
[../] | ||
[] | ||
|
||
[ICs] | ||
[./layer_ic] | ||
type = FunctionIC | ||
function = 'if(x<0.5,1980,1949)' | ||
variable = layer | ||
[../] | ||
[] | ||
|
||
[Materials] | ||
[./linear] | ||
type = LinearSoilMaterial | ||
layer_variable = layer | ||
layer_ids = '1980 1949' | ||
shear_modulus = '1.35e6 4.25e8' | ||
density = '1500 1700' | ||
outputs = exodus | ||
[../] | ||
[] | ||
|
||
[Controls] | ||
[./control_density] | ||
type = LayeredMaterialControl | ||
parameter = Material/linear/density | ||
values = '1700 1500' | ||
execute_on = 'initial' | ||
[../] | ||
[./control_modulus] | ||
type = LayeredMaterialControl | ||
parameter = Material/linear/shear_modulus | ||
values = '4.25e8 1.35e6' | ||
execute_on = 'initial' | ||
[../] | ||
[] | ||
|
||
[Executioner] | ||
type = Transient | ||
num_steps = 1 | ||
[] | ||
|
||
[Outputs] | ||
execute_on = 'TIMESTEP_END' | ||
hide = 'u' | ||
exodus = 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,13 @@ | ||
[Tests] | ||
[./control_layer_values] | ||
type = Exodiff | ||
input = layer_control.i | ||
exodiff = layer_control_out.e | ||
[../] | ||
[./invalid_value_size] | ||
type = RunException | ||
input = layer_control.i | ||
cli_args = Controls/control_density/values='1500' | ||
expect_err = "The layer values specified in the control_density Control object and the values being controlled must be the same size." | ||
[../] | ||
[] |