www.mooseframework.org
ComputeNodalAuxVarsThread.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 "AuxKernel.h"
20 #include "FEProblem.h"
21 #include "MooseMesh.h"
22 
23 #include "libmesh/threads.h"
24 
26  FEProblemBase & fe_problem, const MooseObjectWarehouse<AuxKernel> & storage)
27  : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(fe_problem),
28  _aux_sys(fe_problem.getAuxiliarySystem()),
29  _storage(storage)
30 {
31 }
32 
33 // Splitting Constructor
35  Threads::split split)
36  : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(x, split),
37  _aux_sys(x._aux_sys),
39 {
40 }
41 
42 void
43 ComputeNodalAuxVarsThread::onNode(ConstNodeRange::const_iterator & node_it)
44 {
45  const Node * node = *node_it;
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  _fe_problem.reinitNode(node, _tid);
55 
56  // Get a map of all active block restricted AuxKernel objects
57  const auto & block_kernels = _storage.getActiveBlockObjects(_tid);
58 
59  // Loop over all SubdomainIDs for the curnent node, if an AuxKernel is active on this block then
60  // compute it.
61  const auto & block_ids = _aux_sys.mesh().getNodeBlockIds(*node);
62  for (const auto & block : block_ids)
63  {
64  const auto iter = block_kernels.find(block);
65 
66  if (iter != block_kernels.end())
67  for (const auto & aux : iter->second)
68  aux->compute();
69  }
70 
71  // We are done, so update the solution vector
72  {
73  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
74  for (const auto & it : _aux_sys._nodal_vars[_tid])
75  {
76  MooseVariable * var = it.second;
77  var->insert(_aux_sys.solution());
78  }
79  }
80 }
81 
82 void
84 {
85 }
void join(const ComputeNodalAuxVarsThread &)
Class for stuff related to variables.
Definition: MooseVariable.h:43
std::vector< std::map< std::string, MooseVariable * > > _nodal_vars
static PetscErrorCode Vec x
void onNode(ConstNodeRange::const_iterator &nd)
Called for each node.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
ComputeNodalAuxVarsThread(FEProblemBase &fe_problem, const MooseObjectWarehouse< AuxKernel > &storage)
const MooseObjectWarehouse< AuxKernel > & _storage
Storage object containing active AuxKernel objects.
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
const std::set< SubdomainID > & getNodeBlockIds(const Node &node) const
Return list of blocks to which the given node belongs.
Definition: MooseMesh.C:808
virtual NumericVector< Number > & solution() override
virtual MooseMesh & mesh()
Definition: SystemBase.h:102
virtual void reinitNode(const Node *node, THREAD_ID tid) override
void insert(NumericVector< Number > &residual)