https://mooseframework.inl.gov
Public Member Functions | Protected Attributes | Private Attributes | Static Private Attributes | List of all members
ComputeNodalUserObjectsThread Class Reference

#include <ComputeNodalUserObjectsThread.h>

Inheritance diagram for ComputeNodalUserObjectsThread:
[legend]

Public Member Functions

 ComputeNodalUserObjectsThread (FEProblemBase &fe_problem, const TheWarehouse::Query &query)
 
 ComputeNodalUserObjectsThread (ComputeNodalUserObjectsThread &x, Threads::split split)
 
virtual ~ComputeNodalUserObjectsThread ()
 
void subdomainChanged ()
 
virtual void onNode (ConstNodeRange::const_iterator &node_it) override
 
void join (const ComputeNodalUserObjectsThread &)
 
void printGeneralExecutionInformation () const override
 Print information about the loop, mostly order of execution of objects. More...
 
void operator() (const ConstNodeRange &range)
 
virtual void pre ()
 Called before the node range loop. More...
 
virtual void post ()
 Called after the node range loop. More...
 
virtual void onNode (ConstNodeRange::const_iterator &node_it)
 Called for each node. More...
 
virtual void postNode (ConstNodeRange::const_iterator &node_it)
 Called after the node assembly is done (including surface assembling) More...
 
virtual void caughtMooseException (MooseException &e)
 Called if a MooseException is caught anywhere during the computation. More...
 
virtual bool keepGoing ()
 Whether or not the loop should continue. More...
 

Protected Attributes

FEProblemBase_fe_problem
 
THREAD_ID _tid
 

Private Attributes

const TheWarehouse::Query _query
 
AuxiliarySystem_aux_sys
 
std::set< SubdomainID_block_ids
 

Static Private Attributes

static Threads::spin_mutex writable_variable_mutex
 

Detailed Description

Definition at line 19 of file ComputeNodalUserObjectsThread.h.

Constructor & Destructor Documentation

◆ ComputeNodalUserObjectsThread() [1/2]

ComputeNodalUserObjectsThread::ComputeNodalUserObjectsThread ( FEProblemBase fe_problem,
const TheWarehouse::Query query 
)

◆ ComputeNodalUserObjectsThread() [2/2]

ComputeNodalUserObjectsThread::ComputeNodalUserObjectsThread ( ComputeNodalUserObjectsThread x,
Threads::split  split 
)

◆ ~ComputeNodalUserObjectsThread()

ComputeNodalUserObjectsThread::~ComputeNodalUserObjectsThread ( )
virtual

Definition at line 39 of file ComputeNodalUserObjectsThread.C.

39 {}

Member Function Documentation

◆ caughtMooseException()

virtual void ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::caughtMooseException ( MooseException e)
inlinevirtualinherited

Called if a MooseException is caught anywhere during the computation.

The single input parameter taken is a MooseException object.

Definition at line 56 of file ThreadedNodeLoop.h.

57  {
58  Threads::spin_mutex::scoped_lock lock(threaded_node_mutex);
59 
60  std::string what(e.what());
62  };
virtual const char * what() const
Get out the error message.
virtual void setException(const std::string &message)
Set an exception, which is stored at this point by toggling a member variable in this class...
static Threads::spin_mutex threaded_node_mutex

◆ join()

void ComputeNodalUserObjectsThread::join ( const ComputeNodalUserObjectsThread )

Definition at line 129 of file ComputeNodalUserObjectsThread.C.

130 {
131 }

◆ keepGoing()

virtual bool ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::keepGoing ( )
inlinevirtualinherited

Whether or not the loop should continue.

Returns
true to keep going, false to stop.

Definition at line 69 of file ThreadedNodeLoop.h.

69 { return !_fe_problem.hasException(); }
virtual bool hasException()
Whether or not an exception has occurred.

◆ onNode() [1/2]

void ComputeNodalUserObjectsThread::onNode ( ConstNodeRange::const_iterator node_it)
overridevirtual

Definition at line 60 of file ComputeNodalUserObjectsThread.C.

