LCOV - code coverage report
Current view: top level - src/interfaces - ElementIDInterface.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 30 49 61.2 %
Date: 2025-07-17 01:28:37 Functions: 5 8 62.5 %
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 "ElementIDInterface.h"
      11             : 
      12             : #include "InputParameters.h"
      13             : #include "MooseObject.h"
      14             : #include "MooseApp.h"
      15             : #include "ActionWarehouse.h"
      16             : #include "MooseMesh.h"
      17             : #include "SubProblem.h"
      18             : #include "Assembly.h"
      19             : 
      20             : #include "libmesh/mesh_base.h"
      21             : 
      22             : InputParameters
      23           0 : ElementIDInterface::validParams()
      24             : {
      25           0 :   return emptyInputParameters();
      26             : }
      27             : 
      28      261521 : ElementIDInterface::ElementIDInterface(const MooseObject * moose_object)
      29      523042 :   : _obj_parameters(moose_object->parameters()),
      30      261521 :     _id_mesh(moose_object->getMooseApp().actionWarehouse().mesh()),
      31      523042 :     _ei_name(moose_object->name())
      32             : {
      33      261521 : }
      34             : 
      35             : unsigned int
      36         579 : ElementIDInterface::getElementIDIndex(const std::string & id_parameter_name,
      37             :                                       unsigned int comp) const
      38             : {
      39         579 :   auto & p = _obj_parameters.get<std::vector<ExtraElementIDName>>(id_parameter_name);
      40         579 :   if (comp >= p.size())
      41           0 :     mooseError(id_parameter_name, " does not have enough integer names");
      42             : 
      43         579 :   return getElementIDIndexByName(p[comp]);
      44             : }
      45             : 
      46             : unsigned int
      47        7030 : ElementIDInterface::getElementIDIndexByName(const std::string & id_name) const
      48             : {
      49        7030 :   if (!_id_mesh.get())
      50           0 :     mooseError("Mesh is not available for getting element integers");
      51             : 
      52        7030 :   auto & mesh_base = _id_mesh->getMesh();
      53             : 
      54        7030 :   if (id_name == "subdomain_id")
      55             :   {
      56          52 :     if (mesh_base.has_elem_integer(id_name))
      57           0 :       mooseError("MOOSE does not allow 'subdomain_id' element integer in a mesh. 'subdomain_id' is "
      58             :                  "reserved for element subdomain ID");
      59          52 :     return mesh_base.n_elem_integers();
      60             :   }
      61             : 
      62        6978 :   if (!mesh_base.has_elem_integer(id_name))
      63           0 :     mooseError(
      64           0 :         "Mesh does not have an element integer names as ", id_name, " but required by ", _ei_name);
      65             : 
      66        6978 :   auto id = mesh_base.get_elem_integer_index(id_name);
      67             : 
      68        6978 :   return id;
      69             : }
      70             : 
      71             : const dof_id_type &
      72         423 : ElementIDInterface::getElementID(const std::string & id_parameter_name, unsigned int comp) const
      73             : {
      74         423 :   auto id = getElementIDIndex(id_parameter_name, comp);
      75             : 
      76         423 :   auto & _subproblem = *_obj_parameters.getCheckedPointerParam<SubProblem *>("_subproblem");
      77             : 
      78         423 :   auto tid = _obj_parameters.get<THREAD_ID>("_tid");
      79             : 
      80         423 :   auto & assembly = _subproblem.assembly(tid, 0);
      81             : 
      82         423 :   return assembly.extraElemID(id);
      83             : }
      84             : 
      85             : const dof_id_type &
      86          52 : ElementIDInterface::getElementIDNeighbor(const std::string & id_parameter_name,
      87             :                                          unsigned int comp) const
      88             : {
      89          52 :   auto id = getElementIDIndex(id_parameter_name, comp);
      90             : 
      91          52 :   auto & _subproblem = *_obj_parameters.getCheckedPointerParam<SubProblem *>("_subproblem");
      92             : 
      93          52 :   auto tid = _obj_parameters.get<THREAD_ID>("_tid");
      94             : 
      95          52 :   auto & assembly = _subproblem.assembly(tid, 0);
      96             : 
      97          52 :   return assembly.extraElemIDNeighbor(id);
      98             : }
      99             : 
     100             : const dof_id_type &
     101           0 : ElementIDInterface::getElementIDByName(const std::string & id_name) const
     102             : {
     103           0 :   auto id = getElementIDIndexByName(id_name);
     104             : 
     105           0 :   auto & _subproblem = *_obj_parameters.getCheckedPointerParam<SubProblem *>("_subproblem");
     106             : 
     107           0 :   auto tid = _obj_parameters.get<THREAD_ID>("_tid");
     108             : 
     109           0 :   auto & assembly = _subproblem.assembly(tid, 0);
     110             : 
     111           0 :   return assembly.extraElemID(id);
     112             : }
     113             : 
     114             : const dof_id_type &
     115           0 : ElementIDInterface::getElementIDNeighborByName(const std::string & id_name) const
     116             : {
     117           0 :   auto id = getElementIDIndexByName(id_name);
     118             : 
     119           0 :   auto & _subproblem = *_obj_parameters.getCheckedPointerParam<SubProblem *>("_subproblem");
     120             : 
     121           0 :   auto tid = _obj_parameters.get<THREAD_ID>("_tid");
     122             : 
     123           0 :   auto & assembly = _subproblem.assembly(tid, 0);
     124             : 
     125           0 :   return assembly.extraElemIDNeighbor(id);
     126             : }

Generated by: LCOV version 1.14