Skip to content

Commit

Permalink
enhance TwoMaterialPropertyInterface and make InternalSideUserObject …
Browse files Browse the repository at this point in the history
…derived from it idaholab#3961 idaholab#5375
  • Loading branch information
YaqiWang committed Oct 9, 2015
1 parent 0f1c181 commit 0907e89
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 13 deletions.
54 changes: 45 additions & 9 deletions framework/include/materials/TwoMaterialPropertyInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,44 +26,80 @@
class TwoMaterialPropertyInterface : public MaterialPropertyInterface
{
public:
///@{
/**
* Contructor.
*
* @param parameters The objects input parameters
* @param block_ids A reference to the block ids (optional)
*
* This class has four constructors:
* (1) not restricted to boundaries or blocks
* (2) restricted to only blocks
*/
TwoMaterialPropertyInterface(const InputParameters & parameters);
TwoMaterialPropertyInterface(const InputParameters & parameters, const std::set<SubdomainID> & block_ids);

/**
* Retrieve the property named "name"
*/
template<typename T>
MaterialProperty<T> & getNeighborMaterialProperty(const std::string & name);
const MaterialProperty<T> & getNeighborMaterialProperty(const std::string & name);

template<typename T>
MaterialProperty<T> & getNeighborMaterialPropertyOld(const std::string & name);
const MaterialProperty<T> & getNeighborMaterialPropertyOld(const std::string & name);

template<typename T>
MaterialProperty<T> & getNeighborMaterialPropertyOlder(const std::string & name);
const MaterialProperty<T> & getNeighborMaterialPropertyOlder(const std::string & name);

protected:
MaterialData & _neighbor_material_data;
};


template<typename T>
MaterialProperty<T> &
const MaterialProperty<T> &
TwoMaterialPropertyInterface::getNeighborMaterialProperty(const std::string & name)
{
return _neighbor_material_data.getProperty<T>(name);
// Check if the supplied parameter is a valid imput parameter key
std::string prop_name = deducePropertyName(name);

// Check if it's just a constant
const MaterialProperty<T> * default_property = defaultMaterialProperty<T>(prop_name);
if (default_property)
return *default_property;
else
return _neighbor_material_data.getProperty<T>(prop_name);
}

template<typename T>
MaterialProperty<T> &
const MaterialProperty<T> &
TwoMaterialPropertyInterface::getNeighborMaterialPropertyOld(const std::string & name)
{
return _neighbor_material_data.getPropertyOld<T>(name);
// Check if the supplied parameter is a valid imput parameter key
std::string prop_name = deducePropertyName(name);

// Check if it's just a constant
const MaterialProperty<T> * default_property = defaultMaterialProperty<T>(prop_name);
if (default_property)
return *default_property;
else
return _neighbor_material_data.getPropertyOld<T>(prop_name);
}

template<typename T>
MaterialProperty<T> &
const MaterialProperty<T> &
TwoMaterialPropertyInterface::getNeighborMaterialPropertyOlder(const std::string & name)
{
return _neighbor_material_data.getPropertyOlder<T>(name);
// Check if the supplied parameter is a valid imput parameter key
std::string prop_name = deducePropertyName(name);

// Check if it's just a constant
const MaterialProperty<T> * default_property = defaultMaterialProperty<T>(prop_name);
if (default_property)
return *default_property;
else
return _neighbor_material_data.getPropertyOlder<T>(prop_name);
}

