Line data Source code
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 : #include "InputMatrixSampler.h" 11 : 12 : registerMooseObjectAliased("StochasticToolsApp", InputMatrixSampler, "InputMatrix"); 13 : 14 : InputParameters 15 406 : InputMatrixSampler::validParams() 16 : { 17 406 : InputParameters params = Sampler::validParams(); 18 406 : params.addClassDescription("Sampler that utilizes a sampling matrix defined at input."); 19 812 : params.addRequiredParam<RealEigenMatrix>("matrix", "Sampling matrix."); 20 406 : return params; 21 0 : } 22 : 23 236 : InputMatrixSampler::InputMatrixSampler(const InputParameters & parameters) 24 472 : : Sampler(parameters), _data(getParam<RealEigenMatrix>("matrix")) 25 : { 26 236 : setNumberOfRows(_data.rows()); 27 236 : setNumberOfCols(_data.cols()); 28 236 : } 29 : 30 : Real 31 2500 : InputMatrixSampler::computeSample(dof_id_type row_index, dof_id_type col_index) 32 : { 33 : // Checks to make sure that the row and column indices are not out of bounds 34 : // Static cast to avoid compiler warning and not lose information 35 : mooseAssert(static_cast<Real>(row_index) < static_cast<Real>(_data.rows()), 36 : "row_index cannot be out of bounds of the data."); 37 : mooseAssert(static_cast<Real>(col_index) < static_cast<Real>(_data.cols()), 38 : "col_index cannot be out of bounds of the data."); 39 : 40 2500 : return _data(row_index, col_index); 41 : }