Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
ThreadedNodeLoop.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 
10 #pragma once
11 
12 #include "FEProblemBase.h"
13 #include "ParallelUniqueId.h"
14 
16 
17 template <typename RangeType, typename IteratorType>
19 {
20 public:
21  ThreadedNodeLoop(FEProblemBase & fe_problem);
22 
23  // Splitting Constructor
25 
26  virtual ~ThreadedNodeLoop(){};
27 
28  void operator()(const RangeType & range);
29 
33  virtual void pre();
34 
38  virtual void post();
39 
43  virtual void onNode(IteratorType & node_it);
44 
50  virtual void postNode(IteratorType & node_it);
51 
57  {
58  Threads::spin_mutex::scoped_lock lock(threaded_node_mutex);
59 
60  std::string what(e.what());
62  };
63 
69  virtual bool keepGoing() { return !_fe_problem.hasException(); }
70 
71 protected:
74 
76  virtual void printGeneralExecutionInformation() const {}
77 };
78 
79 template <typename RangeType, typename IteratorType>
81  : _fe_problem(fe_problem)
82 {
83 }
84 
85 template <typename RangeType, typename IteratorType>
87  Threads::split /*split*/)
88  : _fe_problem(x._fe_problem)
89 {
90 }
91 
92 template <typename RangeType, typename IteratorType>
93 void
95 {
96  try
97  {
98  ParallelUniqueId puid;
99  _tid = puid.id;
100 
101  pre();
102  printGeneralExecutionInformation();
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  {
118  caughtMooseException(e);
119  }
120 }
121 
122 template <typename RangeType, typename IteratorType>
123 void
125 {
126 }
127 
128 template <typename RangeType, typename IteratorType>
129 void
131 {
132 }
133 
134 template <typename RangeType, typename IteratorType>
135 void
137 {
138 }
139 
140 template <typename RangeType, typename IteratorType>
141 void
143 {
144 }
virtual const char * what() const
Get out the error message.
void operator()(const RangeType &range)
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 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.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
FEProblemBase & _fe_problem
static Threads::spin_mutex threaded_node_mutex
virtual ~ThreadedNodeLoop()
virtual bool keepGoing()
Whether or not the loop should continue.
tbb::split split
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:205
virtual void onNode(IteratorType &node_it)
Called for each node.