https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
17template <typename RangeType, typename IteratorType>
19{
20public:
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
71protected:
74
76 virtual void printGeneralExecutionInformation() const {}
77};
78
79template <typename RangeType, typename IteratorType>
81 : _fe_problem(fe_problem)
82{
83}
84
85template <typename RangeType, typename IteratorType>
87 Threads::split /*split*/)
88 : _fe_problem(x._fe_problem)
89{
90}
91
92template <typename RangeType, typename IteratorType>
93void
95{
96 try
97 {
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
122template <typename RangeType, typename IteratorType>
123void
127
128template <typename RangeType, typename IteratorType>
129void
133
134template <typename RangeType, typename IteratorType>
135void
137{
138}
139
140template <typename RangeType, typename IteratorType>
141void
143{
144}
unsigned int THREAD_ID
Definition MooseTypes.h:237
static Threads::spin_mutex threaded_node_mutex
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual bool hasException()
Whether or not an exception has occurred.
virtual void setException(const std::string &message)
Set an exception, which is stored at this point by toggling a member variable in this class,...
Provides a way for users to bail out of the current solve.
virtual const char * what() const
Get out the error message.
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.
ThreadedNodeLoop(ThreadedNodeLoop &x, Threads::split split)
ThreadedNodeLoop(FEProblemBase &fe_problem)
virtual bool keepGoing()
Whether or not the loop should continue.
FEProblemBase & _fe_problem
virtual void pre()
Called before the node range loop.
virtual void post()
Called after the node range loop.
virtual ~ThreadedNodeLoop()
void operator()(const RangeType &range)
virtual void caughtMooseException(MooseException &e)
Called if a MooseException is caught anywhere during the computation.