20 #include "libmesh/threads.h" 22 template <
typename AuxKernelType>
28 _aux_sys(problem.getAuxiliarySystem()),
29 _aux_kernels(storage),
30 _need_materials(need_materials)
35 template <
typename AuxKernelType>
40 _aux_kernels(x._aux_kernels),
41 _need_materials(x._need_materials)
45 template <
typename AuxKernelType>
50 template <
typename AuxKernelType>
54 _fe_problem.subdomainSetup(_subdomain, _tid);
56 std::set<MooseVariableFEBase *> needed_moose_vars;
57 std::unordered_set<unsigned int> needed_mat_props;
58 std::set<TagID> needed_fe_var_matrix_tags;
59 std::set<TagID> needed_fe_var_vector_tags;
61 _fe_problem.getMaterialWarehouse().updateBlockFEVariableCoupledVectorTagDependency(
62 _subdomain, needed_fe_var_vector_tags, _tid);
63 if (_aux_kernels.hasActiveBlockObjects(_subdomain, _tid))
65 const std::vector<std::shared_ptr<AuxKernelType>> & kernels =
66 _aux_kernels.getActiveBlockObjects(_subdomain, _tid);
67 for (
const auto & aux : kernels)
69 aux->subdomainSetup();
70 const auto & mv_deps = aux->getMooseVariableDependencies();
71 const auto & mp_deps = aux->getMatPropDependencies();
72 needed_moose_vars.insert(mv_deps.begin(), mv_deps.end());
73 needed_mat_props.insert(mp_deps.begin(), mp_deps.end());
75 auto & fe_var_coup_vtags = aux->getFEVariableCoupleableVectorTags();
76 needed_fe_var_vector_tags.insert(fe_var_coup_vtags.begin(), fe_var_coup_vtags.end());
78 auto & fe_var_coup_mtags = aux->getFEVariableCoupleableMatrixTags();
79 needed_fe_var_matrix_tags.insert(fe_var_coup_mtags.begin(), fe_var_coup_mtags.end());
83 _fe_problem.setActiveElementalMooseVariables(needed_moose_vars, _tid);
84 _fe_problem.prepareMaterials(needed_mat_props, _subdomain, _tid);
85 _fe_problem.setActiveFEVariableCoupleableMatrixTags(needed_fe_var_matrix_tags, _tid);
86 _fe_problem.setActiveFEVariableCoupleableVectorTags(needed_fe_var_vector_tags, _tid);
89 template <
typename AuxKernelType>
93 if (_aux_kernels.hasActiveBlockObjects(_subdomain, _tid))
95 const std::vector<std::shared_ptr<AuxKernelType>> & kernels =
96 _aux_kernels.getActiveBlockObjects(_subdomain, _tid);
97 _fe_problem.prepare(elem, _tid);
98 _fe_problem.reinitElem(elem, _tid);
105 _fe_problem.reinitMaterials(elem->subdomain_id(), _tid);
107 for (
const auto & aux : kernels)
110 aux->variable().insert(_aux_sys.solution());
113 if (aux->hasWritableCoupledVariables())
115 for (
auto * var : aux->getWritableCoupledVariables())
116 var->insert(_aux_sys.solution());
118 _fe_problem.reinitElem(elem, _tid);
124 template <
typename AuxKernelType>
128 _fe_problem.clearActiveElementalMooseVariables(_tid);
129 _fe_problem.clearActiveMaterialProperties(_tid);
131 _fe_problem.clearActiveFEVariableCoupleableVectorTags(_tid);
132 _fe_problem.clearActiveFEVariableCoupleableMatrixTags(_tid);
135 template <
typename AuxKernelType>
141 template <
typename AuxKernelType>
145 if (!_fe_problem.shouldPrintExecution(_tid) || !_aux_kernels.hasActiveObjects())
148 const auto & console = _fe_problem.console();
149 const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
150 console <<
"[DBG] Executing auxiliary kernels on elements on " << execute_on << std::endl;
153 template <
typename AuxKernelType>
157 if (!_fe_problem.shouldPrintExecution(_tid) || _blocks_exec_printed.count(_subdomain) ||
158 !_aux_kernels.hasActiveBlockObjects(_subdomain, _tid))
161 const auto & console = _fe_problem.console();
162 const auto & kernels = _aux_kernels.getActiveBlockObjects(_subdomain, _tid);
163 console <<
"[DBG] Ordering of AuxKernels on block " << _subdomain << std::endl;
164 printExecutionOrdering<AuxKernelType>(kernels,
false);
165 _blocks_exec_printed.insert(_subdomain);
Base class for assembly-like calculations.
void printGeneralExecutionInformation() const override
Print list of object types executed and in which order.
void join(const ComputeElemAuxVarsThread &)
ComputeElemAuxVarsThread(FEProblemBase &problem, const MooseObjectWarehouse< AuxKernelType > &storage, bool need_materials)
void printBlockExecutionInformation() const override
Print list of specific objects executed and in which order.
virtual ~ComputeElemAuxVarsThread()
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual void subdomainChanged() override
Called every time the current subdomain changes (i.e.
virtual void onElement(const Elem *elem) override
Assembly of the element (not including surface assembly)
virtual void swapBackMaterials(const THREAD_ID tid)
virtual void post() override
Called after the element range loop.
The "SwapBackSentinel" class's destructor guarantees that FEProblemBase::swapBackMaterials{Face,Neighbor}() is called even when an exception is thrown from FEProblemBase::reinitMaterials{Face,Neighbor}.