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())
134 for (
auto * var : uo->getWritableCoupledVariables())
140 uo->preExecuteOnElement();
141 uo->executeOnElement();
149 for (
const auto & jvar : jacobian_moose_vars)
151 unsigned int jvar_id = jvar->number();
152 auto && dof_indices = jvar->dofIndices();
156 uo->executeJacobianWrapper(jvar_id, dof_indices);
165 const auto cache_key = std::make_pair(bnd_id, subdomain_id);
167 auto & cache = cache_it->second;
174 std::vector<UserObject *> userobjs;
177 std::vector<const MaterialPropertyInterface *> material_consumers;
178 material_consumers.reserve(userobjs.size() +
_domain_objs.size());
180 const auto add_material_consumers = [&material_consumers](
const auto & objects)
182 for (
const auto *
const object : objects)
184 material_consumers.push_back(consumer);
187 add_material_consumers(userobjs);
190 material_consumers, bnd_id, subdomain_id, cache.face_materials, cache.boundary_materials);
198 const Elem * lower_d_elem )
200 std::vector<UserObject *> userobjs;
220 bnd_id, elem->subdomain_id(),
_tid,
true, &required_mats.face_materials);
223 for (
const auto & uo : userobjs)
228 uo->preExecuteOnBoundary();
229 uo->executeOnBoundary();
233 std::vector<ShapeSideUserObject *> shapers;
239 for (
const auto & jvar : jacobian_moose_vars)
241 unsigned int jvar_id = jvar->number();
242 auto && dof_indices = jvar->dofIndices();
246 for (
const auto & uo : shapers)
247 uo->executeJacobianWrapper(jvar_id, dof_indices);
256 const Elem * neighbor = elem->neighbor_ptr(side);
273 if (!uo->blockRestricted() || uo->hasBlocks(neighbor->subdomain_id()))
277 if (!uo->blockRestricted() || uo->hasBlocks(neighbor->subdomain_id()))
279 uo->preExecuteOnInternalSide();
280 uo->executeOnInternalSide();
291 uo->executeOnExternalSide(elem, side);
298 const Elem * neighbor = elem->neighbor_ptr(side);
299 if (!(neighbor->active()))
302 std::vector<UserObject *> interface_objs;
305 bool has_domain_objs =
false;
309 if (domain_uo->shouldExecuteOnInterface())
311 has_domain_objs =
true;
317 if (interface_objs.empty() && !has_domain_objs)
339 for (
const auto & uo : interface_objs)
343 if (uo->shouldExecuteOnInterface())
345 uo->preExecuteOnInterface();
346 uo->executeOnInterface();
369 console <<
"[DBG] Computing elemental user objects on " << execute_on << std::endl;
370 mooseDoOnce(console <<
"[DBG] Execution order of objects types on each element then its sides:"
373 console <<
"[DBG] - element user objects" << std::endl;
374 console <<
"[DBG] - domain user objects" << std::endl;
375 console <<
"[DBG] - element user objects contributing to the Jacobian" << std::endl;
378 console <<
"[DBG] - side user objects" << std::endl;
379 console <<
"[DBG] - domain user objects executing on sides" << std::endl;
380 console <<
"[DBG] - side user objects contributing to the Jacobian" << std::endl;
383 console <<
"[DBG] - internal side user objects" << std::endl;
384 console <<
"[DBG] - domain user objects executing on internal sides" << std::endl;
387 console <<
"[DBG] - interface user objects" << std::endl;
388 console <<
"[DBG] - domain user objects executing at interfaces" << std::endl;);
401 std::vector<ShapeSideUserObject *> shapers;
405 std::vector<SideUserObject *> side_uos;
409 std::vector<InterfaceUserObject *> interface_objs;
413 std::vector<const DomainUserObject *> domain_interface_uos;
415 if (domain_uo->shouldExecuteOnInterface())
416 domain_interface_uos.push_back(domain_uo);
421 interface_objs.size() + domain_interface_uos.size();
431 console <<
"[DBG] Ordering of User Objects on block " <<
_subdomain << std::endl;
433 printExecutionOrdering<ElementUserObject>(
_element_objs,
"element user objects");
434 printExecutionOrdering<DomainUserObject>(
_domain_objs,
"domain user objects");
436 printExecutionOrdering<ShapeElementUserObject>(
438 printExecutionOrdering<SideUserObject>(side_uos,
"side user objects");
440 printExecutionOrdering<ShapeSideUserObject>(shapers,
441 "side user objects contributing to the Jacobian");
443 "internal side user objects");
444 printExecutionOrdering<InterfaceUserObject>(interface_objs,
"interface user objects");
445 console <<
"[DBG] Only user objects active on local element/sides are executed" << std::endl;
448 console <<
"[DBG] No User Objects on block " <<
_subdomain <<
" on " << execute_on.name()
boundary_id_type BoundaryID
subdomain_id_type SubdomainID
Class for threaded computation of UserObjects.
std::vector< DomainUserObject * > _all_domain_objs
std::vector< ElementUserObject * > _element_objs
virtual void post() override
Called after the element range loop.
virtual void onInternalSide(const Elem *elem, unsigned int side) override
Called when doing internal edge assembling.
const TheWarehouse::Query _query
virtual void onElement(const Elem *elem) override
Assembly of the element (not including surface assembly)
virtual void onInterface(const Elem *elem, unsigned int side, BoundaryID bnd_id) override
Called when doing interface assembling.
virtual void onBoundary(const Elem *elem, unsigned int side, BoundaryID bnd_id, const Elem *lower_d_elem=nullptr) override
Called when doing boundary assembling.
void printBlockExecutionInformation() const override
Print information about the loop, mostly order of execution of particular objects.
void queryBoundary(Interfaces iface, BoundaryID bnd, std::vector< T > &results)
ComputeUserObjectsThread(FEProblemBase &problem, const TheWarehouse::Query &query)
void printGeneralExecutionInformation() const override
Print general information about the loop, like the ordering of class of objects.
void join(const ComputeUserObjectsThread &)
const BoundaryMaterialReinitCache & getBoundaryMaterialReinitCache(BoundaryID bnd_id, SubdomainID subdomain_id)
Return the exact face and boundary materials required while executing on this boundary.
virtual ~ComputeUserObjectsThread()
AuxiliarySystem & _aux_sys
std::map< std::pair< BoundaryID, SubdomainID >, BoundaryMaterialReinitCache > _boundary_material_reinit_cache
virtual void onExternalSide(const Elem *elem, unsigned int side) override
Called when iterating over external sides (no side neighbor)
std::vector< ShapeElementUserObject * > _shape_element_objs
void querySubdomain(Interfaces iface, std::vector< T > &results)
std::vector< DomainUserObject * > _domain_objs
virtual void subdomainChanged() override
Called every time the current subdomain changes (i.e.
std::vector< InternalSideUserObject * > _internal_side_objs
Interface for objects that needs coupling capabilities.
std::set< TagID > & getFEVariableCoupleableVectorTags()
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
virtual void prepareFaceShapes(unsigned int var, const THREAD_ID tid) override
virtual void prepareShapes(unsigned int var, const THREAD_ID tid) override
virtual void reinitElem(const Elem *elem, const THREAD_ID tid) override
virtual void swapBackMaterialsFace(const THREAD_ID tid)
const std::vector< const MooseVariableFEBase * > & getUserObjectJacobianVariables(const THREAD_ID tid) const
const MaterialWarehouse & getMaterialWarehouse() const
void reinitMaterials(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true)
virtual void prepare(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
virtual void swapBackMaterialsNeighbor(const THREAD_ID tid)
void clearActiveMaterialProperties(const THREAD_ID tid)
Clear the active material properties.
virtual void clearActiveElementalMooseVariables(const THREAD_ID tid) override
Clear the active elemental MooseVariableFEBase.
virtual void prepareFace(const Elem *elem, const THREAD_ID tid) override
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.
virtual void subdomainSetup(SubdomainID subdomain, const THREAD_ID tid)
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
An interface for accessing Materials.
virtual const std::unordered_set< unsigned int > & getMatPropDependencies() const
Retrieve the set of material properties that this object depends on.
void updateBlockFEVariableCoupledVectorTagDependency(SubdomainID id, std::set< TagID > &needed_fe_var_vector_tags, THREAD_ID tid=0) const
const std::set< MooseVariableFieldBase * > & getMooseVariableDependencies() const
Retrieve the set of MooseVariableFieldBase that this object depends on.
const ConsoleStream & console() const
Return console handle.
const bool & currentlyComputingJacobian() const
Returns true if the problem is in the process of computing the Jacobian.
The "SwapBackSentinel" class's destructor guarantees that FEProblemBase::swapBackMaterials{Face,...
NumericVector< Number > & solution()
QueryCache is a convenient way to construct and pass around (possible partially constructed) warehous...
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
QueryCache clone() const
clone creates and returns an independent copy of the query in its current state.
SubdomainID _subdomain
The subdomain for the current element.
std::set< SubdomainID > _blocks_exec_printed
Keep track of which blocks were visited.
Base class for assembly-like calculations.
FEProblemBase & _fe_problem
void getRequiredBoundaryMaterials(const std::vector< const MaterialPropertyInterface * > &material_consumers, BoundaryID bnd_id, SubdomainID subdomain_id, std::deque< MaterialBase * > &required_face_materials, std::deque< MaterialBase * > &required_boundary_materials) const
Determine the face and boundary materials required by material property consumers.
const BoundaryID ANY_BOUNDARY_ID