https://mooseframework.inl.gov
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ComputeNodalKernelsThread Class Reference

#include <ComputeNodalKernelsThread.h>

Inheritance diagram for ComputeNodalKernelsThread:
[legend]

Public Member Functions

 ComputeNodalKernelsThread (FEProblemBase &fe_problem, MooseObjectTagWarehouse< NodalKernelBase > &nodal_kernels, const std::set< TagID > &tags)
 
 ComputeNodalKernelsThread (ComputeNodalKernelsThread &x, Threads::split split)
 
virtual void pre () override
 Called before the node range loop. More...
 
virtual void onNode (ConstNodeRange::const_iterator &node_it) override
 
void join (const ComputeNodalKernelsThread &)
 
void operator() (const ConstNodeRange &range)
 
virtual void post ()
 Called after the node range loop. More...
 
virtual void onNode (ConstNodeRange::const_iterator &node_it)
 Called for each node. More...
 
virtual void postNode (ConstNodeRange::const_iterator &node_it)
 Called after the node assembly is done (including surface assembling) More...
 
virtual void caughtMooseException (MooseException &e)
 Called if a MooseException is caught anywhere during the computation. More...
 
virtual bool keepGoing ()
 Whether or not the loop should continue. More...
 

Protected Member Functions

void printGeneralExecutionInformation () const override
 Print execution order of object types in the loop. More...
 

Protected Attributes

FEProblemBase_fe_problem
 
AuxiliarySystem_aux_sys
 
const std::set< TagID > & _tags
 
MooseObjectTagWarehouse< NodalKernelBase > & _nodal_kernels
 
MooseObjectWarehouse< NodalKernelBase > * _nkernel_warehouse
 
unsigned int _num_cached
 Number of contributions cached up. More...
 
THREAD_ID _tid
 

Detailed Description

Definition at line 22 of file ComputeNodalKernelsThread.h.

Constructor & Destructor Documentation

◆ ComputeNodalKernelsThread() [1/2]

ComputeNodalKernelsThread::ComputeNodalKernelsThread ( FEProblemBase fe_problem,
MooseObjectTagWarehouse< NodalKernelBase > &  nodal_kernels,
const std::set< TagID > &  tags 
)

Definition at line 21 of file ComputeNodalKernelsThread.C.

26  _fe_problem(fe_problem),
27  _aux_sys(fe_problem.getAuxiliarySystem()),
28  _tags(tags),
29  _nodal_kernels(nodal_kernels),
30  _num_cached(0)
31 {
32 }
const std::set< TagID > & _tags
AuxiliarySystem & getAuxiliarySystem()
unsigned int _num_cached
Number of contributions cached up.
MooseObjectTagWarehouse< NodalKernelBase > & _nodal_kernels

◆ ComputeNodalKernelsThread() [2/2]

ComputeNodalKernelsThread::ComputeNodalKernelsThread ( ComputeNodalKernelsThread x,
Threads::split  split 
)

Definition at line 35 of file ComputeNodalKernelsThread.C.

39  _aux_sys(x._aux_sys),
40  _tags(x._tags),
41  _nodal_kernels(x._nodal_kernels),
42  _num_cached(0)
43 {
44 }
FEProblemBase & _fe_problem
const std::set< TagID > & _tags
tbb::split split
unsigned int _num_cached
Number of contributions cached up.
MooseObjectTagWarehouse< NodalKernelBase > & _nodal_kernels

Member Function Documentation

◆ caughtMooseException()

virtual void ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::caughtMooseException ( MooseException e)
inlinevirtualinherited

Called if a MooseException is caught anywhere during the computation.

The single input parameter taken is a MooseException object.

Definition at line 56 of file ThreadedNodeLoop.h.

57  {
58  Threads::spin_mutex::scoped_lock lock(threaded_node_mutex);
59 
60  std::string what(e.what());
62  };
virtual const char * what() const
Get out the error message.
virtual void setException(const std::string &message)
Set an exception, which is stored at this point by toggling a member variable in this class...
static Threads::spin_mutex threaded_node_mutex

◆ join()

void ComputeNodalKernelsThread::join ( const ComputeNodalKernelsThread )

