DerivativeSumMaterial Class Reference

#include <DerivativeSumMaterial.h>

Inheritance diagram for DerivativeSumMaterial:
[legend]

## Public Member Functions

DerivativeSumMaterial (const InputParameters &parameters)

virtual void initialSetup ()
Check if we got the right number of components in the 'args' coupled variable vector. More...

## Protected Member Functions

virtual void computeProperties ()

virtual Real computeF ()
Override this method to provide the free energy function. More...

virtual Real computeDF (unsigned int arg)
Override this method for calculating the first derivatives. More...

virtual Real computeD2F (unsigned int arg1, unsigned int arg2)
Override this method to calculate the second derivatives. More...

virtual Real computeD3F (unsigned int, unsigned int, unsigned int)
Override this method to calculate the third derivatives. More...

unsigned int argIndex (unsigned int i_var) const
FunctionMaterialBase keeps an internal list of all the variables the derivatives are taken w.r.t. More...

## Protected Attributes

std::vector< std::string > _sum_materials

unsigned int _num_materials

std::vector< Real > _prefactor
arguments to construct a sum of the form $$c+\gamma\sum_iF_i$$ More...

Real _constant

std::vector< const MaterialProperty< Real > * > _summand_F
Function values of the summands. More...

std::vector< std::vector< const MaterialProperty< Real > * > > _summand_dF
Derivatives of the summands with respect to arg[i]. More...

std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > _summand_d2F
Second derivatives of the summands. More...

std::vector< std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > > _summand_d3F
Third derivatives of the summands. More...

bool _third_derivatives
Calculate (and allocate memory for) the third derivatives of the free energy. More...

std::vector< MaterialProperty< Real > * > _prop_dF
Material properties to store the derivatives of f with respect to arg[i]. More...

std::vector< std::vector< MaterialProperty< Real > * > > _prop_d2F
Material properties to store the second derivatives. More...

std::vector< std::vector< std::vector< MaterialProperty< Real > * > > > _prop_d3F
Material properties to store the third derivatives. More...

std::vector< const VariableValue * > _args
Coupled variables for function arguments. More...

std::string _F_name
Name of the function value material property and used as a base name to concatenate the material property names for the derivatives. More...

bool _mapping_is_unique
Flag that indicates if exactly one linear variable is coupled per input file coupling parameter. More...

unsigned int _nargs
Number of coupled arguments. More...

std::vector< std::string > _arg_names
String vector of all argument names. More...

std::vector< unsigned int > _arg_numbers
Vector of all argument MOOSE variable numbers. More...

std::vector< std::string > _arg_param_names
String vector of the input file coupling parameter name for each argument. More...

std::vector< std::string > _arg_constant_defaults
coupled variables with default values More...

MaterialProperty< Real > * _prop_F
Material property to store the function value. More...

## Detailed Description

Definition at line 17 of file DerivativeSumMaterial.h.

## Constructor & Destructor Documentation

 DerivativeSumMaterial::DerivativeSumMaterial ( const InputParameters & parameters )

Definition at line 40 of file DerivativeSumMaterial.C.

41  : DerivativeFunctionMaterialBase(parameters),
42  _sum_materials(getParam<std::vector<std::string>>("sum_materials")),
45  _constant(getParam<Real>("constant"))
46 {
47  // we need at least one material in the sum
48  if (_num_materials == 0)
49  mooseError("Please supply at least one material to sum in DerivativeSumMaterial ", name());
50
51  // get prefactor values if not 1.0
52  std::vector<Real> p = getParam<std::vector<Real>>("prefactor");
53
54  // if prefactor is used we need the same number of prefactors as sum materials
55  if (_num_materials == p.size())
56  _prefactor = p;
57  else if (p.size() != 0)
58  mooseError("Supply the same nummber of sum materials and prefactors.");
59
60  // reserve space for summand material properties
61  _summand_F.resize(_num_materials);
65
66  for (unsigned int n = 0; n < _num_materials; ++n)
67  {
68  _summand_F[n] = &getMaterialProperty<Real>(_sum_materials[n]);
69  _summand_dF[n].resize(_nargs);
70  _summand_d2F[n].resize(_nargs);
71  _summand_d3F[n].resize(_nargs);
72
73  for (unsigned int i = 0; i < _nargs; ++i)
74  {
75  _summand_dF[n][i] = &getMaterialPropertyDerivative<Real>(_sum_materials[n], _arg_names[i]);
76  _summand_d2F[n][i].resize(_nargs);
77
79  _summand_d3F[n][i].resize(_nargs);
80
81  for (unsigned int j = 0; j < _nargs; ++j)
82  {
83  _summand_d2F[n][i][j] =
84  &getMaterialPropertyDerivative<Real>(_sum_materials[n], _arg_names[i], _arg_names[j]);
85
87  {
88  _summand_d3F[n][i][j].resize(_nargs);
89
90  for (unsigned int k = 0; k < _nargs; ++k)
91  _summand_d3F[n][i][j][k] = &getMaterialPropertyDerivative<Real>(
92  _sum_materials[n], _arg_names[i], _arg_names[j], _arg_names[k]);
93  }
94  }
95  }
96  }
97 }
DerivativeFunctionMaterialBase(const InputParameters &parameters)
std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > _summand_d2F
Second derivatives of the summands.
std::vector< std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > > _summand_d3F
Third derivatives of the summands.
bool _third_derivatives
Calculate (and allocate memory for) the third derivatives of the free energy.
std::vector< Real > _prefactor
arguments to construct a sum of the form
unsigned int _nargs
Number of coupled arguments.
std::vector< std::vector< const MaterialProperty< Real > * > > _summand_dF
Derivatives of the summands with respect to arg[i].
std::vector< std::string > _sum_materials
std::vector< std::string > _arg_names
String vector of all argument names.
std::vector< const MaterialProperty< Real > * > _summand_F
Function values of the summands.

## Member Function Documentation

 unsigned int FunctionMaterialBase::argIndex ( unsigned int i_var ) const
inlineprotectedinherited

FunctionMaterialBase keeps an internal list of all the variables the derivatives are taken w.r.t.

We provide the MOOSE variable bames in _arg_names, the libMesh variable numbers in _arg_numbers, and the input file parameter names in _arg_param_names. All are indexed by the argument index. This method returns the argument index for a given the libMesh variable number.

This mapping is necessary for internal classes which maintain lists of derivatives indexed by argument index and need to pull from those lists from the computeDF, computeD2F, and computeD3F methods, which receive libMesh variable numbers as parameters.

Definition at line 43 of file FunctionMaterialBase.h.

44  {
45  const unsigned int idx = libMeshVarNumberRemap(i_var);
46  mooseAssert(idx < _arg_index.size() && _arg_numbers[_arg_index[idx]] == i_var,
47  "Requesting argIndex() for a derivative w.r.t. a variable not coupled to.");
48  return _arg_index[idx];
49  }
std::vector< unsigned int > _arg_index
Vector to look up the internal coupled variable index into arg* through the libMesh variable number...
unsigned int libMeshVarNumberRemap(unsigned int var) const
map the variable numbers to an even/odd interspersed pattern
std::vector< unsigned int > _arg_numbers
Vector of all argument MOOSE variable numbers.
 virtual Real DerivativeFunctionMaterialBase::computeD2F ( unsigned int arg1, unsigned int arg2 )
inlineprotectedvirtualinherited

Override this method to calculate the second derivatives.

$$\frac{d^2F}{dc_{arg1} dc_{arg2}}$$

Parameters
 arg1 The variable the first derivative is taken of arg2 The variable the second derivative is taken of

Definition at line 82 of file DerivativeFunctionMaterialBase.h.

Referenced by DerivativeFunctionMaterialBase::computeProperties().

83  {
84  libmesh_ignore(arg1);
85  libmesh_ignore(arg2);
86  return 0.0;
87  }
 virtual Real DerivativeFunctionMaterialBase::computeD3F ( unsigned int , unsigned int , unsigned int )
inlineprotectedvirtualinherited

Override this method to calculate the third derivatives.

Note
The implementation of this method is optional. It is only evaluated when the 'third_derivatives' parameter is set to true.

Reimplemented in DerivativeTwoPhaseMaterial, MathFreeEnergy, and DerivativeMultiPhaseMaterial.

Definition at line 95 of file DerivativeFunctionMaterialBase.h.

Referenced by DerivativeFunctionMaterialBase::computeProperties().

