www.mooseframework.org
Public Member Functions | Static 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...
 

Static Public Member Functions

static InputParameters validParams ()
 

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

Constructor & Destructor Documentation

◆ CrystalPlasticityStateVariable()

CrystalPlasticityStateVariable::CrystalPlasticityStateVariable ( const InputParameters &  parameters)

Definition at line 50 of file CrystalPlasticityStateVariable.C.

51  : CrystalPlasticityUOBase(parameters),
53  parameters.get<std::vector<std::string>>("uo_state_var_evol_rate_comp_name").size()),
54  _mat_prop_state_var(getMaterialProperty<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 }

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 }

◆ provideInitialValueByUser()

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

Definition at line 143 of file CrystalPlasticityStateVariable.C.

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 }

Referenced by initSlipSysProps().

◆ readInitialValueFromFile()

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

Definition at line 99 of file CrystalPlasticityStateVariable.C.

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 }

Referenced by initSlipSysProps().

◆ readInitialValueFromInline()

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

Definition at line 114 of file CrystalPlasticityStateVariable.C.

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 }

Referenced by initSlipSysProps().

◆ updateStateVariable()

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

Definition at line 152 of file CrystalPlasticityStateVariable.C.

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

◆ validParams()

InputParameters CrystalPlasticityStateVariable::validParams ( )
static

Definition at line 19 of file CrystalPlasticityStateVariable.C.

20 {
21  InputParameters params = CrystalPlasticityUOBase::validParams();
22  params.addParam<FileName>(
23  "state_variable_file_name",
24  "",
25  "Name of the file containing the initial values of slip system resistances");
26  MooseEnum intvar_read_options("file_input inline_input user_input", "inline_input");
27  params.addParam<MooseEnum>(
28  "intvar_read_type",
29  intvar_read_options,
30  "Read from options for initial value of internal variables: Default from .i file");
31  params.addParam<std::vector<unsigned int>>("groups",
32  "To group the initial values on different "
33  "slip systems 'format: [start end)', i.e.'0 "
34  "4 8 11' groups 0-3, 4-7 and 8-11 ");
35  params.addParam<std::vector<Real>>("group_values",
36  "The initial values corresponding to each "
37  "group, i.e. '0.0 1.0 2.0' means 0-4 = 0.0, "
38  "4-8 = 1.0 and 8-12 = 2.0 ");
39  params.addParam<std::vector<std::string>>("uo_state_var_evol_rate_comp_name",
40  "Name of state variable evolution rate component "
41  "property: Same as state variable evolution rate "
42  "component user object specified in input file.");
43  params.addParam<Real>("zero", 0.0, "Numerical zero for interval variable");
44  params.addParam<std::vector<Real>>("scale_factor", "Scale factor of individual component.");
45  params.addClassDescription(
46  "Crystal plasticity state variable class. Override the virtual functions in your class");
47  return params;
48 }

◆ variableSize()

unsigned int CrystalPlasticityUOBase::variableSize ( ) const
virtualinherited

Returns the size of variable.

Definition at line 30 of file CrystalPlasticityUOBase.C.

31 {
32  return _variable_size;
33 }

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 66 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 60 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 53 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 47 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 72 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 50 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 69 of file CrystalPlasticityStateVariable.h.

Referenced by updateStateVariable().


The documentation for this class was generated from the following files:
CrystalPlasticityStateVariable::_num_mat_state_var_evol_rate_comps
unsigned int _num_mat_state_var_evol_rate_comps
Definition: CrystalPlasticityStateVariable.h:43
CrystalPlasticityStateVariable::readInitialValueFromFile
virtual void readInitialValueFromFile(std::vector< Real > &val) const
Definition: CrystalPlasticityStateVariable.C:99
CrystalPlasticityStateVariable::provideInitialValueByUser
virtual void provideInitialValueByUser(std::vector< Real > &, const Point &) const
Definition: CrystalPlasticityStateVariable.C:143
CrystalPlasticityUOBase::validParams
static InputParameters validParams()
Definition: CrystalPlasticityUOBase.C:15
CrystalPlasticityStateVariable::_mat_prop_state_var_evol_rate_comps
std::vector< const MaterialProperty< std::vector< Real > > * > _mat_prop_state_var_evol_rate_comps
Definition: CrystalPlasticityStateVariable.h:45
CrystalPlasticityUOBase::CrystalPlasticityUOBase
CrystalPlasticityUOBase(const InputParameters &parameters)
Definition: CrystalPlasticityUOBase.C:24
CrystalPlasticityStateVariable::_group_values
std::vector< Real > _group_values
The _group_values are the initial values corresponding to each group.
Definition: CrystalPlasticityStateVariable.h:66
CrystalPlasticityStateVariable::readInitialValueFromInline
virtual void readInitialValueFromInline(std::vector< Real > &val) const
Definition: CrystalPlasticityStateVariable.C:114
CrystalPlasticityStateVariable::_groups
std::vector< unsigned int > _groups
The _groups variable is used to group slip systems and assign the initial values to each group.
Definition: CrystalPlasticityStateVariable.h:60
CrystalPlasticityUOBase::_variable_size
unsigned int _variable_size
Definition: CrystalPlasticityUOBase.h:33
CrystalPlasticityStateVariable::_mat_prop_state_var
const MaterialProperty< std::vector< Real > > & _mat_prop_state_var
Definition: CrystalPlasticityStateVariable.h:47
CrystalPlasticityStateVariable::_zero
Real _zero
Numerical zero for internal variable.
Definition: CrystalPlasticityStateVariable.h:69
CrystalPlasticityStateVariable::_scale_factor
std::vector< Real > _scale_factor
Scale factor of individual component.
Definition: CrystalPlasticityStateVariable.h:72
CrystalPlasticityStateVariable::_intvar_read_type
MooseEnum _intvar_read_type
Read from options for initial values of internal variables.
Definition: CrystalPlasticityStateVariable.h:53
CrystalPlasticityStateVariable::_state_variable_file_name
FileName _state_variable_file_name
File should contain initial values of the state variable.
Definition: CrystalPlasticityStateVariable.h:50