Definition at line 101 of file ComputeNodalKernelsThread.C.

102 {
103 }

◆ keepGoing()

virtual bool ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::keepGoing ( )
inlinevirtualinherited

Whether or not the loop should continue.

Returns
true to keep going, false to stop.

Definition at line 69 of file ThreadedNodeLoop.h.

69 { return !_fe_problem.hasException(); }
virtual bool hasException()
Whether or not an exception has occurred.

◆ onNode() [1/2]

void ComputeNodalKernelsThread::onNode ( ConstNodeRange::const_iterator node_it)
overridevirtual

Definition at line 60 of file ComputeNodalKernelsThread.C.

61 {
62  const Node * node = *node_it;
63 
64  std::set<const NodalKernelBase *> nks_executed;
65 
66  // prepare variables
67  for (auto * var : _aux_sys._nodal_vars[_tid])
68  var->prepareAux();
69 
71 
72  const auto & block_ids = _aux_sys.mesh().getNodeBlockIds(*node);
73  for (const auto block : block_ids)
75  {
76  std::set<TagID> needed_fe_var_vector_tags;
78  block, needed_fe_var_vector_tags, _tid);
79  _fe_problem.setActiveFEVariableCoupleableVectorTags(needed_fe_var_vector_tags, _tid);
80 
81  const auto & objects = _nkernel_warehouse->getActiveBlockObjects(block, _tid);
82  for (const auto & nodal_kernel : objects)
83  if (nks_executed.emplace(nodal_kernel.get()).second)
84  {
85  nodal_kernel->setSubdomains(block_ids);
86  nodal_kernel->computeResidual();
87  }
88  }
89 
90  _num_cached++;
91 
92  if (_num_cached == 20) // Cache 20 nodes worth before adding into the residual
93  {
94  _num_cached = 0;
95  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
97  }
98 }
MooseMesh & mesh()
Definition: SystemBase.h:99
bool hasActiveBlockObjects(THREAD_ID tid=0) const
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
virtual void reinitNode(const Node *node, const THREAD_ID tid) override
const std::set< SubdomainID > & getNodeBlockIds(const Node &node) const
Return list of blocks to which the given node belongs.
Definition: MooseMesh.C:1496
MooseObjectWarehouse< NodalKernelBase > * _nkernel_warehouse
std::vector< std::vector< MooseVariableFEBase * > > _nodal_vars
void updateBlockFEVariableCoupledVectorTagDependency(SubdomainID id, std::set< TagID > &needed_fe_var_vector_tags, THREAD_ID tid=0) const
Update FE variable coupleable vector tag vector.
unsigned int _num_cached
Number of contributions cached up.
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid) override
virtual void addCachedResidual(const THREAD_ID tid) override

◆ onNode() [2/2]

Called for each node.

Definition at line 136 of file ThreadedNodeLoop.h.

137 {
138 }

◆ operator()()

void ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::operator() ( const ConstNodeRange range)
inherited

Definition at line 94 of file ThreadedNodeLoop.h.

95 {
96  try
97  {
98  ParallelUniqueId puid;
99  _tid = puid.id;
100 
101  pre();
103 
104  for (IteratorType nd = range.begin(); nd != range.end(); ++nd)
105  {
106  if (!keepGoing())
107  break;
108 
109  onNode(nd);
110 
111  postNode(nd);
112  }
113 
114  post();
115  }
116  catch (MooseException & e)
117  {
119  }
120 }
virtual void printGeneralExecutionInformation() const
Print information about the loop, mostly order of execution of objects.
virtual void caughtMooseException(MooseException &e)
Called if a MooseException is caught anywhere during the computation.
virtual bool keepGoing()
Whether or not the loop should continue.
const_iterator end() const
Provides a way for users to bail out of the current solve.
virtual void pre()
Called before the node range loop.
const_iterator begin() const
virtual void post()
Called after the node range loop.
virtual void postNode(ConstNodeRange::const_iterator &node_it)
Called after the node assembly is done (including surface assembling)
virtual void onNode(ConstNodeRange::const_iterator &node_it)
Called for each node.

◆ post()

Called after the node range loop.

Reimplemented in ComputeNodalAuxVarsThread< AuxKernelType >.