#endif //TWOMATERIALPROPERTYINTERFACE_H
4 changes: 2 additions & 2 deletions framework/include/userobject/InternalSideUserObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "UserObject.h"
#include "BlockRestrictable.h"
#include "NeighborCoupleable.h"
#include "MaterialPropertyInterface.h"
#include "TwoMaterialPropertyInterface.h"
#include "MooseVariableDependencyInterface.h"
#include "UserObjectInterface.h"
#include "TransientInterface.h"
Expand All @@ -36,7 +36,7 @@ InputParameters validParams<InternalSideUserObject>();
class InternalSideUserObject :
public UserObject,
public BlockRestrictable,
public MaterialPropertyInterface,
public TwoMaterialPropertyInterface,
public NeighborCoupleable,
public MooseVariableDependencyInterface,
public UserObjectInterface,
Expand Down
4 changes: 4 additions & 0 deletions framework/src/base/FEProblem.C
Original file line number Diff line number Diff line change
Expand Up @@ -1857,6 +1857,8 @@ FEProblem::addPostprocessor(std::string pp_name, const std::string & name, Input
mat_data = _bnd_material_data[tid];

parameters.set<MaterialData *>("_material_data") = mat_data;
if (parameters.isParamValid("use_neighbor_material") && parameters.get<bool>("use_neighbor_material"))
parameters.set<MaterialData *>("_neighbor_material_data") = _neighbor_material_data[tid];

MooseSharedPointer<MooseObject> mo = _factory.create(pp_name, name, parameters, tid);
if (!mo)
Expand Down Expand Up @@ -2037,6 +2039,8 @@ FEProblem::addUserObject(std::string user_object_name, const std::string & name,
mat_data = _bnd_material_data[tid];

parameters.set<MaterialData *>("_material_data") = mat_data;
if (parameters.isParamValid("use_neighbor_material") && parameters.get<bool>("use_neighbor_material"))
parameters.set<MaterialData *>("_neighbor_material_data") = _neighbor_material_data[tid];

MooseSharedPointer<UserObject> user_object = MooseSharedNamespace::static_pointer_cast<UserObject>(_factory.create(user_object_name, name, parameters, tid));
if (_displaced_problem != NULL && parameters.get<bool>("use_displaced_mesh"))
Expand Down
3 changes: 2 additions & 1 deletion framework/src/materials/MaterialPropertyInterface.C
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ MaterialPropertyInterface::defaultMaterialProperty(const std::string & name)

// check if the string parsed cleanly into a Real number
if (ss >> real_value && ss.eof())
{ MooseSharedPointer<MaterialProperty<Real> > default_property(new MaterialProperty<Real>);
{
MooseSharedPointer<MaterialProperty<Real> > default_property(new MaterialProperty<Real>);

// resize to accomodate maximum number of qpoints
unsigned int nqp = _mi_feproblem.getMaxQps();
Expand Down
6 changes: 6 additions & 0 deletions framework/src/materials/TwoMaterialPropertyInterface.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ TwoMaterialPropertyInterface::TwoMaterialPropertyInterface(const InputParameters
_neighbor_material_data(*parameters.get<MaterialData *>("_neighbor_material_data"))
{
}

TwoMaterialPropertyInterface::TwoMaterialPropertyInterface(const InputParameters & parameters, const std::set<SubdomainID> & block_ids) :
MaterialPropertyInterface(parameters, block_ids),
_neighbor_material_data(*parameters.get<MaterialData *>("_neighbor_material_data"))
{
}
3 changes: 2 additions & 1 deletion framework/src/userobject/InternalSideUserObject.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ InputParameters validParams<InternalSideUserObject>()
InputParameters params = validParams<UserObject>();
params += validParams<BlockRestrictable>();
params.addPrivateParam<bool>("use_bnd_material", true);
params.addPrivateParam<bool>("use_neighbor_material", true);
return params;
}

InternalSideUserObject::InternalSideUserObject(const InputParameters & parameters) :
UserObject(parameters),
BlockRestrictable(parameters),
MaterialPropertyInterface(parameters, blockIDs()),
TwoMaterialPropertyInterface(parameters, blockIDs()),
NeighborCoupleable(parameters, false, false),
MooseVariableDependencyInterface(),
UserObjectInterface(parameters),
Expand Down

0 comments on commit 0907e89

Please sign in to comment.