www.mooseframework.org
ComputeNodalDampingThread.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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
12 #include "NonlinearSystem.h"
13 #include "Problem.h"
14 #include "NodalDamper.h"
15 
16 #include "libmesh/threads.h"
17 
20  : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(feproblem),
21  _damping(1.0),
22  _nl(nl),
23  _nodal_dampers(_nl.getNodalDamperWarehouse())
24 {
25 }
26 
27 // Splitting Constructor
29  Threads::split split)
30  : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(x, split),
31  _damping(1.0),
32  _nl(x._nl),
33  _nodal_dampers(x._nodal_dampers)
34 {
35 }
36 
38 
39 void
40 ComputeNodalDampingThread::onNode(ConstNodeRange::const_iterator & node_it)
41 {
42  const Node * node = *node_it;
44 
45  std::set<MooseVariable *> damped_vars;
46 
47  const auto & ndampers = _nl.getNodalDamperWarehouse().getActiveObjects(_tid);
48  for (const auto & damper : ndampers)
49  damped_vars.insert(damper->getVariable());
50 
52 
53  const auto & objects = _nodal_dampers.getActiveObjects(_tid);
54  for (const auto & obj : objects)
55  {
56  Real cur_damping = obj->computeDamping();
57  obj->checkMinDamping(cur_damping);
58  if (cur_damping < _damping)
59  _damping = cur_damping;
60  }
61 }
62 
63 Real
65 {
66  return _damping;
67 }
68 
69 void
71 {
72  if (y._damping < _damping)
73  _damping = y._damping;
74 }
75 
76 void
78 {
79  const auto & damper_wh = _nl.getNodalDamperWarehouse();
80  if (!_fe_problem.shouldPrintExecution(_tid) || !damper_wh.hasActiveObjects())
81  return;
82 
83  const auto & console = _fe_problem.console();
84  const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
85  console << "[DBG] Executing nodal dampers on " << execute_on << std::endl;
86  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  console << damper_wh.activeObjectsToFormattedString() << std::endl;
89 }
void reinitIncrementAtNodeForDampers(THREAD_ID tid, const std::set< MooseVariable *> &damped_vars)
Compute the incremental change in variables at nodes for dampers.
virtual void reinitNode(const Node *node, const THREAD_ID tid) override
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
void join(const ComputeNodalDampingThread &y)
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Nonlinear system to be solved.
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread...
virtual void onNode(ConstNodeRange::const_iterator &node_it) override
Called for each node.
StoredRange< MeshBase::const_node_iterator, const Node *> ConstNodeRange
const MooseObjectWarehouse< NodalDamper > & _nodal_dampers
tbb::split split
const ConsoleStream & console() const
Return console handle.
Definition: Problem.h:48
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
ComputeNodalDampingThread(FEProblemBase &feproblem, NonlinearSystemBase &nl)
const MooseObjectWarehouse< NodalDamper > & getNodalDamperWarehouse() const
void printGeneralExecutionInformation() const override
Print information about the loop, mostly order of execution of objects.