www.mooseframework.org
ThreadedNodeLoop.h
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 
15 #ifndef THREADEDNODELOOP_H
16 #define THREADEDNODELOOP_H
17 
18 #include "FEProblemBase.h"
19 #include "ParallelUniqueId.h"
20 
21 template <typename RangeType, typename IteratorType>
23 {
24 public:
25  ThreadedNodeLoop(FEProblemBase & fe_problem);
26 
27  // Splitting Constructor
28  ThreadedNodeLoop(ThreadedNodeLoop & x, Threads::split split);
29 
30  virtual ~ThreadedNodeLoop(){};
31 
32  void operator()(const RangeType & range);
33 
37  virtual void pre();
38 
42  virtual void post();
43 
47  virtual void onNode(IteratorType & node_it);
48 
54  virtual void postNode(IteratorType & node_it);
55 
61  {
62  std::string what(e.what());
64  };
65 
71  virtual bool keepGoing() { return !_fe_problem.hasException(); }
72 
73 protected:
76 };
77 
78 template <typename RangeType, typename IteratorType>
80  : _fe_problem(fe_problem)
81 {
82 }
83 
84 template <typename RangeType, typename IteratorType>
86  Threads::split /*split*/)
88 {
89 }
90 
91 template <typename RangeType, typename IteratorType>
92 void
94 {
95  try
96  {
97  ParallelUniqueId puid;
98  _tid = puid.id;
99 
100  pre();
101 
102  for (IteratorType nd = range.begin(); nd != range.end(); ++nd)
103  {
104  if (!keepGoing())
105  break;
106 
107  onNode(nd);
108 
109  postNode(nd);
110  }
111 
112  post();
113  }
114  catch (MooseException & e)
115  {
117  }
118 }
119 
120 template <typename RangeType, typename IteratorType>
121 void
123 {
124 }
125 
126 template <typename RangeType, typename IteratorType>
127 void
129 {
130 }
131 
132 template <typename RangeType, typename IteratorType>
133 void
135 {
136 }
137 
138 template <typename RangeType, typename IteratorType>
139 void
141 {
142 }
143 
144 #endif // THREADEDNODELOOP_H
void operator()(const RangeType &range)
virtual void setException(const std::string &message)
Set an exception.
virtual void caughtMooseException(MooseException &e)
Called if a MooseException is caught anywhere during the computation.
static PetscErrorCode Vec x
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual const char * what() const
Get out the error message.
FEProblemBase & _fe_problem
virtual ~ThreadedNodeLoop()
virtual bool keepGoing()
Whether or not the loop should continue.
Provides a way for users to bail out of the current solve.
ThreadedNodeLoop(FEProblemBase &fe_problem)
virtual void pre()
Called before the node range loop.
virtual void post()
Called after the node range loop.
virtual bool hasException()
Whether or not an exception has occurred.
virtual void postNode(IteratorType &node_it)
Called after the node assembly is done (including surface assembling)
unsigned int THREAD_ID
Definition: MooseTypes.h:79
virtual void onNode(IteratorType &node_it)
Called for each node.