www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
ThreadedElementLoop< RangeType > Class Template Reference

Base class for assembly-like calculations. More...

#include <ThreadedElementLoop.h>

Inheritance diagram for ThreadedElementLoop< RangeType >:
[legend]

Public Member Functions

 ThreadedElementLoop (FEProblemBase &feproblem)
 
 ThreadedElementLoop (ThreadedElementLoop &x, Threads::split split)
 
virtual ~ThreadedElementLoop ()
 
virtual void caughtMooseException (MooseException &e) override
 Called if a MooseException is caught anywhere during the computation. More...
 
virtual bool keepGoing () override
 Whether or not the loop should continue. More...
 
virtual void preElement (const Elem *elem) override
 Called before the element assembly. More...
 
virtual void preInternalSide (const Elem *elem, unsigned int side) override
 Called before evaluations on an element internal side. More...
 
virtual void neighborSubdomainChanged () override
 Called every time the neighbor subdomain changes (i.e. More...
 
void operator() (const RangeType &range, bool bypass_threading=false)
 
virtual void pre ()
 Called before the element range loop. More...
 
virtual void post ()
 Called after the element range loop. More...
 
virtual void onElement (const Elem *elem)
 Assembly of the element (not including surface assembly) More...
 
virtual void postElement (const Elem *elem)
 Called after the element assembly is done (including surface assembling) More...
 
virtual void onBoundary (const Elem *elem, unsigned int side, BoundaryID bnd_id)
 Called when doing boundary assembling. More...
 
virtual void postInternalSide (const Elem *elem, unsigned int side)
 Called after evaluations on an element internal side. More...
 
virtual void onInternalSide (const Elem *elem, unsigned int side)
 Called when doing internal edge assembling. More...
 
virtual void onInterface (const Elem *elem, unsigned int side, BoundaryID bnd_id)
 Called when doing interface assembling. More...
 
virtual void subdomainChanged ()
 Called every time the current subdomain changes (i.e. More...
 

Protected Attributes

FEProblemBase_fe_problem
 
MooseMesh_mesh
 
THREAD_ID _tid
 
SubdomainID _subdomain
 The subdomain for the current element. More...
 
SubdomainID _old_subdomain
 The subdomain for the last element. More...
 
SubdomainID _neighbor_subdomain
 The subdomain for the current neighbor. More...
 
SubdomainID _old_neighbor_subdomain
 The subdomain for the last neighbor. More...
 

Detailed Description

template<typename RangeType>
class ThreadedElementLoop< RangeType >

Base class for assembly-like calculations.

Definition at line 33 of file ThreadedElementLoop.h.

Constructor & Destructor Documentation

◆ ThreadedElementLoop() [1/2]

template<typename RangeType >
ThreadedElementLoop< RangeType >::ThreadedElementLoop ( FEProblemBase feproblem)

Definition at line 57 of file ThreadedElementLoop.h.

58  : ThreadedElementLoopBase<RangeType>(fe_problem.mesh()), _fe_problem(fe_problem)
59 {
60 }
FEProblemBase & _fe_problem
Base class for assembly-like calculations.

◆ ThreadedElementLoop() [2/2]

template<typename RangeType >
ThreadedElementLoop< RangeType >::ThreadedElementLoop ( ThreadedElementLoop< RangeType > &  x,
Threads::split  split 
)

Definition at line 63 of file ThreadedElementLoop.h.

66 {
67 }
FEProblemBase & _fe_problem
static PetscErrorCode Vec x
Base class for assembly-like calculations.

◆ ~ThreadedElementLoop()

template<typename RangeType >
ThreadedElementLoop< RangeType >::~ThreadedElementLoop ( )
virtual

Definition at line 70 of file ThreadedElementLoop.h.

71 {
72 }

Member Function Documentation

◆ caughtMooseException()

template<typename RangeType >
void ThreadedElementLoop< RangeType >::caughtMooseException ( MooseException )
overridevirtual

Called if a MooseException is caught anywhere during the computation.

The single input parameter taken is a MooseException object.

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 76 of file ThreadedElementLoop.h.

77 {
78  Threads::spin_mutex::scoped_lock lock(threaded_element_mutex);
79 
80  std::string what(e.what());
82 }
FEProblemBase & _fe_problem
virtual void setException(const std::string &message)
Set an exception.
static Threads::spin_mutex threaded_element_mutex
This mutex is used by all derived classes of the ThreadedElementLoop.

◆ keepGoing()

template<typename RangeType>
virtual bool ThreadedElementLoop< RangeType >::keepGoing ( )
inlineoverridevirtual

Whether or not the loop should continue.

Returns
true to keep going, false to stop.

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 44 of file ThreadedElementLoop.h.

44 { return !_fe_problem.hasException(); }
FEProblemBase & _fe_problem
virtual bool hasException()
Whether or not an exception has occurred.

◆ neighborSubdomainChanged()

template<typename RangeType >
void ThreadedElementLoop< RangeType >::neighborSubdomainChanged ( )
overridevirtual

Called every time the neighbor subdomain changes (i.e.

the subdomain of this neighbor is not the same as the subdomain of the last neighbor). Beware of over-using this! You might think that you can do some expensive stuff in here and get away with it... but there are applications that have TONS of subdomains....

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 100 of file ThreadedElementLoop.h.

101 {
104 }
FEProblemBase & _fe_problem
virtual void neighborSubdomainSetup(SubdomainID subdomain, THREAD_ID tid)
Base class for assembly-like calculations.

◆ onBoundary()

template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::onBoundary ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id 
)
virtualinherited

Called when doing boundary assembling.

Parameters
elem- The element we are checking is on the boundary.
side- The side of the element in question.
bnd_id- ID of the boundary we are at

Reimplemented in ComputeUserObjectsThread, ProjectMaterialProperties, ComputeMaterialsObjectThread, ComputeResidualThread, ComputeIndicatorThread, ComputeJacobianThread, and ComputeMarkerThread.

Definition at line 283 of file ThreadedElementLoopBase.h.

286 {
287 }

◆ onElement()

template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::onElement ( const Elem *  elem)
virtualinherited

◆ onInterface()

template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::onInterface ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id 
)
virtualinherited