61 {
62  const Node * node = *node_it;
63 
64  const auto & block_ids = _aux_sys.mesh().getNodeBlockIds(*node);
65  if (_block_ids != block_ids)
66  {
67  _block_ids.clear();
68  _block_ids.insert(block_ids.begin(), block_ids.end());
70  }
71 
73 
74  std::vector<NodalUserObject *> objs;
75 
76  // Boundary Restricted
77  std::vector<BoundaryID> nodeset_ids;
78  _fe_problem.mesh().getMesh().get_boundary_info().boundary_ids(node, nodeset_ids);
79  for (const auto & bnd : nodeset_ids)
80  {
81  _query.clone()
83  .condition<AttribInterfaces>(Interfaces::NodalUserObject)
84  .condition<AttribBoundaries>(bnd, true)
85  .queryInto(objs);
86  for (const auto & uo : objs)
87  {
88  uo->execute();
89 
90  // update the aux solution vector if writable coupled variables are used
91  if (uo->hasWritableCoupledVariables())
92  for (auto * var : uo->getWritableCoupledVariables())
93  var->insert(_aux_sys.solution());
94  }
95  }
96 
97  // Block Restricted
98  // NodalUserObjects may be block restricted, in this case by default the execute() method is
99  // called for each subdomain that the node "belongs". This may be disabled in the NodalUserObject
100  // by setting "unique_node_execute = true".
101 
102  // To enforce the unique execution this vector is populated and checked if the unique flag is
103  // enabled.
104  std::set<NodalUserObject *> computed;
105  for (const auto & block : block_ids)
106  {
107  _query.clone()
109  .condition<AttribInterfaces>(Interfaces::NodalUserObject)
110  .condition<AttribSubdomains>(block)
111  .queryInto(objs);
112 
113  for (const auto & uo : objs)
114  if (!uo->isUniqueNodeExecute() || computed.count(uo) == 0)
115  {
116  uo->execute();
117 
118  // update the aux solution vector if writable coupled variables are used
119  if (uo->hasWritableCoupledVariables())
120  for (auto * var : uo->getWritableCoupledVariables())
121  var->insert(_aux_sys.solution());
122 
123  computed.insert(uo);
124  }
125  }
126 }
MooseMesh & mesh()
Definition: SystemBase.h:99
virtual void reinitNode(const Node *node, const THREAD_ID tid) override
NumericVector< Number > & solution()
Definition: SystemBase.h:196
const std::set< SubdomainID > & getNodeBlockIds(const Node &node) const
Return list of blocks to which the given node belongs.
Definition: MooseMesh.C:1549
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3528
AttribBoundaries tracks all boundary IDs associated with an object.
Definition: Attributes.h:188
QueryCache clone() const
clone creates and returns an independent copy of the query in its current state.
Definition: TheWarehouse.h:292
virtual MooseMesh & mesh() override
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
Definition: TheWarehouse.h:284

◆ onNode() [2/2]

Called for each node.

Definition at line 136 of file ThreadedNodeLoop.h.

137 {
138 }

◆ operator()()

void ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::operator() ( const ConstNodeRange range)
inherited

Definition at line 94 of file ThreadedNodeLoop.h.

95 {
96  try
97  {
98  ParallelUniqueId puid;
99  _tid = puid.id;
100 
101  pre();
103 
104  for (IteratorType nd = range.begin(); nd != range.end(); ++nd)
105  {
106  if (!keepGoing())
107  break;
108 
109  onNode(nd);
110 
111  postNode(nd);
112  }
113 
114  post();
115  }
116  catch (MooseException & e)
117  {
119  }
120 }
virtual void printGeneralExecutionInformation() const
Print information about the loop, mostly order of execution of objects.
virtual void caughtMooseException(MooseException &e)
Called if a MooseException is caught anywhere during the computation.
virtual bool keepGoing()
Whether or not the loop should continue.
const_iterator end() const
Provides a way for users to bail out of the current solve.
virtual void pre()
Called before the node range loop.
const_iterator begin() const
virtual void post()
Called after the node range loop.
virtual void postNode(ConstNodeRange::const_iterator &node_it)
Called after the node assembly is done (including surface assembling)
virtual void onNode(ConstNodeRange::const_iterator &node_it)
Called for each node.

◆ post()

Called after the node range loop.

Reimplemented in ComputeNodalAuxVarsThread< AuxKernelType >.

