www.mooseframework.org
Public Member Functions | Protected 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< NodalKernelBase > &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 Member Functions

void printGeneralExecutionInformation () const override
 Print information about the loop, mostly order of execution of objects. 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
 
THREAD_ID _tid
 

Detailed Description

Definition at line 19 of file ComputeNodalKernelBcsThread.h.

Constructor & Destructor Documentation

◆ ComputeNodalKernelBcsThread() [1/2]

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

Definition at line 20 of file ComputeNodalKernelBcsThread.C.

◆ ComputeNodalKernelBcsThread() [2/2]

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

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 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 ComputeNodalKernelBcsThread::join ( const ComputeNodalKernelBcsThread )

Definition at line 97 of file ComputeNodalKernelBcsThread.C.

98 {
99 }

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

69 { 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 (auto * var : _aux_sys._nodal_vars[_tid])
67  var->prepareAux();
68 
70  {
71  Node * node = bnode->_node;
72  if (node->processor_id() == _fe_problem.processor_id())
73  {
74  std::set<TagID> needed_fe_var_vector_tags;
76  boundary_id, needed_fe_var_vector_tags, _tid);
77  _fe_problem.setActiveFEVariableCoupleableVectorTags(needed_fe_var_vector_tags, _tid);
78 
79  _fe_problem.reinitNodeFace(node, boundary_id, _tid);
80  const auto & objects = _nkernel_warehouse->getActiveBoundaryObjects(boundary_id, _tid);
81  for (const auto & nodal_kernel : objects)
82  nodal_kernel->computeResidual();
83 
84  _num_cached++;
85  }
86  }
87 
88  if (_num_cached == 20) // cache 20 nodes worth before adding into the residual
89  {
90  _num_cached = 0;
91  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
93  }
94 }
MooseObjectWarehouse< NodalKernelBase > * _nkernel_warehouse
BoundaryID _bnd_id
boundary id for the node
Definition: BndNode.h:26
Node * _node
pointer to the node
Definition: BndNode.h:24
void updateBoundaryFEVariableCoupledVectorTagDependency(BoundaryID id, std::set< TagID > &needed_fe_var_vector_tags, THREAD_ID tid=0) const
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
boundary_id_type BoundaryID
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
std::vector< std::vector< MooseVariableFEBase * > > _nodal_vars
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid) override
processor_id_type processor_id() const
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
virtual void addCachedResidual(const THREAD_ID tid) override

◆ operator()()

void ThreadedNodeLoop< ConstBndNodeRange , ConstBndNodeRange::const_iterator >::operator() ( const ConstBndNodeRange 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.
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 130 of file ThreadedNodeLoop.h.

131 {
132 }

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

143 {
144 }

◆ 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 
52  else if (_tags.size() == 1)
54  else
56 }
MooseObjectWarehouse< NodalKernelBase > * _nkernel_warehouse
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(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:172
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 ComputeNodalKernelBcsThread::printGeneralExecutionInformation ( ) const
overrideprotectedvirtual

Print information about the loop, mostly order of execution of objects.

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

Definition at line 102 of file ComputeNodalKernelBcsThread.C.

103 {
105  return;
106 
107  const auto & console = _fe_problem.console();
108  const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
109  console << "[DBG] Executing nodal kernels contribution to residual on nodes on " << execute_on
110  << std::endl;
111  console << "[DBG] Ordering of the nodal kernels on the nodes they are defined on:" << std::endl;
112  console << _nkernel_warehouse->activeObjectsToFormattedString() << std::endl;
113 }
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...
MooseObjectWarehouse< NodalKernelBase > * _nkernel_warehouse
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
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& ComputeNodalKernelBcsThread::_aux_sys
protected

Definition at line 41 of file ComputeNodalKernelBcsThread.h.

Referenced by onNode().

◆ _fe_problem

FEProblemBase& ComputeNodalKernelBcsThread::_fe_problem
protected

Definition at line 39 of file ComputeNodalKernelBcsThread.h.

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

◆ _nkernel_warehouse

MooseObjectWarehouse<NodalKernelBase>* ComputeNodalKernelBcsThread::_nkernel_warehouse
protected

Definition at line 47 of file ComputeNodalKernelBcsThread.h.

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

◆ _nodal_kernels

MooseObjectTagWarehouse<NodalKernelBase>& ComputeNodalKernelBcsThread::_nodal_kernels
protected

Definition at line 45 of file ComputeNodalKernelBcsThread.h.

Referenced by pre().

◆ _num_cached

unsigned int ComputeNodalKernelBcsThread::_num_cached
protected

Definition at line 50 of file ComputeNodalKernelBcsThread.h.

Referenced by onNode(), and pre().

◆ _tags

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

Definition at line 43 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: