https://mooseframework.inl.gov
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ComputeMaterialsObjectThread Class Reference

#include <ComputeMaterialsObjectThread.h>

Inheritance diagram for ComputeMaterialsObjectThread:
[legend]

Public Member Functions

 ComputeMaterialsObjectThread (FEProblemBase &fe_problem, MaterialPropertyStorage &material_props, MaterialPropertyStorage &bnd_material_props, MaterialPropertyStorage &neighbor_material_props, std::vector< std::vector< std::unique_ptr< Assembly >>> &assembly)
 
 ComputeMaterialsObjectThread (ComputeMaterialsObjectThread &x, Threads::split split)
 
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...
 
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, const Elem *lower_d_elem=nullptr) 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 onInterface (const Elem *elem, unsigned int side, BoundaryID bnd_id) override
 Called when doing interface assembling. More...
 
void join (const ComputeMaterialsObjectThread &)
 
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 preBoundary (const Elem *elem, unsigned int side, BoundaryID bnd_id, const Elem *lower_d_elem=nullptr) override
 Called before the boundary assembly. More...
 
virtual void neighborSubdomainChanged () override
 Called every time the neighbor subdomain changes (i.e. More...
 
virtual 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 onExternalSide (const Elem *elem, unsigned int side)
 Called when iterating over external sides (no side neighbor) More...
 

Protected Member Functions

void prepareElement (const Elem *elem)
 
void clearVarsAndMaterials ()
 
void printExecutionOrdering (const std::vector< T * > &objs, const bool print_header=true, const std::string &line_prefix="[DBG]") const
 Routine to output the ordering of objects within a vector of pointers to these objects. More...
 
void printExecutionOrdering (const std::vector< std::shared_ptr< T >> &objs_ptrs, const bool print_header=true, const std::string &line_prefix="[DBG]") const
 
virtual void printGeneralExecutionInformation () const
 Print information about the loop ordering. More...
 
virtual void printBlockExecutionInformation () const
 Print information about the particular ordering of objects on each block. More...
 
virtual void printBoundaryExecutionInformation (const unsigned int) const
 Print information about the particular ordering of objects on each boundary. More...
 
void resetExecPrintedSets () const
 Resets the set of blocks and boundaries visited. More...
 
virtual bool shouldComputeInternalSide (const Elem &elem, const Elem &neighbor) const
 Whether to compute the internal side for the provided element-neighbor pair. More...
 

Protected Attributes

FEProblemBase_fe_problem
 
MaterialPropertyStorage_material_props
 
MaterialPropertyStorage_bnd_material_props
 
MaterialPropertyStorage_neighbor_material_props
 
const MaterialWarehouse_materials
 This is populated using _fe_problem.getResidualMaterialsWarehouse because it has the union of traditional materials and the residual version of AD materials. More...
 
const MaterialWarehouse_interface_materials
 This is populated using _fe_problem.getResidualInterfaceMaterialsWarehouse because it has the union of traditional interface materials and the residual version of AD interface materials. More...
 
const MaterialWarehouse_discrete_materials
 
std::vector< std::vector< std::unique_ptr< Assembly > > > & _assembly
 
bool _need_internal_side_material
 
const bool _has_stateful_props
 
const bool _has_bnd_stateful_props
 
const bool _has_neighbor_stateful_props
 
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...
 
std::set< SubdomainID_blocks_exec_printed
 Keep track of which blocks were visited. More...
 
std::set< BoundaryID_boundaries_exec_printed
 Keep track of which boundaries were visited. More...
 

Detailed Description

Definition at line 23 of file ComputeMaterialsObjectThread.h.

Constructor & Destructor Documentation

◆ ComputeMaterialsObjectThread() [1/2]

ComputeMaterialsObjectThread::ComputeMaterialsObjectThread ( FEProblemBase fe_problem,
MaterialPropertyStorage material_props,
MaterialPropertyStorage bnd_material_props,
MaterialPropertyStorage neighbor_material_props,
std::vector< std::vector< std::unique_ptr< Assembly >>> &  assembly 
)

Definition at line 24 of file ComputeMaterialsObjectThread.C.

31  _fe_problem(fe_problem),
32  _material_props(material_props),
33  _bnd_material_props(bnd_material_props),
34  _neighbor_material_props(neighbor_material_props),
38  _assembly(assembly),
43 {
44 }
MaterialPropertyStorage & _material_props
const MaterialWarehouse & _interface_materials
This is populated using _fe_problem.getResidualInterfaceMaterialsWarehouse because it has the union o...
const MaterialWarehouse & getRegularMaterialsWarehouse() const
const MaterialWarehouse & getInterfaceMaterialsWarehouse() const
const MaterialWarehouse & getDiscreteMaterialWarehouse() const
const MaterialWarehouse & _materials
This is populated using _fe_problem.getResidualMaterialsWarehouse because it has the union of traditi...
MaterialPropertyStorage & _neighbor_material_props
std::vector< std::vector< std::unique_ptr< Assembly > > > & _assembly
MaterialPropertyStorage & _bnd_material_props
const MaterialWarehouse & _discrete_materials

◆ ComputeMaterialsObjectThread() [2/2]

ComputeMaterialsObjectThread::ComputeMaterialsObjectThread ( ComputeMaterialsObjectThread x,
Threads::split  split 
)

Definition at line 47 of file ComputeMaterialsObjectThread.C.

51  _material_props(x._material_props),
52  _bnd_material_props(x._bnd_material_props),
53  _neighbor_material_props(x._neighbor_material_props),
54  _materials(x._materials),
55  _interface_materials(x._interface_materials),
56  _discrete_materials(x._discrete_materials),
57  _assembly(x._assembly),
58  _need_internal_side_material(x._need_internal_side_material),
62 {
63 }
FEProblemBase & _fe_problem
MaterialPropertyStorage & _material_props
const MaterialWarehouse & _interface_materials
This is populated using _fe_problem.getResidualInterfaceMaterialsWarehouse because it has the union o...
const MaterialWarehouse & _materials
This is populated using _fe_problem.getResidualMaterialsWarehouse because it has the union of traditi...
MaterialPropertyStorage & _neighbor_material_props
tbb::split split
std::vector< std::vector< std::unique_ptr< Assembly > > > & _assembly
MaterialPropertyStorage & _bnd_material_props
const MaterialWarehouse & _discrete_materials

Member Function Documentation

◆ caughtMooseException()

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

Definition at line 105 of file ThreadedElementLoop.h.

Referenced by ComputeJacobianForScalingThread::operator()().

106 {
107  Threads::spin_mutex::scoped_lock lock(threaded_element_mutex);
108 
109  std::string what(e.what());
111 }
virtual const char * what() const
Get out the error message.
virtual void setException(const std::string &message)
Set an exception, which is stored at this point by toggling a member variable in this class...
static Threads::spin_mutex threaded_element_mutex
This mutex is used by all derived classes of the ThreadedElementLoop.

◆ clearVarsAndMaterials()

void ThreadedElementLoop< ConstElemRange >::clearVarsAndMaterials ( )
protectedinherited

Definition at line 195 of file ThreadedElementLoop.h.

Referenced by NonlinearThread::post().

196 {
199 }
void clearActiveMaterialProperties(const THREAD_ID tid)
Clear the active material properties.
virtual void clearActiveElementalMooseVariables(const THREAD_ID tid) override
Clear the active elemental MooseVariableFEBase.

◆ join()

void ComputeMaterialsObjectThread::join ( const ComputeMaterialsObjectThread )

Definition at line 296 of file ComputeMaterialsObjectThread.C.

297 {
298 }

◆ keepGoing()

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 45 of file ThreadedElementLoop.h.

Referenced by ComputeJacobianForScalingThread::operator()().

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

◆ neighborSubdomainChanged()

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

Definition at line 139 of file ThreadedElementLoop.h.

140 {
143 }
Base class for assembly-like calculations.
virtual void neighborSubdomainSetup(SubdomainID subdomain, const THREAD_ID tid)

◆ onBoundary()

void ComputeMaterialsObjectThread::onBoundary ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id,
const Elem *  lower_d_elem = nullptr 
)
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
lower_d_elem- Lower dimensional element (e.g. Mortar)

