LCOV - code coverage report
Current view: top level - src/loops - BoundaryNodeIntegrityCheckThread.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 52 52 100.0 %
Date: 2025-07-17 01:28:37 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       55089 : BoundaryNodeIntegrityCheckThread::BoundaryNodeIntegrityCheckThread(
      27       55089 :     FEProblemBase & fe_problem, const TheWarehouse::Query & query)
      28             :   : ThreadedNodeLoop<ConstBndNodeRange, ConstBndNodeRange::const_iterator>(fe_problem),
      29      110178 :     _aux_sys(fe_problem.getAuxiliarySystem()),
      30       55089 :     _nodal_aux(_aux_sys.nodalAuxWarehouse()),
      31       55089 :     _nodal_vec_aux(_aux_sys.nodalVectorAuxWarehouse()),
      32       55089 :     _nodal_array_aux(_aux_sys.nodalArrayAuxWarehouse()),
      33       55089 :     _query(query),
      34      110178 :     _node_to_elem_map(fe_problem.mesh().nodeToActiveSemilocalElemMap())
      35             : {
      36       55089 : }
      37             : 
      38             : // Splitting Constructor
      39        5097 : BoundaryNodeIntegrityCheckThread::BoundaryNodeIntegrityCheckThread(
      40        5097 :     BoundaryNodeIntegrityCheckThread & x, Threads::split split)
      41             :   : ThreadedNodeLoop<ConstBndNodeRange, ConstBndNodeRange::const_iterator>(x, split),
      42        5097 :     _aux_sys(x._aux_sys),
      43        5097 :     _nodal_aux(x._nodal_aux),
      44        5097 :     _nodal_vec_aux(x._nodal_vec_aux),
      45        5097 :     _nodal_array_aux(x._nodal_array_aux),
      46        5097 :     _query(x._query),
      47        5097 :     _node_to_elem_map(x._node_to_elem_map)
      48             : {
      49        5097 : }
      50             : 
      51             : void
      52     4100220 : BoundaryNodeIntegrityCheckThread::onNode(ConstBndNodeRange::const_iterator & node_it)
      53             : {
      54     4100220 :   const BndNode * const bnode = *node_it;
      55     4100220 :   const auto boundary_id = bnode->_bnd_id;
      56     4100220 :   const Node * const node = bnode->_node;
      57             : 
      58             :   // We can distribute work just as the actual execution code will
      59     4100220 :   if (node->processor_id() != _fe_problem.processor_id())
      60     1243217 :     return;
      61             : 
      62     3277056 :   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     3277056 :       mesh.getMesh().elem_ptr(libmesh_map_find(_node_to_elem_map, node->id()).front());
      68     3277056 :   if (!an_elem->is_vertex(an_elem->get_node_index(node)))
      69      420053 :     return;
      70             : 
      71     2857003 :   const auto & bnd_name = mesh.getBoundaryName(boundary_id);
      72             : 
      73             :   // uo check
      74     2857003 :   std::vector<NodalUserObject *> objs;
      75     2857003 :   _query.clone()
      76     2857003 :       .condition<AttribThread>(_tid)
      77     2857003 :       .condition<AttribInterfaces>(Interfaces::NodalUserObject)
      78     5714006 :       .condition<AttribBoundaries>(boundary_id, true)
      79     2857003 :       .queryInto(objs);
      80     2865343 :   for (const auto & uo : objs)
      81        8348 :     if (uo->checkVariableBoundaryIntegrity())
      82        8348 :       boundaryIntegrityCheckError(*uo, uo->checkAllVariables(*node), bnd_name);
      83             : 
      84     8590725 :   auto check = [node, boundary_id, &bnd_name, this](const auto & warehouse)
      85             :   {
      86     8570977 :     if (!warehouse.hasBoundaryObjects(boundary_id, _tid))
      87     8552065 :       return;
      88             : 
      89       18912 :     const auto & bnd_objects = warehouse.getBoundaryObjects(boundary_id, _tid);
      90      129558 :     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      110650 :       if (!bnd_object->requiresGeometricSearch() && bnd_object->checkVariableBoundaryIntegrity())
      94         418 :         boundaryIntegrityCheckError(*bnd_object, bnd_object->checkAllVariables(*node), bnd_name);
      95     2856995 :   };
      96             : 
      97     2856995 :   check(_nodal_aux);
      98     2856991 :   check(_nodal_vec_aux);
      99     2856991 :   check(_nodal_array_aux);
     100     2856991 : }
     101             : 
     102             : void
     103        5094 : BoundaryNodeIntegrityCheckThread::join(const BoundaryNodeIntegrityCheckThread & /*y*/)
     104             : {
     105        5094 : }

Generated by: LCOV version 1.14