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 75 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 183 of file ComputeFVFluxThread.h.

187  : _fe_problem(fe_problem),
188  _mesh(fe_problem.mesh()),
189  _tags(tags),
190  _nl_system_num(nl_system_num),
191  _on_displaced(on_displaced),
192  _subproblem(_on_displaced ? static_cast<SubProblem &>(*_fe_problem.getDisplacedProblem())
193  : static_cast<SubProblem &>(_fe_problem)),
194  _zeroth_copy(true),
196 {
197  Moose::_throw_on_error = true;
198 }
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:845

◆ ThreadedFaceLoop() [2/2]

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

Definition at line 201 of file ComputeFVFluxThread.h.

203  _mesh(x._mesh),
204  _tags(x._tags),
208  _zeroth_copy(false),
210 {
211 }
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 214 of file ComputeFVFluxThread.h.

215 {
216  if (_zeroth_copy)
217  {
219 
220  if (!_error_message.empty())
222  }
223 }
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:311
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:845

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 116 of file ComputeFVFluxThread.h.

117  {
118  Threads::spin_mutex::scoped_lock lock(threaded_element_mutex);
119  std::string what(e.what());
121  }
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 227 of file ComputeFVFluxThread.h.

228 {
229  if (_error_message.empty() && !y._error_message.empty())
231 }
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 110 of file ComputeFVFluxThread.h.

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

111  {
113  }
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 241 of file ComputeFVFluxThread.h.

242 {
243  // TODO: make this query fv flux kernel specific or somehow integrate the
244  // fv source kernels into this loop. Also this check will need to increase
245  // in generality if/when other systems and objects besides FV stuff get
246  // added to this loop.
247  std::vector<FVKernel *> kernels;
249  .query()
250  .template condition<AttribSysNum>(_nl_system_num)
251  .template condition<AttribSystem>("FVFluxKernel")
252  .template condition<AttribDisplaced>(_on_displaced)
253  .queryInto(kernels);
254  if (kernels.size() == 0)
255  return;
256 
257  try
258  {
259  try
260  {
261  ParallelUniqueId puid;
262  _tid = bypass_threading ? 0 : puid.id;
263 
264  pre();
266 
269 
270  typename RangeType::const_iterator faceinfo = range.begin();
271  for (faceinfo = range.begin(); faceinfo != range.end(); ++faceinfo)
272  {
273  const Elem & elem = (*faceinfo)->elem();
274 
276 
278  _subdomain = elem.subdomain_id();
279  if (_subdomain != _old_subdomain)
280  {
283  }
284 
286  if (const Elem * const neighbor = (*faceinfo)->neighborPtr())
287  {
289  _neighbor_subdomain = neighbor->subdomain_id();
290  }
291  else
293 
295  {
297  // This is going to cause a lot more printing
299  }
300 
301  onFace(**faceinfo);
302  // Cache data now because onBoundary may clear it. E.g. there was a nasty bug for two
303  // variable FV systems where if one variable was executing an FVFluxKernel on a boundary
304  // while the other was executing an FVFluxBC, the FVFluxKernel data would get lost because
305  // onBoundary would clear the residual/Jacobian data before it was cached
306  postFace(**faceinfo);
307 
308  const std::set<BoundaryID> boundary_ids = (*faceinfo)->boundaryIDs();
309  for (auto & it : boundary_ids)
310  {
312  onBoundary(**faceinfo, it);
313  }
314 
315  postFace(**faceinfo);
316 
317  } // range
318  post();
319 
320  // Clear execution printing sets to start printing on every block and boundary again
322  }
323  catch (MetaPhysicL::LogicError & e)
324  {
326  }
327  catch (std::exception & e)
328  {
329  // Continue if we find a libMesh degenerate map exception, but
330  // just throw for any real error
331  if (!strstr(e.what(), "Jacobian") && !strstr(e.what(), "singular") &&
332  !strstr(e.what(), "det != 0"))
333  throw;
334 
335  mooseException("We caught a libMesh degeneracy exception in ComputeFVFluxThread:\n",
336  e.what());
337  }
338  }
339  catch (MooseException & e)
340  {
342  }
343  catch (std::runtime_error & e)
344  {
345  _error_message = e.what();
346  }
347 }
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:155
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:467
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 98 of file ComputeFVFluxThread.h.

98 {}

◆ 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 94 of file ComputeFVFluxThread.h.

94 {}

◆ 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 128 of file ComputeFVFluxThread.h.

128 {}

◆ 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 131 of file ComputeFVFluxThread.h.

131 {}

◆ 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 125 of file ComputeFVFluxThread.h.

125 {}

◆ 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 134 of file ComputeFVFluxThread.h.

135  {
136  _blocks_exec_printed.clear();
137  _boundaries_exec_printed.clear();
138  }
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 106 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 165 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 168 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 171 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 179 of file ComputeFVFluxThread.h.

◆ _mesh

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

Definition at line 141 of file ComputeFVFluxThread.h.

◆ _neighbor_subdomain

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

The subdomain for the current neighbor.

Definition at line 159 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 144 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 162 of file ComputeFVFluxThread.h.

◆ _old_subdomain

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

The subdomain for the last element.

Definition at line 156 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 147 of file ComputeFVFluxThread.h.

◆ _subdomain

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

The subdomain for the current element.

Definition at line 153 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 142 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 175 of file ComputeFVFluxThread.h.


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