LCOV - code coverage report
Current view: top level - src/meshgenerators - ParsedSubdomainIDsGenerator.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 22 23 95.7 %
Date: 2025-08-08 20:01:16 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 "ParsedSubdomainIDsGenerator.h"
      11             : 
      12             : registerMooseObject("MooseApp", ParsedSubdomainIDsGenerator);
      13             : 
      14             : InputParameters
      15       14339 : ParsedSubdomainIDsGenerator::validParams()
      16             : {
      17       14339 :   InputParameters params = ParsedSubdomainGeneratorBase::validParams();
      18             : 
      19       14339 :   params.addClassDescription(
      20             :       "Uses a parsed expression to determine the subdomain ids of included elements.");
      21             : 
      22       14339 :   return params;
      23           0 : }
      24             : 
      25          37 : ParsedSubdomainIDsGenerator::ParsedSubdomainIDsGenerator(const InputParameters & parameters)
      26          37 :   : ParsedSubdomainGeneratorBase(parameters)
      27             : {
      28          37 : }
      29             : 
      30             : void
      31         140 : ParsedSubdomainIDsGenerator::assignElemSubdomainID(Elem * elem)
      32             : {
      33         140 :   _func_params[0] = elem->vertex_average()(0);
      34         140 :   _func_params[1] = elem->vertex_average()(1);
      35         140 :   _func_params[2] = elem->vertex_average()(2);
      36         184 :   for (const auto i : index_range(_eeid_indices))
      37          44 :     _func_params[3 + i] = elem->get_extra_integer(_eeid_indices[i]);
      38             : 
      39         140 :   if (std::find(_excluded_ids.begin(), _excluded_ids.end(), elem->subdomain_id()) ==
      40         280 :       _excluded_ids.end())
      41             :   {
      42         140 :     const Real func_val = evaluate(_func_F);
      43         140 :     if (func_val < 0.0)
      44           4 :       paramError("expression",
      45           4 :                  "the value of the function is negative at the element with ID " +
      46           8 :                      std::to_string(elem->id()) +
      47             :                      ". The function must be non-negative. Consider using the absolute value of "
      48             :                      "the function.");
      49         136 :     elem->subdomain_id() = std::round(func_val);
      50             :   }
      51         136 : }

Generated by: LCOV version 1.14