https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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.
 
virtual void pre ()
 This is called once before all face-looping.
 
virtual void post ()
 This is called once after all face-looping is finished.
 
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.
 
virtual void subdomainChanged ()
 Called every time the current subdomain changes (i.e.
 
virtual void neighborSubdomainChanged ()
 Called every time the neighbor subdomain changes (i.e.
 
void caughtMooseException (MooseException &e)
 Called if a MooseException is caught anywhere during the computation.
 

Protected Member Functions

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

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.
 
SubProblem_subproblem
 FEProblemBase or DisplacedProblem depending on _on_displaced.
 
SubdomainID _subdomain
 The subdomain for the current element.
 
SubdomainID _old_subdomain
 The subdomain for the last element.
 
SubdomainID _neighbor_subdomain
 The subdomain for the current neighbor.
 
SubdomainID _old_neighbor_subdomain
 The subdomain for the last neighbor.
 
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.
 
std::set< BoundaryID_boundaries_exec_printed
 Set to keep track of boundaries for which we have printed the execution pattern.
 
std::string _error_message
 Holds caught runtime error messages.
 

Private Attributes

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

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),
193 : static_cast<SubProblem &>(_fe_problem)),
194 _zeroth_copy(true),
196{
198}
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
virtual MooseMesh & mesh() override
Generic class for solving transient nonlinear problems.
Definition SubProblem.h:79
FEProblemBase & _fe_problem
const bool _incoming_throw_on_error
The value of Moose::_throw_on_error at the time of construction.
const bool _zeroth_copy
Whether this is the zeroth threaded copy of this body.
const unsigned int _nl_system_num
const std::set< TagID > & _tags
const bool _on_displaced
Whether this loop is operating on the displaced mesh.
SubProblem & _subproblem
FEProblemBase or DisplacedProblem depending on _on_displaced.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
bool _throw_on_error
Variable to turn on exceptions during mooseError(), should only be used within MOOSE unit tests or wh...
Definition Moose.C:896

◆ ThreadedFaceLoop() [2/2]

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

Definition at line 201 of file ComputeFVFluxThread.h.

◆ ~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}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
std::string _error_message
Holds caught runtime error messages.

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 }
static Threads::spin_mutex threaded_element_mutex
This mutex is used by all derived classes of the ThreadedElementLoop.
virtual void setException(const std::string &message)
Set an exception, which is stored at this point by toggling a member variable in this class,...
virtual const char * what() const
Get out the error message.

◆ 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}

◆ 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, AttribMatrixTags >, and ComputeFVFluxThread< RangeType, AttribVectorTags >.

Definition at line 110 of file ComputeFVFluxThread.h.

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

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

◆ 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, AttribMatrixTags >, and ComputeFVFluxThread< RangeType, AttribVectorTags >.

◆ 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();
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}
virtual void setCurrentSubdomainID(const Elem *elem, const THREAD_ID tid) override
TheWarehouse & theWarehouse() const
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, const THREAD_ID tid) override
Provides a way for users to bail out of the current solve.
std::vector< T * > & queryInto(std::vector< T * > &results, Args &&... args)
queryInto executes the query and stores the results in the given vector.
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse.
virtual void subdomainChanged()
Called every time the current subdomain changes (i.e.
SubdomainID _old_subdomain
The subdomain for the last element.
virtual void post()
This is called once after all face-looping is finished.
virtual void printBlockExecutionInformation() const
Print ordering of objects executed on each block.
virtual void pre()
This is called once before all face-looping.
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...
virtual void printBoundaryExecutionInformation(const BoundaryID) const
Print ordering of objects exected on each boundary.
virtual void onFace(const FaceInfo &fi)=0
virtual void printGeneralExecutionInformation() const
Print list of object types executed and in which order.
void caughtMooseException(MooseException &e)
Called if a MooseException is caught anywhere during the computation.
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.
SubdomainID _old_neighbor_subdomain
The subdomain for the last neighbor.
void resetExecutionPrinting()
Reset lists of blocks and boundaries for which execution printing has been done.
virtual void neighborSubdomainChanged()
Called every time the neighbor subdomain changes (i.e.
const SubdomainID INVALID_BLOCK_ID
Definition MooseTypes.C:20
void translateMetaPhysicLError(const MetaPhysicL::LogicError &)
emit a relatively clear error message when we catch a MetaPhysicL logic error
Definition MooseError.C:155

◆ 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, AttribMatrixTags >, and ComputeFVFluxThread< RangeType, AttribVectorTags >.

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 ComputeFVFluxResidualThread< RangeType >, ComputeFVFluxJacobianThread< RangeType >, and ComputeFVFluxRJThread< 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

◆ 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, AttribMatrixTags >, and ComputeFVFluxThread< RangeType, AttribVectorTags >.

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, AttribMatrixTags >, and ComputeFVFluxThread< RangeType, AttribVectorTags >.

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();
138 }
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.
std::set< BoundaryID > _boundaries_exec_printed
Set to keep track of boundaries 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, AttribMatrixTags >, and ComputeFVFluxThread< RangeType, AttribVectorTags >.

Definition at line 106 of file ComputeFVFluxThread.h.

virtual void subdomainSetup(SubdomainID subdomain, const THREAD_ID tid)

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

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: