LCOV - code coverage report
Current view: top level - src/materials - ConstantMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 25 26 96.2 %
Date: 2025-07-30 13:02:48 Functions: 3 3 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 "ConstantMaterial.h"
      11             : 
      12             : registerMooseObject("ThermalHydraulicsApp", ConstantMaterial);
      13             : 
      14             : InputParameters
      15       19518 : ConstantMaterial::validParams()
      16             : {
      17       19518 :   InputParameters params = Material::validParams();
      18       19518 :   params.addClassDescription("Defines a single constant material property, along with zero "
      19             :                              "derivative material properties for user-defined variables");
      20       39036 :   params.addParam<Real>("value", 0., "Constant value being assigned into the property");
      21       39036 :   params.addRequiredParam<std::string>("property_name", "The property name to declare");
      22       39036 :   params.addCoupledVar(
      23             :       "derivative_vars",
      24             :       "Names of variables for which to create (zero) material derivative properties");
      25       39036 :   params.set<MooseEnum>("constant_on") = "SUBDOMAIN";
      26       19518 :   return params;
      27           0 : }
      28             : 
      29       15267 : ConstantMaterial::ConstantMaterial(const InputParameters & parameters)
      30             :   : DerivativeMaterialInterface<Material>(parameters),
      31       15267 :     _value(getParam<Real>("value")),
      32       15267 :     _property_name(getParam<std::string>("property_name")),
      33       15267 :     _property(declareProperty<Real>(_property_name)),
      34       30534 :     _n_derivative_vars(coupledComponents("derivative_vars"))
      35             : {
      36             :   // get references to new material property derivatives
      37       15267 :   _derivative_properties.resize(_n_derivative_vars);
      38       30534 :   if (!isCoupledConstant("derivative_vars"))
      39       60417 :     for (unsigned int i = 0; i < _n_derivative_vars; ++i)
      40       45150 :       _derivative_properties[i] =
      41       90300 :           &declarePropertyDerivative<Real>(_property_name, coupledName("derivative_vars", i));
      42       15267 : }
      43             : 
      44             : void
      45     9657866 : ConstantMaterial::computeQpProperties()
      46             : {
      47     9657866 :   _property[_qp] = _value;
      48             : 
      49    38654693 :   for (unsigned int i = 0; i < _n_derivative_vars; ++i)
      50    28996827 :     if (_derivative_properties[i])
      51    28996827 :       (*_derivative_properties[i])[_qp] = 0;
      52     9657866 : }

Generated by: LCOV version 1.14