www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
ComputeUserObjectsThread Class Reference

Class for threaded computation of UserObjects. More...

#include <ComputeUserObjectsThread.h>

Inheritance diagram for ComputeUserObjectsThread:
[legend]

Public Member Functions

 ComputeUserObjectsThread (FEProblemBase &problem, SystemBase &sys, const MooseObjectWarehouse< ElementUserObject > &elemental_user_objects, const MooseObjectWarehouse< SideUserObject > &side_user_objects, const MooseObjectWarehouse< InternalSideUserObject > &internal_side_user_objects)
 
 ComputeUserObjectsThread (ComputeUserObjectsThread &x, Threads::split)
 
virtual ~ComputeUserObjectsThread ()
 
virtual void onElement (const Elem *elem) override
 Assembly of the element (not including surface assembly) More...
 
virtual void onBoundary (const Elem *elem, unsigned int side, BoundaryID bnd_id) override
 Called when doing boundary assembling. More...
 
virtual void onInternalSide (const Elem *elem, unsigned int side) override
 Called when doing internal edge assembling. More...
 
virtual void post () override
 Called after the element range loop. More...
 
virtual void subdomainChanged () override
 Called every time the current subdomain changes (i.e. More...
 
void join (const ComputeUserObjectsThread &)
 
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 ConstElemRange &range, bool bypass_threading=false)
 
virtual void pre ()
 Called before the element range loop. More...
 
virtual void postElement (const Elem *elem)
 Called after the element assembly is done (including surface assembling) More...
 
virtual void postInternalSide (const Elem *elem, unsigned int side)
 Called after evaluations on an element internal side. More...
 
virtual void onInterface (const Elem *elem, unsigned int side, BoundaryID bnd_id)
 Called when doing interface assembling. More...
 

Protected Attributes

const NumericVector< Number > & _soln
 
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...
 
const MooseObjectWarehouse< ElementUserObject > & _elemental_user_objects
 
const MooseObjectWarehouse< SideUserObject > & _side_user_objects
 
const MooseObjectWarehouse< InternalSideUserObject > & _internal_side_user_objects
 

Detailed Description

Class for threaded computation of UserObjects.

Definition at line 33 of file ComputeUserObjectsThread.h.

Constructor & Destructor Documentation

ComputeUserObjectsThread::ComputeUserObjectsThread ( FEProblemBase problem,
SystemBase sys,
const MooseObjectWarehouse< ElementUserObject > &  elemental_user_objects,
const MooseObjectWarehouse< SideUserObject > &  side_user_objects,
const MooseObjectWarehouse< InternalSideUserObject > &  internal_side_user_objects 
)

Definition at line 29 of file ComputeUserObjectsThread.C.

36  _soln(*sys.currentSolution()),
37  _elemental_user_objects(elemental_user_objects),
38  _side_user_objects(side_user_objects),
39  _internal_side_user_objects(internal_side_user_objects)
40 {
41 }
const MooseObjectWarehouse< InternalSideUserObject > & _internal_side_user_objects
const MooseObjectWarehouse< SideUserObject > & _side_user_objects
const MooseObjectWarehouse< ElementUserObject > & _elemental_user_objects
const NumericVector< Number > & _soln
virtual const NumericVector< Number > *& currentSolution()=0
The solution vector that is currently being operated on.
ComputeUserObjectsThread::ComputeUserObjectsThread ( ComputeUserObjectsThread x,
Threads::split   
)

Definition at line 44 of file ComputeUserObjectsThread.C.

46  _soln(x._soln),
50 {
51 }
const MooseObjectWarehouse< InternalSideUserObject > & _internal_side_user_objects
FEProblemBase & _fe_problem
const MooseObjectWarehouse< SideUserObject > & _side_user_objects
const MooseObjectWarehouse< ElementUserObject > & _elemental_user_objects
const NumericVector< Number > & _soln
ComputeUserObjectsThread::~ComputeUserObjectsThread ( )
virtual

Definition at line 53 of file ComputeUserObjectsThread.C.

53 {}

Member Function Documentation

