www.mooseframework.org
ComputeNodalAuxBcsThread.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 
15 #include "libmesh/threads.h"
16 
17 // MOOSE includes
19 #include "AuxiliarySystem.h"
20 #include "FEProblem.h"
21 #include "AuxKernel.h"
22 
24  const MooseObjectWarehouse<AuxKernel> & storage)
25  : ThreadedNodeLoop<ConstBndNodeRange, ConstBndNodeRange::const_iterator>(fe_problem),
26  _aux_sys(fe_problem.getAuxiliarySystem()),
27  _storage(storage)
28 {
29 }
30 
31 // Splitting Constructor
33  Threads::split split)
34  : ThreadedNodeLoop<ConstBndNodeRange, ConstBndNodeRange::const_iterator>(x, split),
35  _aux_sys(x._aux_sys),
37 {
38 }
39 
40 void
41 ComputeNodalAuxBcsThread::onNode(ConstBndNodeRange::const_iterator & node_it)
42 {
43  const BndNode * bnode = *node_it;
44 
45  BoundaryID boundary_id = bnode->_bnd_id;
46 
47  // prepare variables
48  for (const auto & it : _aux_sys._nodal_vars[_tid])
49  {
50  MooseVariable * var = it.second;
51  var->prepareAux();
52  }
53 
54  Node * node = bnode->_node;
55 
56  if (node->processor_id() == _fe_problem.processor_id())
57  {
58  // Get a map of all active block restricted AuxKernel objects
59  const auto & kernels = _storage.getActiveBoundaryObjects(_tid);
60 
61  // Operate on the node BoundaryID only
62  const auto iter = kernels.find(boundary_id);
63  if (iter != kernels.end())
64  {
65  _fe_problem.reinitNodeFace(node, boundary_id, _tid);
66 
67  for (const auto & aux : iter->second)
68  aux->compute();
69  }
70  }
71 
72  // We are done, so update the solution vector
73  {
74  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
75  // update the solution vector
76  for (const auto & it : _aux_sys._nodal_vars[_tid])
77  {
78  MooseVariable * var = it.second;
79  var->insert(_aux_sys.solution());
80  }
81  }
82 }
83 
84 void
86 {
87 }
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
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.
ComputeNodalAuxBcsThread(FEProblemBase &fe_problem, const MooseObjectWarehouse< AuxKernel > &storage)
void join(const ComputeNodalAuxBcsThread &)
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid) override
virtual NumericVector< Number > & solution() override
const MooseObjectWarehouse< AuxKernel > & _storage
Storage object containing active AuxKernel objects.
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > ConstBndNodeRange
Some useful StoredRange typedefs.
Definition: MooseMesh.h:1213
virtual void onNode(ConstBndNodeRange::const_iterator &node_it) override
Called for each node.
void insert(NumericVector< Number > &residual)
boundary_id_type BoundaryID
Definition: MooseTypes.h:75