Skip to content

Commit

Permalink
Add IncrementMaterial test (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 2e24b45 commit cb35fc1
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 131 deletions.
1 change: 0 additions & 1 deletion framework/src/base/FEProblemBase.C
Expand Up @@ -2033,7 +2033,6 @@ FEProblemBase::prepareMaterials(SubdomainID blk_id, THREAD_ID 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) && this->hasActiveMaterialProperties(tid))
{
const Elem * & elem = _assembly[tid]->elem();
Expand Down
Expand Up @@ -11,27 +11,28 @@
/* */
/* See COPYRIGHT for full restrictions */
/****************************************************************/
#ifndef ERROR_MATERIAL_H
#define ERROR_MATERIAL_H
#ifndef INCREMENT_MATERIAL_H
#define INCREMENT_MATERIAL_H

#include "Material.h"
#include "GenericConstantMaterial.h"

class ErrorMaterial;
class IncrementMaterial;

template<>
InputParameters validParams<ErrorMaterial>();
InputParameters validParams<GenericConstantMaterial>();

/**
* ErrorMaterial throws a MooseException when certain conditions are
* met.
* GenericConstantMaterial that tracks the number of times computeQpProperties has been called.
*/
class ErrorMaterial : public Material
class IncrementMaterial : public GenericConstantMaterial
{
public:
ErrorMaterial(const InputParameters & parameters);
IncrementMaterial(const InputParameters & parameters);

protected:
virtual void computeQpProperties() override;
unsigned int _inc;
MaterialProperty<Real> & _mat_prop;
};

#endif
4 changes: 2 additions & 2 deletions test/src/base/MooseTestApp.C
Expand Up @@ -129,7 +129,7 @@
#include "DataStructIC.h"

// Materials
#include "ErrorMaterial.h"
#include "IncrementMaterial.h"
#include "MTMaterial.h"
#include "TypesMaterial.h"
#include "StatefulMaterial.h"
Expand Down Expand Up @@ -430,7 +430,7 @@ MooseTestApp::registerObjects(Factory & factory)

// Materials
registerMaterial(MTMaterial);
registerMaterial(ErrorMaterial);
registerMaterial(IncrementMaterial);
registerMaterial(TypesMaterial);
registerMaterial(StatefulMaterial);
registerMaterial(SpatialStatefulMaterial);
Expand Down
Expand Up @@ -11,23 +11,27 @@
/* */
/* See COPYRIGHT for full restrictions */
/****************************************************************/
#include "ErrorMaterial.h"
#include "IncrementMaterial.h"

template<>
InputParameters validParams<ErrorMaterial>()
InputParameters validParams<IncrementMaterial>()
{
InputParameters params = validParams<Material>();
params.addClassDescription("Material that throws an error if its computeQpProperties method gets called.");
InputParameters params = validParams<GenericConstantMaterial>();
params.addClassDescription("Material that tracks the number of times computeQpProperties has been called.");
return params;
}

ErrorMaterial::ErrorMaterial(const InputParameters & parameters) :
Material(parameters)
IncrementMaterial::IncrementMaterial(const InputParameters & parameters) :
GenericConstantMaterial(parameters),
_inc(0),
_mat_prop(declareProperty<Real>("mat_prop"))
{
}

void
ErrorMaterial::computeQpProperties()
IncrementMaterial::computeQpProperties()
{
mooseError("Why are you calling me when I don't provide any properties?");
GenericConstantMaterial::computeQpProperties();
_inc++;
_mat_prop[_qp] = _inc;
}
@@ -1,7 +1,8 @@
[Mesh]
type = GeneratedMesh
dim = 1
dim = 2
nx = 1
ny = 1
[]

[Variables]
Expand Down Expand Up @@ -49,10 +50,12 @@

[Materials]
[./call_me_mat]
type = GenericConstantMaterial
type = IncrementMaterial
prop_names = 'diff'
prop_values = '1'
block = 0
outputs = exodus
output_properties = 'mat_prop'
[../]
[]

Expand Down
Binary file not shown.
51 changes: 0 additions & 51 deletions test/tests/materials/material_dependency/one_mat_depend.i

This file was deleted.

7 changes: 7 additions & 0 deletions test/tests/materials/material_dependency/tests
@@ -0,0 +1,7 @@
[Tests]
[./dont_reinit_mat_for_aux]
type = 'Exodiff'
input = 'diff_kernel_aux_mat_dep.i'
exodiff = 'diff_kernel_aux_mat_dep_out.e'
[../]
[]
58 changes: 0 additions & 58 deletions test/tests/materials/material_dependency/two_mat_depend.i

This file was deleted.

0 comments on commit cb35fc1

Please sign in to comment.