LCOV - code coverage report
Current view: top level - src/loops - ComputeNodalDampingThread.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 46 46 100.0 %
Date: 2026-05-29 20:35:17 Functions: 8 8 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 "ComputeNodalDampingThread.h"
      12             : #include "NonlinearSystem.h"
      13             : #include "Problem.h"
      14             : #include "NodalDamper.h"
      15             : 
      16             : #include "libmesh/threads.h"
      17             : 
      18         771 : ComputeNodalDampingThread::ComputeNodalDampingThread(FEProblemBase & feproblem,
      19         771 :                                                      NonlinearSystemBase & nl)
      20             :   : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(feproblem),
      21         771 :     _damping(1.0),
      22         771 :     _nl(nl),
      23         771 :     _nodal_dampers(_nl.getNodalDamperWarehouse())
      24             : {
      25         771 : }
      26             : 
      27             : // Splitting Constructor
      28         259 : ComputeNodalDampingThread::ComputeNodalDampingThread(ComputeNodalDampingThread & x,
      29         259 :                                                      Threads::split split)
      30             :   : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(x, split),
      31         259 :     _damping(1.0),
      32         259 :     _nl(x._nl),
      33         259 :     _nodal_dampers(x._nodal_dampers)
      34             : {
      35         259 : }
      36             : 
      37        1289 : ComputeNodalDampingThread::~ComputeNodalDampingThread() {}
      38             : 
      39             : void
      40        8178 : ComputeNodalDampingThread::onNode(ConstNodeRange::const_iterator & node_it)
      41             : {
      42        8178 :   const Node * node = *node_it;
      43        8178 :   _fe_problem.reinitNode(node, _tid);
      44             : 
      45        8178 :   std::set<MooseVariable *> damped_vars;
      46             : 
      47        8178 :   const auto & ndampers = _nodal_dampers.getActiveObjects(_tid);
      48       16356 :   for (const auto & damper : ndampers)
      49        8178 :     if (damper->variableDefinedOnNode(node))
      50        7525 :       damped_vars.insert(damper->getVariable());
      51             : 
      52        8178 :   if (!damped_vars.empty())
      53        7525 :     _nl.reinitIncrementAtNodeForDampers(_tid, damped_vars);
      54             : 
      55       16315 :   for (const auto & damper : ndampers)
      56             :   {
      57        8178 :     if (!damper->variableDefinedOnNode(node))
      58         653 :       continue;
      59             : 
      60        7525 :     Real cur_damping = damper->computeDamping();
      61        7525 :     damper->checkMinDamping(cur_damping);
      62        7484 :     if (cur_damping < _damping)
      63        2368 :       _damping = cur_damping;
      64             :   }
      65        8178 : }
      66             : 
      67             : Real
      68         771 : ComputeNodalDampingThread::damping()
      69             : {
      70         771 :   return _damping;
      71             : }
      72             : 
      73             : void
      74         259 : ComputeNodalDampingThread::join(const ComputeNodalDampingThread & y)
      75             : {
      76         259 :   if (y._damping < _damping)
      77          73 :     _damping = y._damping;
      78         259 : }
      79             : 
      80             : void
      81        1030 : ComputeNodalDampingThread::printGeneralExecutionInformation() const
      82             : {
      83        1030 :   const auto & damper_wh = _nl.getNodalDamperWarehouse();
      84        1030 :   if (!_fe_problem.shouldPrintExecution(_tid) || !damper_wh.hasActiveObjects())
      85         580 :     return;
      86             : 
      87         450 :   const auto & console = _fe_problem.console();
      88         450 :   const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
      89         450 :   console << "[DBG] Executing nodal dampers on " << execute_on << std::endl;
      90         450 :   console << "[DBG] Ordering of the dampers on the blocks they are defined on:" << std::endl;
      91             :   // TODO Check that all objects are active at this point
      92        1350 :   console << damper_wh.activeObjectsToFormattedString() << std::endl;
      93             : }

Generated by: LCOV version 1.14