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, const MooseObjectWarehouse< NodalKernel > &nodal_kernels, SparseMatrix< Number > &jacobian)
 
 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

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

Detailed Description

Definition at line 24 of file ComputeNodalKernelBCJacobiansThread.h.

Constructor & Destructor Documentation

ComputeNodalKernelBCJacobiansThread::ComputeNodalKernelBCJacobiansThread ( FEProblemBase fe_problem,
const MooseObjectWarehouse< NodalKernel > &  nodal_kernels,
SparseMatrix< Number > &  jacobian 
)
ComputeNodalKernelBCJacobiansThread::ComputeNodalKernelBCJacobiansThread ( ComputeNodalKernelBCJacobiansThread x,
Threads::split  split 
)

Definition at line 39 of file ComputeNodalKernelBCJacobiansThread.C.

42  _aux_sys(x._aux_sys),
43  _nodal_kernels(x._nodal_kernels),
44  _jacobian(x._jacobian),
45  _num_cached(0)
46 {
47 }
const MooseObjectWarehouse< NodalKernel > & _nodal_kernels
static PetscErrorCode Vec x
unsigned int _num_cached
Number of contributions cached up.

Member Function Documentation

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

Definition at line 138 of file ComputeNodalKernelBCJacobiansThread.C.

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

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

Called for each node.

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

Definition at line 56 of file ComputeNodalKernelBCJacobiansThread.C.

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

Called after the node range loop.

virtual 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
void ComputeNodalKernelBCJacobiansThread::pre ( )
overridevirtual

Called before the node range loop.

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

Definition at line 50 of file ComputeNodalKernelBCJacobiansThread.C.

51 {
52  _num_cached = 0;
53 }
unsigned int _num_cached
Number of contributions cached up.

Member Data Documentation

AuxiliarySystem& ComputeNodalKernelBCJacobiansThread::_aux_sys
protected

Definition at line 43 of file ComputeNodalKernelBCJacobiansThread.h.

Referenced by onNode().

FEProblemBase& ThreadedNodeLoop< ConstBndNodeRange , ConstBndNodeRange::const_iterator >::_fe_problem
protectedinherited
SparseMatrix<Number>& ComputeNodalKernelBCJacobiansThread::_jacobian
protected

Definition at line 47 of file ComputeNodalKernelBCJacobiansThread.h.

Referenced by onNode().

const MooseObjectWarehouse<NodalKernel>& ComputeNodalKernelBCJacobiansThread::_nodal_kernels
protected

Definition at line 45 of file ComputeNodalKernelBCJacobiansThread.h.

Referenced by onNode().

unsigned int ComputeNodalKernelBCJacobiansThread::_num_cached
protected

Number of contributions cached up.

Definition at line 50 of file ComputeNodalKernelBCJacobiansThread.h.

Referenced by onNode(), and pre().

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

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