LCOV - code coverage report
Current view: top level - src/loops - BoundaryNodeIntegrityCheckThread.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: fef103 Lines: 52 52 100.0 %
Date: 2025-09-03 20:01:23 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       60312 : BoundaryNodeIntegrityCheckThread::BoundaryNodeIntegrityCheckThread(
      27       60312 :     FEProblemBase & fe_problem, const TheWarehouse::Query & query)
      28             :   : ThreadedNodeLoop<ConstBndNodeRange, ConstBndNodeRange::const_iterator>(fe_problem),
      29      120624 :     _aux_sys(fe_problem.getAuxiliarySystem()),
      30       60312 :     _nodal_aux(_aux_sys.nodalAuxWarehouse()),
      31       60312 :     _nodal_vec_aux(_aux_sys.nodalVectorAuxWarehouse()),
      32       60312 :     _nodal_array_aux(_aux_sys.nodalArrayAuxWarehouse()),
      33       60312 :     _query(query),
      34      120624 :     _node_to_elem_map(fe_problem.mesh().nodeToActiveSemilocalElemMap())
      35             : {
      36       60312 : }
      37             : 
      38             : // Splitting Constructor
      39        5182 : BoundaryNodeIntegrityCheckThread::BoundaryNodeIntegrityCheckThread(
      40        5182 :     BoundaryNodeIntegrityCheckThread & x, Threads::split split)
      41             :   : ThreadedNodeLoop<ConstBndNodeRange, ConstBndNodeRange::const_iterator>(x, split),
      42        5182 :     _aux_sys(x._aux_sys),
      43        5182 :     _nodal_aux(x._nodal_aux),
      44        5182 :     _nodal_vec_aux(x._nodal_vec_aux),
      45        5182 :     _nodal_array_aux(x._nodal_array_aux),
      46        5182 :     _query(x._query),
      47        5182 :     _node_to_elem_map(x._node_to_elem_map)
      48             : {
      49        5182 : }
      50             : 
      51             : void
      52     4501139 : BoundaryNodeIntegrityCheckThread::onNode(ConstBndNodeRange::const_iterator & node_it)
      53             : {
      54     4501139 :   const BndNode * const bnode = *node_it;
      55     4501139 :   const auto boundary_id = bnode->_bnd_id;
      56     4501139 :   const Node * const node = bnode->_node;
      57             : 
      58             :   // We can distribute work just as the actual execution code will
      59     4501139 :   if (node->processor_id() != _fe_problem.processor_id())
      60     1321116 :     return;
      61             : 
      62     3643780 :   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     3643780 :       mesh.getMesh().elem_ptr(libmesh_map_find(_node_to_elem_map, node->id()).front());
      68     3643780 :   if (!an_elem->is_vertex(an_elem->get_node_index(node)))
      69      463757 :     return;
      70             : 
      71     3180023 :   const auto & bnd_name = mesh.getBoundaryName(boundary_id);
      72             : 
      73             :   // uo check
      74     3180023 :   std::vector<NodalUserObject *> objs;
      75     3180023 :   _query.clone()
      76     3180023 :       .condition<AttribThread>(_tid)
      77     3180023 :       .condition<AttribInterfaces>(Interfaces::NodalUserObject)
      78     6360046 :       .condition<AttribBoundaries>(boundary_id, true)
      79     3180023 :       .queryInto(objs);
      80     3189247 :   for (const auto & uo : objs)
      81        9232 :     if (uo->checkVariableBoundaryIntegrity())
      82        9232 :       boundaryIntegrityCheckError(*uo, uo->checkAllVariables(*node), bnd_name);
      83             : 
      84     9540037 :   auto check = [node, boundary_id, &bnd_name, this](const auto & warehouse)
      85             :   {
      86     9540037 :     if (!warehouse.hasBoundaryObjects(boundary_id, _tid))
      87     9518972 :       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     3180015 :   };
      96             : 
      97     3180015 :   check(_nodal_aux);
      98     3180011 :   check(_nodal_vec_aux);
      99     3180011 :   check(_nodal_array_aux);
     100     3180011 : }
     101             : 
     102             : void
     103        5179 : BoundaryNodeIntegrityCheckThread::join(const BoundaryNodeIntegrityCheckThread & /*y*/)
     104             : {
     105        5179 : }

Generated by: LCOV version 1.14