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 
17 {
19  params.addParam<unsigned int>("num_slip_sys_props",
20  0,
21  "Number of slip system specific properties provided in the file "
22  "containing slip system normals and directions");
23  params.addParam<std::vector<Real>>("flowprops", "Parameters used in slip rate equations");
24  params.addRequiredParam<FileName>("slip_sys_file_name",
25  "Name of the file containing the slip system");
26  params.addParam<FileName>(
27  "slip_sys_flow_prop_file_name",
28  "",
29  "Name of the file containing the values of slip rate equation parameters");
30  params.addParam<unsigned int>(
31  "num_slip_sys_flowrate_props",
32  2,
33  "Number of flow rate properties for a slip system"); // Used for reading flow rate parameters
34  params.addParam<Real>("slip_incr_tol", 2e-2, "Maximum allowable slip in an increment");
35  params.addClassDescription(
36  "Crystal plasticity slip rate class. Override the virtual functions in your class");
37  return params;
38 }
39 
41  : CrystalPlasticityUOBase(parameters),
42  _num_slip_sys_props(getParam<unsigned int>("num_slip_sys_props")),
43  _flowprops(getParam<std::vector<Real>>("flowprops")),
44  _slip_sys_file_name(getParam<FileName>("slip_sys_file_name")),
45  _slip_sys_flow_prop_file_name(getParam<FileName>("slip_sys_flow_prop_file_name")),
46  _num_slip_sys_flowrate_props(getParam<unsigned int>("num_slip_sys_flowrate_props")),
47  _slip_incr_tol(getParam<Real>("slip_incr_tol")),
48  _mo(_variable_size * LIBMESH_DIM),
49  _no(_variable_size * LIBMESH_DIM),
50  _crysrot(getMaterialPropertyByName<RankTwoTensor>("crysrot"))
51 {
53 }
54 
55 void
57 {
58 }
59 
60 void
62 {
63 }
64 
65 void
67 {
68  Real vec[LIBMESH_DIM];
69  std::ifstream fileslipsys;
70 
72 
73  fileslipsys.open(_slip_sys_file_name.c_str());
74 
75  for (unsigned int i = 0; i < _variable_size; ++i)
76  {
77  // Read the slip normal
78  for (const auto j : make_range(Moose::dim))
79  if (!(fileslipsys >> vec[j]))
80  mooseError(
81  "CrystalPlasticitySlipRate Error: Premature end of file reading slip system file \n");
82 
83  // Normalize the vectors
84  Real mag;
85  mag = Utility::pow<2>(vec[0]) + Utility::pow<2>(vec[1]) + Utility::pow<2>(vec[2]);
86  mag = std::sqrt(mag);
87 
88  for (unsigned j = 0; j < LIBMESH_DIM; ++j)
89  _no(i * LIBMESH_DIM + j) = vec[j] / mag;
90 
91  // Read the slip direction
92  for (const auto j : make_range(Moose::dim))
93  if (!(fileslipsys >> vec[j]))
94  mooseError(
95  "CrystalPlasticitySlipRate Error: Premature end of file reading slip system file \n");
96 
97  // Normalize the vectors
98  mag = Utility::pow<2>(vec[0]) + Utility::pow<2>(vec[1]) + Utility::pow<2>(vec[2]);
99  mag = std::sqrt(mag);
100 
101  for (const auto j : make_range(Moose::dim))
102  _mo(i * LIBMESH_DIM + j) = vec[j] / mag;
103 
104  mag = 0.0;
105  for (const auto j : make_range(Moose::dim))
106  mag += _mo(i * LIBMESH_DIM + j) * _no(i * LIBMESH_DIM + j);
107 
108  if (std::abs(mag) > 1e-8)
109  mooseError("CrystalPlasticitySlipRate Error: Slip direction and normal not orthonormal, "
110  "System number = ",
111  i,
112  "\n");
113  }
114 
115  fileslipsys.close();
116 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
static InputParameters validParams()
static constexpr std::size_t dim
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
void addRequiredParam(const std::string &name, const std::string &doc_string)
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
Crystal plasticity system userobject base class.
static InputParameters validParams()
bool checkFileReadable(const std::string &filename, bool check_line_endings=false, bool throw_on_unreadable=true, bool check_for_git_lfs_pointer=true)
CrystalPlasticitySlipRate(const InputParameters &parameters)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
std::string _slip_sys_file_name
File should contain slip plane normal and direction.
void ErrorVector unsigned int