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

Crystal plasticity state variable userobject class. More...

#include <CrystalPlasticityStateVariable.h>

Inheritance diagram for CrystalPlasticityStateVariable:
[legend]

Public Member Functions

 CrystalPlasticityStateVariable (const InputParameters &parameters)
 
virtual bool updateStateVariable (unsigned int qp, Real dt, std::vector< Real > &val) const
 
virtual void initSlipSysProps (std::vector< Real > &val, const Point &q_point) const
 
virtual unsigned int variableSize () const
 Returns the size of variable. More...
 

Protected Member Functions

virtual void readInitialValueFromFile (std::vector< Real > &val) const
 
virtual void readInitialValueFromInline (std::vector< Real > &val) const
 
virtual void provideInitialValueByUser (std::vector< Real > &, const Point &) const
 

Protected Attributes

unsigned int _num_mat_state_var_evol_rate_comps
 
std::vector< const MaterialProperty< std::vector< Real > > * > _mat_prop_state_var_evol_rate_comps
 
const MaterialProperty< std::vector< Real > > & _mat_prop_state_var
 
const MaterialProperty< std::vector< Real > > & _mat_prop_state_var_old
 
FileName _state_variable_file_name
 File should contain initial values of the state variable. More...
 
MooseEnum _intvar_read_type
 Read from options for initial values of internal variables. More...
 
std::vector< unsigned int > _groups
 The _groups variable is used to group slip systems and assign the initial values to each group. More...
 
std::vector< Real > _group_values
 The _group_values are the initial values corresponding to each group. More...
 
Real _zero
 Numerical zero for internal variable. More...
 
std::vector< Real > _scale_factor
 Scale factor of individual component. More...
 
unsigned int _variable_size
 

Detailed Description

Crystal plasticity state variable userobject class.

Definition at line 20 of file CrystalPlasticityStateVariable.h.

Constructor & Destructor Documentation

CrystalPlasticityStateVariable::CrystalPlasticityStateVariable ( const InputParameters &  parameters)

Definition at line 44 of file CrystalPlasticityStateVariable.C.

45  : CrystalPlasticityUOBase(parameters),
47  parameters.get<std::vector<std::string>>("uo_state_var_evol_rate_comp_name").size()),
48  _mat_prop_state_var(getMaterialProperty<std::vector<Real>>(_name)),
49  _mat_prop_state_var_old(getMaterialPropertyOld<std::vector<Real>>(_name)),
50  _state_variable_file_name(getParam<FileName>("state_variable_file_name")),
51  _intvar_read_type(getParam<MooseEnum>("intvar_read_type")),
52  _groups(getParam<std::vector<unsigned int>>("groups")),
53  _group_values(getParam<std::vector<Real>>("group_values")),
54  _zero(getParam<Real>("zero")),
55  _scale_factor(getParam<std::vector<Real>>("scale_factor"))
56 {
58  mooseError("CrystalPlasticityStateVariable: Scale factor should be have the same size of "
59  "evolution rate components.");
60 
62 
63  for (unsigned int i = 0; i < _num_mat_state_var_evol_rate_comps; ++i)
64  _mat_prop_state_var_evol_rate_comps[i] = &getMaterialProperty<std::vector<Real>>(
65  parameters.get<std::vector<std::string>>("uo_state_var_evol_rate_comp_name")[i]);
66 }
MooseEnum _intvar_read_type
Read from options for initial values of internal variables.
const MaterialProperty< std::vector< Real > > & _mat_prop_state_var_old
std::vector< unsigned int > _groups
The _groups variable is used to group slip systems and assign the initial values to each group...
const MaterialProperty< std::vector< Real > > & _mat_prop_state_var
CrystalPlasticityUOBase(const InputParameters &parameters)
std::vector< Real > _scale_factor
Scale factor of individual component.
std::vector< const MaterialProperty< std::vector< Real > > * > _mat_prop_state_var_evol_rate_comps
FileName _state_variable_file_name
File should contain initial values of the state variable.
std::vector< Real > _group_values
The _group_values are the initial values corresponding to each group.
Real _zero
Numerical zero for internal variable.

