www.mooseframework.org
Public 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, const MooseObjectWarehouse< NodalKernel > &nodal_kernels)
 
 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
 Called for each node. More...
 
void join (const ComputeNodalKernelsThread &)
 
void operator() (const ConstNodeRange &range)
 
virtual void post ()
 Called after the node range loop. 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 Attributes

AuxiliarySystem_aux_sys
 
const MooseObjectWarehouse< NodalKernel > & _nodal_kernels
 
unsigned int _num_cached
 Number of contributions cached up. More...
 
FEProblemBase_fe_problem
 
THREAD_ID _tid
 

Detailed Description

Definition at line 27 of file ComputeNodalKernelsThread.h.

Constructor & Destructor Documentation

ComputeNodalKernelsThread::ComputeNodalKernelsThread ( FEProblemBase fe_problem,
const MooseObjectWarehouse< NodalKernel > &  nodal_kernels 
)

Definition at line 26 of file ComputeNodalKernelsThread.C.

29  _aux_sys(fe_problem.getAuxiliarySystem()),
30  _nodal_kernels(nodal_kernels),
31  _num_cached(0)
32 {
33 }
const MooseObjectWarehouse< NodalKernel > & _nodal_kernels
AuxiliarySystem & getAuxiliarySystem()
unsigned int _num_cached
Number of contributions cached up.
ComputeNodalKernelsThread::ComputeNodalKernelsThread ( ComputeNodalKernelsThread x,
Threads::split  split 
)

Definition at line 36 of file ComputeNodalKernelsThread.C.

39  _aux_sys(x._aux_sys),
40  _nodal_kernels(x._nodal_kernels),
41  _num_cached(0)
42 {
43 }
const MooseObjectWarehouse< NodalKernel > & _nodal_kernels
static PetscErrorCode Vec x
unsigned int _num_cached
Number of contributions cached up.

Member Function Documentation

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 60 of file ThreadedNodeLoop.h.

61  {
62  std::string what(e.what());
64  };
virtual void setException(const std::string &message)
Set an exception.
virtual const char * what() const
Get out the error message.
void ComputeNodalKernelsThread::join ( const ComputeNodalKernelsThread )

Definition at line 85 of file ComputeNodalKernelsThread.C.

86 {
87 }
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 71 of file ThreadedNodeLoop.h.

71 { return !_fe_problem.hasException(); }
virtual bool hasException()
Whether or not an exception has occurred.
void ComputeNodalKernelsThread::onNode ( ConstNodeRange::const_iterator &  node_it)
overridevirtual

Called for each node.

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

Definition at line 52 of file ComputeNodalKernelsThread.C.

53 {
54  const Node * node = *node_it;
55 
56  // prepare variables
57  for (const auto & it : _aux_sys._nodal_vars[_tid])
58  {
59  MooseVariable * var = it.second;
60  var->prepareAux();
61  }
62 
63  _fe_problem.reinitNode(node, _tid);
64 
65  const std::set<SubdomainID> & block_ids = _aux_sys.mesh().getNodeBlockIds(*node);
66  for (const auto & block : block_ids)
67  if (_nodal_kernels.hasActiveBlockObjects(block, _tid))
68  {
69  const auto & objects = _nodal_kernels.getActiveBlockObjects(block, _tid);
70  for (const auto & nodal_kernel : objects)
71  nodal_kernel->computeResidual();
72  }
73 
74  _num_cached++;
75 
76  if (_num_cached == 20) // Cache 20 nodes worth before adding into the residual
77  {
78  _num_cached = 0;
79  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
81  }
82 }
const MooseObjectWarehouse< NodalKernel > & _nodal_kernels
Class for stuff related to variables.
Definition: MooseVariable.h:43
std::vector< std::map< std::string, MooseVariable * > > _nodal_vars
virtual void addCachedResidual(THREAD_ID tid) override
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
const std::set< SubdomainID > & getNodeBlockIds(const Node &node) const
Return list of blocks to which the given node belongs.
Definition: MooseMesh.C:769
virtual MooseMesh & mesh()
Definition: SystemBase.h:102
unsigned int _num_cached
Number of contributions cached up.
bool hasActiveBlockObjects(THREAD_ID tid=0) const
virtual void reinitNode(const Node *node, THREAD_ID tid) override
void ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::operator() ( const ConstNodeRange &  range)
inherited
virtual void ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::post ( )
virtualinherited

Called after the node range loop.

virtual void ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::postNode ( ConstNodeRange::const_iterator &  node_it)
virtualinherited

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

Parameters
node- active node
void ComputeNodalKernelsThread::pre ( )
overridevirtual

Called before the node range loop.

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

Definition at line 46 of file ComputeNodalKernelsThread.C.

47 {
48  _num_cached = 0;
49 }
unsigned int _num_cached
Number of contributions cached up.

Member Data Documentation

AuxiliarySystem& ComputeNodalKernelsThread::_aux_sys
protected

Definition at line 44 of file ComputeNodalKernelsThread.h.

Referenced by onNode().

FEProblemBase& ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::_fe_problem
protectedinherited
const MooseObjectWarehouse<NodalKernel>& ComputeNodalKernelsThread::_nodal_kernels
protected

Definition at line 46 of file ComputeNodalKernelsThread.h.

Referenced by onNode().

unsigned int ComputeNodalKernelsThread::_num_cached
protected

Number of contributions cached up.

Definition at line 49 of file ComputeNodalKernelsThread.h.

Referenced by onNode(), and pre().

THREAD_ID ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::_tid
protectedinherited

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