Skip to content

Commit

Permalink
Initial work on mat prop dependencies (idaholab#8444).
Browse files Browse the repository at this point in the history
  • Loading branch information
lindsayad authored and rwcarlsen committed Mar 13, 2017
1 parent c079d1d commit f17e262
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion framework/include/base/MooseVariableDependencyInterface.h
Expand Up @@ -34,7 +34,7 @@ class MooseVariableDependencyInterface
protected:

/**
* Call this function ot add the passed in MooseVariable as a variable that _this_ object depends on.
* Call this function to add the passed in MooseVariable as a variable that _this_ object depends on.
*/
void addMooseVariableDependency(MooseVariable * var) { _moose_variable_dependencies.insert(var); }
void addMooseVariableDependency(std::vector<MooseVariable *> vars) { _moose_variable_dependencies.insert(vars.begin(), vars.end()); }
Expand Down
13 changes: 12 additions & 1 deletion framework/include/materials/MaterialPropertyInterface.h
Expand Up @@ -179,6 +179,8 @@ class MaterialPropertyInterface
*/
bool getMaterialPropertyCalled() const { return _get_material_property_called; }

const std::set<MaterialProperty *> & getMatPropDependencies() const { return _material_property_dependencies; }

protected:
/// Parameters of the object with this interface
const InputParameters & _mi_params;
Expand Down Expand Up @@ -256,6 +258,11 @@ class MaterialPropertyInterface

/// Storage for the boundary ids created by BoundaryRestrictable
const std::set<BoundaryID> _mi_boundary_ids;

void addMatPropDependency(MaterialProperty * mat_prop) { _material_property_dependencies.insert(mat_prop); }
void addMatPropDependency(std::vector<MaterialProperty *> mat_props) { _material_property_dependencies.insert(mat_props.begin(), mat_props.end()); }

std::set<MaterialProperty *> _material_property_dependencies;
};

/**
Expand Down Expand Up @@ -285,6 +292,7 @@ MaterialPropertyInterface::getMaterialProperty(const std::string & name)
{
// Check if the supplied parameter is a valid input parameter key
std::string prop_name = deducePropertyName(name);
std::cout << "Material property " << prop_name << " is being requested by " << _mi_name << "." << std::endl;

// Check if it's just a constant
const MaterialProperty<T> * default_property = defaultMaterialProperty<T>(prop_name);
Expand Down Expand Up @@ -358,7 +366,10 @@ MaterialPropertyInterface::getMaterialPropertyByName(const MaterialPropertyName
// Update the boolean flag.
_get_material_property_called = true;

return _material_data->getProperty<T>(name);
const MaterialProperty<T> & mat_prop = _material_data->getProperty<T>(name);

addMatPropDependency(&mat_prop);
return mat_prop;
}


Expand Down
9 changes: 9 additions & 0 deletions framework/include/materials/MaterialWarehouse.h
Expand Up @@ -51,12 +51,21 @@ class MaterialWarehouse : public MooseObjectWarehouse<Material>
*/
void addObjects(std::shared_ptr<Material> block, std::shared_ptr<Material> neighbor, std::shared_ptr<Material> face, THREAD_ID tid = 0);

void updateBlockMatPropDependency(SubdomainID id, std::set<MaterialProperty *> & needed_mat_props, THREAD_ID tid = 0) const;


protected:
/// Stroage for neighbor material objects (Block are stored in the base class)
MooseObjectWarehouse<Material> _neighbor_materials;

/// Stroage for face material objects (Block are stored in the base class)
MooseObjectWarehouse<Material> _face_materials;

/**
* Helper method for updating variable dependency vector
*/
static void updateMatPropDependencyHelper(std::set<MaterialProperty *> & needed_mat_props,
const std::vector<MooseSharedPointer<T> > & objects);
};

#endif // MATERIALWAREHOUSE_H
17 changes: 17 additions & 0 deletions framework/src/materials/MaterialWarehouse.C
Expand Up @@ -104,3 +104,20 @@ MaterialWarehouse::sort(THREAD_ID tid /*=0*/)
_neighbor_materials.sort(tid);
_face_materials.sort(tid);
}

void
MaterialWarehouse::updateBlockMatPropDependency(SubdomainID id, std::set<MaterialProperty *> & needed_mat_props, THREAD_ID /*tid = 0*/) const
{
if (hasActiveBlockObjects(id, tid))
updateMatPropDependencyHelper(needed_mat_props, getActiveBlockObjects(id, tid));
}

void
MaterialWarehouse::updateMatPropDependencyHelper(std::set<MaterialProperty *> & needed_mat_props, const std::vector<MooseSharedPointer<T> > & objects)
{
for (typename std::vector<MooseSharedPointer<T> >::const_iterator it = objects.begin(); it != objects.end(); ++it)
{
const std::set<MaterialProperty *> & mp_deps = (*it)->getMatPropDependencies();
needed_mat_props.insert(mp_deps.begin(), mp_deps.end());
}
}

0 comments on commit f17e262

Please sign in to comment.