Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 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 : 10 : #include "CrystalPlasticitySlipRate.h" 11 : #include "libmesh/utility.h" 12 : 13 : #include <fstream> 14 : 15 : InputParameters 16 104 : CrystalPlasticitySlipRate::validParams() 17 : { 18 104 : InputParameters params = CrystalPlasticityUOBase::validParams(); 19 208 : params.addParam<unsigned int>("num_slip_sys_props", 20 208 : 0, 21 : "Number of slip system specific properties provided in the file " 22 : "containing slip system normals and directions"); 23 208 : params.addParam<std::vector<Real>>("flowprops", "Parameters used in slip rate equations"); 24 208 : params.addRequiredParam<FileName>("slip_sys_file_name", 25 : "Name of the file containing the slip system"); 26 208 : 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 208 : params.addParam<unsigned int>( 31 : "num_slip_sys_flowrate_props", 32 208 : 2, 33 : "Number of flow rate properties for a slip system"); // Used for reading flow rate parameters 34 208 : params.addParam<Real>("slip_incr_tol", 2e-2, "Maximum allowable slip in an increment"); 35 104 : params.addClassDescription( 36 : "Crystal plasticity slip rate class. Override the virtual functions in your class"); 37 104 : return params; 38 0 : } 39 : 40 52 : CrystalPlasticitySlipRate::CrystalPlasticitySlipRate(const InputParameters & parameters) 41 : : CrystalPlasticityUOBase(parameters), 42 52 : _num_slip_sys_props(getParam<unsigned int>("num_slip_sys_props")), 43 104 : _flowprops(getParam<std::vector<Real>>("flowprops")), 44 104 : _slip_sys_file_name(getParam<FileName>("slip_sys_file_name")), 45 104 : _slip_sys_flow_prop_file_name(getParam<FileName>("slip_sys_flow_prop_file_name")), 46 104 : _num_slip_sys_flowrate_props(getParam<unsigned int>("num_slip_sys_flowrate_props")), 47 104 : _slip_incr_tol(getParam<Real>("slip_incr_tol")), 48 52 : _mo(_variable_size * LIBMESH_DIM), 49 52 : _no(_variable_size * LIBMESH_DIM), 50 156 : _crysrot(getMaterialPropertyByName<RankTwoTensor>("crysrot")) 51 : { 52 52 : getSlipSystems(); 53 52 : } 54 : 55 : void 56 0 : CrystalPlasticitySlipRate::readFileFlowRateParams() 57 : { 58 0 : } 59 : 60 : void 61 0 : CrystalPlasticitySlipRate::getFlowRateParams() 62 : { 63 0 : } 64 : 65 : void 66 52 : CrystalPlasticitySlipRate::getSlipSystems() 67 : { 68 : Real vec[LIBMESH_DIM]; 69 52 : std::ifstream fileslipsys; 70 : 71 52 : MooseUtils::checkFileReadable(_slip_sys_file_name); 72 : 73 52 : fileslipsys.open(_slip_sys_file_name.c_str()); 74 : 75 820 : for (unsigned int i = 0; i < _variable_size; ++i) 76 : { 77 : // Read the slip normal 78 3072 : for (const auto j : make_range(Moose::dim)) 79 2304 : if (!(fileslipsys >> vec[j])) 80 0 : mooseError( 81 : "CrystalPlasticitySlipRate Error: Premature end of file reading slip system file \n"); 82 : 83 : // Normalize the vectors 84 : Real mag; 85 768 : mag = Utility::pow<2>(vec[0]) + Utility::pow<2>(vec[1]) + Utility::pow<2>(vec[2]); 86 768 : mag = std::sqrt(mag); 87 : 88 3072 : for (unsigned j = 0; j < LIBMESH_DIM; ++j) 89 2304 : _no(i * LIBMESH_DIM + j) = vec[j] / mag; 90 : 91 : // Read the slip direction 92 3072 : for (const auto j : make_range(Moose::dim)) 93 2304 : if (!(fileslipsys >> vec[j])) 94 0 : mooseError( 95 : "CrystalPlasticitySlipRate Error: Premature end of file reading slip system file \n"); 96 : 97 : // Normalize the vectors 98 768 : mag = Utility::pow<2>(vec[0]) + Utility::pow<2>(vec[1]) + Utility::pow<2>(vec[2]); 99 768 : mag = std::sqrt(mag); 100 : 101 3072 : for (const auto j : make_range(Moose::dim)) 102 2304 : _mo(i * LIBMESH_DIM + j) = vec[j] / mag; 103 : 104 : mag = 0.0; 105 3072 : for (const auto j : make_range(Moose::dim)) 106 2304 : mag += _mo(i * LIBMESH_DIM + j) * _no(i * LIBMESH_DIM + j); 107 : 108 768 : if (std::abs(mag) > 1e-8) 109 0 : mooseError("CrystalPlasticitySlipRate Error: Slip direction and normal not orthonormal, " 110 : "System number = ", 111 : i, 112 : "\n"); 113 : } 114 : 115 52 : fileslipsys.close(); 116 52 : }