27 #include "libmesh/numeric_vector.h" 33 _query_subdomain(_query),
34 _query_boundary(_query),
35 _aux_sys(problem.getAuxiliarySystem())
43 _query_subdomain(x._query_subdomain),
44 _query_boundary(x._query_boundary),
55 std::vector<UserObject *> objs;
65 std::vector<UserObject *> side_objs;
69 .queryInto(side_objs);
71 objs.insert(objs.begin(), side_objs.begin(), side_objs.end());
76 std::set<MooseVariableFEBase *> needed_moose_vars;
77 std::unordered_set<unsigned int> needed_mat_props;
78 std::set<TagID> needed_fe_var_vector_tags;
79 for (
const auto obj : objs)
85 needed_moose_vars.insert(v_deps.begin(), v_deps.end());
92 needed_mat_props.insert(m_deps.begin(), m_deps.end());
99 needed_fe_var_vector_tags.insert(tag_deps.begin(), tag_deps.end());
102 obj->subdomainSetup();
133 if (uo->hasWritableCoupledVariables())
135 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
136 for (
auto * var : uo->getWritableCoupledVariables())
143 uo->preExecuteOnElement();
144 uo->executeOnElement();
152 for (
const auto & jvar : jacobian_moose_vars)
154 unsigned int jvar_id = jvar->number();
155 auto && dof_indices = jvar->dofIndices();
159 uo->executeJacobianWrapper(jvar_id, dof_indices);
168 const Elem * lower_d_elem )
170 std::vector<UserObject *> userobjs;
187 for (
const auto & uo : userobjs)
192 uo->preExecuteOnBoundary();
193 uo->executeOnBoundary();
197 std::vector<ShapeSideUserObject *> shapers;
203 for (
const auto & jvar : jacobian_moose_vars)
205 unsigned int jvar_id = jvar->number();
206 auto && dof_indices = jvar->dofIndices();
210 for (
const auto & uo : shapers)
211 uo->executeJacobianWrapper(jvar_id, dof_indices);
220 const Elem * neighbor = elem->neighbor_ptr(side);
223 const dof_id_type elem_id = elem->id(), neighbor_id = neighbor->id();
227 if (!((neighbor->active() && (neighbor->level() == elem->level()) && (elem_id < neighbor_id)) ||
228 (neighbor->level() < elem->level())))
243 if (!uo->blockRestricted() || uo->hasBlocks(neighbor->subdomain_id()))
247 if (!uo->blockRestricted() || uo->hasBlocks(neighbor->subdomain_id()))
249 uo->preExecuteOnInternalSide();
250 uo->executeOnInternalSide();
261 uo->executeOnExternalSide(elem, side);
268 const Elem * neighbor = elem->neighbor_ptr(side);
269 if (!(neighbor->active()))
272 std::vector<UserObject *> interface_objs;
275 bool has_domain_objs =
false;
279 if (domain_uo->shouldExecuteOnInterface())
281 has_domain_objs =
true;
287 if (interface_objs.empty() && !has_domain_objs)
309 for (
const auto & uo : interface_objs)
313 if (uo->shouldExecuteOnInterface())
315 uo->preExecuteOnInterface();
316 uo->executeOnInterface();
339 console <<
"[DBG] Computing elemental user objects on " << execute_on << std::endl;
340 mooseDoOnce(console <<
"[DBG] Execution order of objects types on each element then its sides:" 343 console <<
"[DBG] - element user objects" << std::endl;
344 console <<
"[DBG] - domain user objects" << std::endl;
345 console <<
"[DBG] - element user objects contributing to the Jacobian" << std::endl;
348 console <<
"[DBG] - side user objects" << std::endl;
349 console <<
"[DBG] - domain user objects executing on sides" << std::endl;
350 console <<
"[DBG] - side user objects contributing to the Jacobian" << std::endl;
353 console <<
"[DBG] - internal side user objects" << std::endl;
354 console <<
"[DBG] - domain user objects executing on internal sides" << std::endl;
357 console <<
"[DBG] - interface user objects" << std::endl;
358 console <<
"[DBG] - domain user objects executing at interfaces" << std::endl;);
371 std::vector<ShapeSideUserObject *> shapers;
375 std::vector<SideUserObject *> side_uos;
379 std::vector<InterfaceUserObject *> interface_objs;
383 std::vector<const DomainUserObject *> domain_interface_uos;
385 if (domain_uo->shouldExecuteOnInterface())
386 domain_interface_uos.push_back(domain_uo);
391 interface_objs.size() + domain_interface_uos.size();
401 console <<
"[DBG] Ordering of User Objects on block " <<
_subdomain << std::endl;
403 printExecutionOrdering<ElementUserObject>(
_element_objs,
"element user objects");
404 printExecutionOrdering<DomainUserObject>(
_domain_objs,
"domain user objects");
406 printExecutionOrdering<ShapeElementUserObject>(
408 printExecutionOrdering<SideUserObject>(side_uos,
"side user objects");
410 printExecutionOrdering<ShapeSideUserObject>(shapers,
411 "side user objects contributing to the Jacobian");
413 "internal side user objects");
414 printExecutionOrdering<InterfaceUserObject>(interface_objs,
"interface user objects");
415 console <<
"[DBG] Only user objects active on local element/sides are executed" << std::endl;
418 console <<
"[DBG] No User Objects on block " <<
_subdomain <<
" on " << execute_on.name()
const std::set< MooseVariableFieldBase * > & getMooseVariableDependencies() const
Retrieve the set of MooseVariableFieldBase that this object depends on.
virtual void onBoundary(const Elem *elem, unsigned int side, BoundaryID bnd_id, const Elem *lower_d_elem=nullptr) override
Called when doing boundary assembling.
Base class for assembly-like calculations.
virtual void prepareFace(const Elem *elem, const THREAD_ID tid) override
virtual void post() override
Called after the element range loop.
std::vector< ElementUserObject * > _element_objs
std::vector< ShapeElementUserObject * > _shape_element_objs
void querySubdomain(Interfaces iface, std::vector< T > &results)
QueryCache is a convenient way to construct and pass around (possible partially constructed) warehous...
void printBlockExecutionInformation() const override
Print information about the loop, mostly order of execution of particular objects.
virtual void prepare(const Elem *elem, const THREAD_ID tid) override
NumericVector< Number > & solution()
void printGeneralExecutionInformation() const override
Print general information about the loop, like the ordering of class of objects.
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
FEProblemBase & _fe_problem
virtual void onElement(const Elem *elem) override
Assembly of the element (not including surface assembly)
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 onInterface(const Elem *elem, unsigned int side, BoundaryID bnd_id) override
Called when doing interface assembling.
void queryBoundary(Interfaces iface, BoundaryID bnd, std::vector< T > &results)
void clearActiveMaterialProperties(const THREAD_ID tid)
Clear the active material properties.
virtual void subdomainChanged() override
Called every time the current subdomain changes (i.e.
const MaterialWarehouse & getMaterialWarehouse() const
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
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
ComputeUserObjectsThread(FEProblemBase &problem, const TheWarehouse::Query &query)
virtual void swapBackMaterialsFace(const THREAD_ID tid)
virtual void prepareFaceShapes(unsigned int var, const THREAD_ID tid) override
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 std::vector< const MooseVariableFEBase * > & getUserObjectJacobianVariables(const THREAD_ID tid) const
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
AuxiliarySystem & _aux_sys
virtual void reinitElem(const Elem *elem, 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
boundary_id_type BoundaryID
virtual void onExternalSide(const Elem *elem, unsigned int side) override
Called when iterating over external sides (no side neighbor)
const TheWarehouse::Query _query
void join(const ComputeUserObjectsThread &)
QueryCache clone() const
clone creates and returns an independent copy of the query in its current state.
virtual void swapBackMaterialsNeighbor(const THREAD_ID tid)
virtual ~ComputeUserObjectsThread()
std::set< SubdomainID > _blocks_exec_printed
Keep track of which blocks were visited.
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
Interface for objects that needs coupling capabilities.
const ConsoleStream & console() const
Return console handle.
virtual void swapBackMaterials(const THREAD_ID tid)
void updateBlockFEVariableCoupledVectorTagDependency(SubdomainID id, std::set< TagID > &needed_fe_var_vector_tags, THREAD_ID tid=0) const
Update FE variable coupleable vector tag vector.
virtual void subdomainSetup(SubdomainID subdomain, const THREAD_ID tid)
An interface for accessing Materials.
void reinitMaterials(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true)
Class for threaded computation of UserObjects.
virtual void onInternalSide(const Elem *elem, unsigned int side) override
Called when doing internal edge assembling.
std::vector< InternalSideUserObject * > _internal_side_objs
void reinitElemFace(const Elem *elem, unsigned int side, BoundaryID, const THREAD_ID tid)
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
SubdomainID _subdomain
The subdomain for the current element.
std::vector< DomainUserObject * > _domain_objs
virtual void reinitNeighbor(const Elem *elem, unsigned int side, const THREAD_ID tid) override
const bool & currentlyComputingJacobian() const
Returns true if the problem is in the process of computing the Jacobian.
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid) override
virtual void prepareShapes(unsigned int var, const THREAD_ID tid) override
void reinitMaterialsInterface(BoundaryID boundary_id, const THREAD_ID tid, bool swap_stateful=true)
const std::unordered_set< unsigned int > & getMatPropDependencies() const
Retrieve the set of material properties that this object depends on.
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...
std::set< TagID > & getFEVariableCoupleableVectorTags()
virtual void clearActiveElementalMooseVariables(const THREAD_ID tid) override
Clear the active elemental MooseVariableFEBase.
const BoundaryID ANY_BOUNDARY_ID
std::vector< DomainUserObject * > _all_domain_objs
The "SwapBackSentinel" class's destructor guarantees that FEProblemBase::swapBackMaterials{Face,Neighbor}() is called even when an exception is thrown from FEProblemBase::reinitMaterials{Face,Neighbor}.