Reimplemented from ThreadedElementLoopBase< ConstElemRange >.

Definition at line 111 of file ComputeMaterialsObjectThread.C.

115 {
117  {
118  _fe_problem.reinitElemFace(elem, side, _tid);
119  unsigned int face_n_points = _assembly[_tid][0]->qRuleFace()->n_points();
120 
122 
124  {
125  // Face Materials
126  if (_discrete_materials[Moose::FACE_MATERIAL_DATA].hasActiveBlockObjects(_subdomain, _tid))
128  _tid,
130  face_n_points,
131  *elem,
132  side);
133  if (_materials[Moose::FACE_MATERIAL_DATA].hasActiveBlockObjects(_subdomain, _tid))
135  _tid,
136  _materials[Moose::FACE_MATERIAL_DATA].getActiveBlockObjects(_subdomain, _tid),
137  face_n_points,
138  *elem,
139  side);
140 
141  // Boundary Materials
144  _tid, _materials.getActiveBoundaryObjects(bnd_id, _tid), face_n_points, *elem, side);
147  _tid, _materials.getActiveBoundaryObjects(bnd_id, _tid), face_n_points, *elem, side);
148  }
149  }
150 }
bool needBoundaryMaterialOnSide(BoundaryID bnd_id, const THREAD_ID tid)
These methods are used to determine whether stateful material properties need to be stored on interna...
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
const MaterialWarehouse & _materials
This is populated using _fe_problem.getResidualMaterialsWarehouse because it has the union of traditi...
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
std::vector< std::vector< std::unique_ptr< Assembly > > > & _assembly
void reinitElemFace(const Elem *elem, unsigned int side, BoundaryID, const THREAD_ID tid)
SubdomainID _subdomain
The subdomain for the current element.
const MaterialData & getMaterialData(const THREAD_ID tid) const
void initStatefulProps(const THREAD_ID tid, const std::vector< std::shared_ptr< MaterialBase >> &mats, const unsigned int n_qpoints, const Elem &elem, const unsigned int side=0)
Initialize stateful material properties.
MaterialPropertyStorage & _bnd_material_props
const MaterialWarehouse & _discrete_materials
void resize(unsigned int n_qpoints)
Resize the data to hold properties for n_qpoints quadrature points.
Definition: MaterialData.C:21

◆ onElement()

void ComputeMaterialsObjectThread::onElement ( const Elem *  elem)
overridevirtual

Assembly of the element (not including surface assembly)

Parameters
elem- active element

Reimplemented from ThreadedElementLoopBase< ConstElemRange >.

Definition at line 85 of file ComputeMaterialsObjectThread.C.

86 {
89  {
90  _fe_problem.prepare(elem, _tid);
92 
93  auto & material_data = _material_props.getMaterialData(_tid);
94 
95  unsigned int n_points = _assembly[_tid][0]->qRule()->n_points();
96  material_data.resize(n_points);
97 
99  {
105  _tid, _materials.getActiveBlockObjects(_subdomain, _tid), n_points, *elem);
106  }
107  }
108 }
bool hasActiveBlockObjects(THREAD_ID tid=0) const
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
virtual void prepare(const Elem *elem, const THREAD_ID tid) override
MaterialPropertyStorage & _material_props
const MaterialWarehouse & _materials
This is populated using _fe_problem.getResidualMaterialsWarehouse because it has the union of traditi...
virtual void reinitElem(const Elem *elem, const THREAD_ID tid) override
std::vector< std::vector< std::unique_ptr< Assembly > > > & _assembly
SubdomainID _subdomain
The subdomain for the current element.
const MaterialData & getMaterialData(const THREAD_ID tid) const
void initStatefulProps(const THREAD_ID tid, const std::vector< std::shared_ptr< MaterialBase >> &mats, const unsigned int n_qpoints, const Elem &elem, const unsigned int side=0)
Initialize stateful material properties.
const MaterialWarehouse & _discrete_materials

◆ onExternalSide()

void ThreadedElementLoopBase< ConstElemRange >::onExternalSide ( const Elem *  elem,
unsigned int  side 
)
virtualinherited

Called when iterating over external sides (no side neighbor)

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

Reimplemented in ComputeUserObjectsThread.

Definition at line 393 of file ThreadedElementLoopBase.h.

394 {
395 }

◆ onInterface()

void ComputeMaterialsObjectThread::onInterface ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id 
)
overridevirtual

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

Definition at line 210 of file ComputeMaterialsObjectThread.C.

211 {
213  return;
214 
215  _fe_problem.reinitElemFace(elem, side, _tid);
216  unsigned int face_n_points = _assembly[_tid][0]->qRuleFace()->n_points();
217 
220 
222  {
223  // Face Materials
224  if (_discrete_materials[Moose::FACE_MATERIAL_DATA].hasActiveBlockObjects(_subdomain, _tid))
226  _tid,
228  face_n_points,
229  *elem,
230  side);
231 
232  if (_materials[Moose::FACE_MATERIAL_DATA].hasActiveBlockObjects(_subdomain, _tid))
234  _tid,
235  _materials[Moose::FACE_MATERIAL_DATA].getActiveBlockObjects(_subdomain, _tid),
236  face_n_points,
237  *elem,
238  side);
239 
240  // Boundary Materials
243  _tid, _materials.getActiveBoundaryObjects(bnd_id, _tid), face_n_points, *elem, side);
244 
247  _tid, _materials.getActiveBoundaryObjects(bnd_id, _tid), face_n_points, *elem, side);
248  }
249 
250  const Elem * neighbor = elem->neighbor_ptr(side);
251  unsigned int neighbor_side = neighbor->which_neighbor_am_i(_assembly[_tid][0]->elem());
252 
253  // Do we have neighbor stateful properties or do we have stateful interface material properties?
254  // If either then we need to reinit the neighbor, so at least at a minimum _neighbor_elem isn't
255  // NULL!
256  if (neighbor->active() &&
259  _fe_problem.reinitNeighbor(elem, side, _tid);
260 
261  if (_has_neighbor_stateful_props && neighbor->active())
262  {
263  // Neighbor Materials
264  if (_discrete_materials[Moose::NEIGHBOR_MATERIAL_DATA].hasActiveBlockObjects(
265  neighbor->subdomain_id(), _tid))
267  _tid,
268  _discrete_materials[Moose::NEIGHBOR_MATERIAL_DATA].getActiveBlockObjects(
269  neighbor->subdomain_id(), _tid),
270  face_n_points,
271  *elem,
272  side);
273 
274  if (_materials[Moose::NEIGHBOR_MATERIAL_DATA].hasActiveBlockObjects(neighbor->subdomain_id(),
275  _tid))
277  _tid,
278  _materials[Moose::NEIGHBOR_MATERIAL_DATA].getActiveBlockObjects(neighbor->subdomain_id(),
279  _tid),
280  face_n_points,
281  *neighbor,
282  neighbor_side);
283  }
284 
285  // Interface Materials. Make sure we do these after neighbors
288  _tid,
290  face_n_points,
291  *elem,
292  side);
293 }
const MaterialWarehouse & _interface_materials
This is populated using _fe_problem.getResidualInterfaceMaterialsWarehouse because it has the union o...
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
const MaterialWarehouse & _materials
This is populated using _fe_problem.getResidualMaterialsWarehouse because it has the union of traditi...
MaterialPropertyStorage & _neighbor_material_props
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
std::vector< std::vector< std::unique_ptr< Assembly > > > & _assembly
void reinitElemFace(const Elem *elem, unsigned int side, BoundaryID, const THREAD_ID tid)
bool needInterfaceMaterialOnSide(BoundaryID bnd_id, const THREAD_ID tid)
SubdomainID _subdomain
The subdomain for the current element.
virtual void reinitNeighbor(const Elem *elem, unsigned int side, const THREAD_ID tid) override
const MaterialData & getMaterialData(const THREAD_ID tid) const
void initStatefulProps(const THREAD_ID tid, const std::vector< std::shared_ptr< MaterialBase >> &mats, const unsigned int n_qpoints, const Elem &elem, const unsigned int side=0)
Initialize stateful material properties.
MaterialPropertyStorage & _bnd_material_props
const MaterialWarehouse & _discrete_materials
void resize(unsigned int n_qpoints)
Resize the data to hold properties for n_qpoints quadrature points.
Definition: MaterialData.C:21

◆ onInternalSide()

void ComputeMaterialsObjectThread::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 153 of file ComputeMaterialsObjectThread.C.

154 {
156  {
157  const Elem * neighbor = elem->neighbor_ptr(side);
158 
160  unsigned int face_n_points = _assembly[_tid][0]->qRuleFace()->n_points();
163 
165  {
166  if (_discrete_materials[Moose::FACE_MATERIAL_DATA].hasActiveBlockObjects(_subdomain, _tid))
168  _tid,
170  face_n_points,
171  *elem,
172  side);
173  if (_materials[Moose::FACE_MATERIAL_DATA].hasActiveBlockObjects(_subdomain, _tid))
175  _tid,
176  _materials[Moose::FACE_MATERIAL_DATA].getActiveBlockObjects(_subdomain, _tid),
177  face_n_points,
178  *elem,
179  side);
180  }
181 
182  unsigned int neighbor_side = neighbor->which_neighbor_am_i(_assembly[_tid][0]->elem());
183 
185  {
186  // Neighbor Materials
187  if (_discrete_materials[Moose::NEIGHBOR_MATERIAL_DATA].hasActiveBlockObjects(
188  neighbor->subdomain_id(), _tid))
190  _tid,
191  _discrete_materials[Moose::NEIGHBOR_MATERIAL_DATA].getActiveBlockObjects(
192  neighbor->subdomain_id(), _tid),
193  face_n_points,
194  *elem,
195  side);
196  if (_materials[Moose::NEIGHBOR_MATERIAL_DATA].hasActiveBlockObjects(neighbor->subdomain_id(),
197  _tid))
199  _tid,
200  _materials[Moose::NEIGHBOR_MATERIAL_DATA].getActiveBlockObjects(
201  neighbor->subdomain_id(), _tid),
202  face_n_points,
203  *neighbor,
204  neighbor_side);
205  }
206  }
207 }
virtual void reinitElemNeighborAndLowerD(const Elem *elem, unsigned int side, const THREAD_ID tid) override
const MaterialWarehouse & _materials
This is populated using _fe_problem.getResidualMaterialsWarehouse because it has the union of traditi...
MaterialPropertyStorage & _neighbor_material_props
std::vector< std::vector< std::unique_ptr< Assembly > > > & _assembly
SubdomainID _subdomain
The subdomain for the current element.
const MaterialData & getMaterialData(const THREAD_ID tid) const
void initStatefulProps(const THREAD_ID tid, const std::vector< std::shared_ptr< MaterialBase >> &mats, const unsigned int n_qpoints, const Elem &elem, const unsigned int side=0)
Initialize stateful material properties.
MaterialPropertyStorage & _bnd_material_props
const MaterialWarehouse & _discrete_materials
void resize(unsigned int n_qpoints)
Resize the data to hold properties for n_qpoints quadrature points.
Definition: MaterialData.C:21

◆ operator()()

void ThreadedElementLoopBase< ConstElemRange >::operator() ( const ConstElemRange range,
bool  bypass_threading = false 
)
virtualinherited

Reimplemented in NonlinearThread, and ComputeJacobianForScalingThread.

Definition at line 223 of file ThreadedElementLoopBase.h.

