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