From 08c277980030a79aea5cc76f4fd6e34d6001aea6 Mon Sep 17 00:00:00 2001 From: Alex Lindsay Date: Wed, 1 Feb 2017 16:26:29 -0600 Subject: [PATCH] Add new checks and methods in FEProblemBase and SubProblem (#8444). --- framework/include/base/FEProblemBase.h | 8 ++++++ framework/include/base/SubProblem.h | 12 ++++++++ framework/src/base/FEProblemBase.C | 40 +++++++++++++++++++++++++- framework/src/base/SubProblem.C | 26 +++++++++++++++++ 4 files changed, 85 insertions(+), 1 deletion(-) diff --git a/framework/include/base/FEProblemBase.h b/framework/include/base/FEProblemBase.h index 0fd64c403f10..a0cc7f9b6e17 100644 --- a/framework/include/base/FEProblemBase.h +++ b/framework/include/base/FEProblemBase.h @@ -253,6 +253,14 @@ class FEProblemBase : */ virtual void clearActiveElementalMooseVariables(THREAD_ID tid) override; + virtual void setActiveMaterialProperties(const std::set & mat_prop_ids, THREAD_ID tid) override; + + virtual const std::set & getActiveMaterialProperties(THREAD_ID tid) override; + + virtual bool hasActiveMaterialProperties(THREAD_ID tid) override; + + virtual void clearActiveMaterialProperties(THREAD_ID tid) override; + virtual void createQRules(QuadratureType type, Order order, Order volume_order=INVALID_ORDER, Order face_order=INVALID_ORDER); /** diff --git a/framework/include/base/SubProblem.h b/framework/include/base/SubProblem.h index dd69901fe122..53a3bb2b8c30 100644 --- a/framework/include/base/SubProblem.h +++ b/framework/include/base/SubProblem.h @@ -111,6 +111,14 @@ class SubProblem : public Problem */ virtual void clearActiveElementalMooseVariables(THREAD_ID tid); + virtual void setActiveMaterialProperties(const std::set & mat_prop_ids, THREAD_ID tid); + + virtual const std::set &getActiveMaterialProperties(THREAD_ID tid); + + virtual bool hasActiveMaterialProperties(THREAD_ID tid); + + virtual void clearActiveMaterialProperties(THREAD_ID tid); + virtual Assembly & assembly(THREAD_ID tid) = 0; virtual void prepareShapes(unsigned int var, THREAD_ID tid) = 0; virtual void prepareFaceShapes(unsigned int var, THREAD_ID tid) = 0; @@ -368,6 +376,10 @@ class SubProblem : public Problem /* This needs to remain for threading purposes */ std::vector _has_active_elemental_moose_variables; + std::vector > _active_material_property_ids; + + std::vector _has_active_material_property_ids; + /// nonlocal coupling requirement flag bool _requires_nonlocal_coupling; diff --git a/framework/src/base/FEProblemBase.C b/framework/src/base/FEProblemBase.C index 2e94ab8a23dc..9b8064d9935c 100644 --- a/framework/src/base/FEProblemBase.C +++ b/framework/src/base/FEProblemBase.C @@ -2005,9 +2005,14 @@ void FEProblemBase::prepareMaterials(SubdomainID blk_id, THREAD_ID tid) { std::set needed_moose_vars; + std::set needed_mat_props; + if (_all_materials.hasActiveBlockObjects(blk_id, tid)) + { _all_materials.updateVariableDependency(needed_moose_vars, tid); + _all_materials.updateMatPropDependency(needed_mat_props, tid); + } const std::set & ids = _mesh.getSubdomainBoundaryIds(blk_id); for (const auto & id : ids) @@ -2018,12 +2023,15 @@ FEProblemBase::prepareMaterials(SubdomainID blk_id, THREAD_ID tid) if (!needed_moose_vars.empty()) setActiveElementalMooseVariables(needed_moose_vars, tid); + + if (!needed_mat_props.empty()) + setActiveMaterialProperties(needed_mat_props, tid); } void FEProblemBase::reinitMaterials(SubdomainID blk_id, THREAD_ID tid, bool swap_stateful) { - if (_all_materials.hasActiveBlockObjects(blk_id, tid)) + if (_all_materials.hasActiveBlockObjects(blk_id, tid) && _subproblem.hasActiveMaterialProperties(tid)) { const Elem * & elem = _assembly[tid]->elem(); unsigned int n_points = _assembly[tid]->qRule()->n_points(); @@ -3062,6 +3070,36 @@ FEProblemBase::clearActiveElementalMooseVariables(THREAD_ID tid) _displaced_problem->clearActiveElementalMooseVariables(tid); } +void +FEProblemBase::setActiveMaterialProperties(const std::set & mat_prop_ids, THREAD_ID tid) +{ + SubProblem::setActiveMaterialProperties(mat_prop_ids, tid); + + if (_displaced_problem) + _displaced_problem->setActiveMaterialProperties(mat_prop_ids, tid); +} + +const std::set & +FEProblemBase::getActiveMaterialProperties(THREAD_ID tid) +{ + return SubProblem::getActiveMaterialProperties(tid); +} + +bool +FEProblemBase::hasActiveMaterialProperties(THREAD_ID tid) +{ + return SubProblem::hasActiveMaterialProperties(tid); +} + +void +FEProblemBase::clearActiveMaterialProperties(THREAD_ID tid) +{ + SubProblem::clearActiveMaterialProperties(tid); + + if (_displaced_problem) + _displaced_problem->clearActiveMaterialProperties(tid); +} + void FEProblemBase::createQRules(QuadratureType type, Order order, Order volume_order, Order face_order) { diff --git a/framework/src/base/SubProblem.C b/framework/src/base/SubProblem.C index 6ae8db7dc715..349cb523f8ed 100644 --- a/framework/src/base/SubProblem.C +++ b/framework/src/base/SubProblem.C @@ -72,6 +72,32 @@ SubProblem::clearActiveElementalMooseVariables(THREAD_ID tid) _active_elemental_moose_variables[tid].clear(); } +void +SubProblem::setActiveMaterialProperties(const std::set & mat_prop_ids, THREAD_ID tid) +{ + _has_active_material_property_ids[tid] = 1; + _active_material_property_ids[tid] = mat_prop_ids; +} + +const std::set & +SubProblem::getActiveMaterialProperties(THREAD_ID tid) +{ + return _active_material_property_ids[tid]; +} + +bool +SubProblem::hasActiveMaterialProperties(THREAD_ID tid) +{ + return _has_active_material_property_ids[tid]; +} + +void +SubProblem::clearActiveMaterialProperties(THREAD_ID tid) +{ + _has_active_material_property_ids[tid] = 0; + _active_material_property_ids[tid].clear(); +} + std::set SubProblem::getMaterialPropertyBlocks(const std::string & prop_name) {