224 {
225  try
226  {
227  try
228  {
229  ParallelUniqueId puid;
230  _tid = bypass_threading ? 0 : puid.id;
231 
232  pre();
234 
237  typename RangeType::const_iterator el = range.begin();
238  for (el = range.begin(); el != range.end(); ++el)
239  {
240  if (!keepGoing())
241  break;
242 
243  const Elem * elem = *el;
244 
245  preElement(elem);
246 
248  _subdomain = elem->subdomain_id();
249  if (_subdomain != _old_subdomain)
250  {
253  }
254 
255  onElement(elem);
256 
257  if (_mesh.interiorLowerDBlocks().count(elem->subdomain_id()) > 0 ||
258  _mesh.boundaryLowerDBlocks().count(elem->subdomain_id()) > 0)
259  {
260  postElement(elem);
261  continue;
262  }
263 
264  for (unsigned int side = 0; side < elem->n_sides(); side++)
265  {
266  std::vector<BoundaryID> boundary_ids = _mesh.getBoundaryIDs(elem, side);
267  const Elem * lower_d_elem = _mesh.getLowerDElem(elem, side);
268 
269  if (boundary_ids.size() > 0)
270  for (std::vector<BoundaryID>::iterator it = boundary_ids.begin();
271  it != boundary_ids.end();
272  ++it)
273  {
274  preBoundary(elem, side, *it, lower_d_elem);
276  onBoundary(elem, side, *it, lower_d_elem);
277  }
278 
279  const Elem * neighbor = elem->neighbor_ptr(side);
280  if (neighbor)
281  {
282  preInternalSide(elem, side);
283 
285  _neighbor_subdomain = neighbor->subdomain_id();
288 
289  if (shouldComputeInternalSide(*elem, *neighbor))
290  onInternalSide(elem, side);
291 
292  if (boundary_ids.size() > 0)
293  for (std::vector<BoundaryID>::iterator it = boundary_ids.begin();
294  it != boundary_ids.end();
295  ++it)
296  onInterface(elem, side, *it);
297 
298  postInternalSide(elem, side);
299  }
300  else
301  onExternalSide(elem, side);
302  } // sides
303 
304  postElement(elem);
305  } // range
306 
307  post();
309  }
310  catch (libMesh::LogicError & e)
311  {
312  mooseException("We caught a libMesh error in ThreadedElementLoopBase:", e.what());
313  }
314  catch (MetaPhysicL::LogicError & e)
315  {
317  }
318  }
319  catch (MooseException & e)
320  {
322  }
323 }
virtual void onExternalSide(const Elem *elem, unsigned int side)
Called when iterating over external sides (no side neighbor)
virtual bool keepGoing()
Whether or not the loop should continue.
void resetExecPrintedSets() const
Resets the set of blocks and boundaries visited.
virtual bool shouldComputeInternalSide(const Elem &elem, const Elem &neighbor) const
Whether to compute the internal side for the provided element-neighbor pair.
virtual void onElement(const Elem *elem)
Assembly of the element (not including surface assembly)
const std::set< SubdomainID > & interiorLowerDBlocks() const
Definition: MooseMesh.h:1403
void translateMetaPhysicLError(const MetaPhysicL::LogicError &)
emit a relatively clear error message when we catch a MetaPhysicL logic error
Definition: MooseError.C:112
virtual void printBoundaryExecutionInformation(const unsigned int) const
Print information about the particular ordering of objects on each boundary.
virtual void pre()
Called before the element range loop.
const Elem * getLowerDElem(const Elem *, unsigned short int) const
Returns a const pointer to a lower dimensional element that corresponds to a side of a higher dimensi...
Definition: MooseMesh.C:1698
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:20
virtual void onBoundary(const Elem *elem, unsigned int side, BoundaryID bnd_id, const Elem *lower_d_elem=nullptr)
Called when doing boundary assembling.
virtual void postElement(const Elem *elem)
Called after the element assembly is done (including surface assembling)
virtual void printGeneralExecutionInformation() const
Print information about the loop ordering.
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.
const std::set< SubdomainID > & boundaryLowerDBlocks() const
Definition: MooseMesh.h:1407
virtual void onInternalSide(const Elem *elem, unsigned int side)
Called when doing internal edge assembling.
const_iterator end() const
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.
const_iterator begin() const
SubdomainID _subdomain
The subdomain for the current element.
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. ...
SubdomainID _old_subdomain
The subdomain for the last element.
virtual void post()
Called after the element range loop.
virtual void printBlockExecutionInformation() const
Print information about the particular ordering of objects on each block.
virtual void preElement(const Elem *elem)
Called before the element assembly.
virtual void preBoundary(const Elem *elem, unsigned int side, BoundaryID bnd_id, const Elem *lower_d_elem=nullptr)
Called before the boundary assembly.
SubdomainID _neighbor_subdomain
The subdomain for the current neighbor.

◆ post()

void ComputeMaterialsObjectThread::post ( )
overridevirtual

Called after the element range loop.

Reimplemented from ThreadedElementLoopBase< ConstElemRange >.

Definition at line 301 of file ComputeMaterialsObjectThread.C.

302 {
304 }
virtual void clearActiveElementalMooseVariables(const THREAD_ID tid) override
Clear the active elemental MooseVariableFEBase.

◆ postElement()

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, NonlinearThread, ComputeIndicatorThread, ComputeJacobianThread, and ComputeMarkerThread.

Definition at line 351 of file ThreadedElementLoopBase.h.

352 {
353 }

◆ postInternalSide()

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'

Reimplemented in ComputeJacobianBlocksThread.

Definition at line 381 of file ThreadedElementLoopBase.h.

382 {
383 }

◆ pre()

void ThreadedElementLoopBase< ConstElemRange >::pre ( )
virtualinherited

Called before the element range loop.

Definition at line 327 of file ThreadedElementLoopBase.h.

Referenced by ComputeJacobianForScalingThread::operator()().

328 {
329 }

◆ preBoundary()

void ThreadedElementLoop< ConstElemRange >::preBoundary ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id,
const Elem *  lower_d_elem = nullptr 
)
overridevirtualinherited

Called before the boundary assembly.

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
lower_d_elem- Lower dimensional element (e.g. Mortar)

Reimplemented from ThreadedElementLoopBase< ConstElemRange >.

Definition at line 129 of file ThreadedElementLoop.h.

133 {
135 }
virtual void setCurrentBoundaryID(BoundaryID bid, const THREAD_ID tid) override
sets the current boundary ID in assembly
Base class for assembly-like calculations.

◆ preElement()

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

Called before the element assembly.

Parameters
elem- active element

Reimplemented from ThreadedElementLoopBase< ConstElemRange >.

Definition at line 115 of file ThreadedElementLoop.h.

Referenced by ComputeJacobianForScalingThread::operator()().

116 {
118 }
virtual void setCurrentSubdomainID(const Elem *elem, const THREAD_ID tid) override
Base class for assembly-like calculations.

◆ preInternalSide()

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

Definition at line 122 of file ThreadedElementLoop.h.

123 {
125 }
Base class for assembly-like calculations.
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, const THREAD_ID tid) override

◆ prepareElement()

void ThreadedElementLoop< ConstElemRange >::prepareElement ( const Elem *  elem)
protectedinherited

