https://mooseframework.inl.gov
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
ThreadedFaceLoop< RangeType > Class Template Referenceabstract

This loops over a set of mesh faces (i.e. More...

#include <ComputeFVFluxThread.h>

Inheritance diagram for ThreadedFaceLoop< RangeType >:
[legend]

Public Member Functions

 ThreadedFaceLoop (FEProblemBase &fe_problem, const unsigned int nl_system_num, const std::set< TagID > &tags, bool on_displaced)
 
 ThreadedFaceLoop (ThreadedFaceLoop &x, Threads::split split)
 
virtual ~ThreadedFaceLoop ()
 
virtual void operator() (const RangeType &range, bool bypass_threading=false)
 
void join (const ThreadedFaceLoop &y)
 
virtual void onFace (const FaceInfo &fi)=0
 
virtual void postFace (const FaceInfo &)
 This is called once for each face after all face and boundary callbacks have been finished for that face. More...
 
virtual void pre ()
 This is called once before all face-looping. More...
 
virtual void post ()
 This is called once after all face-looping is finished. More...
 
virtual void onBoundary (const FaceInfo &fi, BoundaryID boundary)=0
 This is called once for every face that is on a boundary after onFace is called for the face. 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...
 
void caughtMooseException (MooseException &e)
 Called if a MooseException is caught anywhere during the computation. More...
 

Protected Member Functions

virtual void printGeneralExecutionInformation () const
 Print list of object types executed and in which order. More...
 
virtual void printBlockExecutionInformation () const
 Print ordering of objects executed on each block. More...
 
virtual void printBoundaryExecutionInformation (const BoundaryID) const
 Print ordering of objects exected on each boundary. More...
 
void resetExecutionPrinting ()
 Reset lists of blocks and boundaries for which execution printing has been done. More...
 

Protected Attributes

FEProblemBase_fe_problem
 
MooseMesh_mesh
 
const std::set< TagID > & _tags
 
THREAD_ID _tid
 
const unsigned int _nl_system_num
 
const bool _on_displaced
 Whether this loop is operating on the displaced mesh. More...
 
SubProblem_subproblem
 FEProblemBase or DisplacedProblem depending on _on_displaced. More...
 
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< std::pair< const SubdomainID, const SubdomainID > > _blocks_exec_printed
 Set to keep track of blocks for which we have printed the execution pattern. More...
 
std::set< BoundaryID_boundaries_exec_printed
 Set to keep track of boundaries for which we have printed the execution pattern. More...
 
std::string _error_message
 Holds caught runtime error messages. More...
 

Private Attributes

const bool _zeroth_copy
 Whether this is the zeroth threaded copy of this body. More...
 
const bool _incoming_throw_on_error
 The value of Moose::_throw_on_error at the time of construction. More...
 

Detailed Description

template<typename RangeType>
class ThreadedFaceLoop< RangeType >

This loops over a set of mesh faces (i.e.

FaceInfo objects). Callback routines are provided for visiting each face, for visiting boundary faces, for sudomain changes, and pre/post many of these events.

Definition at line 73 of file ComputeFVFluxThread.h.

Constructor & Destructor Documentation

◆ ThreadedFaceLoop() [1/2]

template<typename RangeType >
ThreadedFaceLoop< RangeType >::ThreadedFaceLoop ( FEProblemBase fe_problem,
const unsigned int  nl_system_num,
const std::set< TagID > &  tags,
bool  on_displaced 
)

Definition at line 181 of file ComputeFVFluxThread.h.

185  : _fe_problem(fe_problem),
186  _mesh(fe_problem.mesh()),
187  _tags(tags),
188  _nl_system_num(nl_system_num),
189  _on_displaced(on_displaced),
190  _subproblem(_on_displaced ? static_cast<SubProblem &>(*_fe_problem.getDisplacedProblem())
191  : static_cast<SubProblem &>(_fe_problem)),
192  _zeroth_copy(true),
194 {
195  Moose::_throw_on_error = true;
196 }
const bool _incoming_throw_on_error
The value of Moose::_throw_on_error at the time of construction.
const unsigned int _nl_system_num
const bool _zeroth_copy
Whether this is the zeroth threaded copy of this body.
FEProblemBase & _fe_problem
const std::set< TagID > & _tags
SubProblem & _subproblem
FEProblemBase or DisplacedProblem depending on _on_displaced.
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
const bool _on_displaced
Whether this loop is operating on the displaced mesh.
virtual MooseMesh & mesh() override
bool _throw_on_error
Variable to turn on exceptions during mooseError(), should only be used within MOOSE unit tests or wh...
Definition: Moose.C:758

◆ ThreadedFaceLoop() [2/2]

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

Definition at line 199 of file ComputeFVFluxThread.h.

201  _mesh(x._mesh),
202  _tags(x._tags),
206  _zeroth_copy(false),
208 {
209 }
const bool _incoming_throw_on_error
The value of Moose::_throw_on_error at the time of construction.
const unsigned int _nl_system_num
const bool _zeroth_copy
Whether this is the zeroth threaded copy of this body.
FEProblemBase & _fe_problem
const std::set< TagID > & _tags
SubProblem & _subproblem
FEProblemBase or DisplacedProblem depending on _on_displaced.
const bool _on_displaced
Whether this loop is operating on the displaced mesh.

◆ ~ThreadedFaceLoop()

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

Definition at line 212 of file ComputeFVFluxThread.h.

213 {
214  if (_zeroth_copy)
215  {
217 
218  if (!_error_message.empty())
220  }
221 }
const bool _incoming_throw_on_error
The value of Moose::_throw_on_error at the time of construction.
std::string _error_message
Holds caught runtime error messages.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
const bool _zeroth_copy
Whether this is the zeroth threaded copy of this body.
bool _throw_on_error
Variable to turn on exceptions during mooseError(), should only be used within MOOSE unit tests or wh...
Definition: Moose.C:758

Member Function Documentation

◆ caughtMooseException()

template<typename RangeType>
void ThreadedFaceLoop< RangeType >::caughtMooseException ( MooseException e)
inline

Called if a MooseException is caught anywhere during the computation.

Definition at line 114 of file ComputeFVFluxThread.h.

115  {
116  Threads::spin_mutex::scoped_lock lock(threaded_element_mutex);
117  std::string what(e.what());
119  }
virtual const char * what() const
Get out the error message.
FEProblemBase & _fe_problem
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.

◆ join()

template<typename RangeType >
void ThreadedFaceLoop< RangeType >::join ( const ThreadedFaceLoop< RangeType > &  y)

Definition at line 225 of file ComputeFVFluxThread.h.

226 {
227  if (_error_message.empty() && !y._error_message.empty())
229 }
std::string _error_message
Holds caught runtime error messages.

◆ neighborSubdomainChanged()

template<typename RangeType>
virtual void ThreadedFaceLoop< RangeType >::neighborSubdomainChanged ( )
inlinevirtual

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

the subdomain of this face's neighbor element is not the same as the subdomain of the last face's neighbor element).

