www.mooseframework.org
ThreadedElementLoop.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 "ParallelUniqueId.h"
13 #include "FEProblemBase.h"
15 
16 // Forward declarations
17 class SystemBase;
18 
26 static Threads::spin_mutex threaded_element_mutex;
27 
31 template <typename RangeType>
33 {
34 public:
36 
38 
39  virtual ~ThreadedElementLoop();
40 
41  virtual void caughtMooseException(MooseException & e) override;
42 
43  virtual bool keepGoing() override { return !_fe_problem.hasException(); }
44 
45  virtual void preElement(const Elem * elem) override;
46 
47  virtual void preInternalSide(const Elem * elem, unsigned int side) override;
48 
49  virtual void neighborSubdomainChanged() override;
50 
51 protected:
53 };
54 
55 template <typename RangeType>
57  : ThreadedElementLoopBase<RangeType>(fe_problem.mesh()), _fe_problem(fe_problem)
58 {
59 }
60 
61 template <typename RangeType>
63  Threads::split /*split*/)
64  : ThreadedElementLoopBase<RangeType>(x), _fe_problem(x._fe_problem)
65 {
66 }
67 
68 template <typename RangeType>
70 {
71 }
72 
73 template <typename RangeType>
74 void
76 {
77  Threads::spin_mutex::scoped_lock lock(threaded_element_mutex);
78 
79  std::string what(e.what());
80  _fe_problem.setException(what);
81 }
82 
83 template <typename RangeType>
84 void
86 {
87  _fe_problem.setCurrentSubdomainID(el, ThreadedElementLoopBase<RangeType>::_tid);
88 }
89 
90 template <typename RangeType>
91 void
92 ThreadedElementLoop<RangeType>::preInternalSide(const Elem * el, unsigned int side)
93 {
94  _fe_problem.setNeighborSubdomainID(el, side, ThreadedElementLoopBase<RangeType>::_tid);
95 }
96 
97 template <typename RangeType>
98 void
100 {
101  _fe_problem.neighborSubdomainSetup(ThreadedElementLoopBase<RangeType>::_neighbor_subdomain,
103 }
104 
Base class for assembly-like calculations.
virtual const char * what() const
Get out the error message.
FEProblemBase & _fe_problem
virtual void neighborSubdomainChanged() override
Called every time the neighbor subdomain changes (i.e.
virtual void preInternalSide(const Elem *elem, unsigned int side) override
Called before evaluations on an element internal side.
virtual void preElement(const Elem *elem) override
Called before the element assembly.
static PetscErrorCode Vec x
Base class for a system (of equations)
Definition: SystemBase.h:92
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
std::vector< std::string > split(const std::string &str, const std::string &delimiter)
Python like split function for strings.
Definition: MooseUtils.C:784
virtual bool keepGoing() override
Whether or not the loop should continue.
ThreadedElementLoop(FEProblemBase &feproblem)
Provides a way for users to bail out of the current solve.
Base class for assembly-like calculations.
static Threads::spin_mutex threaded_element_mutex
This mutex is used by all derived classes of the ThreadedElementLoop.
virtual void caughtMooseException(MooseException &e) override
Called if a MooseException is caught anywhere during the computation.
virtual bool hasException()
Whether or not an exception has occurred.