LCOV - code coverage report
Current view: top level - src/loops - ComputeNodalDampingThread.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 43 43 100.0 %
Date: 2025-07-17 01:28:37 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         524 : ComputeNodalDampingThread::ComputeNodalDampingThread(FEProblemBase & feproblem,
      19         524 :                                                      NonlinearSystemBase & nl)
      20             :   : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(feproblem),
      21         524 :     _damping(1.0),
      22         524 :     _nl(nl),
      23         524 :     _nodal_dampers(_nl.getNodalDamperWarehouse())
      24             : {
      25         524 : }
      26             : 
      27             : // Splitting Constructor
      28         212 : ComputeNodalDampingThread::ComputeNodalDampingThread(ComputeNodalDampingThread & x,
      29         212 :                                                      Threads::split split)
      30             :   : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(x, split),
      31         212 :     _damping(1.0),
      32         212 :     _nl(x._nl),
      33         212 :     _nodal_dampers(x._nodal_dampers)
      34             : {
      35         212 : }
      36             : 
      37         948 : ComputeNodalDampingThread::~ComputeNodalDampingThread() {}
      38             : 
      39             : void
      40        7440 : ComputeNodalDampingThread::onNode(ConstNodeRange::const_iterator & node_it)
      41             : {
      42        7440 :   const Node * node = *node_it;
      43        7440 :   _fe_problem.reinitNode(node, _tid);
      44             : 
      45        7440 :   std::set<MooseVariable *> damped_vars;
      46             : 
      47        7440 :   const auto & ndampers = _nl.getNodalDamperWarehouse().getActiveObjects(_tid);
      48       14880 :   for (const auto & damper : ndampers)
      49        7440 :     damped_vars.insert(damper->getVariable());
      50             : 
      51        7440 :   _nl.reinitIncrementAtNodeForDampers(_tid, damped_vars);
      52             : 
      53        7440 :   const auto & objects = _nodal_dampers.getActiveObjects(_tid);
      54       14848 :   for (const auto & obj : objects)
      55             :   {
      56        7440 :     Real cur_damping = obj->computeDamping();
      57        7440 :     obj->checkMinDamping(cur_damping);
      58        7408 :     if (cur_damping < _damping)
      59        1543 :       _damping = cur_damping;
      60             :   }
      61        7440 : }
      62             : 
      63             : Real
      64         524 : ComputeNodalDampingThread::damping()
      65             : {
      66         524 :   return _damping;
      67             : }
      68             : 
      69             : void
      70         212 : ComputeNodalDampingThread::join(const ComputeNodalDampingThread & y)
      71             : {
      72         212 :   if (y._damping < _damping)
      73          69 :     _damping = y._damping;
      74         212 : }
      75             : 
      76             : void
      77         736 : ComputeNodalDampingThread::printGeneralExecutionInformation() const
      78             : {
      79         736 :   const auto & damper_wh = _nl.getNodalDamperWarehouse();
      80         736 :   if (!_fe_problem.shouldPrintExecution(_tid) || !damper_wh.hasActiveObjects())
      81         524 :     return;
      82             : 
      83         212 :   const auto & console = _fe_problem.console();
      84         212 :   const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
      85         212 :   console << "[DBG] Executing nodal dampers on " << execute_on << std::endl;
      86         212 :   console << "[DBG] Ordering of the dampers on the blocks they are defined on:" << std::endl;
      87             :   // TODO Check that all objects are active at this point
      88         212 :   console << damper_wh.activeObjectsToFormattedString() << std::endl;
      89             : }

Generated by: LCOV version 1.14