https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ThreadedNodeLoop< RangeType, IteratorType > Class Template Reference

#include <ThreadedNodeLoop.h>

Public Member Functions

 ThreadedNodeLoop (FEProblemBase &fe_problem)
 
 ThreadedNodeLoop (ThreadedNodeLoop &x, Threads::split split)
 
virtual ~ThreadedNodeLoop ()
 
void operator() (const RangeType &range)
 
virtual void pre ()
 Called before the node range loop.
 
virtual void post ()
 Called after the node range loop.
 
virtual void onNode (IteratorType &node_it)
 Called for each node.
 
virtual void postNode (IteratorType &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 Member Functions

virtual void printGeneralExecutionInformation () const
 Print information about the loop, mostly order of execution of objects.
 
template<typename T >
void printExecutionOrdering (const std::vector< T * > &objs, const bool print_header=true, const std::string &line_prefix="[DBG]") const
 Routine to output the ordering of objects within a vector of pointers to these objects.
 

Protected Attributes

FEProblemBase & _fe_problem
 
THREAD_ID _tid
 

Detailed Description

template<typename RangeType, typename IteratorType>
class ThreadedNodeLoop< RangeType, IteratorType >

Definition at line 18 of file ThreadedNodeLoop.h.

Constructor & Destructor Documentation

◆ ThreadedNodeLoop() [1/2]

template<typename RangeType , typename IteratorType >
ThreadedNodeLoop< RangeType, IteratorType >::ThreadedNodeLoop ( FEProblemBase &  fe_problem)

Definition at line 96 of file ThreadedNodeLoop.h.

97 : _fe_problem(fe_problem)
98{
99}
FEProblemBase & _fe_problem

◆ ThreadedNodeLoop() [2/2]

template<typename RangeType , typename IteratorType >
ThreadedNodeLoop< RangeType, IteratorType >::ThreadedNodeLoop ( ThreadedNodeLoop< RangeType, IteratorType > &  x,
Threads::split  split 
)

Definition at line 102 of file ThreadedNodeLoop.h.

105{
106}

◆ ~ThreadedNodeLoop()

template<typename RangeType , typename IteratorType >
virtual ThreadedNodeLoop< RangeType, IteratorType >::~ThreadedNodeLoop ( )
inlinevirtual

Definition at line 26 of file ThreadedNodeLoop.h.

26{}

Member Function Documentation

◆ caughtMooseException()

template<typename RangeType , typename IteratorType >
virtual void ThreadedNodeLoop< RangeType, IteratorType >::caughtMooseException ( MooseException &  e)
inlinevirtual

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.

◆ keepGoing()

template<typename RangeType , typename IteratorType >
virtual bool ThreadedNodeLoop< RangeType, IteratorType >::keepGoing ( )
inlinevirtual

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()

template<typename RangeType , typename IteratorType >
void ThreadedNodeLoop< RangeType, IteratorType >::onNode ( IteratorType &  node_it)
virtual

Called for each node.

Definition at line 152 of file ThreadedNodeLoop.h.

153{
154}

◆ operator()()

template<typename RangeType , typename IteratorType >
void ThreadedNodeLoop< RangeType, IteratorType >::operator() ( const RangeType &  range)

Definition at line 110 of file ThreadedNodeLoop.h.

111{
112 try
113 {
114 ParallelUniqueId puid;
115 _tid = puid.id;
116
117 pre();
119
120 for (IteratorType nd = range.begin(); nd != range.end(); ++nd)
121 {
122 if (!keepGoing())
123 break;
124
125 onNode(nd);
126
127 postNode(nd);
128 }
129
130 post();
131 }
132 catch (MooseException & e)
133 {
135 }
136}
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(IteratorType &node_it)
Called after the node assembly is done (including surface assembling)
virtual void onNode(IteratorType &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()

template<typename RangeType , typename IteratorType >
void ThreadedNodeLoop< RangeType, IteratorType >::post ( )
virtual

Called after the node range loop.

Reimplemented in ComputeNodalAuxVarsThread< AuxKernelType >.

Definition at line 146 of file ThreadedNodeLoop.h.

147{
148}

◆ postNode()

template<typename RangeType , typename IteratorType >
void ThreadedNodeLoop< RangeType, IteratorType >::postNode ( IteratorType &  node_it)
virtual

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

Parameters
node- active node

Definition at line 158 of file ThreadedNodeLoop.h.

159{
160}

◆ pre()

template<typename RangeType , typename IteratorType >
void ThreadedNodeLoop< RangeType, IteratorType >::pre ( )
virtual

Called before the node range loop.

Reimplemented in ComputeNodalKernelBCJacobiansThread, ComputeNodalKernelBcsThread, ComputeNodalKernelJacobiansThread, and ComputeNodalKernelsThread.

Definition at line 140 of file ThreadedNodeLoop.h.

141{
142}

◆ printExecutionOrdering()

template<typename RangeType , typename IteratorType >
template<typename T >
void ThreadedNodeLoop< RangeType, IteratorType >::printExecutionOrdering ( const std::vector< T * > &  objs,
const bool  print_header = true,
const std::string &  line_prefix = "[DBG]" 
) const
protected

Routine to output the ordering of objects within a vector of pointers to these objects.

These objects must implement the name() routine, and it must return a string or compatible type.

Template Parameters
Tthe object type
Parameters
objsthe vector with all the objects (should be pointers)
print_headerwhether to print a header about the timing of execution and the type of objects
line_prefixprefix to prepend to each line of the console output

Definition at line 165 of file ThreadedNodeLoop.h.

167{
168 if (!objs.size())
169 return;
170
171 auto & console = _fe_problem.console();
172 const auto objects_type = MooseUtils::prettyCppType(objs[0]);
173 std::vector<MooseObject *> moose_objs;
174 moose_objs.reserve(objs.size());
175 for (auto obj_ptr : objs)
176 moose_objs.push_back(cast_ptr<MooseObject *>(obj_ptr));
177 const auto names = ConsoleUtils::mooseObjectVectorToString(moose_objs);
178
179 // Print string with a DBG prefix and with sufficient line breaks
180 std::string message = print_header ? "Executing " + objects_type + " on " +
182 : "";
183 message += (print_header ? "Order of execution:\n" : "") + names;
184 console << ConsoleUtils::formatString(message, line_prefix) << std::endl;
185}
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
const std::string & name() const
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
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.
std::string prettyCppType(const std::string &cpp_type)
Tnew cast_ptr(Told *oldvar)

◆ printGeneralExecutionInformation()

template<typename RangeType , typename IteratorType >
virtual void ThreadedNodeLoop< RangeType, IteratorType >::printGeneralExecutionInformation ( ) const
inlineprotectedvirtual

Member Data Documentation

◆ _fe_problem

template<typename RangeType , typename IteratorType >
FEProblemBase& ThreadedNodeLoop< RangeType, IteratorType >::_fe_problem
protected

◆ _tid

template<typename RangeType , typename IteratorType >
THREAD_ID ThreadedNodeLoop< RangeType, IteratorType >::_tid
protected

Definition at line 73 of file ThreadedNodeLoop.h.


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