virtual void ThreadedElementLoop< ConstElemRange >::caughtMooseException ( MooseException e)
overridevirtualinherited

Called if a MooseException is caught anywhere during the computation.

The single input parameter taken is a MooseException object.

Reimplemented from ThreadedElementLoopBase< ConstElemRange >.

void ComputeUserObjectsThread::join ( const ComputeUserObjectsThread )

Definition at line 207 of file ComputeUserObjectsThread.C.

208 {
209 }
virtual bool ThreadedElementLoop< ConstElemRange >::keepGoing ( )
inlineoverridevirtualinherited

Whether or not the loop should continue.

Returns
true to keep going, false to stop.

Reimplemented from ThreadedElementLoopBase< ConstElemRange >.

Definition at line 50 of file ThreadedElementLoop.h.

50 { return !_fe_problem.hasException(); }
virtual bool hasException()
Whether or not an exception has occurred.
virtual void ThreadedElementLoop< ConstElemRange >::neighborSubdomainChanged ( )
overridevirtualinherited

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< ConstElemRange >.

void ComputeUserObjectsThread::onBoundary ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id 
)
overridevirtual

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 from ThreadedElementLoopBase< ConstElemRange >.

Definition at line 123 of file ComputeUserObjectsThread.C.

124 {
126  return;
127 
128  _fe_problem.reinitElemFace(elem, side, bnd_id, _tid);
129 
130  // Set up Sentinel class so that, even if reinitMaterialsFace() throws, we
131  // still remember to swap back during stack unwinding.
135 
136  const auto & objects = _side_user_objects.getActiveBoundaryObjects(bnd_id, _tid);
137  for (const auto & uo : objects)
138  uo->execute();
139 
140  // UserObject Jacobians
142  {
143  // Prepare shape functions for ShapeSideUserObjects
144  std::vector<MooseVariable *> jacobian_moose_vars =
146  for (auto & jvar : jacobian_moose_vars)
147  {
148  unsigned int jvar_id = jvar->number();
149  std::vector<dof_id_type> & dof_indices = jvar->dofIndices();
150 
152 
153  for (const auto & uo : objects)
154  {
155  auto shape_side_uo = std::dynamic_pointer_cast<ShapeSideUserObject>(uo);
156  if (shape_side_uo)
157  shape_side_uo->executeJacobianWrapper(jvar_id, dof_indices);
158  }
159  }
160  }
161 }
const std::vector< MooseVariable * > & getUserObjectJacobianVariables(THREAD_ID tid) const
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
virtual bool currentlyComputingJacobian()
Returns true if we are currently computing Jacobian.
virtual void reinitMaterialsBoundary(BoundaryID boundary_id, THREAD_ID tid, bool swap_stateful=true)
const MooseObjectWarehouse< SideUserObject > & _side_user_objects
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
virtual void executeJacobianWrapper(unsigned int jvar, const std::vector< dof_id_type > &dof_indices)
This function will be called with the shape functions for jvar initialized.
virtual void reinitElemFace(const Elem *elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid) override
virtual void reinitMaterialsFace(SubdomainID blk_id, THREAD_ID tid, bool swap_stateful=true)
virtual void prepareFaceShapes(unsigned int var, THREAD_ID tid) override
SubdomainID _subdomain
The subdomain for the current element.
virtual void swapBackMaterialsFace(THREAD_ID tid)
SideUserObject class in which the _phi and _grad_phi shape function data is available and correctly i...
The "SwapBackSentinel" class&#39;s destructor guarantees that FEProblemBase::swapBackMaterials{Face,Neighbor}() is called even when an exception is thrown from FEProblemBase::reinitMaterials{Face,Neighbor}.
void ComputeUserObjectsThread::onElement ( const Elem *  elem)
overridevirtual

Assembly of the element (not including surface assembly)

Parameters
elem- active element

Reimplemented from ThreadedElementLoopBase< ConstElemRange >.

Definition at line 80 of file ComputeUserObjectsThread.C.

81 {
82  _fe_problem.prepare(elem, _tid);
84 
85  // Set up Sentinel class so that, even if reinitMaterials() throws, we
86  // still remember to swap back during stack unwinding.
89 
91  {
93  for (const auto & uo : objects)
94  uo->execute();
95  }
96 
97  // UserObject Jacobians
100  {
101  // Prepare shape functions for ShapeElementUserObjects
102  std::vector<MooseVariable *> jacobian_moose_vars =
104  for (auto & jvar : jacobian_moose_vars)
105  {
106  unsigned int jvar_id = jvar->number();
107  std::vector<dof_id_type> & dof_indices = jvar->dofIndices();
108 
109  _fe_problem.prepareShapes(jvar_id, _tid);
110 
112  for (const auto & uo : e_objects)
113  {
114  auto shape_element_uo = std::dynamic_pointer_cast<ShapeElementUserObject>(uo);
115  if (shape_element_uo)
116  shape_element_uo->executeJacobianWrapper(jvar_id, dof_indices);
117  }
118  }
119  }
120 }
virtual void prepare(const Elem *elem, THREAD_ID tid) override
const std::vector< MooseVariable * > & getUserObjectJacobianVariables(THREAD_ID tid) const
virtual bool currentlyComputingJacobian()
Returns true if we are currently computing Jacobian.
virtual void reinitElem(const Elem *elem, THREAD_ID tid) override
virtual void reinitMaterials(SubdomainID blk_id, THREAD_ID tid, bool swap_stateful=true)
const MooseObjectWarehouse< ElementUserObject > & _elemental_user_objects
ElementUserObject class in which the _phi and _grad_phi shape function data is available and correctl...
virtual void swapBackMaterials(THREAD_ID tid)
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
virtual void executeJacobianWrapper(unsigned int jvar, const std::vector< dof_id_type > &dof_indices)
This function will be called with the shape functions for jvar initialized.
bool hasActiveBlockObjects(THREAD_ID tid=0) const
virtual void prepareShapes(unsigned int var, THREAD_ID tid) override
SubdomainID _subdomain
The subdomain for the current element.
The "SwapBackSentinel" class&#39;s destructor guarantees that FEProblemBase::swapBackMaterials{Face,Neighbor}() is called even when an exception is thrown from FEProblemBase::reinitMaterials{Face,Neighbor}.
virtual void ThreadedElementLoopBase< ConstElemRange >::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 ComputeJacobianThread, and ComputeResidualThread.

void ComputeUserObjectsThread::onInternalSide ( const Elem *  elem,
unsigned int  side 
)
overridevirtual

Called when doing internal edge assembling.

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

Reimplemented from ThreadedElementLoopBase< ConstElemRange >.

Definition at line 164 of file ComputeUserObjectsThread.C.

165 {
166  // Pointer to the neighbor we are currently working on.
167  const Elem * neighbor = elem->neighbor_ptr(side);
168 
169  // Get the global id of the element and the neighbor
170  const dof_id_type elem_id = elem->id(), neighbor_id = neighbor->id();
171 
173  return;
174  if (!((neighbor->active() && (neighbor->level() == elem->level()) && (elem_id < neighbor_id)) ||
175  (neighbor->level() < elem->level())))
176  return;
177 
179  _fe_problem.reinitNeighbor(elem, side, _tid);
180 
181  // Set up Sentinels so that, even if one of the reinitMaterialsXXX() calls throws, we
182  // still remember to swap back during stack unwinding.
184  _fe_problem.reinitMaterialsFace(elem->subdomain_id(), _tid);
185 
187  _fe_problem.reinitMaterialsNeighbor(neighbor->subdomain_id(), _tid);
188 
190  for (const auto & uo : objects)
191  {
192  if (!uo->blockRestricted())
193  uo->execute();
194  else if (uo->hasBlocks(neighbor->subdomain_id()))
195  uo->execute();
196  }
197 }
virtual void prepareFace(const Elem *elem, THREAD_ID tid) override
const MooseObjectWarehouse< InternalSideUserObject > & _internal_side_user_objects
virtual void reinitMaterialsNeighbor(SubdomainID blk_id, THREAD_ID tid, bool swap_stateful=true)
virtual void swapBackMaterialsNeighbor(THREAD_ID tid)
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
virtual void reinitMaterialsFace(SubdomainID blk_id, THREAD_ID tid, bool swap_stateful=true)
virtual void reinitNeighbor(const Elem *elem, unsigned int side, THREAD_ID tid) override
bool hasActiveBlockObjects(THREAD_ID tid=0) const
SubdomainID _subdomain
The subdomain for the current element.
virtual void swapBackMaterialsFace(THREAD_ID tid)
The "SwapBackSentinel" class&#39;s destructor guarantees that FEProblemBase::swapBackMaterials{Face,Neighbor}() is called even when an exception is thrown from FEProblemBase::reinitMaterials{Face,Neighbor}.
void ThreadedElementLoopBase< ConstElemRange >::operator() ( const ConstElemRange &  range,
bool  bypass_threading = false 
)
inherited
void ComputeUserObjectsThread::post ( )
overridevirtual

