Skip to content

Commit

Permalink
Add new checks and methods in FEProblemBase and SubProblem (idaholab#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lindsayad authored and rwcarlsen committed Mar 13, 2017
1 parent b3a08cc commit 08c2779
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 1 deletion.
8 changes: 8 additions & 0 deletions framework/include/base/FEProblemBase.h
Expand Up @@ -253,6 +253,14 @@ class FEProblemBase :
*/
virtual void clearActiveElementalMooseVariables(THREAD_ID tid) override;

virtual void setActiveMaterialProperties(const std::set<unsigned int> & mat_prop_ids, THREAD_ID tid) override;

virtual const std::set<unsigned int> & 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);

/**
Expand Down
12 changes: 12 additions & 0 deletions framework/include/base/SubProblem.h
Expand Up @@ -111,6 +111,14 @@ class SubProblem : public Problem
*/
virtual void clearActiveElementalMooseVariables(THREAD_ID tid);

virtual void setActiveMaterialProperties(const std::set<unsigned int> & mat_prop_ids, THREAD_ID tid);

virtual const std::set<unsigned int> &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;
Expand Down Expand Up @@ -368,6 +376,10 @@ class SubProblem : public Problem
/* This needs to remain <unsigned int> for threading purposes */
std::vector<unsigned int> _has_active_elemental_moose_variables;

std::vector<std::set<unsigned int> > _active_material_property_ids;

std::vector<unsigned int> _has_active_material_property_ids;

/// nonlocal coupling requirement flag
bool _requires_nonlocal_coupling;

Expand Down
40 changes: 39 additions & 1 deletion framework/src/base/FEProblemBase.C
Expand Up @@ -2005,9 +2005,14 @@ void
FEProblemBase::prepareMaterials(SubdomainID blk_id, THREAD_ID tid)
{
std::set<MooseVariable *> needed_moose_vars;
std::set<unsigned int> 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<BoundaryID> & ids = _mesh.getSubdomainBoundaryIds(blk_id);
for (const auto & id : ids)
Expand All @@ -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();
Expand Down Expand Up @@ -3062,6 +3070,36 @@ FEProblemBase::clearActiveElementalMooseVariables(THREAD_ID tid)
_displaced_problem->clearActiveElementalMooseVariables(tid);
}

void
FEProblemBase::setActiveMaterialProperties(const std::set<unsigned int> & 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<unsigned int> &
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)
{
Expand Down
26 changes: 26 additions & 0 deletions framework/src/base/SubProblem.C
Expand Up @@ -72,6 +72,32 @@ SubProblem::clearActiveElementalMooseVariables(THREAD_ID tid)
_active_elemental_moose_variables[tid].clear();
}

void
SubProblem::setActiveMaterialProperties(const std::set<unsigned int> & mat_prop_ids, THREAD_ID tid)
{
_has_active_material_property_ids[tid] = 1;
_active_material_property_ids[tid] = mat_prop_ids;
}

const std::set<unsigned int> &
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<SubdomainID>
SubProblem::getMaterialPropertyBlocks(const std::string & prop_name)
{
Expand Down

0 comments on commit 08c2779

Please sign in to comment.