LCOV - code coverage report
Current view: top level - src/userobjects - VerifyNodalUniqueID.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 25 27 92.6 %
Date: 2025-07-17 01:28:37 Functions: 6 6 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             : // MOOSE includes
      11             : #include "VerifyNodalUniqueID.h"
      12             : #include "SubProblem.h"
      13             : #include "MooseMesh.h"
      14             : 
      15             : registerMooseObject("MooseApp", VerifyNodalUniqueID);
      16             : 
      17             : InputParameters
      18       14341 : VerifyNodalUniqueID::validParams()
      19             : {
      20       14341 :   InputParameters params = NodalUserObject::validParams();
      21       14341 :   params.addClassDescription("Verifies that all node ids are unique.");
      22       14341 :   return params;
      23           0 : }
      24             : 
      25          40 : VerifyNodalUniqueID::VerifyNodalUniqueID(const InputParameters & parameters)
      26          40 :   : NodalUserObject(parameters)
      27             : {
      28          40 : }
      29             : 
      30             : // This object can't test every possible scenario.  For instance, it can't detect recycled ids
      31             : // It's only designed to make sure that all ids are unique in the mesh at any specified execution
      32             : void
      33         720 : VerifyNodalUniqueID::initialize()
      34             : {
      35         720 :   _all_ids.clear();
      36         720 :   _all_ids.reserve(_subproblem.mesh().getMesh().n_local_nodes());
      37         720 : }
      38             : 
      39             : void
      40       38720 : VerifyNodalUniqueID::execute()
      41             : {
      42             : #ifdef LIBMESH_ENABLE_UNIQUE_ID
      43       38720 :   _all_ids.push_back(_current_node->unique_id());
      44             : #else
      45             :   _all_ids.push_back(0);
      46             : #endif
      47       38720 : }
      48             : 
      49             : void
      50          80 : VerifyNodalUniqueID::threadJoin(const UserObject & y)
      51             : {
      52          80 :   const auto & uo = static_cast<const VerifyNodalUniqueID &>(y);
      53             : 
      54          80 :   _all_ids.insert(_all_ids.end(), uo._all_ids.begin(), uo._all_ids.end());
      55          80 : }
      56             : 
      57             : void
      58         640 : VerifyNodalUniqueID::finalize()
      59             : {
      60             :   // On Parallel Mesh we have to look at all the ids over all the processors
      61         640 :   if (_subproblem.mesh().isDistributedMesh())
      62         360 :     _communicator.allgather(_all_ids);
      63             : 
      64         640 :   std::sort(_all_ids.begin(), _all_ids.end());
      65         640 :   std::vector<dof_id_type>::iterator it_end = std::unique(_all_ids.begin(), _all_ids.end());
      66         640 :   if (it_end != _all_ids.end())
      67           0 :     mooseError("Duplicate unique_ids found!");
      68         640 : }

Generated by: LCOV version 1.14