LCOV - code coverage report
Current view: top level - src/samplers - InputMatrixSampler.C (source / functions) Hit Total Coverage
Test: idaholab/moose stochastic_tools: #31730 (e8b711) with base e0c998 Lines: 20 21 95.2 %
Date: 2025-10-29 16:55:33 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          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         668 : InputMatrixSampler::validParams()
      16             : {
      17         668 :   InputParameters params = Sampler::validParams();
      18         668 :   params.addClassDescription("Sampler that utilizes a sampling matrix defined at input.");
      19        1336 :   params.addRequiredParam<RealEigenMatrix>("matrix", "Sampling matrix.");
      20        1336 :   params.declareControllable("matrix");
      21         668 :   return params;
      22           0 : }
      23             : 
      24         386 : InputMatrixSampler::InputMatrixSampler(const InputParameters & parameters)
      25         772 :   : Sampler(parameters), _data(getParam<RealEigenMatrix>("matrix"))
      26             : {
      27         386 :   setNumberOfRows(_data.rows());
      28         386 :   setNumberOfCols(_data.cols());
      29         386 : }
      30             : 
      31             : void
      32         812 : InputMatrixSampler::executeSetUp()
      33             : {
      34         812 :   if ((dof_id_type)_data.cols() != getNumberOfCols())
      35           4 :     paramError("matrix",
      36             :                "Input matrix changed the number of columns from ",
      37             :                getNumberOfCols(),
      38             :                " to ",
      39           4 :                _data.cols());
      40             : 
      41         808 :   if ((dof_id_type)_data.rows() != getNumberOfRows())
      42         562 :     setNumberOfRows(_data.rows());
      43         808 : }
      44             : 
      45             : Real
      46       21035 : InputMatrixSampler::computeSample(dof_id_type row_index, dof_id_type col_index)
      47             : {
      48             :   // Checks to make sure that the row and column indices are not out of bounds
      49             :   // Static cast to avoid compiler warning and not lose information
      50             :   mooseAssert(static_cast<Real>(row_index) < static_cast<Real>(_data.rows()),
      51             :               "row_index cannot be out of bounds of the data.");
      52             :   mooseAssert(static_cast<Real>(col_index) < static_cast<Real>(_data.cols()),
      53             :               "col_index cannot be out of bounds of the data.");
      54             : 
      55       21035 :   return _data(row_index, col_index);
      56             : }

Generated by: LCOV version 1.14