Reimplemented in ComputeFVFluxThread< RangeType, AttributeTagType >, ComputeFVFluxThread< RangeType, AttribVectorTags >, and ComputeFVFluxThread< RangeType, AttribMatrixTags >.

Definition at line 108 of file ComputeFVFluxThread.h.

Referenced by ComputeFVFluxThread< RangeType, AttribMatrixTags >::neighborSubdomainChanged().

109  {
111  }
FEProblemBase & _fe_problem
SubdomainID _neighbor_subdomain
The subdomain for the current neighbor.
virtual void neighborSubdomainSetup(SubdomainID subdomain, const THREAD_ID tid)

◆ onBoundary()

template<typename RangeType>
virtual void ThreadedFaceLoop< RangeType >::onBoundary ( const FaceInfo fi,
BoundaryID  boundary 
)
pure virtual

This is called once for every face that is on a boundary after onFace is called for the face.

Implemented in ComputeFVFluxThread< RangeType, AttributeTagType >, ComputeFVFluxThread< RangeType, AttribVectorTags >, and ComputeFVFluxThread< RangeType, AttribMatrixTags >.

◆ onFace()

template<typename RangeType>
virtual void ThreadedFaceLoop< RangeType >::onFace ( const FaceInfo fi)
pure virtual

◆ operator()()

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

