Skip to content

Commit

Permalink
a test for InternalSideUserObject calling getNeighborMaterialProperty i…
Browse files Browse the repository at this point in the history
  • Loading branch information
YaqiWang committed Oct 9, 2015
1 parent e990dfe commit 0bc2af5
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 6 deletions.
4 changes: 2 additions & 2 deletions test/include/userobjects/InsideUserObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class InsideUserObject : public InternalSideUserObject
VariableValue & _u_neighbor;

Real _value;
std::string _diffusivity;
const MaterialProperty<Real> * _diffusivity_prop;
const MaterialProperty<Real> & _diffusivity_prop;
const MaterialProperty<Real> & _neighbor_diffusivity_prop;
};

#endif /* INSIDEUSEROBJECT_H */
8 changes: 4 additions & 4 deletions test/src/userobjects/InsideUserObject.C
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ template<>
InputParameters validParams<InsideUserObject>()
{
InputParameters params = validParams<InternalSideUserObject>();
params.addParam<std::string>("diffusivity", "The name of the diffusivity material property that will be used in the flux computation.");
params.addParam<MaterialPropertyName>("diffusivity", 0.0, "The name of the diffusivity material property that will be used in the flux computation.");
params.addParam<bool>("use_old_prop", false, "A Boolean to indicate whether the current or old value of a material prop should be used.");
params.addRequiredCoupledVar("variable", "the variable name");

Expand All @@ -30,8 +30,8 @@ InsideUserObject::InsideUserObject(const InputParameters & parameters) :
_u(coupledValue("variable")),
_u_neighbor(coupledNeighborValue("variable")),
_value(0.),
_diffusivity(parameters.get<std::string>("diffusivity")),
_diffusivity_prop(isParamValid("diffusivity") ? (getParam<bool>("use_old_prop") ? &getMaterialPropertyOld<Real>(_diffusivity) : &getMaterialProperty<Real>(_diffusivity)) : NULL)
_diffusivity_prop(getParam<bool>("use_old_prop") ? getMaterialPropertyOld<Real>("diffusivity") : getMaterialProperty<Real>("diffusivity")),
_neighbor_diffusivity_prop(getParam<bool>("use_old_prop") ? getNeighborMaterialPropertyOld<Real>("diffusivity") : getNeighborMaterialProperty<Real>("diffusivity"))
{
}

Expand All @@ -49,7 +49,7 @@ void
InsideUserObject::execute()
{
for (unsigned int qp = 0; qp < _q_point.size(); ++qp)
_value += std::pow(_u[qp] - _u_neighbor[qp], 2) + (_diffusivity_prop ? (*_diffusivity_prop)[qp] : 0);
_value += std::pow(_u[qp] - _u_neighbor[qp], 2) + (_diffusivity_prop[qp] + _neighbor_diffusivity_prop[qp] ) / 2;
}

void
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
[Mesh]
type = GeneratedMesh
dim = 2
xmin = -1
ymin = -1
xmax = 1
ymax = 1
nx = 2
ny = 2
elem_type = QUAD4
[]

[MeshModifiers]
[./subdomain_id]
type = AssignElementSubdomainID
subdomain_ids = '0 1
1 1'
[../]
[]

[Functions]
[./fn_exact]
type = ParsedFunction
value = 'x*x+y*y'
[../]

[./ffn]
type = ParsedFunction
value = -4
[../]
[]

[UserObjects]
[./isuo]
type = InsideUserObject
variable = u
diffusivity = diffusivity
execute_on = 'initial timestep_end'
[../]
[]

[Variables]
[./u]
family = LAGRANGE
order = FIRST
[../]
[]

[Kernels]
[./diff]
type = Diffusion
variable = u
[../]

[./ffn]
type = UserForcingFunction
variable = u
function = ffn
[../]
[]

[BCs]
[./all]
type = FunctionDirichletBC
variable = u
boundary = '0 1 2 3'
function = fn_exact
[../]
[]

[Materials]
[./stateful1]
type = StatefulMaterial
block = 0
initial_diffusivity = 1
[../]
[./stateful2]
type = StatefulMaterial
block = 1
initial_diffusivity = 2
[../]
[]

[Postprocessors]
[./value]
type = InsideValuePPS
user_object = isuo
[../]
[]

[Executioner]
type = Steady
[]

[Outputs]
exodus = true
[]
5 changes: 5 additions & 0 deletions test/tests/userobjects/internal_side_user_object/tests
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@
input = 'internal_side_user_object.i'
exodiff = 'internal_side_user_object_out.e'
[../]
[./get_neighbor_test]
type = 'Exodiff'
input = 'internal_side_user_object_two_materials.i'
exodiff = 'internal_side_user_object_two_materials_out.e'
[../]
[]

0 comments on commit 0bc2af5

Please sign in to comment.