www.mooseframework.org
ComputeNodalUserObjectsThread.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 "FEProblem.h"
19 #include "MooseMesh.h"
20 #include "NodalUserObject.h"
21 
22 #include "libmesh/threads.h"
23 
25  FEProblemBase & fe_problem, const MooseObjectWarehouse<NodalUserObject> & user_objects)
26  : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(fe_problem),
27  _user_objects(user_objects)
28 {
29 }
30 
31 // Splitting Constructor
33  Threads::split split)
34  : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(x, split),
36 {
37 }
38 
40 
41 void
42 ComputeNodalUserObjectsThread::onNode(ConstNodeRange::const_iterator & node_it)
43 {
44  const Node * node = *node_it;
46 
47  // Boundary Restricted
48  std::vector<BoundaryID> nodeset_ids;
49  _fe_problem.mesh().getMesh().get_boundary_info().boundary_ids(node, nodeset_ids);
50  for (const auto & bnd : nodeset_ids)
51  {
53  {
54  const auto & objects = _user_objects.getActiveBoundaryObjects(bnd, _tid);
55  for (const auto & uo : objects)
56  uo->execute();
57  }
58  }
59 
60  // Block Restricted
61  // NodalUserObjects may be block restricted, in this case by default the execute() method is
62  // called for
63  // each subdomain that the node "belongs". This may be disabled in the NodalUserObject by setting
64  // "unique_node_execute = true".
65 
66  // To inforce the unique execution this vector is populated and checked if the unique flag is
67  // enabled.
68  std::vector<std::shared_ptr<NodalUserObject>> computed;
69 
70  const std::set<SubdomainID> & block_ids = _fe_problem.mesh().getNodeBlockIds(*node);
71  for (const auto & block : block_ids)
73  {
74  const auto & objects = _user_objects.getActiveBlockObjects(block, _tid);
75  for (const auto & uo : objects)
76  if (!uo->isUniqueNodeExecute() || std::count(computed.begin(), computed.end(), uo) == 0)
77  {
78  uo->execute();
79  computed.push_back(uo);
80  }
81  }
82 }
83 
84 void
86 {
87 }
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
ComputeNodalUserObjectsThread(FEProblemBase &fe_problem, const MooseObjectWarehouse< NodalUserObject > &user_objects)
static PetscErrorCode Vec x
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:2408
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
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 MooseMesh & mesh() override
void join(const ComputeNodalUserObjectsThread &)
const MooseObjectWarehouse< NodalUserObject > & _user_objects
Storage for NodalUserObjects (see FEProblemBase::cmputeUserObjects)
bool hasActiveBlockObjects(THREAD_ID tid=0) const
virtual void onNode(ConstNodeRange::const_iterator &node_it) override
Called for each node.
virtual void reinitNode(const Node *node, THREAD_ID tid) override