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

#include <ComputeIndicatorThread.h>

Inheritance diagram for ComputeIndicatorThread:
[legend]

Public Member Functions

 ComputeIndicatorThread (FEProblemBase &fe_problem, bool finalize=false)
 
 ComputeIndicatorThread (ComputeIndicatorThread &x, Threads::split split)
 
virtual ~ComputeIndicatorThread ()
 
virtual void subdomainChanged () override
 Called every time the current subdomain changes (i.e. More...
 
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 postElement (const Elem *) override
 Called after the element assembly is done (including surface assembling) More...
 
virtual void post () override
 Called after the element range loop. More...
 
void join (const ComputeIndicatorThread &)
 
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 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

FEProblemBase_fe_problem
 
AuxiliarySystem_aux_sys
 
const MooseObjectWarehouse< Indicator > & _indicator_whs
 Indicator Storage. More...
 
const MooseObjectWarehouse< InternalSideIndicator > & _internal_side_indicators
 InternalSideIndicator Storage. More...
 
bool _finalize
 
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

Definition at line 26 of file ComputeIndicatorThread.h.

Constructor & Destructor Documentation

ComputeIndicatorThread::ComputeIndicatorThread ( FEProblemBase fe_problem,
bool  finalize = false 
)
Parameters
fe_problemreference to the FEProblemBase we are computing on
sysreference to the AuxSystem we are computing on
indicator_whsWarehouse of Indicator objects.
finalizeWhether or not we are just in the "finalize" stage or not.

Definition at line 27 of file ComputeIndicatorThread.C.

29  _fe_problem(fe_problem),
30  _aux_sys(fe_problem.getAuxiliarySystem()),
33  _finalize(finalize)
34 {
35 }
const MooseObjectWarehouse< InternalSideIndicator > & _internal_side_indicators
InternalSideIndicator Storage.
AuxiliarySystem & getAuxiliarySystem()
const MooseObjectWarehouse< Indicator > & getIndicatorWarehouse()
Return indicator/marker storage.
const MooseObjectWarehouse< Indicator > & _indicator_whs
Indicator Storage.
const MooseObjectWarehouse< InternalSideIndicator > & getInternalSideIndicatorWarehouse()
ComputeIndicatorThread::ComputeIndicatorThread ( ComputeIndicatorThread x,
Threads::split  split 
)

Definition at line 38 of file ComputeIndicatorThread.C.

41  _aux_sys(x._aux_sys),
42  _indicator_whs(x._indicator_whs),
43  _internal_side_indicators(x._internal_side_indicators),
44  _finalize(x._finalize)
45 {
46 }
const MooseObjectWarehouse< InternalSideIndicator > & _internal_side_indicators
InternalSideIndicator Storage.
FEProblemBase & _fe_problem
static PetscErrorCode Vec x
const MooseObjectWarehouse< Indicator > & _indicator_whs
Indicator Storage.
ComputeIndicatorThread::~ComputeIndicatorThread ( )
virtual

Definition at line 48 of file ComputeIndicatorThread.C.

48 {}

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 ComputeIndicatorThread::join ( const ComputeIndicatorThread )

Definition at line 195 of file ComputeIndicatorThread.C.

196 {
197 }
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 ComputeIndicatorThread::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 133 of file ComputeIndicatorThread.C.

136 {
137 }
void ComputeIndicatorThread::onElement ( const Elem *  elem)
overridevirtual

Assembly of the element (not including surface assembly)

Parameters
elem- active element

Reimplemented from ThreadedElementLoopBase< ConstElemRange >.

Definition at line 72 of file ComputeIndicatorThread.C.

73 {
74  for (const auto & it : _aux_sys._elem_vars[_tid])
75  {
76  MooseVariable * var = it.second;
77  var->prepareAux();
78  }
79 
80  _fe_problem.prepare(elem, _tid);
81  _fe_problem.reinitElem(elem, _tid);
82 
83  // Set up Sentinel class so that, even if reinitMaterials() throws, we
84  // still remember to swap back during stack unwinding.
86 
88 
89  // Compute
90  if (!_finalize)
91  {
93  {
94  const std::vector<std::shared_ptr<Indicator>> & indicators =
96  for (const auto & indicator : indicators)
97  indicator->computeIndicator();
98  }
99  }
100 
101  // Finalize
102  else
103  {
105  {
106  const std::vector<std::shared_ptr<Indicator>> & indicators =
108  for (const auto & indicator : indicators)
109  indicator->finalize();
110  }
111 
113  {
114  const std::vector<std::shared_ptr<InternalSideIndicator>> & internal_indicators =
116  for (const auto & internal_indicator : internal_indicators)
117  internal_indicator->finalize();
118  }
119  }
120 
121  if (!_finalize) // During finalize the Indicators should be setting values in the vectors manually
122  {
123  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
124  for (const auto & it : _aux_sys._elem_vars[_tid])
125  {
126  MooseVariable * var = it.second;
127  var->add(_aux_sys.solution());
128  }
129  }
130 }
const MooseObjectWarehouse< InternalSideIndicator > & _internal_side_indicators
InternalSideIndicator Storage.
virtual void prepare(const Elem *elem, THREAD_ID tid) override
Class for stuff related to variables.
Definition: MooseVariable.h:43
virtual void reinitElem(const Elem *elem, THREAD_ID tid) override
virtual void reinitMaterials(SubdomainID blk_id, THREAD_ID tid, bool swap_stateful=true)
std::vector< std::map< std::string, MooseVariable * > > _elem_vars
virtual void swapBackMaterials(THREAD_ID tid)
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
virtual NumericVector< Number > & solution() override
const MooseObjectWarehouse< Indicator > & _indicator_whs
Indicator Storage.
bool hasActiveBlockObjects(THREAD_ID tid=0) const
SubdomainID _subdomain
The subdomain for the current element.
void add(NumericVector< Number > &residual)
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 ComputeIndicatorThread::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 140 of file ComputeIndicatorThread.C.

141 {
142  if (_finalize) // If finalizing we only do something on the elements
143  return;
144 
145  // Pointer to the neighbor we are currently working on.
146  const Elem * neighbor = elem->neighbor_ptr(side);
147 
148  // Get the global id of the element and the neighbor
149  const dof_id_type elem_id = elem->id(), neighbor_id = neighbor->id();
150 
151  if ((neighbor->active() && (neighbor->level() == elem->level()) && (elem_id < neighbor_id)) ||
152  (neighbor->level() < elem->level()))
153  {
154  for (const auto & it : _aux_sys._elem_vars[_tid])
155  {
156  MooseVariable * var = it.second;
157  var->prepareAux();
158  }
159 
160  SubdomainID block_id = elem->subdomain_id();
162  {
163  _fe_problem.reinitNeighbor(elem, side, _tid);
164 
165  // Set up Sentinels so that, even if one of the reinitMaterialsXXX() calls throws, we
166  // still remember to swap back during stack unwinding.
168  _fe_problem.reinitMaterialsFace(block_id, _tid);
169 
170  SwapBackSentinel neighbor_sentinel(
172  _fe_problem.reinitMaterialsNeighbor(neighbor->subdomain_id(), _tid);
173 
174  const std::vector<std::shared_ptr<InternalSideIndicator>> & indicators =
176  for (const auto & indicator : indicators)
177  indicator->computeIndicator();
178  }
179  }
180 }
const MooseObjectWarehouse< InternalSideIndicator > & _internal_side_indicators
InternalSideIndicator Storage.
Class for stuff related to variables.
Definition: MooseVariable.h:43
subdomain_id_type SubdomainID
Definition: MooseTypes.h:77
virtual void reinitMaterialsNeighbor(SubdomainID blk_id, THREAD_ID tid, bool swap_stateful=true)
std::vector< std::map< std::string, MooseVariable * > > _elem_vars
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
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 ComputeIndicatorThread::post ( )
overridevirtual

Called after the element range loop.

Reimplemented from ThreadedElementLoopBase< ConstElemRange >.

Definition at line 188 of file ComputeIndicatorThread.C.

189 {
192 }
virtual void clearActiveMaterialProperties(THREAD_ID tid) override
Clear the active material properties.
virtual void clearActiveElementalMooseVariables(THREAD_ID tid) override
Clear the active elemental MooseVariable.
void ComputeIndicatorThread::postElement ( const Elem *  elem)
overridevirtual

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

Parameters
elem- active element

Reimplemented from ThreadedElementLoopBase< ConstElemRange >.

Definition at line 183 of file ComputeIndicatorThread.C.

184 {
185 }
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 ComputeIndicatorThread::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 51 of file ComputeIndicatorThread.C.

52 {
54 
57 
58  std::set<MooseVariable *> needed_moose_vars;
59  _indicator_whs.updateVariableDependency(needed_moose_vars, _tid);
62 
63  std::set<unsigned int> needed_mat_props;
64  _indicator_whs.updateMatPropDependency(needed_mat_props, _tid);
66  _fe_problem.setActiveMaterialProperties(needed_mat_props, _tid);
67 
69 }
virtual void setActiveElementalMooseVariables(const std::set< MooseVariable * > &moose_vars, THREAD_ID tid) override
Set the MOOSE variables to be reinited on each element.
const MooseObjectWarehouse< InternalSideIndicator > & _internal_side_indicators
InternalSideIndicator Storage.
virtual void prepareMaterials(SubdomainID blk_id, THREAD_ID tid)
Add the MooseVariables that the current materials depend on to the dependency list.
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)
void updateVariableDependency(std::set< MooseVariable * > &needed_moose_vars, THREAD_ID tid=0) const
Update variable dependency vector.
void updateMatPropDependency(std::set< unsigned int > &needed_mat_props, THREAD_ID tid=0) const
Update material property dependency vector.
const MooseObjectWarehouse< Indicator > & _indicator_whs
Indicator Storage.
SubdomainID _subdomain
The subdomain for the current element.

Member Data Documentation

AuxiliarySystem& ComputeIndicatorThread::_aux_sys
protected

Definition at line 53 of file ComputeIndicatorThread.h.

Referenced by onElement(), and onInternalSide().

FEProblemBase& ComputeIndicatorThread::_fe_problem
protected

Definition at line 52 of file ComputeIndicatorThread.h.

Referenced by onElement(), onInternalSide(), post(), and subdomainChanged().

bool ComputeIndicatorThread::_finalize
protected

Definition at line 61 of file ComputeIndicatorThread.h.

Referenced by onElement(), and onInternalSide().

const MooseObjectWarehouse<Indicator>& ComputeIndicatorThread::_indicator_whs
protected

Indicator Storage.

Definition at line 56 of file ComputeIndicatorThread.h.

Referenced by onElement(), and subdomainChanged().

const MooseObjectWarehouse<InternalSideIndicator>& ComputeIndicatorThread::_internal_side_indicators
protected

InternalSideIndicator Storage.

Definition at line 59 of file ComputeIndicatorThread.h.

Referenced by onElement(), 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.

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(), ComputeUserObjectsThread::onBoundary(), ComputeMaterialsObjectThread::onBoundary(), ComputeMarkerThread::onElement(), ComputeElemDampingThread::onElement(), ComputeElemAuxVarsThread::onElement(), ComputeResidualThread::onElement(), ComputeJacobianThread::onElement(), onElement(), ComputeUserObjectsThread::onElement(), ComputeMaterialsObjectThread::onElement(), ComputeResidualThread::onInterface(), ComputeJacobianThread::onInterface(), ComputeJacobianThread::onInternalSide(), ComputeResidualThread::onInternalSide(), onInternalSide(), ComputeUserObjectsThread::onInternalSide(), ComputeMaterialsObjectThread::onInternalSide(), ComputeMarkerThread::post(), ComputeElemAuxVarsThread::post(), ComputeMaterialsObjectThread::post(), ComputeResidualThread::post(), post(), ComputeJacobianThread::post(), ComputeUserObjectsThread::post(), ComputeResidualThread::postElement(), ComputeJacobianThread::postElement(), ComputeJacobianBlocksThread::postElement(), ComputeMarkerThread::subdomainChanged(), ComputeElemAuxVarsThread::subdomainChanged(), ComputeResidualThread::subdomainChanged(), subdomainChanged(), ComputeJacobianThread::subdomainChanged(), ComputeMaterialsObjectThread::subdomainChanged(), and ComputeUserObjectsThread::subdomainChanged().


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