LCOV - code coverage report
Current view: top level - src/userobjects - CrystalPlasticitySlipRate.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 46 54 85.2 %
Date: 2025-07-25 05:00:39 Functions: 3 5 60.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14