Definition at line 186 of file ThreadedElementLoop.h.

Referenced by NonlinearThread::onElement().

187 {
188  _fe_problem.prepare(elem, this->_tid);
189  _fe_problem.reinitElem(elem, this->_tid);
191 }
virtual void prepare(const Elem *elem, const THREAD_ID tid) override
virtual void reinitElem(const Elem *elem, const THREAD_ID tid) override
void reinitMaterials(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true)
SubdomainID _subdomain
The subdomain for the current element.

◆ printBlockExecutionInformation()

virtual void ThreadedElementLoopBase< ConstElemRange >::printBlockExecutionInformation ( ) const
inlineprotectedvirtualinherited

Print information about the particular ordering of objects on each block.

Reimplemented in NonlinearThread, ComputeUserObjectsThread, ComputeIndicatorThread, ComputeElemAuxVarsThread< AuxKernelType >, and ComputeMarkerThread.

Definition at line 181 of file ThreadedElementLoopBase.h.

181 {}

◆ printBoundaryExecutionInformation()

virtual void ThreadedElementLoopBase< ConstElemRange >::printBoundaryExecutionInformation ( const unsigned int  ) const
inlineprotectedvirtualinherited

Print information about the particular ordering of objects on each boundary.

Reimplemented in NonlinearThread.

Definition at line 184 of file ThreadedElementLoopBase.h.

184 {}

◆ printExecutionOrdering() [1/2]

void ThreadedElementLoop< ConstElemRange >::printExecutionOrdering ( const std::vector< T *> &  objs,
const bool  print_header = true,
const std::string &  line_prefix = "[DBG]" 
) const
protectedinherited

Routine to output the ordering of objects within a vector of pointers to these objects.

These objects must implement the name() routine, and it must return a string or compatible type.

Template Parameters
Tthe object type
Parameters
objsthe vector with all the objects (should be pointers)
objects_typethe name of the type of objects. Defaults to the CPP object name
print_headerwhether to print a header about the timing of execution and the type of objects

Definition at line 148 of file ThreadedElementLoop.h.

151 {
152  if (!objs.size())
153  return;
154 
155  auto & console = _fe_problem.console();
156  const auto objects_type = MooseUtils::prettyCppType(objs[0]);
157  std::vector<MooseObject *> moose_objs;
158  for (auto obj_ptr : objs)
159  moose_objs.push_back(dynamic_cast<MooseObject *>(obj_ptr));
160  const auto names = ConsoleUtils::mooseObjectVectorToString(moose_objs);
161 
162  // Print string with a DBG prefix and with sufficient line breaks
163  std::string message = print_header ? "Executing " + objects_type + " on " +
165  : "";
166  message += (print_header ? "Order of execution:\n" : "") + names;
167  console << ConsoleUtils::formatString(message, line_prefix) << std::endl;
168 }
std::string mooseObjectVectorToString(const std::vector< MooseObject *> &objs, const std::string &sep=" ")
Routine to output the name of MooseObjects in a string.
Definition: ConsoleUtils.C:598
const std::string & name() const
Definition: MooseEnumItem.h:35
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
std::string formatString(std::string message, const std::string &prefix)
Add new lines and prefixes to a string for pretty display in output NOTE: This makes a copy of the st...
Definition: ConsoleUtils.C:582
const ConsoleStream & console() const
Return console handle.
Definition: Problem.h:48
std::string prettyCppType(const std::string &cpp_type)
Definition: MooseUtils.C:1246

◆ printExecutionOrdering() [2/2]

void ThreadedElementLoop< ConstElemRange >::printExecutionOrdering ( const std::vector< std::shared_ptr< T >> &  objs_ptrs,
const bool  print_header = true,
const std::string &  line_prefix = "[DBG]" 
) const
protectedinherited

Definition at line 173 of file ThreadedElementLoop.h.

177 {
178  std::vector<T *> regular_ptrs;
179  for (auto shared_ptr : objs_ptrs)
180  regular_ptrs.push_back(shared_ptr.get());
181  printExecutionOrdering<T>(regular_ptrs, print_header, line_prefix);
182 }

◆ printGeneralExecutionInformation()

virtual void ThreadedElementLoopBase< ConstElemRange >::printGeneralExecutionInformation ( ) const
inlineprotectedvirtualinherited

◆ resetExecPrintedSets()

void ThreadedElementLoopBase< ConstElemRange >::resetExecPrintedSets ( ) const
protectedinherited

Resets the set of blocks and boundaries visited.

Definition at line 444 of file ThreadedElementLoopBase.h.

445 {
446  _blocks_exec_printed.clear();
447  _boundaries_exec_printed.clear();
448 }
std::set< SubdomainID > _blocks_exec_printed
Keep track of which blocks were visited.
std::set< BoundaryID > _boundaries_exec_printed
Keep track of which boundaries were visited.

◆ shouldComputeInternalSide()

bool ThreadedElementLoopBase< ConstElemRange >::shouldComputeInternalSide ( const Elem &  elem,
const Elem &  neighbor 
) const
protectedvirtualinherited

Whether to compute the internal side for the provided element-neighbor pair.

Typically this will return true if the element id is less than the neighbor id when the elements are equal level, or when the element is more refined than the neighbor, and then false otherwise. One type of loop where the logic will be different is when projecting stateful material properties

Reimplemented in NonlinearThread, and FlagElementsThread.

Definition at line 419 of file ThreadedElementLoopBase.h.

