16 #include "libmesh/libmesh_exceptions.h" 17 #include "libmesh/elem.h" 22 template <
typename RangeType>
32 virtual void operator()(
const RangeType & range,
bool bypass_threading =
false);
49 virtual void onElement(
const Elem * elem);
76 const Elem * lower_d_elem =
nullptr);
89 const Elem * lower_d_elem =
nullptr);
113 virtual void onInternalSide(
const Elem * elem,
unsigned int side);
197 template <
typename RangeType>
202 template <
typename RangeType>
209 template <
typename RangeType>
214 template <
typename RangeType>
223 _tid = bypass_threading ? 0 : puid.
id;
226 printGeneralExecutionInformation();
230 typename RangeType::const_iterator el = range.begin();
231 for (el = range.begin(); el != range.end(); ++el)
236 const Elem * elem = *el;
240 _old_subdomain = _subdomain;
241 _subdomain = elem->subdomain_id();
242 if (_subdomain != _old_subdomain)
245 printBlockExecutionInformation();
257 for (
unsigned int side = 0; side < elem->n_sides(); side++)
259 std::vector<BoundaryID> boundary_ids = _mesh.getBoundaryIDs(elem, side);
260 const Elem * lower_d_elem = _mesh.getLowerDElem(elem, side);
262 if (boundary_ids.size() > 0)
263 for (std::vector<BoundaryID>::iterator it = boundary_ids.begin();
264 it != boundary_ids.end();
267 preBoundary(elem, side, *it, lower_d_elem);
268 printBoundaryExecutionInformation(*it);
272 const Elem * neighbor = elem->neighbor_ptr(side);
275 preInternalSide(elem, side);
277 _old_neighbor_subdomain = _neighbor_subdomain;
278 _neighbor_subdomain = neighbor->subdomain_id();
279 if (_neighbor_subdomain != _old_neighbor_subdomain)
280 neighborSubdomainChanged();
282 if (shouldComputeInternalSide(*elem, *neighbor))
283 onInternalSide(elem, side);
285 if (boundary_ids.size() > 0)
286 for (std::vector<BoundaryID>::iterator it = boundary_ids.begin();
287 it != boundary_ids.end();
289 onInterface(elem, side, *it);
291 postInternalSide(elem, side);
299 resetExecPrintedSets();
303 mooseException(
"We caught a libMesh error in ThreadedElementLoopBase:", e.what());
305 catch (MetaPhysicL::LogicError & e)
312 caughtMooseException(e);
316 template <
typename RangeType>
322 template <
typename RangeType>
328 template <
typename RangeType>
334 template <
typename RangeType>
340 template <
typename RangeType>
346 template <
typename RangeType>
355 template <
typename RangeType>
364 template <
typename RangeType>
370 template <
typename RangeType>
376 template <
typename RangeType>
382 template <
typename RangeType>
390 template <
typename RangeType>
396 template <
typename RangeType>
402 template <
typename RangeType>
405 const Elem & neighbor)
const 407 auto level = [
this](
const auto & elem_arg)
409 if (_mesh.doingPRefinement())
410 return elem_arg.p_level();
412 return elem_arg.level();
414 const auto elem_id = elem.id(), neighbor_id = neighbor.id();
415 const auto elem_level = level(elem), neighbor_level = level(neighbor);
423 return (neighbor.active() && (neighbor_level == elem_level) && (elem_id < neighbor_id)) ||
424 (neighbor_level < elem_level);
427 template <
typename RangeType>
431 _blocks_exec_printed.clear();
432 _boundaries_exec_printed.clear();
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.
const SubdomainID BOUNDARY_SIDE_LOWERD_ID
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.
const SubdomainID INTERNAL_SIDE_LOWERD_ID
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.