24#include "libmesh/threads.h"
28 _nl(fe_problem.currentNonlinearSystem()),
30 _integrated_bcs(_nl.getIntegratedBCWarehouse()),
31 _dg_kernels(_nl.getDGKernelWarehouse()),
32 _interface_kernels(_nl.getInterfaceKernelWarehouse()),
33 _kernels(_nl.getKernelWarehouse()),
34 _hdg_kernels(_nl.getHDGKernelWarehouse()),
35 _has_active_objects(_integrated_bcs.hasActiveObjects() || _dg_kernels.hasActiveObjects() ||
36 _interface_kernels.hasActiveObjects() || _kernels.hasActiveObjects() ||
37 _fe_problem.haveFV()),
38 _should_execute_dg(false)
46 _num_cached(x._num_cached),
47 _integrated_bcs(x._integrated_bcs),
48 _dg_kernels(x._dg_kernels),
49 _interface_kernels(x._interface_kernels),
51 _tag_kernels(x._tag_kernels),
52 _hdg_kernels(x._hdg_kernels),
53 _has_active_objects(x._has_active_objects),
54 _should_execute_dg(x._should_execute_dg)
77 std::set<MooseVariableFEBase *> needed_moose_vars;
84 std::set<TagID> needed_fe_var_vector_tags;
93 std::unordered_set<unsigned int> needed_mat_props;
105 .template condition<AttribSysNum>(
_nl.
number())
106 .template condition<AttribSystem>(
"FVElementalKernel")
107 .template condition<AttribSubdomains>(
_subdomain)
108 .template condition<AttribThread>(
_tid)
112 const auto & fv_mv_deps = fv_kernel->getMooseVariableDependencies();
113 needed_moose_vars.insert(fv_mv_deps.begin(), fv_mv_deps.end());
114 const auto & fv_mp_deps = fv_kernel->getMatPropDependencies();
115 needed_mat_props.insert(fv_mp_deps.begin(), fv_mp_deps.end());
150 for (
const auto & kernel : kernels)
161 const unsigned int side,
163 const Elem *
const lower_d_elem )
185 for (
const auto & bc : bcs)
186 if (bc->shouldApply())
197 const Elem * neighbor = elem->neighbor_ptr(side);
199 if (neighbor->active())
230 for (
const auto & interface_kernel : int_ks)
240 const Elem * neighbor = elem->neighbor_ptr(side);
275 bool has_interface_kernels =
false;
276 for (
const auto bid : boundary_ids)
278 has_interface_kernels =
true;
280 if (has_interface_kernels)
285 " is missing a neighbor (hence identified as an external side) but "
286 "has interface kernel(s) defined on the boundary.");
293 for (
const auto & dg_kernel : dgks)
294 if (dg_kernel->hasBlocks(neighbor->subdomain_id()))
347 console <<
"[DBG] Beginning elemental loop to compute " +
objectType() +
" on " << execute_on
350 console <<
"[DBG] Execution order on each element:" << std::endl;
351 console <<
"[DBG] - kernels on element quadrature points" << std::endl;
352 console <<
"[DBG] - finite volume elemental kernels on element" << std::endl;
353 console <<
"[DBG] - integrated boundary conditions on element side quadrature points"
355 console <<
"[DBG] - DG kernels on element side quadrature points" << std::endl;
356 console <<
"[DBG] - interface kernels on element side quadrature points" << std::endl;);
373 console <<
"[DBG] Ordering of " +
objectType() +
" Objects on block " << block_name <<
" ("
377 console <<
"[DBG] Ordering of kernels:" << std::endl;
382 console <<
"[DBG] Ordering of FV elemental kernels:" << std::endl;
383 std::string fvkernels =
388 { return str_out +
" " + kernel->name(); });
393 console <<
"[DBG] Ordering of DG kernels:" << std::endl;
399 console <<
"[DBG] No Active " +
objectType() +
" Objects on block " << block_name <<
" ("
415 console <<
"[DBG] Ordering of " +
objectType() +
" Objects on boundary " << b_name <<
" (" << bid
420 console <<
"[DBG] Ordering of integrated boundary conditions:" << std::endl;
429 console <<
"[DBG] Ordering of interface kernels:" << std::endl;
438 const unsigned int side,
440 const Elem *
const lower_d_elem)
boundary_id_type BoundaryID
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Serves as a base class for DGKernel and ADDGKernel.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
void reinitMaterialsFace(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true, const std::deque< MaterialBase * > *reinit_mats=nullptr)
reinit materials on element faces
virtual void reinitOffDiagScalars(const THREAD_ID tid) override
virtual void swapBackMaterialsFace(const THREAD_ID tid)
const MaterialWarehouse & getMaterialWarehouse() const
virtual void reinitElemNeighborAndLowerD(const Elem *elem, unsigned int side, const THREAD_ID tid) override
void reinitMaterialsNeighbor(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true, const std::deque< MaterialBase * > *reinit_mats=nullptr)
reinit materials on the neighboring element face
virtual void swapBackMaterialsNeighbor(const THREAD_ID tid)
void prepareMaterials(const std::unordered_set< unsigned int > &consumer_needed_mat_props, const SubdomainID blk_id, const THREAD_ID tid)
Add the MooseVariables and the material properties that the current materials depend on to the depend...
void reinitElemFace(const Elem *elem, unsigned int side, BoundaryID, const THREAD_ID tid)
virtual void reinitLowerDElem(const Elem *lower_d_elem, const THREAD_ID tid, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr) override
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
void reinitMaterialsFaceOnBoundary(const BoundaryID boundary_id, const SubdomainID blk_id, const THREAD_ID tid, const bool swap_stateful=true, const std::deque< MaterialBase * > *const reinit_mats=nullptr)
reinit materials on element faces on a boundary (internal or external) This specific routine helps us...
void reinitMaterialsBoundary(BoundaryID boundary_id, const THREAD_ID tid, bool swap_stateful=true, const std::deque< MaterialBase * > *reinit_mats=nullptr)
reinit materials on a boundary
virtual void setActiveElementalMooseVariables(const std::set< MooseVariableFEBase * > &moose_vars, const THREAD_ID tid) override
Set the MOOSE variables to be reinited on each element.
virtual void swapBackMaterials(const THREAD_ID tid)
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid) override
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
TheWarehouse & theWarehouse() const
virtual void subdomainSetup(SubdomainID subdomain, const THREAD_ID tid)
void reinitMaterialsNeighborOnBoundary(const BoundaryID boundary_id, const SubdomainID blk_id, const THREAD_ID tid, const bool swap_stateful=true, const std::deque< MaterialBase * > *const reinit_mats=nullptr)
reinit materials on neighbor element (usually faces) on a boundary (internal or external) This specif...
void reinitMaterialsInterface(BoundaryID boundary_id, const THREAD_ID tid, bool swap_stateful=true)
virtual void reinitNeighbor(const Elem *elem, unsigned int side, const THREAD_ID tid) override
FVElemental is used for calculating residual contributions from volume integral terms of a PDE where ...
Base class for deriving any boundary condition of a integrated type.
InterfaceKernelBase is the base class for all InterfaceKernel type classes.
This is the common base class for the three main kernel types implemented in MOOSE,...
const std::string & getBoundaryName(const BoundaryID boundary_id) const
Return the name of the boundary given the id.
const std::string & getSubdomainName(SubdomainID subdomain_id) const
Return the name of a block given an id.
std::vector< BoundaryID > getBoundaryIDs(const Elem *const elem, const unsigned short int side) const
Returns a vector of boundary IDs for the requested element on the requested side.
unsigned int size(THREAD_ID tid=0) const
Return how many kernels we store in the current warehouse.
std::string activeObjectsToFormattedString(THREAD_ID tid=0, const std::string &prefix="[DBG]") const
Output the active content of the warehouse to a string, meant to be output to the console.
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
void updateBlockMatPropDependency(SubdomainID id, std::unordered_set< unsigned int > &needed_mat_props, THREAD_ID tid=0, const bool producer_only=false) const
void updateBlockFEVariableCoupledVectorTagDependency(SubdomainID id, std::set< TagID > &needed_fe_var_vector_tags, THREAD_ID tid=0) const
void updateBoundaryVariableDependency(std::set< MooseVariableFieldBase * > &needed_moose_vars, THREAD_ID tid=0) const
void updateBlockVariableDependency(SubdomainID id, std::set< MooseVariableFieldBase * > &needed_moose_vars, THREAD_ID tid=0) const
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
bool hasActiveBlockObjects(THREAD_ID tid=0) const
void updateBoundaryMatPropDependency(std::unordered_set< unsigned int > &needed_mat_props, THREAD_ID tid=0, const bool producer_only=false) const
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
MooseObjectTagWarehouse< KernelBase > & _kernels
virtual std::string objectType() const
Return what the loops is meant to compute.
virtual void onBoundary(const Elem *elem, unsigned int side, BoundaryID bnd_id, const Elem *lower_d_elem=nullptr) override
Called when doing boundary assembling.
bool shouldComputeInternalSide(const Elem &elem, const Elem &neighbor) const override
Whether to compute the internal side for the provided element-neighbor pair.
virtual void onInternalSide(const Elem *elem, unsigned int side) override
Called when doing internal edge assembling.
NonlinearThread(FEProblemBase &fe_problem)
MooseObjectTagWarehouse< IntegratedBCBase > & _integrated_bcs
Reference to BC storage structures.
virtual void accumulateNeighbor()=0
Add neighbor residual/Jacobian into assembly global data.
virtual void operator()(const ConstElemRange &range, bool bypass_threading=false) override
virtual void determineObjectWarehouses()=0
Determine the objects we will actually compute based on vector/matrix tag information.
virtual void computeOnInterface(BoundaryID bnd_id)
void prepareFace(const Elem *elem, unsigned int side, BoundaryID bnd_id=Moose::INVALID_BOUNDARY_ID, const Elem *lower_d_elem=nullptr)
Reinitialize variables and materials on a face.
MooseObjectWarehouse< InterfaceKernelBase > * _ik_warehouse
bool _subdomain_has_dg
Whether the subdomain has DGKernels.
virtual void computeOnBoundary(BoundaryID bnd_id, const Elem *lower_d_elem)
MooseObjectTagWarehouse< DGKernelBase > & _dg_kernels
Reference to DGKernel storage structure.
virtual void post() override
Called after the element range loop.
virtual void accumulateNeighborLower()=0
Add neighbor and lower residual/Jacobian into assembly global data.
void printBlockExecutionInformation() const override
Print list of specific objects executed on each block and in which order.
virtual void accumulate()=0
Add element residual/Jacobian into assembly global data.
virtual void onExternalSide(const Elem *elem, unsigned int side) override
Called when iterating over external sides (no side neighbor)
virtual void compute(ResidualObject &ro)=0
Will dispatch to computeResidual/computeJacobian/computeResidualAndJacobian based on the derived clas...
virtual void computeOnElement()
virtual void computeOnInternalFace()=0
std::vector< FVElementalKernel * > _fv_kernels
Current subdomain FVElementalKernels.
bool _subdomain_has_hdg
Whether the subdomain has HDGKernels.
NonlinearSystemBase & _nl
Reference to the underlying NonlinearSystemBase.
void printBoundaryExecutionInformation(const unsigned int bid) const override
Print list of specific objects executed on each boundary and in which order.
virtual void subdomainChanged() override
Called every time the current subdomain changes (i.e.
const bool _has_active_objects
Whether there are any active residual objects; otherwise we will do an early return.
MooseObjectWarehouse< DGKernelBase > * _dg_warehouse
MooseObjectWarehouse< HDGKernel > * _hdg_warehouse
MooseObjectWarehouse< KernelBase > * _tag_kernels
void printGeneralExecutionInformation() const override
Print information about the loop, mostly order of execution of objects.
virtual ~NonlinearThread()
MooseObjectTagWarehouse< InterfaceKernelBase > & _interface_kernels
Reference to interface kernel storage structure.
virtual void accumulateLower()=0
Add lower-d residual/Jacobian into assembly global data.
virtual void onInterface(const Elem *elem, unsigned int side, BoundaryID bnd_id) override
Called when doing interface assembling.
virtual void postElement(const Elem *) override
Called after the element assembly is done (including surface assembling)
MooseObjectWarehouse< IntegratedBCBase > * _ibc_warehouse
bool _should_execute_dg
Whether DG kernels should be executed for a given elem-neighbor pairing.
virtual void onElement(const Elem *elem) override
Assembly of the element (not including surface assembly)
const ConsoleStream & console() const
Return console handle.
This is the common base class for objects that give residual contributions.
The "SwapBackSentinel" class's destructor guarantees that FEProblemBase::swapBackMaterials{Face,...
unsigned int number() const
Gets the number of this system.
const std::vector< MooseVariableScalar * > & getScalarVariables(THREAD_ID tid)
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 operator()(const RangeType &range, bool bypass_threading=false)
SubdomainID _subdomain
The subdomain for the current element.
std::set< BoundaryID > _boundaries_exec_printed
Keep track of which boundaries were visited.
virtual bool shouldComputeInternalSide(const Elem &elem, const Elem &neighbor) const
Whether to compute the internal side for the provided element-neighbor pair.
std::set< SubdomainID > _blocks_exec_printed
Keep track of which blocks were visited.
Base class for assembly-like calculations.
void clearVarsAndMaterials()
void prepareElement(const Elem *elem)
FEProblemBase & _fe_problem
std::string formatString(std::string message, const std::string &prefix)
Add new lines and prefixes to a string for pretty display in output NOTE: This makes a copy of the st...
const BoundaryID INVALID_BOUNDARY_ID