LCOV - code coverage report
Current view: top level - src/meshgenerators - ParsedSubdomainMeshGenerator.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 26 27 96.3 %
Date: 2025-07-17 01:28:37 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       18321 : ParsedSubdomainMeshGenerator::validParams()
      16             : {
      17       18321 :   InputParameters params = ParsedSubdomainGeneratorBase::validParams();
      18             : 
      19       18321 :   params.renameParam("expression",
      20             :                      "combinatorial_geometry",
      21             :                      "Function expression encoding a combinatorial geometry");
      22       18321 :   params.addRequiredParam<subdomain_id_type>("block_id",
      23             :                                              "Subdomain id to set for inside of the combinatorial");
      24       18321 :   params.addParam<SubdomainName>("block_name",
      25             :                                  "Subdomain name to set for inside of the combinatorial");
      26       18321 :   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       18321 :   return params;
      32           0 : }
      33             : 
      34        2028 : ParsedSubdomainMeshGenerator::ParsedSubdomainMeshGenerator(const InputParameters & parameters)
      35             :   : ParsedSubdomainGeneratorBase(parameters),
      36        2028 :     _block_id(parameters.get<subdomain_id_type>("block_id"))
      37             : {
      38        2028 : }
      39             : 
      40             : void
      41      720392 : ParsedSubdomainMeshGenerator::assignElemSubdomainID(Elem * elem)
      42             : {
      43      720392 :   _func_params[0] = elem->vertex_average()(0);
      44      720392 :   _func_params[1] = elem->vertex_average()(1);
      45      720392 :   _func_params[2] = elem->vertex_average()(2);
      46      720535 :   for (const auto i : index_range(_eeid_indices))
      47         143 :     _func_params[3 + i] = elem->get_extra_integer(_eeid_indices[i]);
      48      720392 :   bool contains = evaluate(_func_F);
      49             : 
      50      758090 :   if (contains && std::find(_excluded_ids.begin(), _excluded_ids.end(), elem->subdomain_id()) ==
      51      758090 :                       _excluded_ids.end())
      52       37616 :     elem->subdomain_id() = _block_id;
      53      720392 : }
      54             : 
      55             : void
      56        1980 : ParsedSubdomainMeshGenerator::setBlockName(std::unique_ptr<MeshBase> & mesh)
      57             : {
      58        1980 :   if (isParamValid("block_name"))
      59         234 :     mesh->subdomain_name(getParam<subdomain_id_type>("block_id")) =
      60         351 :         getParam<SubdomainName>("block_name");
      61        1980 : }

Generated by: LCOV version 1.14