LCOV - code coverage report
Current view: top level - src/meshmodifiers - ThresholdElementSubdomainModifier.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 28 32 87.5 %
Date: 2026-05-29 20:35:17 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 "ThresholdElementSubdomainModifier.h"
      11             : 
      12             : InputParameters
      13        4305 : ThresholdElementSubdomainModifier::validParams()
      14             : {
      15        4305 :   InputParameters params = ElementSubdomainModifier::validParams();
      16             : 
      17       17220 :   params.addRequiredParam<Real>("threshold",
      18             :                                 "The value above (or below) which to change the element subdomain");
      19       12915 :   params.addParam<MooseEnum>("criterion_type",
      20       21525 :                              MooseEnum("BELOW EQUAL ABOVE", "ABOVE"),
      21             :                              "Criterion to use for the threshold");
      22       17220 :   params.addRequiredParam<SubdomainID>("subdomain_id",
      23             :                                        "The subdomain ID of the element when the criterion is met");
      24       12915 :   params.addParam<SubdomainID>(
      25             :       "complement_subdomain_id",
      26             :       "The subdomain ID of the element when the criterion is not met. If not provided, the element "
      27             :       "subdomain ID will not be modified if the criterion is not met.");
      28        4305 :   return params;
      29           0 : }
      30             : 
      31         648 : ThresholdElementSubdomainModifier::ThresholdElementSubdomainModifier(
      32         648 :     const InputParameters & parameters)
      33             :   : ElementSubdomainModifier(parameters),
      34         648 :     _threshold(getParam<Real>("threshold")),
      35        1296 :     _criterion_type(getParam<MooseEnum>("criterion_type").getEnum<CriterionType>()),
      36        1296 :     _subdomain_id(getParam<SubdomainID>("subdomain_id")),
      37        1296 :     _complement_subdomain_id(isParamValid("complement_subdomain_id")
      38         726 :                                  ? getParam<SubdomainID>("complement_subdomain_id")
      39         648 :                                  : Moose::INVALID_BLOCK_ID)
      40             : {
      41         648 : }
      42             : 
      43             : SubdomainID
      44      758115 : ThresholdElementSubdomainModifier::computeSubdomainID()
      45             : {
      46      758115 :   Real criterion = computeValue();
      47             : 
      48      758115 :   bool criterion_met = false;
      49      758115 :   switch (_criterion_type)
      50             :   {
      51           0 :     case CriterionType::Equal:
      52           0 :       criterion_met = MooseUtils::absoluteFuzzyEqual(criterion - _threshold, 0);
      53           0 :       break;
      54             : 
      55      708263 :     case CriterionType::Below:
      56      708263 :       criterion_met = criterion < _threshold;
      57      708263 :       break;
      58             : 
      59       49852 :     case CriterionType::Above:
      60       49852 :       criterion_met = criterion > _threshold;
      61       49852 :       break;
      62             :   }
      63             : 
      64      758115 :   return criterion_met ? _subdomain_id : _complement_subdomain_id;
      65             : }

Generated by: LCOV version 1.14