www.mooseframework.org
ComputeNodalKernelBcsThread.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
16 
17 // MOOSE includes
18 #include "AuxiliarySystem.h"
19 #include "FEProblem.h"
20 #include "MooseVariable.h"
21 #include "NodalKernel.h"
22 
23 #include "libmesh/threads.h"
24 
26  FEProblemBase & fe_problem, const MooseObjectWarehouse<NodalKernel> & nodal_kernels)
27  : ThreadedNodeLoop<ConstBndNodeRange, ConstBndNodeRange::const_iterator>(fe_problem),
28  _aux_sys(fe_problem.getAuxiliarySystem()),
29  _nodal_kernels(nodal_kernels),
30  _num_cached(0)
31 {
32 }
33 
34 // Splitting Constructor
36  Threads::split split)
37  : ThreadedNodeLoop<ConstBndNodeRange, ConstBndNodeRange::const_iterator>(x, split),
38  _aux_sys(x._aux_sys),
40  _num_cached(0)
41 {
42 }
43 
44 void
46 {
47  _num_cached = 0;
48 }
49 
50 void
51 ComputeNodalKernelBcsThread::onNode(ConstBndNodeRange::const_iterator & node_it)
52 {
53  const BndNode * bnode = *node_it;
54 
55  BoundaryID boundary_id = bnode->_bnd_id;
56 
57  // prepare variables
58  for (const auto & it : _aux_sys._nodal_vars[_tid])
59  {
60  MooseVariable * var = it.second;
61  var->prepareAux();
62  }
63 
64  if (_nodal_kernels.hasActiveBoundaryObjects(boundary_id, _tid))
65  {
66  Node * node = bnode->_node;
67  if (node->processor_id() == _fe_problem.processor_id())
68  {
69  _fe_problem.reinitNodeFace(node, boundary_id, _tid);
70  const auto & objects = _nodal_kernels.getActiveBoundaryObjects(boundary_id, _tid);
71  for (const auto & nodal_kernel : objects)
72  nodal_kernel->computeResidual();
73 
74  _num_cached++;
75  }
76  }
77 
78  if (_num_cached == 20) // cache 20 nodes worth before adding into the residual
79  {
80  _num_cached = 0;
81  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
83  }
84 }
85 
86 void
88 {
89 }
virtual void pre() override
Called before the node range loop.
Class for stuff related to variables.
Definition: MooseVariable.h:43
std::vector< std::map< std::string, MooseVariable * > > _nodal_vars
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
static PetscErrorCode Vec x
virtual void onNode(ConstBndNodeRange::const_iterator &node_it) override
Called for each node.
BoundaryID _bnd_id
boundary id for the node
Definition: BndNode.h:28
Node * _node
pointer to the node
Definition: BndNode.h:26
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
ComputeNodalKernelBcsThread(FEProblemBase &fe_problem, const MooseObjectWarehouse< NodalKernel > &nodal_kernels)
virtual void addCachedResidual(THREAD_ID tid) override
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
const MooseObjectWarehouse< NodalKernel > & _nodal_kernels
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid) override
void join(const ComputeNodalKernelBcsThread &)
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > ConstBndNodeRange
Some useful StoredRange typedefs.
Definition: MooseMesh.h:1184
boundary_id_type BoundaryID
Definition: MooseTypes.h:75