diff --git a/include/controls/LayeredMaterialControl.h b/include/controls/LayeredMaterialControl.h new file mode 100644 index 0000000000..96f2bf234d --- /dev/null +++ b/include/controls/LayeredMaterialControl.h @@ -0,0 +1,31 @@ +#ifndef LAYEREDMATERIALCONTROL_H +#define LAYEREDMATERIALCONTROL_H + +// MOOSE includes +#include "Control.h" + +// Forward Declarations +class LayeredMaterialControl; + +template <> +InputParameters validParams(); + +/** + * 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 & _current_values; + + /// The values to use from this control + const std::vector & _control_values; +}; + +#endif diff --git a/src/base/MastodonApp.C b/src/base/MastodonApp.C index a14acce1fb..d95e57efed 100644 --- a/src/base/MastodonApp.C +++ b/src/base/MastodonApp.C @@ -45,6 +45,9 @@ #include "ResponseSpectraCalculator.h" #include "HousnerSpectrumIntensity.h" +// Controls +#include "LayeredMaterialControl.h" + // Testing #include "TestLayeredMaterialInterface.h" @@ -123,6 +126,9 @@ MastodonApp::registerObjects(Factory & factory) registerVectorPostprocessor(ResponseSpectraCalculator); registerVectorPostprocessor(HousnerSpectrumIntensity); + // Controls + registerControl(LayeredMaterialControl); + // Testing registerMaterial(TestLayeredMaterialInterfaceDocString); registerKernel(TestLayeredMaterialInterfaceTypeError); diff --git a/src/controls/LayeredMaterialControl.C b/src/controls/LayeredMaterialControl.C new file mode 100644 index 0000000000..8e631893bc --- /dev/null +++ b/src/controls/LayeredMaterialControl.C @@ -0,0 +1,27 @@ +// Mastodon includes +#include "LayeredMaterialControl.h" + +template <> +InputParameters +validParams() +{ + InputParameters params = validParams(); + params.addRequiredParam("parameter", "The name of the parameter to control."); + params.addRequiredParam>("values", "The values to replace on the specified material object."); + return params; +} + +LayeredMaterialControl::LayeredMaterialControl(const InputParameters & parameters) + : Control(parameters), + _current_values(getControllableValue>("parameter")), + _control_values(getParam>("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>("parameter", _control_values); +} diff --git a/src/materials/LinearSoilMaterial.C b/src/materials/LinearSoilMaterial.C index ca7ed2b5bf..90dec543da 100644 --- a/src/materials/LinearSoilMaterial.C +++ b/src/materials/LinearSoilMaterial.C @@ -21,6 +21,8 @@ validParams() params.addClassDescription("Material for computing the shear wave speed " "and minimum element size as a function " "of shear modulus and density."); + + params.declareControllable("shear_modulus density"); return params; } diff --git a/test/tests/controls/gold/layer_control_out.e b/test/tests/controls/gold/layer_control_out.e new file mode 100644 index 0000000000..79b8d6af2e Binary files /dev/null and b/test/tests/controls/gold/layer_control_out.e differ diff --git a/test/tests/controls/layer_control.i b/test/tests/controls/layer_control.i new file mode 100644 index 0000000000..9f617c26fe --- /dev/null +++ b/test/tests/controls/layer_control.i @@ -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 +[] diff --git a/test/tests/controls/tests b/test/tests/controls/tests new file mode 100644 index 0000000000..12b7ae5756 --- /dev/null +++ b/test/tests/controls/tests @@ -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." + [../] +[]