www.mooseframework.org
ThreadedNodeLoop.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
15 template <typename RangeType, typename IteratorType>
17 {
18 public:
19  ThreadedNodeLoop(FEProblemBase & fe_problem);
20 
21  // Splitting Constructor
23 
24  virtual ~ThreadedNodeLoop(){};
25 
26  void operator()(const RangeType & range);
27 
31  virtual void pre();
32 
36  virtual void post();
37 
41  virtual void onNode(IteratorType & node_it);
42 
48  virtual void postNode(IteratorType & node_it);
49 
55  {
56  std::string what(e.what());
58  };
59 
65  virtual bool keepGoing() { return !_fe_problem.hasException(); }
66 
67 protected:
70 };
71 
72 template <typename RangeType, typename IteratorType>
74  : _fe_problem(fe_problem)
75 {
76 }
77 
78 template <typename RangeType, typename IteratorType>
80  Threads::split /*split*/)
81  : _fe_problem(x._fe_problem)
82 {
83 }
84 
85 template <typename RangeType, typename IteratorType>
86 void
88 {
89  try
90  {
91  ParallelUniqueId puid;
92  _tid = puid.id;
93 
94  pre();
95 
96  for (IteratorType nd = range.begin(); nd != range.end(); ++nd)
97  {
98  if (!keepGoing())
99  break;
100 
101  onNode(nd);
102 
103  postNode(nd);
104  }
105 
106  post();
107  }
108  catch (MooseException & e)
109  {
110  caughtMooseException(e);
111  }
112 }
113 
114 template <typename RangeType, typename IteratorType>
115 void
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 
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.
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.
FEProblemBase & _fe_problem
std::vector< std::string > split(const std::string &str, const std::string &delimiter)
Python like split function for strings.
Definition: MooseUtils.C:736
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:161
virtual void onNode(IteratorType &node_it)
Called for each node.