Called after the element range loop.

Reimplemented from ThreadedElementLoopBase< ConstElemRange >.

Definition at line 200 of file ComputeUserObjectsThread.C.

201 {
204 }
virtual void clearActiveMaterialProperties(THREAD_ID tid) override
Clear the active material properties.
virtual void clearActiveElementalMooseVariables(THREAD_ID tid) override
Clear the active elemental MooseVariable.
virtual void ThreadedElementLoopBase< ConstElemRange >::postElement ( const Elem *  elem)
virtualinherited

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

Parameters
elem- active element

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

virtual void ThreadedElementLoopBase< ConstElemRange >::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'
virtual void ThreadedElementLoopBase< ConstElemRange >::pre ( )
virtualinherited

Called before the element range loop.

virtual void ThreadedElementLoop< ConstElemRange >::preElement ( const Elem *  elem)
overridevirtualinherited

Called before the element assembly.

Parameters
elem- active element

Reimplemented from ThreadedElementLoopBase< ConstElemRange >.

virtual void ThreadedElementLoop< ConstElemRange >::preInternalSide ( const Elem *  elem,
unsigned int  side 
)
overridevirtualinherited

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< ConstElemRange >.

void ComputeUserObjectsThread::subdomainChanged ( )
overridevirtual

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 from ThreadedElementLoopBase< ConstElemRange >.

Definition at line 56 of file ComputeUserObjectsThread.C.

57 {
59 
60  std::set<MooseVariable *> needed_moose_vars;
64 
65  std::set<unsigned int> needed_mat_props;
69 
73 
75  _fe_problem.setActiveMaterialProperties(needed_mat_props, _tid);
77 }
void updateBlockVariableDependency(SubdomainID id, std::set< MooseVariable * > &needed_moose_vars, THREAD_ID tid=0) const
virtual void setActiveElementalMooseVariables(const std::set< MooseVariable * > &moose_vars, THREAD_ID tid) override
Set the MOOSE variables to be reinited on each element.
virtual void prepareMaterials(SubdomainID blk_id, THREAD_ID tid)
Add the MooseVariables that the current materials depend on to the dependency list.
void updateBlockMatPropDependency(SubdomainID id, std::set< unsigned int > &needed_mat_props, THREAD_ID tid=0) const
const MooseObjectWarehouse< InternalSideUserObject > & _internal_side_user_objects
virtual void subdomainSetup(THREAD_ID tid=0) const
virtual void setActiveMaterialProperties(const std::set< unsigned int > &mat_prop_ids, THREAD_ID tid) override
Record and set the material properties required by the current computing thread.
virtual void subdomainSetup(SubdomainID subdomain, THREAD_ID tid)
const MooseObjectWarehouse< SideUserObject > & _side_user_objects
void updateBoundaryVariableDependency(std::set< MooseVariable * > &needed_moose_vars, THREAD_ID tid=0) const
const MooseObjectWarehouse< ElementUserObject > & _elemental_user_objects
void updateBoundaryMatPropDependency(std::set< unsigned int > &needed_mat_props, THREAD_ID tid=0) const
SubdomainID _subdomain
The subdomain for the current element.

Member Data Documentation

