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

#include <ComputeNodalKernelBCJacobiansThread.h>

Inheritance diagram for ComputeNodalKernelBCJacobiansThread:
[legend]

Public Member Functions

 ComputeNodalKernelBCJacobiansThread (FEProblemBase &fe_problem, MooseObjectTagWarehouse< NodalKernel > &nodal_kernels, const std::set< TagID > &tags)
 
 ComputeNodalKernelBCJacobiansThread (ComputeNodalKernelBCJacobiansThread &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 ComputeNodalKernelBCJacobiansThread &)
 
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
 Number of contributions cached up. More...
 
THREAD_ID _tid
 

Detailed Description

Definition at line 20 of file ComputeNodalKernelBCJacobiansThread.h.

Constructor & Destructor Documentation

◆ ComputeNodalKernelBCJacobiansThread() [1/2]

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

◆ ComputeNodalKernelBCJacobiansThread() [2/2]

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

Definition at line 144 of file ComputeNodalKernelBCJacobiansThread.C.

145 {
146 }

◆ 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 ComputeNodalKernelBCJacobiansThread::onNode ( ConstBndNodeRange::const_iterator &  node_it)
overridevirtual

Called for each node.

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

Definition at line 60 of file ComputeNodalKernelBCJacobiansThread.C.

61 {
62  const BndNode * bnode = *node_it;
63 
64  BoundaryID boundary_id = bnode->_bnd_id;
65 
66  std::vector<std::pair<MooseVariableFEBase *, MooseVariableFEBase *>> & ce =
68  for (const auto & it : ce)
69  {
70  MooseVariableFEBase & ivariable = *(it.first);
71  MooseVariableFEBase & jvariable = *(it.second);
72 
73  unsigned int ivar = ivariable.number();
74  unsigned int jvar = jvariable.number();
75 
76  // The NodalKernels that are active and are coupled to the jvar in question
77  std::vector<std::shared_ptr<NodalKernel>> active_involved_kernels;
78 
80  {
81  // Loop over each NodalKernel to see if it's involved with the jvar
82  const auto & objects = _nkernel_warehouse->getActiveBoundaryObjects(boundary_id, _tid);
83  for (const auto & nodal_kernel : objects)
84  {
85  if (nodal_kernel->variable().number() == ivar)
86  {
87  // If this NodalKernel is acting on the jvar add it to the list and short-circuit the
88  // loop
89  if (nodal_kernel->variable().number() == jvar)
90  {
91  active_involved_kernels.push_back(nodal_kernel);
92  continue;
93  }
94 
95  // See if this NodalKernel is coupled to the jvar
96  const std::vector<MooseVariableFEBase *> & coupled_vars =
97  nodal_kernel->getCoupledMooseVars();
98  for (const auto & var : coupled_vars)
99  {
100  if (var->number() == jvar)
101  {
102  active_involved_kernels.push_back(nodal_kernel);
103  break; // It only takes one
104  }
105  }
106  }
107  }
108  }
109 
110  // Did we find any NodalKernels coupled to this jvar?
111  if (!active_involved_kernels.empty())
112  {
113  // prepare variables
114  for (const auto & it : _aux_sys._nodal_vars[_tid])
115  {
116  MooseVariable * var = it.second;
117  var->prepareAux();
118  }
119 
121  {
122  Node * node = bnode->_node;
123  if (node->processor_id() == _fe_problem.processor_id())
124  {
125  _fe_problem.reinitNodeFace(node, boundary_id, _tid);
126  for (const auto & nodal_kernel : active_involved_kernels)
127  nodal_kernel->computeOffDiagJacobian(jvar);
128 
129  _num_cached++;
130  }
131  }
132 
133  if (_num_cached == 20) // cache 20 nodes worth before adding into the jacobian
134  {
135  _num_cached = 0;
136  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
138  }
139  }
140  }
141 }
std::vector< std::map< std::string, MooseVariable * > > _nodal_vars
unsigned int number() const
Get variable number coming from libMesh.
virtual Assembly & assembly(THREAD_ID tid) override
BoundaryID _bnd_id
boundary id for the node
Definition: BndNode.h:23
Node * _node
pointer to the node
Definition: BndNode.h:21
std::vector< std::pair< MooseVariableFEBase *, MooseVariableFEBase * > > & couplingEntries(THREAD_ID tid)
MooseObjectWarehouse< NodalKernel > * _nkernel_warehouse
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
unsigned int _num_cached
Number of contributions cached up.
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
void addCachedJacobianContributions()
Adds previously-cached Jacobian values via SparseMatrix::add() calls.
Definition: Assembly.C:2201
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 ComputeNodalKernelBCJacobiansThread::pre ( )
overridevirtual

Called before the node range loop.

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

Definition at line 47 of file ComputeNodalKernelBCJacobiansThread.C.

48 {
49  _num_cached = 0;
50 
51  if (!_tags.size() || _tags.size() == _fe_problem.numMatrixTags())
53  else if (_tags.size() == 1)
55  else
57 }
MooseObjectWarehouse< NodalKernel > * _nkernel_warehouse
MooseObjectTagWarehouse< NodalKernel > & _nodal_kernels
unsigned int _num_cached
Number of contributions cached up.
MooseObjectWarehouse< T > & getMatrixTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given matrix tag...
MooseObjectWarehouse< T > & getMatrixTagsObjectWarehouse(const std::set< TagID > &tags, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has one of the given matrix tags...
virtual unsigned int numMatrixTags()
The total number of tags.
Definition: SubProblem.h:145

Member Data Documentation

◆ _aux_sys

AuxiliarySystem& ComputeNodalKernelBCJacobiansThread::_aux_sys
protected

Definition at line 41 of file ComputeNodalKernelBCJacobiansThread.h.

Referenced by onNode().

◆ _fe_problem

FEProblemBase& ComputeNodalKernelBCJacobiansThread::_fe_problem
protected

Definition at line 39 of file ComputeNodalKernelBCJacobiansThread.h.

Referenced by onNode(), and pre().

◆ _nkernel_warehouse

MooseObjectWarehouse<NodalKernel>* ComputeNodalKernelBCJacobiansThread::_nkernel_warehouse
protected

Definition at line 47 of file ComputeNodalKernelBCJacobiansThread.h.

Referenced by onNode(), and pre().

◆ _nodal_kernels

MooseObjectTagWarehouse<NodalKernel>& ComputeNodalKernelBCJacobiansThread::_nodal_kernels
protected

Definition at line 45 of file ComputeNodalKernelBCJacobiansThread.h.

Referenced by pre().

◆ _num_cached

unsigned int ComputeNodalKernelBCJacobiansThread::_num_cached
protected

Number of contributions cached up.

Definition at line 50 of file ComputeNodalKernelBCJacobiansThread.h.

Referenced by onNode(), and pre().

◆ _tags

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

Definition at line 43 of file ComputeNodalKernelBCJacobiansThread.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: