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());
133 if (dynamic_cast<ComputeJacobianThread *>(
this))
146 for (
const auto & kernel : kernels)
157 const unsigned int side,
159 const Elem *
const lower_d_elem )
174 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
184 for (
const auto & bc : bcs)
185 if (bc->shouldApply())
196 const Elem * neighbor = elem->neighbor_ptr(side);
198 if (neighbor->active())
221 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
232 for (
const auto & interface_kernel : int_ks)
242 const Elem * neighbor = elem->neighbor_ptr(side);
257 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
278 for (
const auto & dg_kernel : dgks)
279 if (dg_kernel->hasBlocks(neighbor->subdomain_id()))
286 compute(static_cast<ResidualObject &>(kernel));
292 compute(static_cast<ResidualObject &>(kernel));
298 compute(static_cast<ResidualObject &>(bc));
304 compute(static_cast<ResidualObject &>(dg));
310 compute(static_cast<ResidualObject &>(ik));
332 console <<
"[DBG] Beginning elemental loop to compute " +
objectType() +
" on " << execute_on
335 console <<
"[DBG] Execution order on each element:" << std::endl;
336 console <<
"[DBG] - kernels on element quadrature points" << std::endl;
337 console <<
"[DBG] - finite volume elemental kernels on element" << std::endl;
338 console <<
"[DBG] - integrated boundary conditions on element side quadrature points" 340 console <<
"[DBG] - DG kernels on element side quadrature points" << std::endl;
341 console <<
"[DBG] - interface kernels on element side quadrature points" << std::endl;);
358 console <<
"[DBG] Ordering of " +
objectType() +
" Objects on block " << block_name <<
" (" 362 console <<
"[DBG] Ordering of kernels:" << std::endl;
367 console <<
"[DBG] Ordering of FV elemental kernels:" << std::endl;
368 std::string fvkernels =
373 {
return str_out +
" " + kernel->name(); });
378 console <<
"[DBG] Ordering of DG kernels:" << std::endl;
384 console <<
"[DBG] No Active " +
objectType() +
" Objects on block " << block_name <<
" (" 400 console <<
"[DBG] Ordering of " +
objectType() +
" Objects on boundary " << b_name <<
" (" << bid
405 console <<
"[DBG] Ordering of integrated boundary conditions:" << std::endl;
414 console <<
"[DBG] Ordering of interface kernels:" << std::endl;
423 const unsigned int side,
425 const Elem *
const lower_d_elem)
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...
unsigned int size(THREAD_ID tid=0) const
Return how many kernels we store in the current warehouse.
virtual bool shouldComputeInternalSide(const Elem &elem, const Elem &neighbor) const
Whether to compute the internal side for the provided element-neighbor pair.
Base class for assembly-like calculations.
virtual void accumulate()=0
Add element residual/Jacobian into assembly global data.
virtual void accumulateLower()=0
Add lower-d residual/Jacobian into assembly global data.
const std::vector< MooseVariableScalar * > & getScalarVariables(THREAD_ID tid)
bool hasActiveBlockObjects(THREAD_ID tid=0) const
virtual void compute(ResidualObject &ro)=0
Will dispatch to computeResidual/computeJacobian/computeResidualAndJacobian based on the derived clas...
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
MooseObjectWarehouse< InterfaceKernelBase > * _ik_warehouse
virtual void computeOnBoundary(BoundaryID bnd_id, const Elem *lower_d_elem)
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
const BoundaryID INVALID_BOUNDARY_ID
MooseObjectTagWarehouse< IntegratedBCBase > & _integrated_bcs
Reference to BC storage structures.
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
FEProblemBase & _fe_problem
std::vector< T * > & queryInto(std::vector< T *> &results, Args &&... args)
queryInto executes the query and stores the results in the given vector.
const std::string & getBoundaryName(BoundaryID boundary_id)
Return the name of the boundary given the id.
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
const MaterialWarehouse & getMaterialWarehouse() const
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
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.
void updateBlockVariableDependency(SubdomainID id, std::set< MooseVariableFieldBase *> &needed_moose_vars, THREAD_ID tid=0) const
const std::string & getSubdomainName(SubdomainID subdomain_id) const
Return the name of a block given an id.
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
bool shouldComputeInternalSide(const Elem &elem, const Elem &neighbor) const override
Whether to compute the internal side for the provided element-neighbor pair.
void prepareElement(const Elem *elem)
Serves as a base class for DGKernel and ADDGKernel.
virtual void reinitElemNeighborAndLowerD(const Elem *elem, unsigned int side, const THREAD_ID tid) override
virtual void onBoundary(const Elem *elem, unsigned int side, BoundaryID bnd_id, const Elem *lower_d_elem=nullptr) override
Called when doing boundary assembling.
virtual void accumulateNeighbor()=0
Add neighbor residual/Jacobian into assembly global data.
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
virtual void swapBackMaterialsFace(const THREAD_ID tid)
FVElemental is used for calculating residual contributions from volume integral terms of a PDE where ...
virtual void setActiveElementalMooseVariables(const std::set< MooseVariableFEBase *> &moose_vars, const THREAD_ID tid) override
Set the MOOSE variables to be reinited on each element.
const bool _has_active_objects
Whether there are any active residual objects; otherwise we will do an early return.
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
MooseObjectWarehouse< HDGKernel > * _hdg_warehouse
This is the common base class for the three main kernel types implemented in MOOSE, Kernel, VectorKernel and ArrayKernel.
TheWarehouse & theWarehouse() const
void printBlockExecutionInformation() const override
Print list of specific objects executed on each block and in which order.
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
MooseObjectTagWarehouse< KernelBase > & _kernels
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...
boundary_id_type BoundaryID
virtual void computeOnElement()
void clearVarsAndMaterials()
virtual std::string objectType() const
Return what the loops is meant to compute.
NonlinearThread(FEProblemBase &fe_problem)
void printGeneralExecutionInformation() const override
Print information about the loop, mostly order of execution of objects.
unsigned int number() const
Gets the number of this system.
virtual void computeOnInterface(BoundaryID bnd_id)
NonlinearSystemBase & _nl
virtual void postElement(const Elem *) override
Called after the element assembly is done (including surface assembling)
virtual void operator()(const RangeType &range, bool bypass_threading=false)
virtual void operator()(const ConstElemRange &range, bool bypass_threading=false) override
void updateBoundaryMatPropDependency(std::unordered_set< unsigned int > &needed_mat_props, THREAD_ID tid=0) const
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
virtual void swapBackMaterialsNeighbor(const THREAD_ID tid)
virtual void onInternalSide(const Elem *elem, unsigned int side) override
Called when doing internal edge assembling.
virtual void computeOnInternalFace()=0
std::set< SubdomainID > _blocks_exec_printed
Keep track of which blocks were visited.
MooseObjectWarehouse< IntegratedBCBase > * _ibc_warehouse
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 ConsoleStream & console() const
Return console handle.
virtual void swapBackMaterials(const THREAD_ID tid)
void updateBlockMatPropDependency(SubdomainID id, std::unordered_set< unsigned int > &needed_mat_props, THREAD_ID tid=0) const
void updateBlockFEVariableCoupledVectorTagDependency(SubdomainID id, std::set< TagID > &needed_fe_var_vector_tags, THREAD_ID tid=0) const
Update FE variable coupleable vector tag vector.
std::set< BoundaryID > _boundaries_exec_printed
Keep track of which boundaries were visited.
virtual void subdomainSetup(SubdomainID subdomain, const THREAD_ID tid)
bool _should_execute_dg
Whether DG kernels should be executed for a given elem-neighbor pairing.
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
virtual void accumulateNeighborLower()=0
Add neighbor and lower residual/Jacobian into assembly global data.
MooseObjectTagWarehouse< InterfaceKernelBase > & _interface_kernels
Reference to interface kernel storage structure.
Base class for deriving any boundary condition of a integrated type.
void printBoundaryExecutionInformation(const unsigned int bid) const override
Print list of specific objects executed on each boundary and in which order.
virtual void onInterface(const Elem *elem, unsigned int side, BoundaryID bnd_id) override
Called when doing interface assembling.
void reinitElemFace(const Elem *elem, unsigned int side, BoundaryID, const THREAD_ID tid)
InterfaceKernelBase is the base class for all InterfaceKernel type classes.
virtual void determineObjectWarehouses()=0
Determine the objects we will actually compute based on vector/matrix tag information.
SubdomainID _subdomain
The subdomain for the current element.
MooseObjectWarehouse< KernelBase > * _tag_kernels
MooseObjectWarehouse< DGKernelBase > * _dg_warehouse
virtual void reinitNeighbor(const Elem *elem, unsigned int side, const THREAD_ID tid) override
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid) override
virtual void onElement(const Elem *elem) override
Assembly of the element (not including surface assembly)
void reinitMaterialsInterface(BoundaryID boundary_id, const THREAD_ID tid, bool swap_stateful=true)
void updateBoundaryVariableDependency(std::set< MooseVariableFieldBase *> &needed_moose_vars, THREAD_ID tid=0) const
std::vector< FVElementalKernel * > _fv_kernels
Current subdomain FVElementalKernels.
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...
virtual void reinitOffDiagScalars(const THREAD_ID tid) override
virtual void post() override
Called after the element range loop.
MooseObjectTagWarehouse< DGKernelBase > & _dg_kernels
Reference to DGKernel storage structure.
virtual ~NonlinearThread()
virtual void subdomainChanged() override
Called every time the current subdomain changes (i.e.
The "SwapBackSentinel" class's destructor guarantees that FEProblemBase::swapBackMaterials{Face,Neighbor}() is called even when an exception is thrown from FEProblemBase::reinitMaterials{Face,Neighbor}.