LCOV - code coverage report
Current view: top level - src/loops - ComputeElemDampingThread.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 "ComputeElemDampingThread.h"
      12             : #include "NonlinearSystemBase.h"
      13             : #include "NonlinearSystem.h"
      14             : #include "Problem.h"
      15             : #include "ElementDamper.h"
      16             : 
      17             : #include "libmesh/threads.h"
      18             : 
      19         484 : ComputeElemDampingThread::ComputeElemDampingThread(FEProblemBase & feproblem,
      20         484 :                                                    NonlinearSystemBase & nl)
      21             :   : ThreadedElementLoop<ConstElemRange>(feproblem),
      22         484 :     _damping(1.0),
      23         484 :     _nl(nl),
      24         484 :     _element_dampers(_nl.getElementDamperWarehouse())
      25             : {
      26         484 : }
      27             : 
      28             : // Splitting Constructor
      29         202 : ComputeElemDampingThread::ComputeElemDampingThread(ComputeElemDampingThread & x,
      30         202 :                                                    Threads::split split)
      31             :   : ThreadedElementLoop<ConstElemRange>(x, split),
      32         202 :     _damping(1.0),
      33         202 :     _nl(x._nl),
      34         202 :     _element_dampers(x._element_dampers)
      35             : {
      36         202 : }
      37             : 
      38         888 : ComputeElemDampingThread::~ComputeElemDampingThread() {}
      39             : 
      40             : void
      41        1857 : ComputeElemDampingThread::onElement(const Elem * elem)
      42             : {
      43        1857 :   _fe_problem.prepare(elem, _tid);
      44        1857 :   _fe_problem.reinitElem(elem, _tid);
      45             : 
      46        1857 :   std::set<MooseVariable *> damped_vars;
      47             : 
      48        1857 :   const auto & edampers = _element_dampers.getActiveObjects(_tid);
      49        3736 :   for (const auto & damper : edampers)
      50        1879 :     if (damper->variableDefinedOnElement(elem))
      51        1563 :       damped_vars.insert(damper->getVariable());
      52             : 
      53        1857 :   if (!damped_vars.empty())
      54        1541 :     _nl.reinitIncrementAtQpsForDampers(_tid, damped_vars);
      55             : 
      56        3682 :   for (const auto & damper : edampers)
      57             :   {
      58        1870 :     if (!damper->variableDefinedOnElement(elem))
      59         316 :       continue;
      60             : 
      61        1554 :     Real cur_damping = damper->computeDamping();
      62        1554 :     damper->checkMinDamping(cur_damping);
      63        1509 :     if (cur_damping < _damping)
      64         461 :       _damping = cur_damping;
      65             :   }
      66        1857 : }
      67             : 
      68             : Real
      69         484 : ComputeElemDampingThread::damping()
      70             : {
      71         484 :   return _damping;
      72             : }
      73             : 
      74             : void
      75         202 : ComputeElemDampingThread::join(const ComputeElemDampingThread & y)
      76             : {
      77         202 :   if (y._damping < _damping)
      78          25 :     _damping = y._damping;
      79         202 : }
      80             : 
      81             : void
      82         686 : ComputeElemDampingThread::printGeneralExecutionInformation() const
      83             : {
      84         686 :   const auto & damper_wh = _nl.getElementDamperWarehouse();
      85         686 :   if (!_fe_problem.shouldPrintExecution(_tid) || !damper_wh.hasActiveObjects())
      86         677 :     return;
      87             : 
      88           9 :   const auto & console = _fe_problem.console();
      89           9 :   const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
      90           9 :   console << "[DBG] Beginning elemental loop to compute damping on " << execute_on << std::endl;
      91             :   // Dampers are currently not block restricted
      92           9 :   console << "[DBG] Ordering of dampers " << std::endl;
      93          27 :   console << damper_wh.activeObjectsToFormattedString() << std::endl;
      94             : }

Generated by: LCOV version 1.14