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, MooseObjectTagWarehouse< NodalKernel > &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
 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

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

Detailed Description

Definition at line 23 of file ComputeNodalKernelsThread.h.

Constructor & Destructor Documentation

◆ ComputeNodalKernelsThread() [1/2]

ComputeNodalKernelsThread::ComputeNodalKernelsThread ( FEProblemBase fe_problem,
MooseObjectTagWarehouse< NodalKernel > &  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 }
MooseObjectTagWarehouse< NodalKernel > & _nodal_kernels
const std::set< TagID > & _tags
AuxiliarySystem & getAuxiliarySystem()
unsigned int _num_cached
Number of contributions cached up.

◆ ComputeNodalKernelsThread() [2/2]

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

Definition at line 35 of file ComputeNodalKernelsThread.C.

38  _fe_problem(x._fe_problem),
39  _aux_sys(x._aux_sys),
40  _tags(x._tags),
41  _nodal_kernels(x._nodal_kernels),
42  _num_cached(0)
43 {
44 }
MooseObjectTagWarehouse< NodalKernel > & _nodal_kernels
static PetscErrorCode Vec x
const std::set< TagID > & _tags
unsigned int _num_cached
Number of contributions cached up.

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

56  {
57  std::string what(e.what());
59  };
virtual const char * what() const
Get out the error message.
virtual void setException(const std::string &message)
Set an exception.

◆ join()

void ComputeNodalKernelsThread::join ( const ComputeNodalKernelsThread )

Definition at line 93 of file ComputeNodalKernelsThread.C.

94 {
95 }

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

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

◆ onNode()

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

Called for each node.

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

Definition at line 60 of file ComputeNodalKernelsThread.C.

61 {
62  const Node * node = *node_it;
63 
64  // prepare variables
65  for (const auto & it : _aux_sys._nodal_vars[_tid])
66  {
67  MooseVariable * var = it.second;
68  var->prepareAux();
69  }
70 
72 
73  const std::set<SubdomainID> & block_ids = _aux_sys.mesh().getNodeBlockIds(*node);
74  for (const auto & block : block_ids)
76  {
77  const auto & objects = _nkernel_warehouse->getActiveBlockObjects(block, _tid);
78  for (const auto & nodal_kernel : objects)
79  nodal_kernel->computeResidual();
80  }
81 
82  _num_cached++;
83 
84  if (_num_cached == 20) // Cache 20 nodes worth before adding into the residual
85  {
86  _num_cached = 0;
87  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
89  }
90 }
MooseObjectWarehouse< NodalKernel > * _nkernel_warehouse
bool hasActiveBlockObjects(THREAD_ID tid=0) const
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
std::vector< std::map< std::string, MooseVariable * > > _nodal_vars
const std::set< SubdomainID > & getNodeBlockIds(const Node &node) const
Return list of blocks to which the given node belongs.
Definition: MooseMesh.C:883
virtual void addCachedResidual(THREAD_ID tid) override
virtual MooseMesh & mesh()
Definition: SystemBase.h:102
unsigned int _num_cached
Number of contributions cached up.
virtual void reinitNode(const Node *node, THREAD_ID tid) override
void prepareAux() override

◆ operator()()

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

Definition at line 88 of file ThreadedNodeLoop.h.

89 {
90  try
91  {
92  ParallelUniqueId puid;
93  _tid = puid.id;
94 
95  pre();
96 
97  for (IteratorType nd = range.begin(); nd != range.end(); ++nd)
98  {
99  if (!keepGoing())
100  break;
101 
102  onNode(nd);
103 
104  postNode(nd);
105  }
106 
107  post();
108  }
109  catch (MooseException & e)
110  {
112  }
113 }
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.
Provides a way for users to bail out of the current solve.
virtual void pre()
Called before the node range loop.
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()

void ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::post ( )
virtualinherited

Called after the node range loop.

Reimplemented in ComputeNodalAuxVarsThread.

Definition at line 123 of file ThreadedNodeLoop.h.

124 {
125 }

◆ postNode()

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

Definition at line 135 of file ThreadedNodeLoop.h.

136 {
137 }

◆ 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 
51  if (!_tags.size() || _tags.size() == _fe_problem.numVectorTags())
53  else if (_tags.size() == 1)
55  else
57 }
MooseObjectWarehouse< NodalKernel > * _nkernel_warehouse
MooseObjectTagWarehouse< NodalKernel > & _nodal_kernels
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...
virtual unsigned int numVectorTags()
The total number of tags.
Definition: SubProblem.h:110
const std::set< TagID > & _tags
unsigned int _num_cached
Number of contributions cached up.
MooseObjectWarehouse< T > & getVectorTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given vector tag...

Member Data Documentation

◆ _aux_sys

AuxiliarySystem& ComputeNodalKernelsThread::_aux_sys
protected

Definition at line 43 of file ComputeNodalKernelsThread.h.

Referenced by onNode().

◆ _fe_problem

FEProblemBase& ComputeNodalKernelsThread::_fe_problem
protected

Definition at line 41 of file ComputeNodalKernelsThread.h.

Referenced by onNode(), and pre().

◆ _nkernel_warehouse

MooseObjectWarehouse<NodalKernel>* ComputeNodalKernelsThread::_nkernel_warehouse
protected

Definition at line 49 of file ComputeNodalKernelsThread.h.

Referenced by onNode(), and pre().

◆ _nodal_kernels

MooseObjectTagWarehouse<NodalKernel>& ComputeNodalKernelsThread::_nodal_kernels
protected

Definition at line 47 of file ComputeNodalKernelsThread.h.

Referenced by pre().

◆ _num_cached

unsigned int ComputeNodalKernelsThread::_num_cached
protected

Number of contributions cached up.

Definition at line 52 of file ComputeNodalKernelsThread.h.

Referenced by onNode(), and pre().

◆ _tags

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

Definition at line 45 of file ComputeNodalKernelsThread.h.

Referenced by pre().

◆ _tid

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

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