www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
ComputeNodalKernelBcsThread Class Reference

#include <ComputeNodalKernelBcsThread.h>

Inheritance diagram for ComputeNodalKernelBcsThread:
[legend]

Public Member Functions

 ComputeNodalKernelBcsThread (FEProblemBase &fe_problem, MooseObjectTagWarehouse< NodalKernel > &nodal_kernels, const std::set< TagID > &tags)
 
 ComputeNodalKernelBcsThread (ComputeNodalKernelBcsThread &x, Threads::split split)
 
virtual void pre () override
 Called before the node range loop. More...
 
virtual void onNode (ConstBndNodeRange::const_iterator &node_it) override
 Called for each node. More...
 
void join (const ComputeNodalKernelBcsThread &)
 
void operator() (const ConstBndNodeRange &range)
 
virtual void post ()
 Called after the node range loop. More...
 
virtual void postNode (ConstBndNodeRange::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
 
THREAD_ID _tid
 

Detailed Description

Definition at line 20 of file ComputeNodalKernelBcsThread.h.

Constructor & Destructor Documentation

◆ ComputeNodalKernelBcsThread() [1/2]

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

◆ ComputeNodalKernelBcsThread() [2/2]

ComputeNodalKernelBcsThread::ComputeNodalKernelBcsThread ( ComputeNodalKernelBcsThread x,
Threads::split  split 
)

Definition at line 34 of file ComputeNodalKernelBcsThread.C.

37  _fe_problem(x._fe_problem),
38  _aux_sys(x._aux_sys),
39  _tags(x._tags),
40  _nodal_kernels(x._nodal_kernels),
41  _num_cached(0)
42 {
43 }
static PetscErrorCode Vec x
MooseObjectTagWarehouse< NodalKernel > & _nodal_kernels

Member Function Documentation

◆ caughtMooseException()

virtual void ThreadedNodeLoop< ConstBndNodeRange , ConstBndNodeRange::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 ComputeNodalKernelBcsThread::join ( const ComputeNodalKernelBcsThread )

Definition at line 95 of file ComputeNodalKernelBcsThread.C.

96 {
97 }

◆ keepGoing()

virtual bool ThreadedNodeLoop< ConstBndNodeRange , ConstBndNodeRange::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 ComputeNodalKernelBcsThread::onNode ( ConstBndNodeRange::const_iterator &  node_it)
overridevirtual

Called for each node.

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

Definition at line 59 of file ComputeNodalKernelBcsThread.C.

60 {
61  const BndNode * bnode = *node_it;
62 
63  BoundaryID boundary_id = bnode->_bnd_id;
64 
65  // prepare variables
66  for (const auto & it : _aux_sys._nodal_vars[_tid])
67  {
68  MooseVariable * var = it.second;
69  var->prepareAux();
70  }
71 
73  {
74  Node * node = bnode->_node;
75  if (node->processor_id() == _fe_problem.processor_id())
76  {
77  _fe_problem.reinitNodeFace(node, boundary_id, _tid);
78  const auto & objects = _nkernel_warehouse->getActiveBoundaryObjects(boundary_id, _tid);
79  for (const auto & nodal_kernel : objects)
80  nodal_kernel->computeResidual();
81 
82  _num_cached++;
83  }
84  }
85 
86  if (_num_cached == 20) // cache 20 nodes worth before adding into the residual
87  {
88  _num_cached = 0;
89  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
91  }
92 }
std::vector< std::map< std::string, MooseVariable * > > _nodal_vars
MooseObjectWarehouse< NodalKernel > * _nkernel_warehouse
BoundaryID _bnd_id
boundary id for the node
Definition: BndNode.h:23
Node * _node
pointer to the node
Definition: BndNode.h:21
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
virtual void addCachedResidual(THREAD_ID tid) override
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid) override
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
boundary_id_type BoundaryID
Definition: MooseTypes.h:93
void prepareAux() override

◆ operator()()

void ThreadedNodeLoop< ConstBndNodeRange , ConstBndNodeRange::const_iterator >::operator() ( const ConstBndNodeRange 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 postNode(ConstBndNodeRange::const_iterator &node_it)
Called after the node assembly is done (including surface assembling)
virtual void onNode(ConstBndNodeRange::const_iterator &node_it)
Called for each node.

◆ post()

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

Called after the node range loop.

Definition at line 123 of file ThreadedNodeLoop.h.

124 {
125 }

◆ postNode()

void ThreadedNodeLoop< ConstBndNodeRange , ConstBndNodeRange::const_iterator >::postNode ( ConstBndNodeRange::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 ComputeNodalKernelBcsThread::pre ( )
overridevirtual

Called before the node range loop.

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

Definition at line 46 of file ComputeNodalKernelBcsThread.C.

47 {
48  _num_cached = 0;
49 
50  if (!_tags.size() || _tags.size() == _fe_problem.numVectorTags())
52  else if (_tags.size() == 1)
54  else
56 }
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< NodalKernel > * _nkernel_warehouse
virtual unsigned int numVectorTags()
The total number of tags.
Definition: SubProblem.h:110
MooseObjectTagWarehouse< NodalKernel > & _nodal_kernels
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& ComputeNodalKernelBcsThread::_aux_sys
protected

Definition at line 39 of file ComputeNodalKernelBcsThread.h.

Referenced by onNode().

◆ _fe_problem

FEProblemBase& ComputeNodalKernelBcsThread::_fe_problem
protected

Definition at line 37 of file ComputeNodalKernelBcsThread.h.

Referenced by onNode(), and pre().

◆ _nkernel_warehouse

MooseObjectWarehouse<NodalKernel>* ComputeNodalKernelBcsThread::_nkernel_warehouse
protected

Definition at line 45 of file ComputeNodalKernelBcsThread.h.

Referenced by onNode(), and pre().

◆ _nodal_kernels

MooseObjectTagWarehouse<NodalKernel>& ComputeNodalKernelBcsThread::_nodal_kernels
protected

Definition at line 43 of file ComputeNodalKernelBcsThread.h.

Referenced by pre().

◆ _num_cached

unsigned int ComputeNodalKernelBcsThread::_num_cached
protected

Definition at line 48 of file ComputeNodalKernelBcsThread.h.

Referenced by onNode(), and pre().

◆ _tags

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

Definition at line 41 of file ComputeNodalKernelBcsThread.h.

Referenced by pre().

◆ _tid

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

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