Called when doing interface assembling.

Parameters
elem- Element we are on
side- local side number of the element 'elem'
bnd_id- ID of the interface we are at

Reimplemented in ComputeResidualThread, and ComputeJacobianThread.

Definition at line 309 of file ThreadedElementLoopBase.h.

312 {
313 }

◆ onInternalSide()

template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::onInternalSide ( const Elem *  elem,
unsigned int  side 
)
virtualinherited

Called when doing internal edge assembling.

Parameters
elem- Element we are on
side- local side number of the element 'elem'

Reimplemented in ComputeUserObjectsThread, ProjectMaterialProperties, ComputeMaterialsObjectThread, ComputeResidualThread, ComputeIndicatorThread, ComputeJacobianThread, and ComputeMarkerThread.

Definition at line 303 of file ThreadedElementLoopBase.h.

304 {
305 }

◆ operator()()

template<typename RangeType>
void ThreadedElementLoopBase< RangeType >::operator() ( const RangeType &  range,
bool  bypass_threading = false 
)
inherited

Definition at line 173 of file ThreadedElementLoopBase.h.

174 {
175  try
176  {
177  try
178  {
179  ParallelUniqueId puid;
180  _tid = bypass_threading ? 0 : puid.id;
181 
182  pre();
183 
186  typename RangeType::const_iterator el = range.begin();
187  for (el = range.begin(); el != range.end(); ++el)
188  {
189  if (!keepGoing())
190  break;
191 
192  const Elem * elem = *el;
193 
194  preElement(elem);
195 
197  _subdomain = elem->subdomain_id();
198  if (_subdomain != _old_subdomain)
200 
201  onElement(elem);
202 
203  for (unsigned int side = 0; side < elem->n_sides(); side++)
204  {
205  std::vector<BoundaryID> boundary_ids = _mesh.getBoundaryIDs(elem, side);
206 
207  if (boundary_ids.size() > 0)
208  for (std::vector<BoundaryID>::iterator it = boundary_ids.begin();
209  it != boundary_ids.end();
210  ++it)
211  onBoundary(elem, side, *it);
212 
213  const Elem * neighbor = elem->neighbor_ptr(side);
214  if (neighbor != nullptr)
215  {
216  preInternalSide(elem, side);
217 
219  _neighbor_subdomain = neighbor->subdomain_id();
222 
223  onInternalSide(elem, side);
224 
225  if (boundary_ids.size() > 0)
226  for (std::vector<BoundaryID>::iterator it = boundary_ids.begin();
227  it != boundary_ids.end();
228  ++it)
229  onInterface(elem, side, *it);
230 
231  postInternalSide(elem, side);
232  }
233  } // sides
234  postElement(elem);
235 
236  } // range
237 
238  post();
239  }
240  catch (libMesh::LogicError & e)
241  {
242  throw MooseException("We caught a libMesh error");
243  }
244  }
245  catch (MooseException & e)
246  {
248  }
249 }
virtual bool keepGoing()
Whether or not the loop should continue.
virtual void onElement(const Elem *elem)
Assembly of the element (not including surface assembly)
virtual void pre()
Called before the element range loop.
virtual void subdomainChanged()
Called every time the current subdomain changes (i.e.
virtual void neighborSubdomainChanged()
Called every time the neighbor subdomain changes (i.e.
virtual void preInternalSide(const Elem *elem, unsigned int side)
Called before evaluations on an element internal side.
virtual void postInternalSide(const Elem *elem, unsigned int side)
Called after evaluations on an element internal side.
const SubdomainID INVALID_BLOCK_ID
Definition: MooseTypes.C:16
virtual void postElement(const Elem *elem)
Called after the element assembly is done (including surface assembling)
virtual void onInterface(const Elem *elem, unsigned int side, BoundaryID bnd_id)
Called when doing interface assembling.
SubdomainID _old_neighbor_subdomain
The subdomain for the last neighbor.
virtual void onInternalSide(const Elem *elem, unsigned int side)
Called when doing internal edge assembling.
Provides a way for users to bail out of the current solve.
virtual void caughtMooseException(MooseException &)
Called if a MooseException is caught anywhere during the computation.
std::vector< BoundaryID > getBoundaryIDs(const Elem *const elem, const unsigned short int side) const
Returns a vector of boundary IDs for the requested element on the requested side. ...
Definition: MooseMesh.C:2148
SubdomainID _subdomain
The subdomain for the current element.
SubdomainID _old_subdomain
The subdomain for the last element.
virtual void post()
Called after the element range loop.
virtual void preElement(const Elem *elem)
Called before the element assembly.
SubdomainID _neighbor_subdomain
The subdomain for the current neighbor.
virtual void onBoundary(const Elem *elem, unsigned int side, BoundaryID bnd_id)
Called when doing boundary assembling.

◆ post()

template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::post ( )
virtualinherited

◆ postElement()

template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::postElement ( const Elem *  elem)
virtualinherited

Called after the element assembly is done (including surface assembling)

Parameters
elem- active element

Reimplemented in ComputeJacobianBlocksThread, ComputeResidualThread, ComputeDiracThread, ComputeIndicatorThread, ComputeJacobianThread, and ComputeMarkerThread.

Definition at line 277 of file ThreadedElementLoopBase.h.

278 {
279 }

◆ postInternalSide()

template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::postInternalSide ( const Elem *  elem,
unsigned int  side 
)
virtualinherited

Called after evaluations on an element internal side.

Parameters
elem- Element we are on
side- local side number of the element 'elem'

Definition at line 297 of file ThreadedElementLoopBase.h.

298 {
299 }

◆ pre()

template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::pre ( )
virtualinherited

Called before the element range loop.

Reimplemented in ComputeDiracThread.

Definition at line 253 of file ThreadedElementLoopBase.h.

254 {
255 }

◆ preElement()

template<typename RangeType >
void ThreadedElementLoop< RangeType >::preElement ( const Elem *  elem)
overridevirtual

Called before the element assembly.

Parameters
elem- active element

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 86 of file ThreadedElementLoop.h.

87 {
89 }
FEProblemBase & _fe_problem
virtual void setCurrentSubdomainID(const Elem *elem, THREAD_ID tid) override
Base class for assembly-like calculations.

◆ preInternalSide()

template<typename RangeType >
void ThreadedElementLoop< RangeType >::preInternalSide ( const Elem *  elem,
unsigned int  side 
)
overridevirtual

Called before evaluations on an element internal side.

Parameters
elem- Element we are on
side- local side number of the element 'elem'

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 93 of file ThreadedElementLoop.h.

94 {
96 }
FEProblemBase & _fe_problem
Base class for assembly-like calculations.
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, THREAD_ID tid) override

◆ subdomainChanged()

template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::subdomainChanged ( )
virtualinherited

Called every time the current subdomain changes (i.e.

the subdomain of this element is not the same as the subdomain of the last element). Beware of over-using this! You might think that you can do some expensive stuff in here and get away with it... but there are applications that have TONS of subdomains....

Reimplemented in ComputeUserObjectsThread, ProjectMaterialProperties, ComputeMaterialsObjectThread, ComputeDiracThread, ComputeResidualThread, ComputeIndicatorThread, ComputeJacobianThread, ComputeElemAuxVarsThread, and ComputeMarkerThread.

Definition at line 317 of file ThreadedElementLoopBase.h.

318 {
319 }

Member Data Documentation

◆ _fe_problem

template<typename RangeType>
FEProblemBase& ThreadedElementLoop< RangeType >::_fe_problem
protected

◆ _mesh

template<typename RangeType>
MooseMesh& ThreadedElementLoopBase< RangeType >::_mesh
protectedinherited

Definition at line 138 of file ThreadedElementLoopBase.h.

◆ _neighbor_subdomain

template<typename RangeType>
SubdomainID ThreadedElementLoopBase< RangeType >::_neighbor_subdomain
protectedinherited

The subdomain for the current neighbor.

Definition at line 148 of file ThreadedElementLoopBase.h.

◆ _old_neighbor_subdomain

template<typename RangeType>
SubdomainID ThreadedElementLoopBase< RangeType >::_old_neighbor_subdomain
protectedinherited

The subdomain for the last neighbor.

Definition at line 151 of file ThreadedElementLoopBase.h.

◆ _old_subdomain

template<typename RangeType>
SubdomainID ThreadedElementLoopBase< RangeType >::_old_subdomain
protectedinherited

The subdomain for the last element.

Definition at line 145 of file ThreadedElementLoopBase.h.

◆ _subdomain

template<typename RangeType>
SubdomainID ThreadedElementLoopBase< RangeType >::_subdomain
protectedinherited

The subdomain for the current element.

Definition at line 142 of file ThreadedElementLoopBase.h.

◆ _tid

template<typename RangeType>
THREAD_ID ThreadedElementLoopBase< RangeType >::_tid
protectedinherited

Definition at line 139 of file ThreadedElementLoopBase.h.


The documentation for this class was generated from the following file: