LCOV - code coverage report
Current view: top level - src/materials - CostSensitivity.C (source / functions) Hit Total Coverage
Test: idaholab/moose optimization: #31405 (292dce) with base fef103 Lines: 18 19 94.7 %
Date: 2025-09-04 07:54:57 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 "CostSensitivity.h"
      11             : 
      12             : registerMooseObject("OptimizationApp", CostSensitivity);
      13             : 
      14             : InputParameters
      15         170 : CostSensitivity::validParams()
      16             : {
      17         170 :   InputParameters params = Material::validParams();
      18         170 :   params.addClassDescription("Computes cost sensitivity needed for multimaterial SIMP method.");
      19         340 :   params.addRequiredCoupledVar("design_density", "Design density variable name.");
      20         340 :   params.addRequiredParam<MaterialPropertyName>("cost",
      21             :                                                 "DerivativeParsedMaterial for cost of materials.");
      22         170 :   return params;
      23           0 : }
      24             : 
      25         132 : CostSensitivity::CostSensitivity(const InputParameters & parameters)
      26             :   : DerivativeMaterialInterface<Material>(parameters),
      27         132 :     _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
      28         132 :     _sensitivity(declareProperty<Real>(_base_name + "cost_sensitivity")),
      29         132 :     _design_density(coupledValue("design_density")),
      30         132 :     _design_density_name(coupledName("design_density", 0)),
      31         264 :     _dcostdrho(getMaterialPropertyDerivativeByName<Real>(getParam<MaterialPropertyName>("cost"),
      32             :                                                          _design_density_name)),
      33         396 :     _cost(getMaterialPropertyByName<Real>(getParam<MaterialPropertyName>("cost")))
      34             : {
      35         132 : }
      36             : 
      37             : void
      38     1268960 : CostSensitivity::computeQpProperties()
      39             : {
      40     1268960 :   _sensitivity[_qp] = _current_elem->volume() * _cost[_qp] +
      41     1268960 :                       _current_elem->volume() * _design_density[_qp] * _dcostdrho[_qp];
      42     1268960 : }

Generated by: LCOV version 1.14