Skip to content

Commit

Permalink
Add test and test object for coupledVectorDotDotDu
Browse files Browse the repository at this point in the history
  • Loading branch information
cticenhour committed Aug 28, 2019
1 parent 2aaa4c6 commit d108c6f
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 1 deletion.
43 changes: 43 additions & 0 deletions test/include/materials/VectorCoupledValuesMaterial.h
@@ -0,0 +1,43 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#pragma once

#include "Material.h"

class VectorCoupledValuesMaterial;

template <>
InputParameters validParams<VectorCoupledValuesMaterial>();

/**
* A material that couples vector variable values and stores them into material properties
* This makes sure that everything is properly resized and can be indexed into.
*/
class VectorCoupledValuesMaterial : public Material
{
public:
VectorCoupledValuesMaterial(const InputParameters & parameters);

protected:
virtual void computeQpProperties() override;

const VectorVariableValue & _value;
const VectorVariableValue & _dot;
const VectorVariableValue & _dot_dot;
const VariableValue & _dot_du;
const VariableValue & _dot_dot_du;

const std::string & _var_name;
MaterialProperty<RealVectorValue> & _value_prop;
MaterialProperty<RealVectorValue> & _dot_prop;
MaterialProperty<RealVectorValue> & _dot_dot_prop;
MaterialProperty<Real> & _dot_du_prop;
MaterialProperty<Real> & _dot_dot_du_prop;
};
48 changes: 48 additions & 0 deletions test/src/materials/VectorCoupledValuesMaterial.C
@@ -0,0 +1,48 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#include "VectorCoupledValuesMaterial.h"

registerMooseObject("MooseTestApp", VectorCoupledValuesMaterial);

template <>
InputParameters
validParams<VectorCoupledValuesMaterial>()
{
InputParameters params = validParams<Material>();
params.addRequiredCoupledVar("variable", "Coupled variable");
return params;
}

VectorCoupledValuesMaterial::VectorCoupledValuesMaterial(const InputParameters & parameters)
: Material(parameters),
_value(coupledVectorValue("variable")),
_dot(coupledVectorDot("variable")),
_dot_dot(coupledVectorDotDot("variable")),
_dot_du(coupledVectorDotDu("variable")),
_dot_dot_du(coupledVectorDotDotDu("variable")),

_var_name(getVectorVar("variable", 0)->name()),
_value_prop(declareProperty<RealVectorValue>(_var_name + "_value")),
_dot_prop(declareProperty<RealVectorValue>(_var_name + "_dot")),
_dot_dot_prop(declareProperty<RealVectorValue>(_var_name + "_dot_dot")),
_dot_du_prop(declareProperty<Real>(_var_name + "_dot_du")),
_dot_dot_du_prop(declareProperty<Real>(_var_name + "_dot_dot_du"))
{
}

void
VectorCoupledValuesMaterial::computeQpProperties()
{
_value_prop[_qp] = _value[_qp];
_dot_prop[_qp] = _dot[_qp];
_dot_dot_prop[_qp] = _dot_dot[_qp];
_dot_du_prop[_qp] = _dot_du[_qp];
_dot_dot_du_prop[_qp] = _dot_dot_du[_qp];
}
10 changes: 9 additions & 1 deletion test/tests/variables/time_derivatives_neighbor/tests
@@ -1,10 +1,18 @@
[Tests]
[./test]
[./const_monomial_neighbor_time_derivatives]
type = 'Exodiff'
input = 'test.i'
exodiff = 'test_out.e'
requirement = 'The system shall compute time derivatives on a neighbor element for constant monomials'
design = 'MooseVariableConstMonomial.md'
issues = '#9836 #12185'
[../]
[./vector_neighbor_time_derivatives]
type = 'Exodiff'
input = 'vector_test.i'
exodiff = 'vector_test_out.e'
requirement = 'The system shall compute time derivatives on a neighbor element for vector variables'
design = `VectorMooseVariable.md`
issues = '#13913'
[../]
[]
83 changes: 83 additions & 0 deletions test/tests/variables/time_derivatives_neighbor/vector_test.i
@@ -0,0 +1,83 @@
# Tests calculation of first and second time derivative
# of a coupled vector variable in a material
# a_vec(x,y,z,t) = [t*(t*x + y), t*y, 0]
# a_vec_dot(x,y,z,t) = [2*t*x + y, y, 0]
# a_vec_dot_dot(x,y,z,t) = [2*x, 0, 0]

[Mesh]
type = GeneratedMesh
dim = 2
xmin = 0
xmax = 4
ymin = 0
ymax = 4
nx = 8
ny = 8
[]

[Functions]
[a_fn]
type = ParsedVectorFunction
value_x = 't*(t*x + y)'
value_y = 't*y'
value_z = 0
[]
[]

[AuxVariables]
[a]
family = LAGRANGE_VEC
order = FIRST
[]
[]

[AuxKernels]
[a_ak]
type = VectorFunctionAux
variable = a
function = a_fn
[]
[]

[Materials]
[cm]
type = VectorCoupledValuesMaterial
variable = a
[]
[]

[Variables]
[u]
family = LAGRANGE_VEC
order = FIRST
[]
[]

[Kernels]
[td]
type = VectorTimeDerivative
variable = u
[]
[]

[Executioner]
type = Transient
dt = 0.1
num_steps = 3

[TimeIntegrator]
type = NewmarkBeta
[]
[Quadrature]
type = GAUSS
order = FIRST
[]
[]

[Outputs]
[./out]
type = Exodus
output_material_properties = true
show_material_properties = 'a_value a_dot a_dot_dot a_dot_du a_dot_dot_du'
[../]
[]

0 comments on commit d108c6f

Please sign in to comment.