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

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

#include <ThreadedElementLoopBase.h>

Inheritance diagram for ThreadedElementLoopBase< RangeType >:
[legend]

Public Member Functions

 ThreadedElementLoopBase (MooseMesh &mesh)
 
 ThreadedElementLoopBase (ThreadedElementLoopBase &x, Threads::split split)
 
virtual ~ThreadedElementLoopBase ()
 
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 preElement (const Elem *elem)
 Called before the element 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 preInternalSide (const Elem *elem, unsigned int side)
 Called before evaluations on an element internal side. 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...
 
virtual void neighborSubdomainChanged ()
 Called every time the neighbor subdomain changes (i.e. More...
 
virtual void caughtMooseException (MooseException &)
 Called if a MooseException is caught anywhere during the computation. More...
 
virtual bool keepGoing ()
 Whether or not the loop should continue. More...
 

Protected Attributes

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 ThreadedElementLoopBase< RangeType >

Base class for assembly-like calculations.

Definition at line 27 of file ThreadedElementLoopBase.h.

Constructor & Destructor Documentation

template<typename RangeType >
ThreadedElementLoopBase< RangeType >::ThreadedElementLoopBase ( MooseMesh mesh)

Definition at line 158 of file ThreadedElementLoopBase.h.

158  : _mesh(mesh)
159 {
160 }
template<typename RangeType >
ThreadedElementLoopBase< RangeType >::ThreadedElementLoopBase ( ThreadedElementLoopBase< RangeType > &  x,
Threads::split  split 
)

Definition at line 163 of file ThreadedElementLoopBase.h.

165  : _mesh(x._mesh)
166 {
167 }
template<typename RangeType >
ThreadedElementLoopBase< RangeType >::~ThreadedElementLoopBase ( )
virtual

Definition at line 170 of file ThreadedElementLoopBase.h.

171 {
172 }

Member Function Documentation

template<typename RangeType>
virtual void ThreadedElementLoopBase< RangeType >::caughtMooseException ( MooseException )
inlinevirtual

Called if a MooseException is caught anywhere during the computation.

The single input parameter taken is a MooseException object.

Reimplemented in ThreadedElementLoop< RangeType >, ThreadedElementLoop< ConstElemRange >, ThreadedElementLoop< DistElemRange >, and ThreadedElementLoop< ConstElemPointerRange >.

Definition at line 131 of file ThreadedElementLoopBase.h.

Referenced by ThreadedElementLoopBase< RangeType >::operator()().

131 {};
template<typename RangeType>
virtual bool ThreadedElementLoopBase< RangeType >::keepGoing ( )
inlinevirtual

Whether or not the loop should continue.

Returns
true to keep going, false to stop.

Reimplemented in ThreadedElementLoop< RangeType >, ThreadedElementLoop< ConstElemRange >, ThreadedElementLoop< DistElemRange >, and ThreadedElementLoop< ConstElemPointerRange >.

Definition at line 138 of file ThreadedElementLoopBase.h.

Referenced by ThreadedElementLoopBase< RangeType >::operator()().

138 { return true; }
template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::neighborSubdomainChanged ( )
virtual

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 in ThreadedElementLoop< RangeType >, ThreadedElementLoop< ConstElemRange >, ThreadedElementLoop< DistElemRange >, and ThreadedElementLoop< ConstElemPointerRange >.

Definition at line 319 of file ThreadedElementLoopBase.h.

Referenced by ThreadedElementLoopBase< RangeType >::operator()().

320 {
321 }
template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::onBoundary ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id 
)
virtual

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 ComputeMaterialsObjectThread, ComputeUserObjectsThread, ProjectMaterialProperties, ComputeIndicatorThread, ComputeJacobianThread, ComputeResidualThread, and ComputeMarkerThread.

Definition at line 279 of file ThreadedElementLoopBase.h.

Referenced by ThreadedElementLoopBase< RangeType >::operator()().

282 {
283 }
template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::onElement ( const Elem *  elem)
virtual
template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::onInterface ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id 
)
virtual

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 ComputeJacobianThread, and ComputeResidualThread.

Definition at line 305 of file ThreadedElementLoopBase.h.

Referenced by ThreadedElementLoopBase< RangeType >::operator()().

308 {
309 }
template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::onInternalSide ( const Elem *  elem,
unsigned int  side 
)
virtual

Called when doing internal edge assembling.

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

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

Definition at line 299 of file ThreadedElementLoopBase.h.

Referenced by ThreadedElementLoopBase< RangeType >::operator()().

300 {
301 }
template<typename RangeType>
void ThreadedElementLoopBase< RangeType >::operator() ( const RangeType &  range,
bool  bypass_threading = false 
)

Definition at line 176 of file ThreadedElementLoopBase.h.

