LCOV - code coverage report
Current view: top level - src/interfaces - ElementIDInterface.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 99787a Lines: 34 53 64.2 %
Date: 2025-10-14 20:01:24 Functions: 6 9 66.7 %
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      287950 : ElementIDInterface::ElementIDInterface(const MooseObject * moose_object)
      29      575900 :   : _obj_parameters(moose_object->parameters()),
      30      287950 :     _id_mesh(moose_object->getMooseApp().actionWarehouse().mesh()),
      31      575900 :     _ei_name(moose_object->name())
      32             : {
      33      287950 : }
      34             : 
      35             : #ifdef MOOSE_KOKKOS_ENABLED
      36       37959 : ElementIDInterface::ElementIDInterface(const ElementIDInterface & object,
      37       37959 :                                        const Moose::Kokkos::FunctorCopy &)
      38       37959 :   : _obj_parameters(object._obj_parameters), _id_mesh(object._id_mesh), _ei_name(object._ei_name)
      39             : {
      40       37959 : }
      41             : #endif
      42             : 
      43             : unsigned int
      44         625 : ElementIDInterface::getElementIDIndex(const std::string & id_parameter_name,
      45             :                                       unsigned int comp) const
      46             : {
      47         625 :   auto & p = _obj_parameters.get<std::vector<ExtraElementIDName>>(id_parameter_name);
      48         625 :   if (comp >= p.size())
      49           0 :     mooseError(id_parameter_name, " does not have enough integer names");
      50             : 
      51         625 :   return getElementIDIndexByName(p[comp]);
      52             : }
      53             : 
      54             : unsigned int
      55        7858 : ElementIDInterface::getElementIDIndexByName(const std::string & id_name) const
      56             : {
      57        7858 :   if (!_id_mesh.get())
      58           0 :     mooseError("Mesh is not available for getting element integers");
      59             : 
      60        7858 :   auto & mesh_base = _id_mesh->getMesh();
      61             : 
      62        7858 :   if (id_name == "subdomain_id")
      63             :   {
      64          56 :     if (mesh_base.has_elem_integer(id_name))
      65           0 :       mooseError("MOOSE does not allow 'subdomain_id' element integer in a mesh. 'subdomain_id' is "
      66             :                  "reserved for element subdomain ID");
      67          56 :     return mesh_base.n_elem_integers();
      68             :   }
      69             : 
      70        7802 :   if (!mesh_base.has_elem_integer(id_name))
      71           0 :     mooseError(
      72           0 :         "Mesh does not have an element integer names as ", id_name, " but required by ", _ei_name);
      73             : 
      74        7802 :   auto id = mesh_base.get_elem_integer_index(id_name);
      75             : 
      76        7802 :   return id;
      77             : }
      78             : 
      79             : const dof_id_type &
      80         457 : ElementIDInterface::getElementID(const std::string & id_parameter_name, unsigned int comp) const
      81             : {
      82         457 :   auto id = getElementIDIndex(id_parameter_name, comp);
      83             : 
      84        1828 :   auto & _subproblem = *_obj_parameters.getCheckedPointerParam<SubProblem *>("_subproblem");
      85             : 
      86         457 :   auto tid = _obj_parameters.get<THREAD_ID>("_tid");
      87             : 
      88         457 :   auto & assembly = _subproblem.assembly(tid, 0);
      89             : 
      90         457 :   return assembly.extraElemID(id);
      91             : }
      92             : 
      93             : const dof_id_type &
      94          56 : ElementIDInterface::getElementIDNeighbor(const std::string & id_parameter_name,
      95             :                                          unsigned int comp) const
      96             : {
      97          56 :   auto id = getElementIDIndex(id_parameter_name, comp);
      98             : 
      99         224 :   auto & _subproblem = *_obj_parameters.getCheckedPointerParam<SubProblem *>("_subproblem");
     100             : 
     101          56 :   auto tid = _obj_parameters.get<THREAD_ID>("_tid");
     102             : 
     103          56 :   auto & assembly = _subproblem.assembly(tid, 0);
     104             : 
     105          56 :   return assembly.extraElemIDNeighbor(id);
     106             : }
     107             : 
     108             : const dof_id_type &
     109           0 : ElementIDInterface::getElementIDByName(const std::string & id_name) const
     110             : {
     111           0 :   auto id = getElementIDIndexByName(id_name);
     112             : 
     113           0 :   auto & _subproblem = *_obj_parameters.getCheckedPointerParam<SubProblem *>("_subproblem");
     114             : 
     115           0 :   auto tid = _obj_parameters.get<THREAD_ID>("_tid");
     116             : 
     117           0 :   auto & assembly = _subproblem.assembly(tid, 0);
     118             : 
     119           0 :   return assembly.extraElemID(id);
     120             : }
     121             : 
     122             : const dof_id_type &
     123           0 : ElementIDInterface::getElementIDNeighborByName(const std::string & id_name) const
     124             : {
     125           0 :   auto id = getElementIDIndexByName(id_name);
     126             : 
     127           0 :   auto & _subproblem = *_obj_parameters.getCheckedPointerParam<SubProblem *>("_subproblem");
     128             : 
     129           0 :   auto tid = _obj_parameters.get<THREAD_ID>("_tid");
     130             : 
     131           0 :   auto & assembly = _subproblem.assembly(tid, 0);
     132             : 
     133           0 :   return assembly.extraElemIDNeighbor(id);
     134             : }

Generated by: LCOV version 1.14