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 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  _mat_prop_state_var_old(getMaterialPropertyOld<std::vector<Real>>(_name)),
55  _state_variable_file_name(getParam<FileName>("state_variable_file_name")),
56  _intvar_read_type(getParam<MooseEnum>("intvar_read_type")),
57  _groups(getParam<std::vector<unsigned int>>("groups")),
58  _group_values(getParam<std::vector<Real>>("group_values")),
59  _zero(getParam<Real>("zero")),
60  _scale_factor(getParam<std::vector<Real>>("scale_factor"))
61 {
63  mooseError("CrystalPlasticityStateVariable: Scale factor should be have the same size of "
64  "evolution rate components.");
65 
67 
68  for (unsigned int i = 0; i < _num_mat_state_var_evol_rate_comps; ++i)
69  _mat_prop_state_var_evol_rate_comps[i] = &getMaterialProperty<std::vector<Real>>(
70  parameters.get<std::vector<std::string>>("uo_state_var_evol_rate_comp_name")[i]);
71 }
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

◆ initSlipSysProps()

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

Definition at line 74 of file CrystalPlasticityStateVariable.C.

76 {
77  switch (_intvar_read_type)
78  {
79  case 0:
81  break;
82  case 1:
84  break;
85  case 2:
86  provideInitialValueByUser(val, q_point);
87  break;
88  default:
89  mooseError("CrystalPlasticityStateVariable: Read option for initial value of internal "
90  "variables is not supported.");
91  }
92 
93  for (unsigned int i = 0; i < _variable_size; ++i)
94  if (val[i] <= 0.0)
95  mooseError("CrystalPlasticityStateVariable: Value of state variables ", i, " non positive");
96 }
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 143 of file CrystalPlasticityStateVariable.C.

Referenced by initSlipSysProps().

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

◆ readInitialValueFromFile()

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

Definition at line 99 of file CrystalPlasticityStateVariable.C.

Referenced by initSlipSysProps().

100 {
101  MooseUtils::checkFileReadable(_state_variable_file_name);
102 
103  std::ifstream file;
104  file.open(_state_variable_file_name.c_str());
105 
106  for (unsigned int i = 0; i < _variable_size; ++i)
107  if (!(file >> val[i]))
108  mooseError("Error CrystalPlasticityStateVariable: Premature end of state_variable file");
109 
110  file.close();
111 }
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 114 of file CrystalPlasticityStateVariable.C.

Referenced by initSlipSysProps().

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

Definition at line 152 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 (_mat_prop_state_var_old[qp][i] < _zero && val[i] < 0.0)
166  val[i] = _mat_prop_state_var_old[qp][i];
167  else
168  val[i] = _mat_prop_state_var_old[qp][i] + val[i];
169 
170  if (val[i] < 0.0)
171  return false;
172  }
173  return true;
174 }
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.

◆ 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 63 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 57 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 50 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 43 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

◆ _mat_prop_state_var_old

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

Definition at line 44 of file CrystalPlasticityStateVariable.h.

Referenced by updateStateVariable().

◆ _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 69 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 47 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 66 of file CrystalPlasticityStateVariable.h.

Referenced by updateStateVariable().


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