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 490 : ComputeElemDampingThread::ComputeElemDampingThread(FEProblemBase & feproblem, 20 490 : NonlinearSystemBase & nl) 21 : : ThreadedElementLoop<ConstElemRange>(feproblem), 22 490 : _damping(1.0), 23 490 : _nl(nl), 24 490 : _element_dampers(_nl.getElementDamperWarehouse()) 25 : { 26 490 : } 27 : 28 : // Splitting Constructor 29 151 : ComputeElemDampingThread::ComputeElemDampingThread(ComputeElemDampingThread & x, 30 151 : Threads::split split) 31 : : ThreadedElementLoop<ConstElemRange>(x, split), 32 151 : _damping(1.0), 33 151 : _nl(x._nl), 34 151 : _element_dampers(x._element_dampers) 35 : { 36 151 : } 37 : 38 792 : ComputeElemDampingThread::~ComputeElemDampingThread() {} 39 : 40 : void 41 1752 : ComputeElemDampingThread::onElement(const Elem * elem) 42 : { 43 1752 : _fe_problem.prepare(elem, _tid); 44 1752 : _fe_problem.reinitElem(elem, _tid); 45 : 46 1752 : std::set<MooseVariable *> damped_vars; 47 : 48 : const std::vector<std::shared_ptr<ElementDamper>> & edampers = 49 1752 : _nl.getElementDamperWarehouse().getActiveObjects(_tid); 50 3526 : for (const auto & damper : edampers) 51 1774 : damped_vars.insert(damper->getVariable()); 52 : 53 1752 : _nl.reinitIncrementAtQpsForDampers(_tid, damped_vars); 54 : 55 : const std::vector<std::shared_ptr<ElementDamper>> & objects = 56 1752 : _element_dampers.getActiveObjects(_tid); 57 3480 : for (const auto & obj : objects) 58 : { 59 1764 : Real cur_damping = obj->computeDamping(); 60 1764 : obj->checkMinDamping(cur_damping); 61 1728 : if (cur_damping < _damping) 62 477 : _damping = cur_damping; 63 : } 64 1752 : } 65 : 66 : Real 67 490 : ComputeElemDampingThread::damping() 68 : { 69 490 : return _damping; 70 : } 71 : 72 : void 73 151 : ComputeElemDampingThread::join(const ComputeElemDampingThread & y) 74 : { 75 151 : if (y._damping < _damping) 76 25 : _damping = y._damping; 77 151 : } 78 : 79 : void 80 641 : ComputeElemDampingThread::printGeneralExecutionInformation() const 81 : { 82 641 : const auto & damper_wh = _nl.getElementDamperWarehouse(); 83 641 : if (!_fe_problem.shouldPrintExecution(_tid) || !damper_wh.hasActiveObjects()) 84 631 : return; 85 : 86 10 : const auto & console = _fe_problem.console(); 87 10 : const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag(); 88 10 : console << "[DBG] Beginning elemental loop to compute damping on " << execute_on << std::endl; 89 : // Dampers are currently not block restricted 90 10 : console << "[DBG] Ordering of dampers " << std::endl; 91 10 : console << damper_wh.activeObjectsToFormattedString() << std::endl; 92 : }