LCOV - code coverage report
Current view: top level - src/loops - BoundaryNodeIntegrityCheckThread.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 52 52 100.0 %
Date: 2025-08-08 20:01:16 Functions: 7 7 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 "BoundaryNodeIntegrityCheckThread.h"
      12             : #include "BoundaryElemIntegrityCheckThread.h"
      13             : #include "AuxiliarySystem.h"
      14             : #include "NonlinearSystemBase.h"
      15             : #include "FEProblemBase.h"
      16             : #include "NodalUserObject.h"
      17             : #include "MooseMesh.h"
      18             : #include "MooseObjectTagWarehouse.h"
      19             : 
      20             : #include "libmesh/threads.h"
      21             : #include "libmesh/node.h"
      22             : #include "libmesh/mesh_base.h"
      23             : 
      24             : #include <vector>
      25             : 
      26       59600 : BoundaryNodeIntegrityCheckThread::BoundaryNodeIntegrityCheckThread(
      27       59600 :     FEProblemBase & fe_problem, const TheWarehouse::Query & query)
      28             :   : ThreadedNodeLoop<ConstBndNodeRange, ConstBndNodeRange::const_iterator>(fe_problem),
      29      119200 :     _aux_sys(fe_problem.getAuxiliarySystem()),
      30       59600 :     _nodal_aux(_aux_sys.nodalAuxWarehouse()),
      31       59600 :     _nodal_vec_aux(_aux_sys.nodalVectorAuxWarehouse()),
      32       59600 :     _nodal_array_aux(_aux_sys.nodalArrayAuxWarehouse()),
      33       59600 :     _query(query),
      34      119200 :     _node_to_elem_map(fe_problem.mesh().nodeToActiveSemilocalElemMap())
      35             : {
      36       59600 : }
      37             : 
      38             : // Splitting Constructor
      39        5121 : BoundaryNodeIntegrityCheckThread::BoundaryNodeIntegrityCheckThread(
      40        5121 :     BoundaryNodeIntegrityCheckThread & x, Threads::split split)
      41             :   : ThreadedNodeLoop<ConstBndNodeRange, ConstBndNodeRange::const_iterator>(x, split),
      42        5121 :     _aux_sys(x._aux_sys),
      43        5121 :     _nodal_aux(x._nodal_aux),
      44        5121 :     _nodal_vec_aux(x._nodal_vec_aux),
      45        5121 :     _nodal_array_aux(x._nodal_array_aux),
      46        5121 :     _query(x._query),
      47        5121 :     _node_to_elem_map(x._node_to_elem_map)
      48             : {
      49        5121 : }
      50             : 
      51             : void
      52     4465739 : BoundaryNodeIntegrityCheckThread::onNode(ConstBndNodeRange::const_iterator & node_it)
      53             : {
      54     4465739 :   const BndNode * const bnode = *node_it;
      55     4465739 :   const auto boundary_id = bnode->_bnd_id;
      56     4465739 :   const Node * const node = bnode->_node;
      57             : 
      58             :   // We can distribute work just as the actual execution code will
      59     4465739 :   if (node->processor_id() != _fe_problem.processor_id())
      60     1312198 :     return;
      61             : 
      62     3615433 :   auto & mesh = _fe_problem.mesh();
      63             : 
      64             :   // Only check vertices. Variables may not be defined on non-vertex nodes (think first order
      65             :   // Lagrange on a second order mesh) and user-code can often handle that
      66             :   const Elem * const an_elem =
      67     3615433 :       mesh.getMesh().elem_ptr(libmesh_map_find(_node_to_elem_map, node->id()).front());
      68     3615433 :   if (!an_elem->is_vertex(an_elem->get_node_index(node)))
      69      461892 :     return;
      70             : 
      71     3153541 :   const auto & bnd_name = mesh.getBoundaryName(boundary_id);
      72             : 
      73             :   // uo check
      74     3153541 :   std::vector<NodalUserObject *> objs;
      75     3153541 :   _query.clone()
      76     3153541 :       .condition<AttribThread>(_tid)
      77     3153541 :       .condition<AttribInterfaces>(Interfaces::NodalUserObject)
      78     6307082 :       .condition<AttribBoundaries>(boundary_id, true)
      79     3153541 :       .queryInto(objs);
      80     3162765 :   for (const auto & uo : objs)
      81        9232 :     if (uo->checkVariableBoundaryIntegrity())
      82        9232 :       boundaryIntegrityCheckError(*uo, uo->checkAllVariables(*node), bnd_name);
      83             : 
      84     9482584 :   auto check = [node, boundary_id, &bnd_name, this](const auto & warehouse)
      85             :   {
      86     9460591 :     if (!warehouse.hasBoundaryObjects(boundary_id, _tid))
      87     9439526 :       return;
      88             : 
      89       21065 :     const auto & bnd_objects = warehouse.getBoundaryObjects(boundary_id, _tid);
      90      144288 :     for (const auto & bnd_object : bnd_objects)
      91             :       // Skip if this object uses geometric search because coupled variables may be defined on
      92             :       // paired boundaries instead of the boundary this node is on
      93      123227 :       if (!bnd_object->requiresGeometricSearch() && bnd_object->checkVariableBoundaryIntegrity())
      94         464 :         boundaryIntegrityCheckError(*bnd_object, bnd_object->checkAllVariables(*node), bnd_name);
      95     3153533 :   };
      96             : 
      97     3153533 :   check(_nodal_aux);
      98     3153529 :   check(_nodal_vec_aux);
      99     3153529 :   check(_nodal_array_aux);
     100     3153529 : }
     101             : 
     102             : void
     103        5118 : BoundaryNodeIntegrityCheckThread::join(const BoundaryNodeIntegrityCheckThread & /*y*/)
     104             : {
     105        5118 : }

Generated by: LCOV version 1.14