https://mooseframework.inl.gov
Loading...
Searching...
No Matches
InputMatrixControl.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10// MOOSE includes
11#include "InputMatrixControl.h"
12#include "Function.h"
13
14registerMooseObject("StochasticToolsTestApp", InputMatrixControl);
15
18{
20 params.addClassDescription("Controls the 'matrix' parameter of a InputMatrix sampler.");
21 params.addRequiredParam<FunctionName>(
22 "num_rows_function", "The function to use for controlling the number of matrix rows.");
23 params.addRequiredParam<FunctionName>(
24 "num_cols_function", "The function to use for controlling the number of matrix columns.");
25 params.addRequiredParam<FunctionName>("sample_function",
26 "The function to use for producing the samples; x and y "
27 "will be the row and column index, respectively.");
28 params.addRequiredParam<std::string>("parameter",
29 "The InputMatrix 'matrix' parameter to control.");
30 return params;
31}
32
34 : Control(parameters),
35 _nrow_function(getFunction("num_rows_function")),
36 _ncol_function(getFunction("num_cols_function")),
37 _sample_function(getFunction("sample_function"))
38{
39}
40
41void
43{
44 const dof_id_type nrow = _nrow_function.value(_t);
45 const dof_id_type ncol = _ncol_function.value(_t);
46
47 RealEigenMatrix matrix(nrow, ncol);
48 for (const auto i : make_range(nrow))
49 for (const auto j : make_range(ncol))
50 matrix(i, j) = _sample_function.value(_t, Point(i, j));
51
52 setControllableValue<RealEigenMatrix>("parameter", matrix);
53}
registerMooseObject("StochasticToolsTestApp", InputMatrixControl)
static InputParameters validParams()
virtual Real value(Real t, const Point &p) const
const Function & _ncol_function
Function controlling the number of columns.
const Function & _nrow_function
Function controlling the number of rows.
static InputParameters validParams()
Class constructor.
virtual void execute() override
InputMatrixControl(const InputParameters &parameters)
const Function & _sample_function
Function controlling the sample value.
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
Real & _t