177 {
178  try
179  {
180  ParallelUniqueId puid;
181  _tid = bypass_threading ? 0 : puid.id;
182 
183  pre();
184 
187  typename RangeType::const_iterator el = range.begin();
188  for (el = range.begin(); el != range.end(); ++el)
189  {
190  if (!keepGoing())
191  break;
192 
193  const Elem * elem = *el;
194 
195  preElement(elem);
196 
198  _subdomain = elem->subdomain_id();
199  if (_subdomain != _old_subdomain)
201 
202  onElement(elem);
203 
204  for (unsigned int side = 0; side < elem->n_sides(); side++)
205  {
206  std::vector<BoundaryID> boundary_ids = _mesh.getBoundaryIDs(elem, side);
207 
208  if (boundary_ids.size() > 0)
209  for (std::vector<BoundaryID>::iterator it = boundary_ids.begin();
210  it != boundary_ids.end();
211  ++it)
212  onBoundary(elem, side, *it);
213 
214  const Elem * neighbor = elem->neighbor_ptr(side);
215  if (neighbor != nullptr)
216  {
217  preInternalSide(elem, side);
218 
220  _neighbor_subdomain = neighbor->subdomain_id();
223 
224  onInternalSide(elem, side);
225 
226  if (boundary_ids.size() > 0)
227  for (std::vector<BoundaryID>::iterator it = boundary_ids.begin();
228  it != boundary_ids.end();
229  ++it)
230  onInterface(elem, side, *it);
231 
232  postInternalSide(elem, side);
233  }
234  } // sides
235  postElement(elem);
236 
237  } // range
238 
239  post();
240  }
241  catch (MooseException & e)
242  {
244  }
245 }
virtual bool keepGoing()
Whether or not the loop should continue.
virtual void onElement(const Elem *elem)
Assembly of the element (not including surface assembly)
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:1951
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.h:118
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.
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.
template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::post ( )
virtual
template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::postElement ( const Elem *  elem)
virtual

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

Parameters
elem- active element

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

Definition at line 273 of file ThreadedElementLoopBase.h.

Referenced by ThreadedElementLoopBase< RangeType >::operator()().

274 {
275 }
template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::postInternalSide ( const Elem *  elem,
unsigned int  side 
)
virtual

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 293 of file ThreadedElementLoopBase.h.

Referenced by ThreadedElementLoopBase< RangeType >::operator()().

294 {
295 }
template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::pre ( )
virtual

Called before the element range loop.

Reimplemented in ComputeDiracThread.

Definition at line 249 of file ThreadedElementLoopBase.h.

Referenced by ThreadedElementLoopBase< RangeType >::operator()().

250 {
251 }
template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::preElement ( const Elem *  elem)
virtual

Called before the element assembly.

Parameters
elem- active element

Reimplemented in ThreadedElementLoop< RangeType >, ThreadedElementLoop< ConstElemRange >, ThreadedElementLoop< DistElemRange >, and ThreadedElementLoop< ConstElemPointerRange >.

Definition at line 267 of file ThreadedElementLoopBase.h.

Referenced by ThreadedElementLoopBase< RangeType >::operator()().

268 {
269 }
template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::preInternalSide ( const Elem *  elem,
unsigned int  side 
)
virtual

Called before evaluations on an element internal side.

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

Reimplemented in ThreadedElementLoop< RangeType >, ThreadedElementLoop< ConstElemRange >, ThreadedElementLoop< DistElemRange >, and ThreadedElementLoop< ConstElemPointerRange >.

Definition at line 287 of file ThreadedElementLoopBase.h.

Referenced by ThreadedElementLoopBase< RangeType >::operator()().

288 {
289 }
template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::subdomainChanged ( )
virtual

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, ComputeMaterialsObjectThread, ProjectMaterialProperties, ComputeIndicatorThread, ComputeJacobianThread, ComputeDiracThread, ComputeResidualThread, ComputeElemAuxVarsThread, and ComputeMarkerThread.

Definition at line 313 of file ThreadedElementLoopBase.h.

Referenced by ThreadedElementLoopBase< RangeType >::operator()().

314 {
315 }

Member Data Documentation

template<typename RangeType>
MooseMesh& ThreadedElementLoopBase< RangeType >::_mesh
protected
template<typename RangeType>
SubdomainID ThreadedElementLoopBase< RangeType >::_neighbor_subdomain
protected

The subdomain for the current neighbor.

Definition at line 151 of file ThreadedElementLoopBase.h.

Referenced by ThreadedElementLoopBase< RangeType >::operator()().

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

The subdomain for the last neighbor.

Definition at line 154 of file ThreadedElementLoopBase.h.

Referenced by ThreadedElementLoopBase< RangeType >::operator()().

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

The subdomain for the last element.

Definition at line 148 of file ThreadedElementLoopBase.h.

Referenced by ThreadedElementLoopBase< RangeType >::operator()().

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

The subdomain for the current element.

Definition at line 145 of file ThreadedElementLoopBase.h.

Referenced by ThreadedElementLoopBase< RangeType >::operator()().

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

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