www.mooseframework.org
CrystalPlasticitySlipRate.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
8 #include "libmesh/utility.h"
9 
10 #include <fstream>
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<CrystalPlasticityUOBase>();
17  params.addParam<unsigned int>("num_slip_sys_props",
18  0,
19  "Number of slip system specific properties provided in the file "
20  "containing slip system normals and directions");
21  params.addParam<std::vector<Real>>("flowprops", "Parameters used in slip rate equations");
22  params.addRequiredParam<FileName>("slip_sys_file_name",
23  "Name of the file containing the slip system");
24  params.addParam<FileName>(
25  "slip_sys_flow_prop_file_name",
26  "",
27  "Name of the file containing the values of slip rate equation parameters");
28  params.addParam<unsigned int>(
29  "num_slip_sys_flowrate_props",
30  2,
31  "Number of flow rate properties for a slip system"); // Used for reading flow rate parameters
32  params.addParam<Real>("slip_incr_tol", 2e-2, "Maximum allowable slip in an increment");
33  params.addClassDescription(
34  "Crystal plasticity slip rate class. Override the virtual functions in your class");
35  return params;
36 }
37 
38 CrystalPlasticitySlipRate::CrystalPlasticitySlipRate(const InputParameters & parameters)
39  : CrystalPlasticityUOBase(parameters),
40  _num_slip_sys_props(getParam<unsigned int>("num_slip_sys_props")),
41  _flowprops(getParam<std::vector<Real>>("flowprops")),
42  _slip_sys_file_name(getParam<FileName>("slip_sys_file_name")),
43  _slip_sys_flow_prop_file_name(getParam<FileName>("slip_sys_flow_prop_file_name")),
44  _num_slip_sys_flowrate_props(getParam<unsigned int>("num_slip_sys_flowrate_props")),
45  _slip_incr_tol(getParam<Real>("slip_incr_tol")),
46  _mo(_variable_size * LIBMESH_DIM),
47  _no(_variable_size * LIBMESH_DIM),
48  _crysrot(getMaterialPropertyByName<RankTwoTensor>("crysrot"))
49 {
51 }
52 
53 void
55 {
56 }
57 
58 void
60 {
61 }
62 
63 void
65 {
66  Real vec[LIBMESH_DIM];
67  std::ifstream fileslipsys;
68 
69  MooseUtils::checkFileReadable(_slip_sys_file_name);
70 
71  fileslipsys.open(_slip_sys_file_name.c_str());
72 
73  for (unsigned int i = 0; i < _variable_size; ++i)
74  {
75  // Read the slip normal
76  for (unsigned int j = 0; j < LIBMESH_DIM; ++j)
77  if (!(fileslipsys >> vec[j]))
78  mooseError(
79  "CrystalPlasticitySlipRate Error: Premature end of file reading slip system file \n");
80 
81  // Normalize the vectors
82  Real mag;
83  mag = Utility::pow<2>(vec[0]) + Utility::pow<2>(vec[1]) + Utility::pow<2>(vec[2]);
84  mag = std::sqrt(mag);
85 
86  for (unsigned j = 0; j < LIBMESH_DIM; ++j)
87  _no(i * LIBMESH_DIM + j) = vec[j] / mag;
88 
89  // Read the slip direction
90  for (unsigned int j = 0; j < LIBMESH_DIM; ++j)
91  if (!(fileslipsys >> vec[j]))
92  mooseError(
93  "CrystalPlasticitySlipRate Error: Premature end of file reading slip system file \n");
94 
95  // Normalize the vectors
96  mag = Utility::pow<2>(vec[0]) + Utility::pow<2>(vec[1]) + Utility::pow<2>(vec[2]);
97  mag = std::sqrt(mag);
98 
99  for (unsigned int j = 0; j < LIBMESH_DIM; ++j)
100  _mo(i * LIBMESH_DIM + j) = vec[j] / mag;
101 
102  mag = 0.0;
103  for (unsigned int j = 0; j < LIBMESH_DIM; ++j)
104  mag += _mo(i * LIBMESH_DIM + j) * _no(i * LIBMESH_DIM + j);
105 
106  if (std::abs(mag) > 1e-8)
107  mooseError("CrystalPlasticitySlipRate Error: Slip direction and normal not orthonormal, "
108  "System number = ",
109  i,
110  "\n");
111  }
112 
113  fileslipsys.close();
114 }
InputParameters validParams< CrystalPlasticityUOBase >()
Crystal plasticity system userobject base class.
InputParameters validParams< CrystalPlasticitySlipRate >()
CrystalPlasticitySlipRate(const InputParameters &parameters)
std::string _slip_sys_file_name
File should contain slip plane normal and direction.