Definition at line 130 of file ThreadedNodeLoop.h.

131 {
132 }

◆ postNode()

Called after the node assembly is done (including surface assembling)

Parameters
node- active node

Definition at line 142 of file ThreadedNodeLoop.h.

143 {
144 }

◆ pre()

void ComputeNodalKernelsThread::pre ( )
overridevirtual

Called before the node range loop.

Reimplemented from ThreadedNodeLoop< ConstNodeRange, ConstNodeRange::const_iterator >.

Definition at line 47 of file ComputeNodalKernelsThread.C.

48 {
49  _num_cached = 0;
50 
53  else if (_tags.size() == 1)
55  else
57 }
MooseObjectWarehouse< T > & getVectorTagsObjectWarehouse(const std::set< TagID > &tags, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object at least has one of the given vector ta...
MooseObjectWarehouse< NodalKernelBase > * _nkernel_warehouse
const std::set< TagID > & _tags
unsigned int _num_cached
Number of contributions cached up.
virtual unsigned int numVectorTags(const Moose::VectorTagType type=Moose::VECTOR_TAG_ANY) const
The total number of tags, which can be limited to the tag type.
Definition: SubProblem.C:195
MooseObjectWarehouse< T > & getVectorTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given vector tag...
MooseObjectTagWarehouse< NodalKernelBase > & _nodal_kernels

◆ printGeneralExecutionInformation()

void ComputeNodalKernelsThread::printGeneralExecutionInformation ( ) const
overrideprotectedvirtual

Print execution order of object types in the loop.

Reimplemented from ThreadedNodeLoop< ConstNodeRange, ConstNodeRange::const_iterator >.

Definition at line 106 of file ComputeNodalKernelsThread.C.

107 {
109  return;
110 
111  const auto & console = _fe_problem.console();
112  const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
113  console << "[DBG] Computing nodal kernels contribution to residual on nodes on " << execute_on
114  << std::endl;
115  console << "[DBG] Nodes at boundaries between blocks will execute lower block ID first"
116  << std::endl;
117  console << "[DBG] Ordering of the nodal kernels on nodes they are defined on:" << std::endl;
118  console << _nkernel_warehouse->activeObjectsToFormattedString() << std::endl;
119 }
std::string activeObjectsToFormattedString(THREAD_ID tid=0, const std::string &prefix="[DBG]") const
Output the active content of the warehouse to a string, meant to be output to the console...
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
MooseObjectWarehouse< NodalKernelBase > * _nkernel_warehouse
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
const ConsoleStream & console() const
Return console handle.
Definition: Problem.h:48
bool hasActiveObjects(THREAD_ID tid=0) const

Member Data Documentation

◆ _aux_sys

AuxiliarySystem& ComputeNodalKernelsThread::_aux_sys
protected

Definition at line 45 of file ComputeNodalKernelsThread.h.

Referenced by onNode().

◆ _fe_problem

FEProblemBase& ComputeNodalKernelsThread::_fe_problem
protected

Definition at line 43 of file ComputeNodalKernelsThread.h.

Referenced by onNode(), pre(), and printGeneralExecutionInformation().

◆ _nkernel_warehouse

MooseObjectWarehouse<NodalKernelBase>* ComputeNodalKernelsThread::_nkernel_warehouse
protected

Definition at line 51 of file ComputeNodalKernelsThread.h.

Referenced by onNode(), pre(), and printGeneralExecutionInformation().

◆ _nodal_kernels

MooseObjectTagWarehouse<NodalKernelBase>& ComputeNodalKernelsThread::_nodal_kernels
protected

Definition at line 49 of file ComputeNodalKernelsThread.h.

Referenced by pre().

◆ _num_cached

unsigned int ComputeNodalKernelsThread::_num_cached
protected

Number of contributions cached up.

Definition at line 54 of file ComputeNodalKernelsThread.h.

Referenced by onNode(), and pre().

◆ _tags

const std::set<TagID>& ComputeNodalKernelsThread::_tags
protected

Definition at line 47 of file ComputeNodalKernelsThread.h.

Referenced by pre().

◆ _tid


The documentation for this class was generated from the following files: