www.mooseframework.org
ComputeNodalUserObjectsThread.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 
12 // MOOSE includes
13 #include "FEProblem.h"
14 #include "MooseMesh.h"
15 #include "NodalUserObject.h"
16 
17 #include "libmesh/threads.h"
18 
20  const TheWarehouse::Query & query)
21  : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(fe_problem), _query(query)
22 {
23 }
24 
25 // Splitting Constructor
28  : ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(x, split), _query(x._query)
29 {
30 }
31 
33 
34 void
35 ComputeNodalUserObjectsThread::onNode(ConstNodeRange::const_iterator & node_it)
36 {
37  const Node * node = *node_it;
39 
40  std::vector<NodalUserObject *> objs;
41 
42  // Boundary Restricted
43  std::vector<BoundaryID> nodeset_ids;
44  _fe_problem.mesh().getMesh().get_boundary_info().boundary_ids(node, nodeset_ids);
45  for (const auto & bnd : nodeset_ids)
46  {
47  _query.clone()
49  .condition<AttribInterfaces>(Interfaces::NodalUserObject)
50  .condition<AttribBoundaries>(bnd, true)
51  .queryInto(objs);
52  for (const auto & uo : objs)
53  uo->execute();
54  }
55 
56  // Block Restricted
57  // NodalUserObjects may be block restricted, in this case by default the execute() method is
58  // called for
59  // each subdomain that the node "belongs". This may be disabled in the NodalUserObject by setting
60  // "unique_node_execute = true".
61 
62  // To inforce the unique execution this vector is populated and checked if the unique flag is
63  // enabled.
64  std::set<NodalUserObject *> computed;
65  const std::set<SubdomainID> & block_ids = _fe_problem.mesh().getNodeBlockIds(*node);
66  for (const auto & block : block_ids)
67  {
68  _query.clone()
70  .condition<AttribInterfaces>(Interfaces::NodalUserObject)
71  .condition<AttribSubdomains>(block)
72  .queryInto(objs);
73 
74  for (const auto & uo : objs)
75  if (!uo->isUniqueNodeExecute() || computed.count(uo) == 0)
76  {
77  uo->execute();
78  computed.insert(uo);
79  }
80  }
81 }
82 
83 void
85 {
86 }
const std::set< SubdomainID > & getNodeBlockIds(const Node &node) const
Return list of blocks to which the given node belongs.
Definition: MooseMesh.C:847
ComputeNodalUserObjectsThread(FEProblemBase &fe_problem, const TheWarehouse::Query &query)
static PetscErrorCode Vec x
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Query & condition(Args &&... args)
Adds a new condition to the query.
Definition: TheWarehouse.h:157
std::vector< std::string > split(const std::string &str, const std::string &delimiter)
Python like split function for strings.
Definition: MooseUtils.C:736
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:2567
Query clone() const
clone creates and returns an independent copy of the query in its current state.
Definition: TheWarehouse.h:164
virtual MooseMesh & mesh() override
void join(const ComputeNodalUserObjectsThread &)
virtual void onNode(ConstNodeRange::const_iterator &node_it) override
Called for each node.
virtual void reinitNode(const Node *node, THREAD_ID tid) override
Query is a convenient way to construct and pass around (possible partially constructed) warehouse que...
Definition: TheWarehouse.h:128