https://mooseframework.inl.gov
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 
14 registerMooseObject("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 
41 void
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 }
const Function & _ncol_function
Function controlling the number of columns.
static InputParameters validParams()
virtual void execute() override
const Function & _sample_function
Function controlling the sample value.
void addRequiredParam(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
Class constructor.
InputMatrixControl(const InputParameters &parameters)
Real & _t
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > RealEigenMatrix
IntRange< T > make_range(T beg, T end)
const Function & _nrow_function
Function controlling the number of rows.
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
virtual Real value(Real t, const Point &p) const
registerMooseObject("StochasticToolsTestApp", InputMatrixControl)
uint8_t dof_id_type