LCOV - code coverage report
Current view: top level - src/loops - ComputeNodalKernelBcsThread.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 55 59 93.2 %
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             : #include "ComputeNodalKernelBcsThread.h"
      11             : 
      12             : // MOOSE includes
      13             : #include "AuxiliarySystem.h"
      14             : #include "FEProblem.h"
      15             : #include "MooseVariableFE.h"
      16             : #include "NodalKernelBase.h"
      17             : 
      18             : #include "libmesh/threads.h"
      19             : 
      20         977 : ComputeNodalKernelBcsThread::ComputeNodalKernelBcsThread(
      21             :     FEProblemBase & fe_problem,
      22             :     MooseObjectTagWarehouse<NodalKernelBase> & nodal_kernels,
      23         977 :     const std::set<TagID> & tags)
      24             :   : ThreadedNodeLoop<ConstBndNodeRange, ConstBndNodeRange::const_iterator>(fe_problem),
      25         977 :     _fe_problem(fe_problem),
      26        1954 :     _aux_sys(fe_problem.getAuxiliarySystem()),
      27         977 :     _tags(tags),
      28         977 :     _nodal_kernels(nodal_kernels),
      29         977 :     _num_cached(0)
      30             : {
      31         977 : }
      32             : 
      33             : // Splitting Constructor
      34          86 : ComputeNodalKernelBcsThread::ComputeNodalKernelBcsThread(ComputeNodalKernelBcsThread & x,
      35          86 :                                                          Threads::split split)
      36             :   : ThreadedNodeLoop<ConstBndNodeRange, ConstBndNodeRange::const_iterator>(x, split),
      37          86 :     _fe_problem(x._fe_problem),
      38          86 :     _aux_sys(x._aux_sys),
      39          86 :     _tags(x._tags),
      40          86 :     _nodal_kernels(x._nodal_kernels),
      41          86 :     _num_cached(0)
      42             : {
      43          86 : }
      44             : 
      45             : void
      46        1063 : ComputeNodalKernelBcsThread::pre()
      47             : {
      48        1063 :   _num_cached = 0;
      49             : 
      50        1063 :   if (!_tags.size() || _tags.size() == _fe_problem.numVectorTags(Moose::VECTOR_TAG_RESIDUAL))
      51        1063 :     _nkernel_warehouse = &_nodal_kernels;
      52           0 :   else if (_tags.size() == 1)
      53           0 :     _nkernel_warehouse = &(_nodal_kernels.getVectorTagObjectWarehouse(*(_tags.begin()), _tid));
      54             :   else
      55           0 :     _nkernel_warehouse = &(_nodal_kernels.getVectorTagsObjectWarehouse(_tags, _tid));
      56        1063 : }
      57             : 
      58             : void
      59       25690 : ComputeNodalKernelBcsThread::onNode(ConstBndNodeRange::const_iterator & node_it)
      60             : {
      61       25690 :   const BndNode * bnode = *node_it;
      62             : 
      63       25690 :   BoundaryID boundary_id = bnode->_bnd_id;
      64             : 
      65             :   // prepare variables
      66       25690 :   for (auto * var : _aux_sys._nodal_vars[_tid])
      67           0 :     var->prepareAux();
      68             : 
      69       25690 :   if (_nkernel_warehouse->hasActiveBoundaryObjects(boundary_id, _tid))
      70             :   {
      71       17830 :     Node * node = bnode->_node;
      72       17830 :     if (node->processor_id() == _fe_problem.processor_id())
      73             :     {
      74       13242 :       std::set<TagID> needed_fe_var_vector_tags;
      75       13242 :       _nkernel_warehouse->updateBoundaryFEVariableCoupledVectorTagDependency(
      76             :           boundary_id, needed_fe_var_vector_tags, _tid);
      77       13242 :       _fe_problem.setActiveFEVariableCoupleableVectorTags(needed_fe_var_vector_tags, _tid);
      78             : 
      79       13242 :       _fe_problem.reinitNodeFace(node, boundary_id, _tid);
      80       13242 :       const auto & objects = _nkernel_warehouse->getActiveBoundaryObjects(boundary_id, _tid);
      81       28374 :       for (const auto & nodal_kernel : objects)
      82             :       {
      83       15132 :         nodal_kernel->setSubdomains(Moose::NodeArg::undefined_subdomain_connection);
      84       15132 :         nodal_kernel->computeResidual();
      85             :       }
      86             : 
      87       13242 :       _num_cached++;
      88       13242 :     }
      89             :   }
      90             : 
      91       25690 :   if (_num_cached == 20) // cache 20 nodes worth before adding into the residual
      92             :   {
      93         504 :     _num_cached = 0;
      94         504 :     Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
      95         504 :     _fe_problem.addCachedResidual(_tid);
      96         504 :   }
      97       25690 : }
      98             : 
      99             : void
     100          86 : ComputeNodalKernelBcsThread::join(const ComputeNodalKernelBcsThread & /*y*/)
     101             : {
     102          86 : }
     103             : 
     104             : void
     105        1063 : ComputeNodalKernelBcsThread::printGeneralExecutionInformation() const
     106             : {
     107        1063 :   if (!_fe_problem.shouldPrintExecution(_tid) || !_nkernel_warehouse->hasActiveObjects())
     108         995 :     return;
     109             : 
     110          68 :   const auto & console = _fe_problem.console();
     111          68 :   const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
     112          68 :   console << "[DBG] Executing nodal kernels contribution to residual on nodes on " << execute_on
     113          68 :           << std::endl;
     114          68 :   console << "[DBG] Ordering of the nodal kernels on the nodes they are defined on:" << std::endl;
     115          68 :   console << _nkernel_warehouse->activeObjectsToFormattedString() << std::endl;
     116             : }

Generated by: LCOV version 1.14