LCOV - code coverage report
Current view: top level - models/solid_mechanics - PowerLawIsotropicHardeningStaticRecovery.cxx (source / functions) Coverage Total Hit
Test: coverage.info Lines: 96.3 % 27 26
Test Date: 2025-06-29 01:25:44 Functions: 100.0 % 3 3

            Line data    Source code
       1              : // Copyright 2024, UChicago Argonne, LLC
       2              : // All Rights Reserved
       3              : // Software Name: NEML2 -- the New Engineering material Model Library, version 2
       4              : // By: Argonne National Laboratory
       5              : // OPEN SOURCE LICENSE (MIT)
       6              : //
       7              : // Permission is hereby granted, free of charge, to any person obtaining a copy
       8              : // of this software and associated documentation files (the "Software"), to deal
       9              : // in the Software without restriction, including without limitation the rights
      10              : // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      11              : // copies of the Software, and to permit persons to whom the Software is
      12              : // furnished to do so, subject to the following conditions:
      13              : //
      14              : // The above copyright notice and this permission notice shall be included in
      15              : // all copies or substantial portions of the Software.
      16              : //
      17              : // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      18              : // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      19              : // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      20              : // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      21              : // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      22              : // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
      23              : // THE SOFTWARE.
      24              : 
      25              : #include "neml2/models/solid_mechanics/PowerLawIsotropicHardeningStaticRecovery.h"
      26              : #include "neml2/tensors/Scalar.h"
      27              : #include "neml2/tensors/functions/abs.h"
      28              : #include "neml2/tensors/functions/log.h"
      29              : #include "neml2/tensors/functions/pow.h"
      30              : 
      31              : namespace neml2
      32              : {
      33              : register_NEML2_object(PowerLawIsotropicHardeningStaticRecovery);
      34              : 
      35              : OptionSet
      36            2 : PowerLawIsotropicHardeningStaticRecovery::expected_options()
      37              : {
      38            2 :   OptionSet options = IsotropicHardeningStaticRecovery::expected_options();
      39            2 :   options.doc() = " This particular model implements a power law recovery of the type "
      40              :                   "\\f$ \\dot{k} = -\\left(\\frac{\\lVert k \\rVert}{\\tau}\\right)^{n-1} "
      41            2 :                   "\\frac{k}{\\tau} \\f$";
      42              : 
      43            4 :   options.set_parameter<TensorName<Scalar>>("tau");
      44            4 :   options.set("tau").doc() = "Recovery rate";
      45            4 :   options.set_parameter<TensorName<Scalar>>("n");
      46            2 :   options.set("n").doc() = "Recovery exponent";
      47              : 
      48            2 :   return options;
      49            0 : }
      50              : 
      51            1 : PowerLawIsotropicHardeningStaticRecovery::PowerLawIsotropicHardeningStaticRecovery(
      52            1 :     const OptionSet & options)
      53              :   : IsotropicHardeningStaticRecovery(options),
      54            3 :     _tau(declare_parameter<Scalar>("tau", "tau", true)),
      55            5 :     _n(declare_parameter<Scalar>("n", "n", true))
      56              : {
      57            1 : }
      58              : 
      59              : void
      60            2 : PowerLawIsotropicHardeningStaticRecovery::set_value(bool out, bool dout_din, bool /*d2out_din2*/)
      61              : {
      62            2 :   if (out)
      63            2 :     _h_dot = -pow(abs(Scalar(_h)) / _tau, _n - 1.0) * _h / _tau;
      64              : 
      65            2 :   if (dout_din)
      66              :   {
      67            1 :     if (_h.is_dependent())
      68            1 :       _h_dot.d(_h) = -_n * pow(abs(_h / _tau), _n - 1) / abs(_tau);
      69              : 
      70            3 :     if (const auto * const tau = nl_param("tau"))
      71            1 :       _h_dot.d(*tau) = _n * _h * pow(_tau, -1 - _n) * pow(abs(Scalar(_h)), _n - 1);
      72              : 
      73            3 :     if (const auto * const n = nl_param("n"))
      74            4 :       _h_dot.d(*n) = -_h * pow(_tau, -_n) * pow(abs(Scalar(_h)), _n - 1) *
      75            5 :                      log(abs(Scalar(_h)) / _tau + machine_precision(_h.scalar_type()));
      76              :   }
      77            2 : }
      78              : } // namespace neml2
        

Generated by: LCOV version 2.0-1