const MooseObjectWarehouse<ElementUserObject>& ComputeUserObjectsThread::_elemental_user_objects
protected

Storage for UserObjects (see FEProblemBase::computeUserObjects)

Definition at line 60 of file ComputeUserObjectsThread.h.

Referenced by onElement(), and subdomainChanged().

FEProblemBase& ThreadedElementLoop< ConstElemRange >::_fe_problem
protectedinherited
const MooseObjectWarehouse<InternalSideUserObject>& ComputeUserObjectsThread::_internal_side_user_objects
protected

Definition at line 62 of file ComputeUserObjectsThread.h.

Referenced by onInternalSide(), and subdomainChanged().

MooseMesh& ThreadedElementLoopBase< ConstElemRange >::_mesh
protectedinherited

Definition at line 141 of file ThreadedElementLoopBase.h.

SubdomainID ThreadedElementLoopBase< ConstElemRange >::_neighbor_subdomain
protectedinherited

The subdomain for the current neighbor.

Definition at line 151 of file ThreadedElementLoopBase.h.

SubdomainID ThreadedElementLoopBase< ConstElemRange >::_old_neighbor_subdomain
protectedinherited

The subdomain for the last neighbor.

Definition at line 154 of file ThreadedElementLoopBase.h.

SubdomainID ThreadedElementLoopBase< ConstElemRange >::_old_subdomain
protectedinherited

The subdomain for the last element.

Definition at line 148 of file ThreadedElementLoopBase.h.

const MooseObjectWarehouse<SideUserObject>& ComputeUserObjectsThread::_side_user_objects
protected

Definition at line 61 of file ComputeUserObjectsThread.h.

Referenced by onBoundary(), and subdomainChanged().

const NumericVector<Number>& ComputeUserObjectsThread::_soln
protected

Definition at line 56 of file ComputeUserObjectsThread.h.

SubdomainID ThreadedElementLoopBase< ConstElemRange >::_subdomain
protectedinherited
THREAD_ID ThreadedElementLoopBase< ConstElemRange >::_tid
protectedinherited

Definition at line 142 of file ThreadedElementLoopBase.h.

Referenced by ComputeFullJacobianThread::computeFaceJacobian(), ComputeJacobianThread::computeFaceJacobian(), ComputeFullJacobianThread::computeInternalFaceJacobian(), ComputeJacobianThread::computeInternalFaceJacobian(), ComputeFullJacobianThread::computeInternalInterFaceJacobian(), ComputeJacobianThread::computeInternalInterFaceJacobian(), ComputeFullJacobianThread::computeJacobian(), ComputeJacobianThread::computeJacobian(), ComputeResidualThread::onBoundary(), ComputeJacobianThread::onBoundary(), onBoundary(), ComputeMaterialsObjectThread::onBoundary(), ComputeMarkerThread::onElement(), ComputeElemDampingThread::onElement(), ComputeElemAuxVarsThread::onElement(), ComputeResidualThread::onElement(), ComputeJacobianThread::onElement(), ComputeIndicatorThread::onElement(), onElement(), ComputeMaterialsObjectThread::onElement(), ComputeResidualThread::onInterface(), ComputeJacobianThread::onInterface(), ComputeJacobianThread::onInternalSide(), ComputeResidualThread::onInternalSide(), ComputeIndicatorThread::onInternalSide(), onInternalSide(), ComputeMaterialsObjectThread::onInternalSide(), ComputeMarkerThread::post(), ComputeElemAuxVarsThread::post(), ComputeMaterialsObjectThread::post(), ComputeResidualThread::post(), ComputeIndicatorThread::post(), ComputeJacobianThread::post(), post(), ComputeResidualThread::postElement(), ComputeJacobianThread::postElement(), ComputeJacobianBlocksThread::postElement(), ComputeMarkerThread::subdomainChanged(), ComputeElemAuxVarsThread::subdomainChanged(), ComputeResidualThread::subdomainChanged(), ComputeIndicatorThread::subdomainChanged(), ComputeJacobianThread::subdomainChanged(), ComputeMaterialsObjectThread::subdomainChanged(), and subdomainChanged().


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