Definition at line 239 of file ComputeFVFluxThread.h.

240 {
241  // TODO: make this query fv flux kernel specific or somehow integrate the
242  // fv source kernels into this loop. Also this check will need to increase
243  // in generality if/when other systems and objects besides FV stuff get
244  // added to this loop.
245  std::vector<FVKernel *> kernels;
247  .query()
248  .template condition<AttribSysNum>(_nl_system_num)
249  .template condition<AttribSystem>("FVFluxKernel")
250  .template condition<AttribDisplaced>(_on_displaced)
251  .queryInto(kernels);
252  if (kernels.size() == 0)
253  return;
254 
255  try
256  {
257  try
258  {
259  ParallelUniqueId puid;
260  _tid = bypass_threading ? 0 : puid.id;
261 
262  pre();
264 
267 
268  typename RangeType::const_iterator faceinfo = range.begin();
269  for (faceinfo = range.begin(); faceinfo != range.end(); ++faceinfo)
270  {
271  const Elem & elem = (*faceinfo)->elem();
272 
274 
276  _subdomain = elem.subdomain_id();
277  if (_subdomain != _old_subdomain)
278  {
281  }
282 
284  if (const Elem * const neighbor = (*faceinfo)->neighborPtr())
285  {
287  _neighbor_subdomain = neighbor->subdomain_id();
288  }
289  else
291 
293  {
295  // This is going to cause a lot more printing
297  }
298 
299  onFace(**faceinfo);
300  // Cache data now because onBoundary may clear it. E.g. there was a nasty bug for two
301  // variable FV systems where if one variable was executing an FVFluxKernel on a boundary
302  // while the other was executing an FVFluxBC, the FVFluxKernel data would get lost because
303  // onBoundary would clear the residual/Jacobian data before it was cached
304  postFace(**faceinfo);
305 
306  const std::set<BoundaryID> boundary_ids = (*faceinfo)->boundaryIDs();
307  for (auto & it : boundary_ids)
308  {
310  onBoundary(**faceinfo, it);
311  }
312 
313  postFace(**faceinfo);
314 
315  } // range
316  post();
317 
318  // Clear execution printing sets to start printing on every block and boundary again
320  }
321  catch (libMesh::LogicError & e)
322  {
323  mooseException("We caught a libMesh error: ", e.what());
324  }
325  catch (MetaPhysicL::LogicError & e)
326  {
328  }
329  }
330  catch (MooseException & e)
331  {
333  }
334  catch (std::runtime_error & e)
335  {
336  _error_message = e.what();
337  }
338 }
const unsigned int _nl_system_num
std::string _error_message
Holds caught runtime error messages.
FEProblemBase & _fe_problem
void translateMetaPhysicLError(const MetaPhysicL::LogicError &)
emit a relatively clear error message when we catch a MetaPhysicL logic error
Definition: MooseError.C:112
SubdomainID _subdomain
The subdomain for the current element.
virtual void postFace(const FaceInfo &)
This is called once for each face after all face and boundary callbacks have been finished for that f...
void resetExecutionPrinting()
Reset lists of blocks and boundaries for which execution printing has been done.
virtual void post()
This is called once after all face-looping is finished.
virtual void printBoundaryExecutionInformation(const BoundaryID) const
Print ordering of objects exected on each boundary.
SubdomainID _neighbor_subdomain
The subdomain for the current neighbor.
const SubdomainID INVALID_BLOCK_ID
Definition: MooseTypes.C:20
virtual void neighborSubdomainChanged()
Called every time the neighbor subdomain changes (i.e.
virtual void onBoundary(const FaceInfo &fi, BoundaryID boundary)=0
This is called once for every face that is on a boundary after onFace is called for the face...
TheWarehouse & theWarehouse() const
virtual void printGeneralExecutionInformation() const
Print list of object types executed and in which order.
virtual void pre()
This is called once before all face-looping.
virtual void onFace(const FaceInfo &fi)=0
virtual void setCurrentSubdomainID(const Elem *elem, const THREAD_ID tid) override
Provides a way for users to bail out of the current solve.
void caughtMooseException(MooseException &e)
Called if a MooseException is caught anywhere during the computation.
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:466
virtual void subdomainChanged()
Called every time the current subdomain changes (i.e.
const bool _on_displaced
Whether this loop is operating on the displaced mesh.
virtual void printBlockExecutionInformation() const
Print ordering of objects executed on each block.
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, const THREAD_ID tid) override
SubdomainID _old_subdomain
The subdomain for the last element.
SubdomainID _old_neighbor_subdomain
The subdomain for the last neighbor.

◆ post()

template<typename RangeType>
virtual void ThreadedFaceLoop< RangeType >::post ( )
inlinevirtual

This is called once after all face-looping is finished.

Reimplemented in ComputeFVFluxThread< RangeType, AttributeTagType >, ComputeFVFluxThread< RangeType, AttribVectorTags >, and ComputeFVFluxThread< RangeType, AttribMatrixTags >.

Definition at line 96 of file ComputeFVFluxThread.h.

96 {}

◆ postFace()

template<typename RangeType>
virtual void ThreadedFaceLoop< RangeType >::postFace ( const FaceInfo )
inlinevirtual

This is called once for each face after all face and boundary callbacks have been finished for that face.

Reimplemented in ComputeFVFluxRJThread< RangeType >, ComputeFVFluxJacobianThread< RangeType >, and ComputeFVFluxResidualThread< RangeType >.

Definition at line 92 of file ComputeFVFluxThread.h.

92 {}

◆ pre()

template<typename RangeType>
virtual void ThreadedFaceLoop< RangeType >::pre ( )
inlinevirtual

◆ printBlockExecutionInformation()

template<typename RangeType>
virtual void ThreadedFaceLoop< RangeType >::printBlockExecutionInformation ( ) const
inlineprotectedvirtual

Print ordering of objects executed on each block.

Reimplemented in ComputeFVFluxThread< RangeType, AttributeTagType >, ComputeFVFluxThread< RangeType, AttribVectorTags >, and ComputeFVFluxThread< RangeType, AttribMatrixTags >.

Definition at line 126 of file ComputeFVFluxThread.h.

126 {}

◆ printBoundaryExecutionInformation()

template<typename RangeType>
virtual void ThreadedFaceLoop< RangeType >::printBoundaryExecutionInformation ( const BoundaryID  ) const
inlineprotectedvirtual

Print ordering of objects exected on each boundary.

Reimplemented in ComputeFVFluxThread< RangeType, AttributeTagType >, ComputeFVFluxThread< RangeType, AttribVectorTags >, and ComputeFVFluxThread< RangeType, AttribMatrixTags >.

Definition at line 129 of file ComputeFVFluxThread.h.

129 {}

◆ printGeneralExecutionInformation()

template<typename RangeType>
virtual void ThreadedFaceLoop< RangeType >::printGeneralExecutionInformation ( ) const
inlineprotectedvirtual

Print list of object types executed and in which order.

Reimplemented in ComputeFVFluxThread< RangeType, AttributeTagType >, ComputeFVFluxThread< RangeType, AttribVectorTags >, and ComputeFVFluxThread< RangeType, AttribMatrixTags >.

Definition at line 123 of file ComputeFVFluxThread.h.

123 {}

◆ resetExecutionPrinting()

template<typename RangeType>
void ThreadedFaceLoop< RangeType >::resetExecutionPrinting ( )
inlineprotected

Reset lists of blocks and boundaries for which execution printing has been done.

Definition at line 132 of file ComputeFVFluxThread.h.

133  {
134  _blocks_exec_printed.clear();
135  _boundaries_exec_printed.clear();
136  }
std::set< BoundaryID > _boundaries_exec_printed
Set to keep track of boundaries for which we have printed the execution pattern.
std::set< std::pair< const SubdomainID, const SubdomainID > > _blocks_exec_printed
Set to keep track of blocks for which we have printed the execution pattern.

◆ subdomainChanged()

template<typename RangeType>
virtual void ThreadedFaceLoop< RangeType >::subdomainChanged ( )
inlinevirtual

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

the subdomain of this face's elem element is not the same as the subdomain of the last face's elem element).

Reimplemented in ComputeFVFluxThread< RangeType, AttributeTagType >, ComputeFVFluxThread< RangeType, AttribVectorTags >, and ComputeFVFluxThread< RangeType, AttribMatrixTags >.

Definition at line 104 of file ComputeFVFluxThread.h.

Referenced by ComputeFVFluxThread< RangeType, AttribMatrixTags >::subdomainChanged().

FEProblemBase & _fe_problem
SubdomainID _subdomain
The subdomain for the current element.
virtual void subdomainSetup(SubdomainID subdomain, const THREAD_ID tid)

Member Data Documentation

◆ _blocks_exec_printed

template<typename RangeType>
std::set<std::pair<const SubdomainID, const SubdomainID> > ThreadedFaceLoop< RangeType >::_blocks_exec_printed
mutableprotected

Set to keep track of blocks for which we have printed the execution pattern.

Definition at line 163 of file ComputeFVFluxThread.h.

Referenced by ThreadedFaceLoop< RangeType >::resetExecutionPrinting().

◆ _boundaries_exec_printed

template<typename RangeType>
std::set<BoundaryID> ThreadedFaceLoop< RangeType >::_boundaries_exec_printed
mutableprotected

Set to keep track of boundaries for which we have printed the execution pattern.

Definition at line 166 of file ComputeFVFluxThread.h.

Referenced by ThreadedFaceLoop< RangeType >::resetExecutionPrinting().

◆ _error_message

template<typename RangeType>
std::string ThreadedFaceLoop< RangeType >::_error_message
protected

Holds caught runtime error messages.

Definition at line 169 of file ComputeFVFluxThread.h.

Referenced by ThreadedFaceLoop< RangeType >::join().

◆ _fe_problem

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

◆ _incoming_throw_on_error

template<typename RangeType>
const bool ThreadedFaceLoop< RangeType >::_incoming_throw_on_error
private

The value of Moose::_throw_on_error at the time of construction.

This data member only has meaning and will only be read if this is the thread 0 copy of the class

Definition at line 177 of file ComputeFVFluxThread.h.

◆ _mesh

template<typename RangeType>
MooseMesh& ThreadedFaceLoop< RangeType >::_mesh
protected

Definition at line 139 of file ComputeFVFluxThread.h.

◆ _neighbor_subdomain

template<typename RangeType>
SubdomainID ThreadedFaceLoop< RangeType >::_neighbor_subdomain
protected

The subdomain for the current neighbor.

Definition at line 157 of file ComputeFVFluxThread.h.

Referenced by ThreadedFaceLoop< RangeType >::neighborSubdomainChanged().

◆ _nl_system_num

template<typename RangeType>
const unsigned int ThreadedFaceLoop< RangeType >::_nl_system_num
protected

Definition at line 142 of file ComputeFVFluxThread.h.

◆ _old_neighbor_subdomain

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

The subdomain for the last neighbor.

Definition at line 160 of file ComputeFVFluxThread.h.

◆ _old_subdomain

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

The subdomain for the last element.

Definition at line 154 of file ComputeFVFluxThread.h.

◆ _on_displaced

template<typename RangeType>
const bool ThreadedFaceLoop< RangeType >::_on_displaced
protected

Whether this loop is operating on the displaced mesh.

Definition at line 145 of file ComputeFVFluxThread.h.

◆ _subdomain

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

The subdomain for the current element.

Definition at line 151 of file ComputeFVFluxThread.h.

Referenced by ThreadedFaceLoop< RangeType >::subdomainChanged().

◆ _subproblem

template<typename RangeType>
SubProblem& ThreadedFaceLoop< RangeType >::_subproblem
protected

◆ _tags

template<typename RangeType>
const std::set<TagID>& ThreadedFaceLoop< RangeType >::_tags
protected

Definition at line 140 of file ComputeFVFluxThread.h.

◆ _tid

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

◆ _zeroth_copy

template<typename RangeType>
const bool ThreadedFaceLoop< RangeType >::_zeroth_copy
private

Whether this is the zeroth threaded copy of this body.

Definition at line 173 of file ComputeFVFluxThread.h.


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