Member Function Documentation

void CrystalPlasticityStateVariable::initSlipSysProps ( std::vector< Real > &  val,
const Point &  q_point 
) const
virtual

Definition at line 69 of file CrystalPlasticityStateVariable.C.

71 {
72  switch (_intvar_read_type)
73  {
74  case 0:
76  break;
77  case 1:
79  break;
80  case 2:
81  provideInitialValueByUser(val, q_point);
82  break;
83  default:
84  mooseError("CrystalPlasticityStateVariable: Read option for initial value of internal "
85  "variables is not supported.");
86  }
87 
88  for (unsigned int i = 0; i < _variable_size; ++i)
89  if (val[i] <= 0.0)
90  mooseError("CrystalPlasticityStateVariable: Value of state variables ", i, " non positive");
91 }
MooseEnum _intvar_read_type
Read from options for initial values of internal variables.
virtual void provideInitialValueByUser(std::vector< Real > &, const Point &) const
virtual void readInitialValueFromInline(std::vector< Real > &val) const
virtual void readInitialValueFromFile(std::vector< Real > &val) const
void CrystalPlasticityStateVariable::provideInitialValueByUser ( std::vector< Real > &  ,
const Point &   
) const
protectedvirtual

Definition at line 138 of file CrystalPlasticityStateVariable.C.

Referenced by initSlipSysProps().

140 {
141  mooseError("Error CrystalPlasticityStateVariable: User has to overwrite "
142  "'provideInitialValueByUser' function"
143  "in order to provide specific initial values based on quadrature point location.");
144 }
void CrystalPlasticityStateVariable::readInitialValueFromFile ( std::vector< Real > &  val) const
protectedvirtual

Definition at line 94 of file CrystalPlasticityStateVariable.C.

Referenced by initSlipSysProps().

95 {
96  MooseUtils::checkFileReadable(_state_variable_file_name);
97 
98  std::ifstream file;
99  file.open(_state_variable_file_name.c_str());
100 
101  for (unsigned int i = 0; i < _variable_size; ++i)
102  if (!(file >> val[i]))
103  mooseError("Error CrystalPlasticityStateVariable: Premature end of state_variable file");
104 
105  file.close();
106 }
FileName _state_variable_file_name
File should contain initial values of the state variable.
void CrystalPlasticityStateVariable::readInitialValueFromInline ( std::vector< Real > &  val) const
protectedvirtual

Definition at line 109 of file CrystalPlasticityStateVariable.C.

Referenced by initSlipSysProps().

110 {
111  if (_groups.size() <= 0)
112  mooseError("CrystalPlasticityStateVariable: Error in reading initial state variable values: "
113  "Specify input in .i file or in state_variable file");
114  else if (_groups.size() != (_group_values.size() + 1))
115  mooseError(
116  "CrystalPlasticityStateVariable: The size of the groups and group_values does not match.");
117 
118  for (unsigned int i = 0; i < _groups.size() - 1; ++i)
119  {
120  unsigned int is, ie;
121 
122  is = _groups[i];
123  ie = _groups[i + 1] - 1;
124 
125  if (is > ie)
126  mooseError("CrystalPlasticityStateVariable: Start index is = ",
127  is,
128  " should be greater than end index ie = ",
129  ie,
130  " in state variable read");
131 
132  for (unsigned int j = is; j <= ie; ++j)
133  val[j] = _group_values[i];
134  }
135 }
std::vector< unsigned int > _groups
The _groups variable is used to group slip systems and assign the initial values to each group...
std::vector< Real > _group_values
The _group_values are the initial values corresponding to each group.
bool CrystalPlasticityStateVariable::updateStateVariable ( unsigned int  qp,
Real  dt,
std::vector< Real > &  val 
) const
virtual

Definition at line 147 of file CrystalPlasticityStateVariable.C.

150 {
151  for (unsigned int i = 0; i < _variable_size; ++i)
152  {
153  val[i] = 0.0;
154  for (unsigned int j = 0; j < _num_mat_state_var_evol_rate_comps; j++)
155  val[i] += (*_mat_prop_state_var_evol_rate_comps[j])[qp][i] * dt * _scale_factor[j];
156  }
157 
158  for (unsigned int i = 0; i < _variable_size; ++i)
159  {
160  if (_mat_prop_state_var_old[qp][i] < _zero && val[i] < 0.0)
161  val[i] = _mat_prop_state_var_old[qp][i];
162  else
163  val[i] = _mat_prop_state_var_old[qp][i] + val[i];
164 
165  if (val[i] < 0.0)
166  return false;
167  }
168  return true;
169 }
const MaterialProperty< std::vector< Real > > & _mat_prop_state_var_old
std::vector< Real > _scale_factor
Scale factor of individual component.
std::vector< const MaterialProperty< std::vector< Real > > * > _mat_prop_state_var_evol_rate_comps
Real _zero
Numerical zero for internal variable.
unsigned int CrystalPlasticityUOBase::variableSize ( ) const
virtualinherited

Returns the size of variable.

Definition at line 26 of file CrystalPlasticityUOBase.C.

27 {
28  return _variable_size;
29 }

Member Data Documentation

std::vector<Real> CrystalPlasticityStateVariable::_group_values
protected

The _group_values are the initial values corresponding to each group.

i.e. _groups = '0 4 8 11', and _group_values = '1.0 2.0 3.0' it means that initial values of slip system 0-3 is 1.0 , 4-7 is 2.0 and 8-11 is 3.0

Definition at line 60 of file CrystalPlasticityStateVariable.h.

Referenced by readInitialValueFromInline().

std::vector<unsigned int> CrystalPlasticityStateVariable::_groups
protected

The _groups variable is used to group slip systems and assign the initial values to each group.

The format is taken as [start end) i.e. _groups = '0 4 8 11', it means three groups 0-3, 4-7 and 8-11

Definition at line 54 of file CrystalPlasticityStateVariable.h.

Referenced by readInitialValueFromInline().

MooseEnum CrystalPlasticityStateVariable::_intvar_read_type
protected

Read from options for initial values of internal variables.

Definition at line 47 of file CrystalPlasticityStateVariable.h.

Referenced by initSlipSysProps().

const MaterialProperty<std::vector<Real> >& CrystalPlasticityStateVariable::_mat_prop_state_var
protected

Definition at line 40 of file CrystalPlasticityStateVariable.h.

std::vector<const MaterialProperty<std::vector<Real> > *> CrystalPlasticityStateVariable::_mat_prop_state_var_evol_rate_comps
protected
const MaterialProperty<std::vector<Real> >& CrystalPlasticityStateVariable::_mat_prop_state_var_old
protected

Definition at line 41 of file CrystalPlasticityStateVariable.h.

Referenced by updateStateVariable().

unsigned int CrystalPlasticityStateVariable::_num_mat_state_var_evol_rate_comps
protected
std::vector<Real> CrystalPlasticityStateVariable::_scale_factor
protected

Scale factor of individual component.

Definition at line 66 of file CrystalPlasticityStateVariable.h.

Referenced by CrystalPlasticityStateVariable(), and updateStateVariable().

FileName CrystalPlasticityStateVariable::_state_variable_file_name
protected

File should contain initial values of the state variable.

Definition at line 44 of file CrystalPlasticityStateVariable.h.

Referenced by readInitialValueFromFile().

unsigned int CrystalPlasticityUOBase::_variable_size
protectedinherited
Real CrystalPlasticityStateVariable::_zero
protected

Numerical zero for internal variable.

Definition at line 63 of file CrystalPlasticityStateVariable.h.

Referenced by updateStateVariable().


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