Definition at line 130 of file ThreadedNodeLoop.h.

131 {
132 }

◆ postNode()

Called after the node assembly is done (including surface assembling)

Parameters
node- active node

Definition at line 142 of file ThreadedNodeLoop.h.

143 {
144 }

◆ pre()

Called before the node range loop.

Reimplemented in ComputeNodalKernelJacobiansThread, and ComputeNodalKernelsThread.

Definition at line 124 of file ThreadedNodeLoop.h.

125 {
126 }

◆ printGeneralExecutionInformation()

void ComputeNodalUserObjectsThread::printGeneralExecutionInformation ( ) const
overridevirtual

Print information about the loop, mostly order of execution of objects.

Reimplemented from ThreadedNodeLoop< ConstNodeRange, ConstNodeRange::const_iterator >.

Definition at line 134 of file ComputeNodalUserObjectsThread.C.

135 {
137  return;
138 
139  // Get all nodal UOs
140  std::vector<MooseObject *> nodal_uos;
141  _query.clone()
143  .condition<AttribInterfaces>(Interfaces::NodalUserObject)
144  .queryInto(nodal_uos);
145 
146  if (nodal_uos.size())
147  {
148  const auto & console = _fe_problem.console();
149  const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
150  console << "[DBG] Computing nodal user objects on " << execute_on << std::endl;
151  mooseDoOnce(
152  console << "[DBG] Ordering on nodes:" << std::endl;
153  console << "[DBG] - boundary restricted user objects" << std::endl;
154  console << "[DBG] - block restricted user objects" << std::endl;
155  console << "[DBG] Nodal UOs executed on each node will differ based on these restrictions"
156  << std::endl;);
157 
158  auto message = ConsoleUtils::mooseObjectVectorToString(nodal_uos);
159  message = "Order of execution:\n" + message;
160  console << ConsoleUtils::formatString(message, "[DBG]") << std::endl;
161  }
162 }
std::string mooseObjectVectorToString(const std::vector< MooseObject *> &objs, const std::string &sep=" ")
Routine to output the name of MooseObjects in a string.
Definition: ConsoleUtils.C:597
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
std::string formatString(std::string message, const std::string &prefix)
Add new lines and prefixes to a string for pretty display in output NOTE: This makes a copy of the st...
Definition: ConsoleUtils.C:581
QueryCache clone() const
clone creates and returns an independent copy of the query in its current state.
Definition: TheWarehouse.h:292
const ConsoleStream & console() const
Return console handle.
Definition: Problem.h:48
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
Definition: TheWarehouse.h:284

◆ subdomainChanged()

void ComputeNodalUserObjectsThread::subdomainChanged ( )

Definition at line 42 of file ComputeNodalUserObjectsThread.C.

Referenced by onNode().

43 {
44  std::vector<NodalUserObject *> objs;
45  _query.clone()
47  .condition<AttribInterfaces>(Interfaces::NodalUserObject)
48  .queryInto(objs);
49 
50  std::set<TagID> needed_vector_tags;
51  for (const auto obj : objs)
52  {
53  auto & vector_tags = obj->getFEVariableCoupleableVectorTags();
54  needed_vector_tags.insert(vector_tags.begin(), vector_tags.end());
55  }
57 }
QueryCache clone() const
clone creates and returns an independent copy of the query in its current state.
Definition: TheWarehouse.h:292
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
Definition: TheWarehouse.h:284
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid) override

Member Data Documentation

◆ _aux_sys

AuxiliarySystem& ComputeNodalUserObjectsThread::_aux_sys
private

Definition at line 40 of file ComputeNodalUserObjectsThread.h.

Referenced by onNode().

◆ _block_ids

std::set<SubdomainID> ComputeNodalUserObjectsThread::_block_ids
private

Definition at line 41 of file ComputeNodalUserObjectsThread.h.

Referenced by onNode().

◆ _fe_problem

◆ _query

const TheWarehouse::Query ComputeNodalUserObjectsThread::_query
private

◆ _tid

◆ writable_variable_mutex

Threads::spin_mutex ComputeNodalUserObjectsThread::writable_variable_mutex
staticprivate

Definition at line 43 of file ComputeNodalUserObjectsThread.h.


The documentation for this class was generated from the following files: