16 #include "libmesh/libmesh_exceptions.h" 17 #include "libmesh/elem.h" 25 template <
typename RangeType>
35 virtual void operator()(
const RangeType & range,
bool bypass_threading =
false);
52 virtual void onElement(
const Elem * elem);
79 const Elem * lower_d_elem =
nullptr);
92 const Elem * lower_d_elem =
nullptr);
116 virtual void onInternalSide(
const Elem * elem,
unsigned int side);
124 virtual void onExternalSide(
const Elem * elem,
unsigned int side);
207 template <
typename RangeType>
212 template <
typename RangeType>
219 template <
typename RangeType>
224 template <
typename RangeType>
233 _tid = bypass_threading ? 0 : puid.
id;
236 printGeneralExecutionInformation();
240 typename RangeType::const_iterator el = range.begin();
241 for (el = range.begin(); el != range.end(); ++el)
246 const Elem * elem = *el;
250 _old_subdomain = _subdomain;
251 _subdomain = elem->subdomain_id();
252 if (_subdomain != _old_subdomain)
255 printBlockExecutionInformation();
260 if (_mesh.interiorLowerDBlocks().count(elem->subdomain_id()) > 0 ||
261 _mesh.boundaryLowerDBlocks().count(elem->subdomain_id()) > 0)
267 for (
unsigned int side = 0; side < elem->n_sides(); side++)
269 std::vector<BoundaryID> boundary_ids = _mesh.getBoundaryIDs(elem, side);
270 const Elem * lower_d_elem = _mesh.getLowerDElem(elem, side);
272 if (boundary_ids.size() > 0)
273 for (std::vector<BoundaryID>::iterator it = boundary_ids.begin();
274 it != boundary_ids.end();
277 preBoundary(elem, side, *it, lower_d_elem);
278 printBoundaryExecutionInformation(*it);
282 const Elem * neighbor = elem->neighbor_ptr(side);
285 preInternalSide(elem, side);
287 _old_neighbor_subdomain = _neighbor_subdomain;
288 _neighbor_subdomain = neighbor->subdomain_id();
289 if (_neighbor_subdomain != _old_neighbor_subdomain)
290 neighborSubdomainChanged();
292 if (shouldComputeInternalSide(*elem, *neighbor))
293 onInternalSide(elem, side);
295 if (boundary_ids.size() > 0)
296 for (std::vector<BoundaryID>::iterator it = boundary_ids.begin();
297 it != boundary_ids.end();
299 onInterface(elem, side, *it);
301 postInternalSide(elem, side);
304 onExternalSide(elem, side);
311 resetExecPrintedSets();
313 catch (MetaPhysicL::LogicError & e)
317 catch (std::exception & e)
321 if (!strstr(e.what(),
"Jacobian") && !strstr(e.what(),
"singular") &&
322 !strstr(e.what(),
"det != 0"))
325 mooseException(
"We caught a libMesh degeneracy exception in ThreadedElementLoopBase:\n",
331 caughtMooseException(e);
335 template <
typename RangeType>
341 template <
typename RangeType>
347 template <
typename RangeType>
353 template <
typename RangeType>
359 template <
typename RangeType>
365 template <
typename RangeType>
374 template <
typename RangeType>
383 template <
typename RangeType>
389 template <
typename RangeType>
395 template <
typename RangeType>
401 template <
typename RangeType>
407 template <
typename RangeType>
415 template <
typename RangeType>
421 template <
typename RangeType>
427 template <
typename RangeType>
430 const Elem & neighbor)
const 432 auto level = [
this](
const auto & elem_arg)
434 if (_mesh.doingPRefinement())
435 return elem_arg.p_level();
437 return elem_arg.level();
439 const auto elem_id = elem.id(), neighbor_id = neighbor.id();
440 const auto elem_level = level(elem), neighbor_level = level(neighbor);
448 return (neighbor.active() && (neighbor_level == elem_level) && (elem_id < neighbor_id)) ||
449 (neighbor_level < elem_level);
452 template <
typename RangeType>
456 _blocks_exec_printed.clear();
457 _boundaries_exec_printed.clear();
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.
virtual ~ThreadedElementLoopBase()
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)
void translateMetaPhysicLError(const MetaPhysicL::LogicError &)
emit a relatively clear error message when we catch a MetaPhysicL logic error
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.
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
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.
boundary_id_type BoundaryID
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
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.
virtual void operator()(const RangeType &range, bool bypass_threading=false)
virtual void onInternalSide(const Elem *elem, unsigned int side)
Called when doing internal edge assembling.
bool onBoundary(const SubdomainRestrictable &obj, const FaceInfo &fi)
Return whether the supplied face is on a boundary of the object's execution.
std::set< SubdomainID > _blocks_exec_printed
Keep track of which blocks were visited.
Provides a way for users to bail out of the current solve.
std::set< BoundaryID > _boundaries_exec_printed
Keep track of which boundaries were visited.
virtual void caughtMooseException(MooseException &)
Called if a MooseException is caught anywhere during the computation.
Base class for assembly-like calculations.
SubdomainID _subdomain
The subdomain for the current element.
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.
ThreadedElementLoopBase(MooseMesh &mesh)
SubdomainID _neighbor_subdomain
The subdomain for the current neighbor.