421 {
422  auto level = [this](const auto & elem_arg)
423  {
424  if (_mesh.doingPRefinement())
425  return elem_arg.p_level();
426  else
427  return elem_arg.level();
428  };
429  const auto elem_id = elem.id(), neighbor_id = neighbor.id();
430  const auto elem_level = level(elem), neighbor_level = level(neighbor);
431 
432  // When looping over elements and then sides, we need to make sure that we do not duplicate
433  // effort, e.g. if a face is shared by element 1 and element 2, then we do not want to do compute
434  // work both when we are visiting element 1 *and* then later when visiting element 2. Our rule is
435  // to only compute when we are visiting the element that has the lower element id when element and
436  // neighbor are of the same adaptivity level, and then if they are not of the same level, then
437  // we only compute when we are visiting the finer element
438  return (neighbor.active() && (neighbor_level == elem_level) && (elem_id < neighbor_id)) ||
439  (neighbor_level < elem_level);
440 }
void doingPRefinement(bool doing_p_refinement)
Indicate whether the kind of adaptivity we&#39;re doing is p-refinement.
Definition: MooseMesh.h:1347

◆ subdomainChanged()

void ComputeMaterialsObjectThread::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 66 of file ComputeMaterialsObjectThread.C.

67 {
70 
71  std::set<MooseVariableFEBase *> needed_moose_vars;
72  _materials.updateVariableDependency(needed_moose_vars, _tid);
75 
76  std::set<TagID> needed_fe_var_vector_tags;
78  _subdomain, needed_fe_var_vector_tags, _tid);
80  _subdomain, needed_fe_var_vector_tags, _tid);
81  _fe_problem.setActiveFEVariableCoupleableVectorTags(needed_fe_var_vector_tags, _tid);
82 }
void updateVariableDependency(std::set< MooseVariableFieldBase *> &needed_moose_vars, THREAD_ID tid=0) const
Update variable dependency vector.
virtual void setActiveElementalMooseVariables(const std::set< MooseVariableFEBase *> &moose_vars, const THREAD_ID tid) override
Set the MOOSE variables to be reinited on each element.
const MaterialWarehouse & _materials
This is populated using _fe_problem.getResidualMaterialsWarehouse because it has the union of traditi...
bool needSubdomainMaterialOnSide(SubdomainID subdomain_id, const THREAD_ID tid)
void updateBlockFEVariableCoupledVectorTagDependency(SubdomainID id, std::set< TagID > &needed_fe_var_vector_tags, THREAD_ID tid=0) const
Update FE variable coupleable vector tag vector.
virtual void subdomainSetup(SubdomainID subdomain, const THREAD_ID tid)
SubdomainID _subdomain
The subdomain for the current element.
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid) override
const MaterialWarehouse & _discrete_materials

Member Data Documentation

◆ _assembly

std::vector<std::vector<std::unique_ptr<Assembly> > >& ComputeMaterialsObjectThread::_assembly
protected

Definition at line 66 of file ComputeMaterialsObjectThread.h.

Referenced by onBoundary(), onElement(), onInterface(), and onInternalSide().

◆ _blocks_exec_printed

std::set<SubdomainID> ThreadedElementLoopBase< ConstElemRange >::_blocks_exec_printed
mutableprotectedinherited

◆ _bnd_material_props

MaterialPropertyStorage& ComputeMaterialsObjectThread::_bnd_material_props
protected

Definition at line 50 of file ComputeMaterialsObjectThread.h.

Referenced by onBoundary(), onInterface(), and onInternalSide().

◆ _boundaries_exec_printed

std::set<BoundaryID> ThreadedElementLoopBase< ConstElemRange >::_boundaries_exec_printed
mutableprotectedinherited

Keep track of which boundaries were visited.

Definition at line 190 of file ThreadedElementLoopBase.h.

Referenced by NonlinearThread::printBoundaryExecutionInformation().

◆ _discrete_materials

const MaterialWarehouse& ComputeMaterialsObjectThread::_discrete_materials
protected

◆ _fe_problem

FEProblemBase& ComputeMaterialsObjectThread::_fe_problem
protected

◆ _has_bnd_stateful_props

const bool ComputeMaterialsObjectThread::_has_bnd_stateful_props
protected

Definition at line 70 of file ComputeMaterialsObjectThread.h.

Referenced by onBoundary(), onInterface(), and onInternalSide().

◆ _has_neighbor_stateful_props

const bool ComputeMaterialsObjectThread::_has_neighbor_stateful_props
protected

Definition at line 71 of file ComputeMaterialsObjectThread.h.

Referenced by onInterface(), and onInternalSide().

◆ _has_stateful_props

const bool ComputeMaterialsObjectThread::_has_stateful_props
protected

Definition at line 69 of file ComputeMaterialsObjectThread.h.

Referenced by onElement().

◆ _interface_materials

const MaterialWarehouse& ComputeMaterialsObjectThread::_interface_materials
protected

This is populated using _fe_problem.getResidualInterfaceMaterialsWarehouse because it has the union of traditional interface materials and the residual version of AD interface materials.

We don't need the Jacobian version of the ADInterfaceMaterial for doing stateful stuff

Definition at line 62 of file ComputeMaterialsObjectThread.h.

Referenced by onInterface().

◆ _material_props

MaterialPropertyStorage& ComputeMaterialsObjectThread::_material_props
protected

Definition at line 49 of file ComputeMaterialsObjectThread.h.

Referenced by onElement().

◆ _materials

const MaterialWarehouse& ComputeMaterialsObjectThread::_materials
protected

This is populated using _fe_problem.getResidualMaterialsWarehouse because it has the union of traditional materials and the residual version of AD materials.

We don't need the Jacobian version of the ADMaterial for doing stateful stuff

Definition at line 56 of file ComputeMaterialsObjectThread.h.

Referenced by onBoundary(), onElement(), onInterface(), onInternalSide(), and subdomainChanged().

◆ _mesh

MooseMesh& ThreadedElementLoopBase< ConstElemRange >::_mesh
protectedinherited

◆ _need_internal_side_material

bool ComputeMaterialsObjectThread::_need_internal_side_material
protected

Definition at line 67 of file ComputeMaterialsObjectThread.h.

Referenced by onInternalSide(), and subdomainChanged().

◆ _neighbor_material_props

MaterialPropertyStorage& ComputeMaterialsObjectThread::_neighbor_material_props
protected

Definition at line 51 of file ComputeMaterialsObjectThread.h.

Referenced by onInterface(), and onInternalSide().

◆ _neighbor_subdomain

SubdomainID ThreadedElementLoopBase< ConstElemRange >::_neighbor_subdomain
protectedinherited

◆ _old_neighbor_subdomain

SubdomainID ThreadedElementLoopBase< ConstElemRange >::_old_neighbor_subdomain
protectedinherited

The subdomain for the last neighbor.

Definition at line 175 of file ThreadedElementLoopBase.h.

◆ _old_subdomain

SubdomainID ThreadedElementLoopBase< ConstElemRange >::_old_subdomain
protectedinherited

The subdomain for the last element.

Definition at line 169 of file ThreadedElementLoopBase.h.

Referenced by ComputeJacobianForScalingThread::operator()().

◆ _subdomain

SubdomainID ThreadedElementLoopBase< ConstElemRange >::_subdomain
protectedinherited

◆ _tid

THREAD_ID ThreadedElementLoopBase< ConstElemRange >::_tid
protectedinherited

Definition at line 163 of file ThreadedElementLoopBase.h.

Referenced by ComputeResidualThread::accumulate(), ComputeResidualAndJacobianThread::accumulate(), ComputeResidualThread::accumulateLower(), ComputeResidualAndJacobianThread::accumulateLower(), ComputeJacobianThread::accumulateLower(), ComputeResidualThread::accumulateNeighbor(), ComputeResidualAndJacobianThread::accumulateNeighbor(), ComputeJacobianThread::accumulateNeighbor(), ComputeResidualThread::accumulateNeighborLower(), ComputeResidualAndJacobianThread::accumulateNeighborLower(), ComputeJacobianThread::accumulateNeighborLower(), ComputeFullJacobianThread::computeOnBoundary(), NonlinearThread::computeOnBoundary(), ComputeFullJacobianThread::computeOnElement(), NonlinearThread::computeOnElement(), ComputeFullJacobianThread::computeOnInterface(), NonlinearThread::computeOnInterface(), ComputeResidualThread::computeOnInternalFace(), ComputeFullJacobianThread::computeOnInternalFace(), ComputeResidualAndJacobianThread::computeOnInternalFace(), ComputeJacobianThread::computeOnInternalFace(), NonlinearThread::computeOnInternalFace(), ComputeResidualThread::determineObjectWarehouses(), ComputeJacobianThread::determineObjectWarehouses(), ComputeResidualAndJacobianThread::determineObjectWarehouses(), onBoundary(), NonlinearThread::onBoundary(), ComputeUserObjectsThread::onBoundary(), ComputeMarkerThread::onElement(), ComputeElemDampingThread::onElement(), ComputeIndicatorThread::onElement(), onElement(), NonlinearThread::onElement(), ComputeUserObjectsThread::onElement(), onInterface(), NonlinearThread::onInterface(), ComputeUserObjectsThread::onInterface(), ComputeIndicatorThread::onInternalSide(), onInternalSide(), NonlinearThread::onInternalSide(), ComputeUserObjectsThread::onInternalSide(), ComputeJacobianForScalingThread::operator()(), post(), ComputeMarkerThread::post(), ComputeIndicatorThread::post(), ComputeUserObjectsThread::post(), ComputeJacobianThread::postElement(), ComputeJacobianBlocksThread::postElement(), ComputeJacobianBlocksThread::postInternalSide(), NonlinearThread::prepareFace(), ComputeMarkerThread::printBlockExecutionInformation(), ComputeIndicatorThread::printBlockExecutionInformation(), ComputeUserObjectsThread::printBlockExecutionInformation(), NonlinearThread::printBlockExecutionInformation(), NonlinearThread::printBoundaryExecutionInformation(), ComputeElemDampingThread::printGeneralExecutionInformation(), ComputeMarkerThread::printGeneralExecutionInformation(), ComputeIndicatorThread::printGeneralExecutionInformation(), ComputeUserObjectsThread::printGeneralExecutionInformation(), NonlinearThread::printGeneralExecutionInformation(), ComputeUserObjectsThread::queryBoundary(), ComputeUserObjectsThread::querySubdomain(), NonlinearThread::shouldComputeInternalSide(), ComputeMarkerThread::subdomainChanged(), ComputeIndicatorThread::subdomainChanged(), subdomainChanged(), NonlinearThread::subdomainChanged(), and ComputeUserObjectsThread::subdomainChanged().


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