www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DiscreteNucleation Class Reference

Free energy penalty contribution to force the nucleation of subresolution particles. More...

#include <DiscreteNucleation.h>

Inheritance diagram for DiscreteNucleation:
[legend]

Public Member Functions

 DiscreteNucleation (const InputParameters &params)
 
virtual void computeProperties ()
 

Protected Member Functions

virtual void initialSetup ()
 Check if we got the right number of components in the 'args' coupled variable vector. More...
 
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

unsigned int _nvar
 
std::vector< unsigned int > _op_index
 map op_names indices to _args indices More...
 
const std::vector< Real > _op_values
 Target concentration values. More...
 
const Real _penalty
 Nucleation free energy prefactor. More...
 
const unsigned int _penalty_mode
 Match concentration exactly or use the target as a minumum or maximum value. More...
 
const DiscreteNucleationMap_map
 UserObject providing a map of currently active nuclei. 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

Free energy penalty contribution to force the nucleation of subresolution particles.

Definition at line 22 of file DiscreteNucleation.h.

Constructor & Destructor Documentation

DiscreteNucleation::DiscreteNucleation ( const InputParameters &  params)

Definition at line 32 of file DiscreteNucleation.C.

34  _nvar(coupledComponents("op_names")),
36  _op_values(getParam<std::vector<Real>>("op_values")),
37  _penalty(getParam<Real>("penalty")),
38  _penalty_mode(getParam<MooseEnum>("penalty_mode")),
39  _map(getUserObject<DiscreteNucleationMap>("map"))
40 {
41  // check inputs
42  if (_nvar != _op_values.size())
43  mooseError("The op_names and op_values parameter vectors must have the same number of entries");
44  if (_nvar != _args.size())
45  mooseError("Internal error.");
46 
47  // get libMesh variable numbers
48  for (unsigned int i = 0; i < _nvar; ++i)
49  _op_index[i] = argIndex(coupled("op_names", i));
50 }
DerivativeFunctionMaterialBase(const InputParameters &parameters)
const unsigned int _penalty_mode
Match concentration exactly or use the target as a minumum or maximum value.
const Real _penalty
Nucleation free energy prefactor.
std::vector< const VariableValue * > _args
Coupled variables for function arguments.
const DiscreteNucleationMap & _map
UserObject providing a map of currently active nuclei.
std::vector< unsigned int > _op_index
map op_names indices to _args indices
const std::vector< Real > _op_values
Target concentration values.
unsigned int argIndex(unsigned int i_var) const
FunctionMaterialBase keeps an internal list of all the variables the derivatives are taken w...

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.

Referenced by DerivativeMultiPhaseMaterial::computeD2F(), ElasticEnergyMaterial::computeD2F(), DerivativeTwoPhaseMaterial::computeD2F(), DerivativeMultiPhaseMaterial::computeD3F(), DerivativeTwoPhaseMaterial::computeD3F(), DerivativeMultiPhaseMaterial::computeDF(), ElasticEnergyMaterial::computeDF(), DerivativeTwoPhaseMaterial::computeDF(), DerivativeMultiPhaseBase::DerivativeMultiPhaseBase(), and DiscreteNucleation().

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
arg1The variable the first derivative is taken of
arg2The variable the second derivative is taken of

Reimplemented in DerivativeTwoPhaseMaterial, ElasticEnergyMaterial, MathFreeEnergy, DerivativeMultiPhaseMaterial, and KKSXeVacSolidMaterial.

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
argThe index of the function argument the derivative is taken of

Reimplemented in DerivativeTwoPhaseMaterial, ElasticEnergyMaterial, MathFreeEnergy, DerivativeMultiPhaseMaterial, and KKSXeVacSolidMaterial.

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.

Reimplemented in DerivativeMultiPhaseBase, DerivativeTwoPhaseMaterial, ElasticEnergyMaterial, MathFreeEnergy, and KKSXeVacSolidMaterial.

Definition at line 59 of file DerivativeFunctionMaterialBase.h.

Referenced by DerivativeFunctionMaterialBase::computeProperties().

59 { return 0.0; }
void DiscreteNucleation::computeProperties ( )
virtual

Reimplemented from DerivativeFunctionMaterialBase.

Definition at line 53 of file DiscreteNucleation.C.

54 {
55  // check if a nucleation event list is available for the current element
56  const std::vector<Real> & nucleus = _map.nuclei(_current_elem);
57 
58  // calculate penalty
59  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
60  {
61  // clear penalty value
62  if (_prop_F)
63  (*_prop_F)[_qp] = 0.0;
64 
65  for (unsigned int i = 0; i < _nvar; ++i)
66  {
67  const unsigned ii = _op_index[i];
68 
69  // modify the penalty magnitude with the nucleus mask
70  const Real penalty = _penalty * nucleus[_qp];
71 
72  // deviation from the target concentration
73  Real dc = (*_args[ii])[_qp] - _op_values[i];
74 
75  // ignore above/below target values for min/max modes respectively
76  if ((_penalty_mode == 1 && dc > 0.0) || (_penalty_mode == 2 && dc < 0.0))
77  dc = 0.0;
78 
79  // build free energy correction
80  if (_prop_F)
81  (*_prop_F)[_qp] += dc * dc * penalty;
82 
83  // first derivative
84  if (_prop_dF[ii])
85  (*_prop_dF[ii])[_qp] = 2.0 * dc * penalty;
86 
87  // second derivatives
88  for (unsigned int jj = ii; jj < _nvar; ++jj)
89  {
90  if (_prop_d2F[ii][jj])
91  (*_prop_d2F[ii][jj])[_qp] = 2.0 * penalty;
92 
93  // third derivatives
95  for (unsigned int kk = jj; kk < _nvar; ++kk)
96  if (_prop_d3F[ii][jj][kk])
97  (*_prop_d3F[ii][jj][kk])[_qp] = 0.0;
98  }
99  }
100  }
101 }
std::vector< std::vector< MaterialProperty< Real > * > > _prop_d2F
Material properties to store the second derivatives.
std::vector< std::vector< std::vector< MaterialProperty< Real > * > > > _prop_d3F
Material properties to store the third derivatives.
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.
const unsigned int _penalty_mode
Match concentration exactly or use the target as a minumum or maximum value.
const Real _penalty
Nucleation free energy prefactor.
std::vector< MaterialProperty< Real > * > _prop_dF
Material properties to store the derivatives of f with respect to arg[i].
std::vector< const VariableValue * > _args
Coupled variables for function arguments.
const DiscreteNucleationMap & _map
UserObject providing a map of currently active nuclei.
std::vector< unsigned int > _op_index
map op_names indices to _args indices
const std::vector< Real > & nuclei(const Elem *) const
const std::vector< Real > _op_values
Target concentration values.
void DerivativeFunctionMaterialBase::initialSetup ( )
protectedvirtualinherited

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

Reimplemented in DerivativeMultiPhaseBase, DerivativeTwoPhaseMaterial, ElasticEnergyMaterial, and DerivativeSumMaterial.

Definition at line 81 of file DerivativeFunctionMaterialBase.C.

82 {
83  // set the _prop_* pointers of all material properties that are not beeing used back to NULL
84  bool needs_third_derivatives = false;
85 
86  if (!_fe_problem.isMatPropRequested(_F_name))
87  _prop_F = NULL;
88 
89  for (unsigned int i = 0; i < _nargs; ++i)
90  {
91  if (!_fe_problem.isMatPropRequested(propertyNameFirst(_F_name, _arg_names[i])))
92  _prop_dF[i] = NULL;
93 
94  // second derivatives
95  for (unsigned int j = i; j < _nargs; ++j)
96  {
97  if (!_fe_problem.isMatPropRequested(
98  propertyNameSecond(_F_name, _arg_names[i], _arg_names[j])))
99  _prop_d2F[i][j] = _prop_d2F[j][i] = NULL;
100 
101  // third derivatives
102  if (_third_derivatives)
103  {
104  for (unsigned int k = j; k < _nargs; ++k)
105  {
106  if (!_fe_problem.isMatPropRequested(
107  propertyNameThird(_F_name, _arg_names[i], _arg_names[j], _arg_names[k])))
108  _prop_d3F[i][j][k] = _prop_d3F[k][i][j] = _prop_d3F[j][k][i] = _prop_d3F[k][j][i] =
109  _prop_d3F[j][i][k] = _prop_d3F[i][k][j] = NULL;
110  else
111  needs_third_derivatives = true;
112  }
113 
114  if (!needs_third_derivatives)
115  mooseWarning("This simulation does not actually need the third derivatives of "
116  "DerivativeFunctionMaterialBase " +
117  name());
118  }
119  }
120  }
121 }
std::vector< std::vector< MaterialProperty< Real > * > > _prop_d2F
Material properties to store the second derivatives.
std::vector< std::vector< std::vector< MaterialProperty< Real > * > > > _prop_d3F
Material properties to store the third derivatives.
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.
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::string _F_name
Name of the function value material property and used as a base name to concatenate the material prop...
std::vector< std::string > _arg_names
String vector of all argument names.

Member Data Documentation

std::vector<std::string> FunctionMaterialBase::_arg_constant_defaults
protectedinherited

coupled variables with default values

Definition at line 76 of file FunctionMaterialBase.h.

Referenced by FunctionMaterialBase::FunctionMaterialBase(), and ParsedMaterialHelper::functionParse().

std::vector<std::string> FunctionMaterialBase::_arg_names
protectedinherited
std::vector<unsigned int> FunctionMaterialBase::_arg_numbers
protectedinherited

Vector of all argument MOOSE variable numbers.

Definition at line 70 of file FunctionMaterialBase.h.

Referenced by FunctionMaterialBase::argIndex(), DerivativeFunctionMaterialBase::computeProperties(), and FunctionMaterialBase::FunctionMaterialBase().

std::vector<std::string> 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.

Referenced by FunctionMaterialBase::FunctionMaterialBase(), and ParsedMaterialHelper::functionParse().

std::vector<const VariableValue *> FunctionMaterialBase::_args
protectedinherited
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.

Referenced by DerivativeParsedMaterialHelper::assembleDerivatives(), DerivativeFunctionMaterialBase::DerivativeFunctionMaterialBase(), and DerivativeFunctionMaterialBase::initialSetup().

const DiscreteNucleationMap& DiscreteNucleation::_map
protected

UserObject providing a map of currently active nuclei.

Definition at line 45 of file DiscreteNucleation.h.

Referenced by computeProperties().

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.

Referenced by FunctionMaterialBase::FunctionMaterialBase(), and ParsedMaterialHelper::functionParse().

unsigned int FunctionMaterialBase::_nargs
protectedinherited
unsigned int DiscreteNucleation::_nvar
protected

Definition at line 30 of file DiscreteNucleation.h.

Referenced by computeProperties(), and DiscreteNucleation().

std::vector<unsigned int> DiscreteNucleation::_op_index
protected

map op_names indices to _args indices

Definition at line 33 of file DiscreteNucleation.h.

Referenced by computeProperties(), and DiscreteNucleation().

const std::vector<Real> DiscreteNucleation::_op_values
protected

Target concentration values.

Definition at line 36 of file DiscreteNucleation.h.

Referenced by computeProperties(), and DiscreteNucleation().

const Real DiscreteNucleation::_penalty
protected

Nucleation free energy prefactor.

Definition at line 39 of file DiscreteNucleation.h.

Referenced by computeProperties().

const unsigned int DiscreteNucleation::_penalty_mode
protected

Match concentration exactly or use the target as a minumum or maximum value.

Definition at line 42 of file DiscreteNucleation.h.

Referenced by computeProperties().

std::vector<std::vector<MaterialProperty<Real> *> > DerivativeFunctionMaterialBase::_prop_d2F
protectedinherited
std::vector<std::vector<std::vector<MaterialProperty<Real> *> > > DerivativeFunctionMaterialBase::_prop_d3F
protectedinherited
std::vector<MaterialProperty<Real> *> DerivativeFunctionMaterialBase::_prop_dF
protectedinherited
MaterialProperty<Real>* FunctionMaterialBase::_prop_F
protectedinherited
bool DerivativeFunctionMaterialBase::_third_derivatives
protectedinherited

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