LCOV - code coverage report
Current view: top level - src/meshgenerators - ParsedSubdomainMeshGenerator.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 26 27 96.3 %
Date: 2026-05-29 20:35:17 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 "ParsedSubdomainMeshGenerator.h"
      11             : 
      12             : registerMooseObject("MooseApp", ParsedSubdomainMeshGenerator);
      13             : 
      14             : InputParameters
      15        7666 : ParsedSubdomainMeshGenerator::validParams()
      16             : {
      17        7666 :   InputParameters params = ParsedSubdomainGeneratorBase::validParams();
      18             : 
      19       45996 :   params.renameParam("expression",
      20             :                      "combinatorial_geometry",
      21             :                      "Function expression encoding a combinatorial geometry");
      22       30664 :   params.addRequiredParam<subdomain_id_type>("block_id",
      23             :                                              "Subdomain id to set for inside of the combinatorial");
      24       30664 :   params.addParam<SubdomainName>("block_name",
      25             :                                  "Subdomain name to set for inside of the combinatorial");
      26        7666 :   params.addClassDescription(
      27             :       "Uses a parsed expression (`combinatorial_geometry`) to determine if an "
      28             :       "element (via its centroid) is inside the region defined by the expression and "
      29             :       "assigns a new block ID.");
      30             : 
      31        7666 :   return params;
      32           0 : }
      33             : 
      34        2304 : ParsedSubdomainMeshGenerator::ParsedSubdomainMeshGenerator(const InputParameters & parameters)
      35             :   : ParsedSubdomainGeneratorBase(parameters),
      36        2304 :     _block_id(parameters.get<subdomain_id_type>("block_id"))
      37             : {
      38        2301 : }
      39             : 
      40             : void
      41      708372 : ParsedSubdomainMeshGenerator::assignElemSubdomainID(Elem * elem)
      42             : {
      43      708372 :   _func_params[0] = elem->vertex_average()(0);
      44      708372 :   _func_params[1] = elem->vertex_average()(1);
      45      708372 :   _func_params[2] = elem->vertex_average()(2);
      46      708515 :   for (const auto i : index_range(_eeid_indices))
      47         143 :     _func_params[3 + i] = elem->get_extra_integer(_eeid_indices[i]);
      48     1416744 :   bool contains = evaluate(_func_F);
      49             : 
      50      751228 :   if (contains && std::find(_excluded_ids.begin(), _excluded_ids.end(), elem->subdomain_id()) ==
      51      751228 :                       _excluded_ids.end())
      52       42532 :     elem->subdomain_id() = _block_id;
      53      708372 : }
      54             : 
      55             : void
      56        2241 : ParsedSubdomainMeshGenerator::setBlockName(std::unique_ptr<MeshBase> & mesh)
      57             : {
      58        6723 :   if (isParamValid("block_name"))
      59         405 :     mesh->subdomain_name(getParam<subdomain_id_type>("block_id")) =
      60         675 :         getParam<SubdomainName>("block_name");
      61        2241 : }

Generated by: LCOV version 1.14