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

Material base class central for all Materials that provide a Function as a material property value. More...

#include <FunctionMaterialBase.h>

Inheritance diagram for FunctionMaterialBase:
[legend]

Public Member Functions

 FunctionMaterialBase (const InputParameters &parameters)
 

Protected Member Functions

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< 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...
 
bool _third_derivatives
 Calculate (and allocate memory for) the third derivatives of the free energy. More...
 
MaterialProperty< Real > * _prop_F
 Material property to store the function value. More...
 

Private Member Functions

unsigned int libMeshVarNumberRemap (unsigned int var) const
 map the variable numbers to an even/odd interspersed pattern More...
 

Private Attributes

std::vector< unsigned int > _arg_index
 Vector to look up the internal coupled variable index into arg* through the libMesh variable number. More...
 

Detailed Description

Material base class central for all Materials that provide a Function as a material property value.

Definition at line 23 of file FunctionMaterialBase.h.

Constructor & Destructor Documentation

FunctionMaterialBase::FunctionMaterialBase ( const InputParameters &  parameters)

Definition at line 22 of file FunctionMaterialBase.C.

23  : DerivativeMaterialInterface<Material>(parameters),
24  _F_name(getParam<std::string>("f_name")),
25  _prop_F(&declareProperty<Real>(_F_name))
26 {
27  // fetch names and numbers of all coupled variables
28  _mapping_is_unique = true;
29  for (std::set<std::string>::const_iterator it = _pars.coupledVarsBegin();
30  it != _pars.coupledVarsEnd();
31  ++it)
32  {
33  // find the variable in the list of coupled variables
34  std::map<std::string, std::vector<MooseVariable *>>::iterator vars = _coupled_vars.find(*it);
35 
36  // no MOOSE variable was provided for this coupling, add to a list of variables set to constant
37  // default values
38  if (vars == _coupled_vars.end())
39  {
40  if (_pars.hasDefaultCoupledValue(*it))
41  _arg_constant_defaults.push_back(*it);
42  continue;
43  }
44 
45  // check if we have a 1:1 mapping between parameters and variables
46  if (vars->second.size() != 1)
47  _mapping_is_unique = false;
48 
49  // iterate over all components
50  for (unsigned int j = 0; j < vars->second.size(); ++j)
51  {
52  // make sure each nonlinear variable is coupled in only once
53  if (std::find(_arg_names.begin(), _arg_names.end(), vars->second[j]->name()) !=
54  _arg_names.end())
55  mooseError("A nonlinear variable can only be coupled in once.");
56 
57  // insert the map values
58  // unsigned int number = vars->second[j]->number();
59  unsigned int number = coupled(*it, j);
60  _arg_names.push_back(vars->second[j]->name());
61  _arg_numbers.push_back(number);
62  _arg_param_names.push_back(*it);
63 
64  // populate number -> arg index lookup table
65  unsigned int idx = libMeshVarNumberRemap(number);
66  if (idx >= _arg_index.size())
67  _arg_index.resize(idx + 1, -1);
68 
69  _arg_index[idx] = _args.size();
70 
71  // get variable value
72  _args.push_back(&coupledValue(*it, j));
73  }
74  }
75 
76  _nargs = _arg_names.size();
77 }
std::vector< std::string > _arg_constant_defaults
coupled variables with default values
std::vector< std::string > _arg_param_names
String vector of the input file coupling parameter name for each argument.
std::vector< unsigned int > _arg_index
Vector to look up the internal coupled variable index into arg* through the libMesh variable number...
MaterialProperty< Real > * _prop_F
Material property to store the function value.
unsigned int _nargs
Number of coupled arguments.
unsigned int libMeshVarNumberRemap(unsigned int var) const
map the variable numbers to an even/odd interspersed pattern
std::string _F_name
Name of the function value material property and used as a base name to concatenate the material prop...
std::vector< const VariableValue * > _args
Coupled variables for function arguments.
std::vector< std::string > _arg_names
String vector of all argument names.
bool _mapping_is_unique
Flag that indicates if exactly one linear variable is coupled per input file coupling parameter...
std::vector< unsigned int > _arg_numbers
Vector of all argument MOOSE variable numbers.

Member Function Documentation

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

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::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.
unsigned int FunctionMaterialBase::libMeshVarNumberRemap ( unsigned int  var) const
inlineprivate

map the variable numbers to an even/odd interspersed pattern

Definition at line 86 of file FunctionMaterialBase.h.

Referenced by argIndex(), and FunctionMaterialBase().

87  {
88  const int b = static_cast<int>(var);
89  return b >= 0 ? b << 1 : (-b << 1) - 1;
90  }

Member Data Documentation

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

coupled variables with default values

Definition at line 76 of file FunctionMaterialBase.h.

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

std::vector<unsigned int> FunctionMaterialBase::_arg_index
private

Vector to look up the internal coupled variable index into arg* through the libMesh variable number.

Definition at line 93 of file FunctionMaterialBase.h.

Referenced by argIndex(), and FunctionMaterialBase().

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

Vector of all argument MOOSE variable numbers.

Definition at line 70 of file FunctionMaterialBase.h.

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

std::vector<std::string> FunctionMaterialBase::_arg_param_names
protected

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

Definition at line 73 of file FunctionMaterialBase.h.

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

std::vector<const VariableValue *> FunctionMaterialBase::_args
protected
std::string FunctionMaterialBase::_F_name
protected

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().

bool FunctionMaterialBase::_mapping_is_unique
protected

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(), and ParsedMaterialHelper::functionParse().

unsigned int FunctionMaterialBase::_nargs
protected
MaterialProperty<Real>* FunctionMaterialBase::_prop_F
protected
bool FunctionMaterialBase::_third_derivatives
protected

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

Definition at line 79 of file FunctionMaterialBase.h.


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