https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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.
 
void operator() (const ConstNodeRange &range)
 
virtual void pre ()
 Called before the node range loop.
 
virtual void post ()
 Called after the node range loop.
 
virtual void onNode (ConstNodeRange::const_iterator &node_it)
 Called for each node.
 
virtual void postNode (ConstNodeRange::const_iterator &node_it)
 Called after the node assembly is done (including surface assembling)
 
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.
 

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 };
static Threads::spin_mutex threaded_node_mutex
virtual void setException(const std::string &message)
Set an exception, which is stored at this point by toggling a member variable in this class,...
virtual const char * what() const
Get out the error message.

◆ 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 ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::onNode ( ConstNodeRange::const_iterator &  node_it)
virtualinherited

Called for each node.

Definition at line 43 of file ThreadedNodeLoop.h.

137{
138}

◆ onNode() [2/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 {
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}
unsigned int count
Definition MortarUtils.C:53
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
AttribBoundaries tracks all boundary IDs associated with an object.
Definition Attributes.h:190
virtual void reinitNode(const Node *node, const THREAD_ID tid) override
virtual MooseMesh & mesh() override
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition MooseMesh.C:3549
const std::set< SubdomainID > & getNodeBlockIds(const Node &node) const
Return list of blocks to which the given node belongs.
Definition MooseMesh.C:1489
MooseMesh & mesh()
Definition SystemBase.h:100
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
QueryCache clone() const
clone creates and returns an independent copy of the query in its current state.

◆ operator()()

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

Definition at line 28 of file ThreadedNodeLoop.h.

95{
96 try
97 {
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}
Provides a way for users to bail out of the current solve.
virtual void printGeneralExecutionInformation() const
Print information about the loop, mostly order of execution of objects.
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.
virtual bool keepGoing()
Whether or not the loop should continue.
virtual void pre()
Called before the node range loop.
virtual void post()
Called after the node range loop.
virtual void caughtMooseException(MooseException &e)
Called if a MooseException is caught anywhere during the computation.

◆ post()

void ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::post ( )
virtualinherited

Called after the node range loop.

Reimplemented in ComputeNodalAuxVarsThread< AuxKernelType >.

Definition at line 38 of file ThreadedNodeLoop.h.

131{
132}

◆ postNode()

void ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::postNode ( ConstNodeRange::const_iterator &  node_it)
virtualinherited

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

Parameters
node- active node

Definition at line 50 of file ThreadedNodeLoop.h.

143{
144}

◆ pre()

void ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::pre ( )
virtualinherited

Called before the node range loop.

Reimplemented in ComputeNodalKernelJacobiansThread, and ComputeNodalKernelsThread.

Definition at line 33 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}
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.
const ConsoleStream & console() const
Return console handle.
Definition Problem.h:48
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...
std::string mooseObjectVectorToString(const std::vector< MooseObject * > &objs, const std::string &sep=" ")
Routine to output the name of MooseObjects in a string.

◆ subdomainChanged()

void ComputeNodalUserObjectsThread::subdomainChanged ( )

Definition at line 42 of file ComputeNodalUserObjectsThread.C.

43{
44 std::vector<NodalUserObject *> objs;
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}
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid) override

Referenced by onNode().

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

FEProblemBase& ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::_fe_problem
protectedinherited

Definition at line 72 of file ThreadedNodeLoop.h.

◆ _query

const TheWarehouse::Query ComputeNodalUserObjectsThread::_query
private

◆ _tid

THREAD_ID ThreadedNodeLoop< ConstNodeRange , ConstNodeRange::const_iterator >::_tid
protectedinherited

Definition at line 73 of file ThreadedNodeLoop.h.

◆ 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: