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, std::vector< Real > &val_old) 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
 
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 23 of file CrystalPlasticityStateVariable.h.

Constructor & Destructor Documentation

◆ CrystalPlasticityStateVariable()

CrystalPlasticityStateVariable::CrystalPlasticityStateVariable ( const InputParameters &  parameters)

Definition at line 49 of file CrystalPlasticityStateVariable.C.

50  : CrystalPlasticityUOBase(parameters),
52  parameters.get<std::vector<std::string>>("uo_state_var_evol_rate_comp_name").size()),
53  _mat_prop_state_var(getMaterialProperty<std::vector<Real>>(_name)),
54  _state_variable_file_name(getParam<FileName>("state_variable_file_name")),
55  _intvar_read_type(getParam<MooseEnum>("intvar_read_type")),
56  _groups(getParam<std::vector<unsigned int>>("groups")),
57  _group_values(getParam<std::vector<Real>>("group_values")),
58  _zero(getParam<Real>("zero")),
59  _scale_factor(getParam<std::vector<Real>>("scale_factor"))
60 {
62  mooseError("CrystalPlasticityStateVariable: Scale factor should be have the same size of "
63  "evolution rate components.");
64 
66 
67  for (unsigned int i = 0; i < _num_mat_state_var_evol_rate_comps; ++i)
68  _mat_prop_state_var_evol_rate_comps[i] = &getMaterialProperty<std::vector<Real>>(
69  parameters.get<std::vector<std::string>>("uo_state_var_evol_rate_comp_name")[i]);
70 }
MooseEnum _intvar_read_type
Read from options for initial values of internal variables.
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

◆ initSlipSysProps()

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

Definition at line 73 of file CrystalPlasticityStateVariable.C.

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

◆ provideInitialValueByUser()

void CrystalPlasticityStateVariable::provideInitialValueByUser ( std::vector< Real > &  ,
const Point &   
) const
protectedvirtual

Definition at line 142 of file CrystalPlasticityStateVariable.C.

Referenced by initSlipSysProps().

144 {
145  mooseError("Error CrystalPlasticityStateVariable: User has to overwrite "
146  "'provideInitialValueByUser' function"
147  "in order to provide specific initial values based on quadrature point location.");
148 }

◆ readInitialValueFromFile()

void CrystalPlasticityStateVariable::readInitialValueFromFile ( std::vector< Real > &  val) const
protectedvirtual

Definition at line 98 of file CrystalPlasticityStateVariable.C.

Referenced by initSlipSysProps().

99 {
100  MooseUtils::checkFileReadable(_state_variable_file_name);
101 
102  std::ifstream file;
103  file.open(_state_variable_file_name.c_str());
104 
105  for (unsigned int i = 0; i < _variable_size; ++i)
106  if (!(file >> val[i]))
107  mooseError("Error CrystalPlasticityStateVariable: Premature end of state_variable file");
108 
109  file.close();
110 }
FileName _state_variable_file_name
File should contain initial values of the state variable.

◆ readInitialValueFromInline()

void CrystalPlasticityStateVariable::readInitialValueFromInline ( std::vector< Real > &  val) const
protectedvirtual

Definition at line 113 of file CrystalPlasticityStateVariable.C.

Referenced by initSlipSysProps().

114 {
115  if (_groups.size() <= 0)
116  mooseError("CrystalPlasticityStateVariable: Error in reading initial state variable values: "
117  "Specify input in .i file or in state_variable file");
118  else if (_groups.size() != (_group_values.size() + 1))
119  mooseError(
120  "CrystalPlasticityStateVariable: The size of the groups and group_values does not match.");
121 
122  for (unsigned int i = 0; i < _groups.size() - 1; ++i)
123  {
124  unsigned int is, ie;
125 
126  is = _groups[i];
127  ie = _groups[i + 1] - 1;
128 
129  if (is > ie)
130  mooseError("CrystalPlasticityStateVariable: Start index is = ",
131  is,
132  " should be greater than end index ie = ",
133  ie,
134  " in state variable read");
135 
136  for (unsigned int j = is; j <= ie; ++j)
137  val[j] = _group_values[i];
138  }
139 }
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.

◆ updateStateVariable()

bool CrystalPlasticityStateVariable::updateStateVariable ( unsigned int  qp,
Real  dt,
std::vector< Real > &  val,
std::vector< Real > &  val_old 
) const
virtual

Definition at line 151 of file CrystalPlasticityStateVariable.C.

155 {
156  for (unsigned int i = 0; i < _variable_size; ++i)
157  {
158  val[i] = 0.0;
159  for (unsigned int j = 0; j < _num_mat_state_var_evol_rate_comps; j++)
160  val[i] += (*_mat_prop_state_var_evol_rate_comps[j])[qp][i] * dt * _scale_factor[j];
161  }
162 
163  for (unsigned int i = 0; i < _variable_size; ++i)
164  {
165  if (val_old[i] < _zero && val[i] < 0.0)
166  val[i] = val_old[i];
167  else
168  val[i] = val_old[i] + val[i];
169 
170  if (val[i] < 0.0)
171  return false;
172  }
173  return true;
174 }
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.

◆ variableSize()

unsigned int CrystalPlasticityUOBase::variableSize ( ) const
virtualinherited

Returns the size of variable.

Definition at line 29 of file CrystalPlasticityUOBase.C.

30 {
31  return _variable_size;
32 }

Member Data Documentation

◆ _group_values

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 65 of file CrystalPlasticityStateVariable.h.

Referenced by readInitialValueFromInline().

◆ _groups

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 59 of file CrystalPlasticityStateVariable.h.

Referenced by readInitialValueFromInline().

◆ _intvar_read_type

MooseEnum CrystalPlasticityStateVariable::_intvar_read_type
protected

Read from options for initial values of internal variables.

Definition at line 52 of file CrystalPlasticityStateVariable.h.

Referenced by initSlipSysProps().

◆ _mat_prop_state_var

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

Definition at line 46 of file CrystalPlasticityStateVariable.h.

◆ _mat_prop_state_var_evol_rate_comps

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

◆ _num_mat_state_var_evol_rate_comps

unsigned int CrystalPlasticityStateVariable::_num_mat_state_var_evol_rate_comps
protected

◆ _scale_factor

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

Scale factor of individual component.

Definition at line 71 of file CrystalPlasticityStateVariable.h.

Referenced by CrystalPlasticityStateVariable(), and updateStateVariable().

◆ _state_variable_file_name

FileName CrystalPlasticityStateVariable::_state_variable_file_name
protected

File should contain initial values of the state variable.

Definition at line 49 of file CrystalPlasticityStateVariable.h.

Referenced by readInitialValueFromFile().

◆ _variable_size

unsigned int CrystalPlasticityUOBase::_variable_size
protectedinherited

◆ _zero

Real CrystalPlasticityStateVariable::_zero
protected

Numerical zero for internal variable.

Definition at line 68 of file CrystalPlasticityStateVariable.h.

Referenced by updateStateVariable().


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