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 182 : CrystalPlasticitySlipRate::validParams() 17 : { 18 182 : InputParameters params = CrystalPlasticityUOBase::validParams(); 19 364 : params.addParam<unsigned int>("num_slip_sys_props", 20 364 : 0, 21 : "Number of slip system specific properties provided in the file " 22 : "containing slip system normals and directions"); 23 364 : params.addParam<std::vector<Real>>("flowprops", "Parameters used in slip rate equations"); 24 364 : params.addRequiredParam<FileName>("slip_sys_file_name", 25 : "Name of the file containing the slip system"); 26 364 : 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 364 : params.addParam<unsigned int>( 31 : "num_slip_sys_flowrate_props", 32 364 : 2, 33 : "Number of flow rate properties for a slip system"); // Used for reading flow rate parameters 34 364 : params.addParam<Real>("slip_incr_tol", 2e-2, "Maximum allowable slip in an increment"); 35 182 : params.addClassDescription( 36 : "Crystal plasticity slip rate class. Override the virtual functions in your class"); 37 182 : return params; 38 0 : } 39 : 40 91 : CrystalPlasticitySlipRate::CrystalPlasticitySlipRate(const InputParameters & parameters) 41 : : CrystalPlasticityUOBase(parameters), 42 91 : _num_slip_sys_props(getParam<unsigned int>("num_slip_sys_props")), 43 182 : _flowprops(getParam<std::vector<Real>>("flowprops")), 44 182 : _slip_sys_file_name(getParam<FileName>("slip_sys_file_name")), 45 182 : _slip_sys_flow_prop_file_name(getParam<FileName>("slip_sys_flow_prop_file_name")), 46 182 : _num_slip_sys_flowrate_props(getParam<unsigned int>("num_slip_sys_flowrate_props")), 47 182 : _slip_incr_tol(getParam<Real>("slip_incr_tol")), 48 91 : _mo(_variable_size * LIBMESH_DIM), 49 91 : _no(_variable_size * LIBMESH_DIM), 50 273 : _crysrot(getMaterialPropertyByName<RankTwoTensor>("crysrot")) 51 : { 52 91 : getSlipSystems(); 53 91 : } 54 : 55 : void 56 0 : CrystalPlasticitySlipRate::readFileFlowRateParams() 57 : { 58 0 : } 59 : 60 : void 61 0 : CrystalPlasticitySlipRate::getFlowRateParams() 62 : { 63 0 : } 64 : 65 : void 66 91 : CrystalPlasticitySlipRate::getSlipSystems() 67 : { 68 : Real vec[LIBMESH_DIM]; 69 91 : std::ifstream fileslipsys; 70 : 71 91 : MooseUtils::checkFileReadable(_slip_sys_file_name); 72 : 73 91 : fileslipsys.open(_slip_sys_file_name.c_str()); 74 : 75 1435 : for (unsigned int i = 0; i < _variable_size; ++i) 76 : { 77 : // Read the slip normal 78 5376 : for (const auto j : make_range(Moose::dim)) 79 4032 : 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 1344 : mag = Utility::pow<2>(vec[0]) + Utility::pow<2>(vec[1]) + Utility::pow<2>(vec[2]); 86 1344 : mag = std::sqrt(mag); 87 : 88 5376 : for (unsigned j = 0; j < LIBMESH_DIM; ++j) 89 4032 : _no(i * LIBMESH_DIM + j) = vec[j] / mag; 90 : 91 : // Read the slip direction 92 5376 : for (const auto j : make_range(Moose::dim)) 93 4032 : 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 1344 : mag = Utility::pow<2>(vec[0]) + Utility::pow<2>(vec[1]) + Utility::pow<2>(vec[2]); 99 1344 : mag = std::sqrt(mag); 100 : 101 5376 : for (const auto j : make_range(Moose::dim)) 102 4032 : _mo(i * LIBMESH_DIM + j) = vec[j] / mag; 103 : 104 : mag = 0.0; 105 5376 : for (const auto j : make_range(Moose::dim)) 106 4032 : mag += _mo(i * LIBMESH_DIM + j) * _no(i * LIBMESH_DIM + j); 107 : 108 1344 : 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 91 : fileslipsys.close(); 116 91 : }