95 { return 0.0; }
 virtual Real DerivativeFunctionMaterialBase::computeDF ( unsigned int arg )
inlineprotectedvirtualinherited

Override this method for calculating the first derivatives.

The parameter is the libMesh variable number of the coupled variable. These numbers can be obtained using the coupled() method for each coupled variable.

Parameters
 arg The index of the function argument the derivative is taken of

Definition at line 68 of file DerivativeFunctionMaterialBase.h.

Referenced by DerivativeFunctionMaterialBase::computeProperties().

69  {
70  libmesh_ignore(arg);
71  return 0.0;
72  }
 virtual Real DerivativeFunctionMaterialBase::computeF ( )
inlineprotectedvirtualinherited

Override this method to provide the free energy function.

Definition at line 59 of file DerivativeFunctionMaterialBase.h.

Referenced by DerivativeFunctionMaterialBase::computeProperties().

59 { return 0.0; }
 void DerivativeSumMaterial::computeProperties ( )
protectedvirtual

Reimplemented from DerivativeFunctionMaterialBase.

Definition at line 107 of file DerivativeSumMaterial.C.

108 {
109  unsigned int i, j, k;
110
111  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
112  {
113  // set function value
114  if (_prop_F)
115  {
116  (*_prop_F)[_qp] = (*_summand_F[0])[_qp] * _prefactor[0];
117  for (unsigned int n = 1; n < _num_materials; ++n)
118  (*_prop_F)[_qp] += (*_summand_F[n])[_qp] * _prefactor[n];
119  }
120
121  for (i = 0; i < _nargs; ++i)
122  {
123  // set first derivatives
124  if (_prop_dF[i])
125  {
126  (*_prop_dF[i])[_qp] = (*_summand_dF[0][i])[_qp] * _prefactor[0];
127  for (unsigned int n = 1; n < _num_materials; ++n)
128  (*_prop_dF[i])[_qp] += (*_summand_dF[n][i])[_qp] * _prefactor[n];
129  }
130
131  // second derivatives
132  for (j = i; j < _nargs; ++j)
133  {
134  if (_prop_d2F[i][j])
135  {
136  (*_prop_d2F[i][j])[_qp] = (*_summand_d2F[0][i][j])[_qp] * _prefactor[0];
137  for (unsigned int n = 1; n < _num_materials; ++n)
138  (*_prop_d2F[i][j])[_qp] += (*_summand_d2F[n][i][j])[_qp] * _prefactor[n];
139  }
140
141  // third derivatives
142  if (_third_derivatives)
143  {
144  for (k = j; k < _nargs; ++k)
145  if (_prop_d3F[i][j][k])
146  {
147  (*_prop_d3F[i][j][k])[_qp] = (*_summand_d3F[0][i][j][k])[_qp] * _prefactor[0];
148  for (unsigned int n = 1; n < _num_materials; ++n)
149  (*_prop_d3F[i][j][k])[_qp] += (*_summand_d3F[n][i][j][k])[_qp] * _prefactor[n];
150  }
151  }
152  }
153  }
154  }
155 }
std::vector< std::vector< MaterialProperty< Real > * > > _prop_d2F
Material properties to store the second derivatives.
std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > _summand_d2F
Second derivatives of the summands.
std::vector< std::vector< std::vector< MaterialProperty< Real > * > > > _prop_d3F
Material properties to store the third derivatives.
std::vector< std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > > _summand_d3F
Third derivatives of the summands.
MaterialProperty< Real > * _prop_F
Material property to store the function value.
bool _third_derivatives
Calculate (and allocate memory for) the third derivatives of the free energy.
std::vector< Real > _prefactor
arguments to construct a sum of the form
unsigned int _nargs
Number of coupled arguments.
std::vector< MaterialProperty< Real > * > _prop_dF
Material properties to store the derivatives of f with respect to arg[i].
std::vector< std::vector< const MaterialProperty< Real > * > > _summand_dF
Derivatives of the summands with respect to arg[i].
std::vector< const MaterialProperty< Real > * > _summand_F
Function values of the summands.
 void DerivativeSumMaterial::initialSetup ( )
virtual

Check if we got the right number of components in the 'args' coupled variable vector.

Reimplemented from DerivativeFunctionMaterialBase.

Definition at line 100 of file DerivativeSumMaterial.C.

101 {
102  for (unsigned int n = 0; n < _num_materials; ++n)
103  validateCoupling<Real>(_sum_materials[n]);
104 }
std::vector< std::string > _sum_materials

## Member Data Documentation

 std::vector FunctionMaterialBase::_arg_constant_defaults
protectedinherited

coupled variables with default values

Definition at line 76 of file FunctionMaterialBase.h.

 std::vector FunctionMaterialBase::_arg_names
protectedinherited
 std::vector FunctionMaterialBase::_arg_numbers
protectedinherited

Vector of all argument MOOSE variable numbers.

Definition at line 70 of file FunctionMaterialBase.h.

 std::vector FunctionMaterialBase::_arg_param_names
protectedinherited

String vector of the input file coupling parameter name for each argument.

Definition at line 73 of file FunctionMaterialBase.h.

 std::vector FunctionMaterialBase::_args
protectedinherited

Coupled variables for function arguments.

Definition at line 52 of file FunctionMaterialBase.h.

 Real DerivativeSumMaterial::_constant
protected

Definition at line 32 of file DerivativeSumMaterial.h.

 std::string FunctionMaterialBase::_F_name
protectedinherited

Name of the function value material property and used as a base name to concatenate the material property names for the derivatives.

Definition at line 58 of file FunctionMaterialBase.h.

 bool FunctionMaterialBase::_mapping_is_unique
protectedinherited

Flag that indicates if exactly one linear variable is coupled per input file coupling parameter.

Definition at line 61 of file FunctionMaterialBase.h.

 unsigned int FunctionMaterialBase::_nargs
protectedinherited
 unsigned int DerivativeSumMaterial::_num_materials
protected

Definition at line 28 of file DerivativeSumMaterial.h.

Referenced by computeProperties(), DerivativeSumMaterial(), and initialSetup().

 std::vector DerivativeSumMaterial::_prefactor
protected

arguments to construct a sum of the form $$c+\gamma\sum_iF_i$$

Definition at line 31 of file DerivativeSumMaterial.h.

Referenced by computeProperties(), and DerivativeSumMaterial().

 std::vector *> > DerivativeFunctionMaterialBase::_prop_d2F
protectedinherited

Material properties to store the second derivatives.

Definition at line 104 of file DerivativeFunctionMaterialBase.h.

 std::vector *> > > DerivativeFunctionMaterialBase::_prop_d3F
protectedinherited

Material properties to store the third derivatives.

Definition at line 107 of file DerivativeFunctionMaterialBase.h.

 std::vector *> DerivativeFunctionMaterialBase::_prop_dF
protectedinherited

Material properties to store the derivatives of f with respect to arg[i].

Definition at line 101 of file DerivativeFunctionMaterialBase.h.

 MaterialProperty* FunctionMaterialBase::_prop_F
protectedinherited

Material property to store the function value.

Definition at line 82 of file FunctionMaterialBase.h.

 std::vector DerivativeSumMaterial::_sum_materials
protected

Definition at line 27 of file DerivativeSumMaterial.h.

Referenced by DerivativeSumMaterial(), and initialSetup().

 std::vector *> > > DerivativeSumMaterial::_summand_d2F
protected

Second derivatives of the summands.

Definition at line 41 of file DerivativeSumMaterial.h.

Referenced by computeProperties(), and DerivativeSumMaterial().

 std::vector *> > > > DerivativeSumMaterial::_summand_d3F
protected

Third derivatives of the summands.

Definition at line 44 of file DerivativeSumMaterial.h.

Referenced by computeProperties(), and DerivativeSumMaterial().

 std::vector *> > DerivativeSumMaterial::_summand_dF
protected

Derivatives of the summands with respect to arg[i].

Definition at line 38 of file DerivativeSumMaterial.h.

Referenced by computeProperties(), and DerivativeSumMaterial().

 std::vector *> DerivativeSumMaterial::_summand_F
protected

Function values of the summands.

Definition at line 35 of file DerivativeSumMaterial.h.

Referenced by computeProperties(), and DerivativeSumMaterial().

 bool DerivativeFunctionMaterialBase::_third_derivatives
protectedinherited

Calculate (and allocate memory for) the third derivatives of the free energy.

Definition at line 98 of file DerivativeFunctionMaterialBase.h.

The documentation for this class was generated from the following files: