LCOV - code coverage report
Current view: top level - src/loops - ComputeNodalKernelsThread.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 59 60 98.3 %
Date: 2026-05-29 20:35:17 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 "ComputeNodalKernelsThread.h"
      11             : 
      12             : // MOOSE includes
      13             : #include "AuxiliarySystem.h"
      14             : #include "FEProblem.h"
      15             : #include "MooseMesh.h"
      16             : #include "MooseVariableFE.h"
      17             : #include "NodalKernelBase.h"
      18             : 
      19             : #include "libmesh/threads.h"
      20             : 
      21       14958 : ComputeNodalKernelsThread::ComputeNodalKernelsThread(
      22             :     FEProblemBase & fe_problem,
      23             :     MooseObjectTagWarehouse<NodalKernelBase> & nodal_kernels,
      24       14958 :     const std::set<TagID> & tags)
      25             :   : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(fe_problem),
      26       14958 :     _fe_problem(fe_problem),
      27       29916 :     _aux_sys(fe_problem.getAuxiliarySystem()),
      28       14958 :     _tags(tags),
      29       14958 :     _nodal_kernels(nodal_kernels),
      30       14958 :     _num_cached(0)
      31             : {
      32       14958 : }
      33             : 
      34             : // Splitting Constructor
      35        6952 : ComputeNodalKernelsThread::ComputeNodalKernelsThread(ComputeNodalKernelsThread & x,
      36        6952 :                                                      Threads::split split)
      37             :   : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(x, split),
      38        6952 :     _fe_problem(x._fe_problem),
      39        6952 :     _aux_sys(x._aux_sys),
      40        6952 :     _tags(x._tags),
      41        6952 :     _nodal_kernels(x._nodal_kernels),
      42        6952 :     _num_cached(0)
      43             : {
      44        6952 : }
      45             : 
      46             : void
      47       21910 : ComputeNodalKernelsThread::pre()
      48             : {
      49       21910 :   _num_cached = 0;
      50             : 
      51       21910 :   if (!_tags.size() || _tags.size() == _fe_problem.numVectorTags(Moose::VECTOR_TAG_RESIDUAL))
      52       21898 :     _nkernel_warehouse = &_nodal_kernels;
      53          12 :   else if (_tags.size() == 1)
      54           0 :     _nkernel_warehouse = &(_nodal_kernels.getVectorTagObjectWarehouse(*(_tags.begin()), _tid));
      55             :   else
      56          12 :     _nkernel_warehouse = &(_nodal_kernels.getVectorTagsObjectWarehouse(_tags, _tid));
      57       21910 : }
      58             : 
      59             : void
      60     1116088 : ComputeNodalKernelsThread::onNode(ConstNodeRange::const_iterator & node_it)
      61             : {
      62     1116088 :   const Node * node = *node_it;
      63             : 
      64     1116088 :   std::set<const NodalKernelBase *> nks_executed;
      65             : 
      66             :   // prepare variables
      67     1502096 :   for (auto * var : _aux_sys._nodal_vars[_tid])
      68      386008 :     var->prepareAux();
      69             : 
      70     1116088 :   _fe_problem.reinitNode(node, _tid);
      71             : 
      72     1116088 :   const auto & block_ids = _aux_sys.mesh().getNodeBlockIds(*node);
      73     2241223 :   for (const auto block : block_ids)
      74     1125135 :     if (_nkernel_warehouse->hasActiveBlockObjects(block, _tid))
      75             :     {
      76     1073839 :       std::set<TagID> needed_fe_var_vector_tags;
      77     1073839 :       _nkernel_warehouse->updateBlockFEVariableCoupledVectorTagDependency(
      78             :           block, needed_fe_var_vector_tags, _tid);
      79     1073839 :       _fe_problem.setActiveFEVariableCoupleableVectorTags(needed_fe_var_vector_tags, _tid);
      80             : 
      81     1073839 :       const auto & objects = _nkernel_warehouse->getActiveBlockObjects(block, _tid);
      82     3266215 :       for (const auto & nodal_kernel : objects)
      83     2192376 :         if (nks_executed.emplace(nodal_kernel.get()).second)
      84             :         {
      85     2192308 :           nodal_kernel->setSubdomains(block_ids);
      86     2192308 :           nodal_kernel->computeResidual();
      87             :         }
      88     1073839 :     }
      89             : 
      90     1116088 :   _num_cached++;
      91             : 
      92     1116088 :   if (_num_cached == 20) // Cache 20 nodes worth before adding into the residual
      93             :   {
      94       48872 :     _num_cached = 0;
      95       48872 :     _fe_problem.addCachedResidual(_tid);
      96             :   }
      97     1116088 : }
      98             : 
      99             : void
     100        6952 : ComputeNodalKernelsThread::join(const ComputeNodalKernelsThread & /*y*/)
     101             : {
     102        6952 : }
     103             : 
     104             : void
     105       21910 : ComputeNodalKernelsThread::printGeneralExecutionInformation() const
     106             : {
     107       21910 :   if (!_fe_problem.shouldPrintExecution(_tid) || !_nkernel_warehouse->hasActiveObjects())
     108       21847 :     return;
     109             : 
     110          63 :   const auto & console = _fe_problem.console();
     111          63 :   const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
     112          63 :   console << "[DBG] Computing nodal kernels contribution to residual on nodes on " << execute_on
     113          63 :           << std::endl;
     114          63 :   console << "[DBG] Nodes at boundaries between blocks will execute lower block ID first"
     115          63 :           << std::endl;
     116          63 :   console << "[DBG] Ordering of the nodal kernels on nodes they are defined on:" << std::endl;
     117         189 :   console << _nkernel_warehouse->activeObjectsToFormattedString() << std::endl;
     118             : }

Generated by: LCOV version 1.14