LCOV - code coverage report
Current view: top level - models/solid_mechanics/elasticity - IsotropicElasticityConverter.cxx (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 28 28
Test Date: 2025-06-29 01:25:44 Functions: 100.0 % 4 4

            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/elasticity/IsotropicElasticityConverter.h"
      26              : 
      27              : namespace neml2
      28              : {
      29              : const IsotropicElasticityConverter::ConversionTableType IsotropicElasticityConverter::table = {
      30              :     {{ElasticConstant::BULK_MODULUS, ElasticConstant::SHEAR_MODULUS},
      31              :      {&IsotropicElasticityConverter::K_G_to_K, &IsotropicElasticityConverter::K_G_to_G}},
      32              :     {{ElasticConstant::YOUNGS_MODULUS, ElasticConstant::POISSONS_RATIO},
      33              :      {&IsotropicElasticityConverter::E_nu_to_K, &IsotropicElasticityConverter::E_nu_to_G}}};
      34              : 
      35              : IsotropicElasticityConverter::ConversionType
      36            3 : IsotropicElasticityConverter::K_G_to_K(const InputType & input, const DerivativeFlagType & deriv)
      37              : {
      38            3 :   const auto & K = input[0];
      39              : 
      40            3 :   const auto dK_dK = deriv[0] ? Scalar::identity_map(K.options()) : Scalar();
      41            3 :   const auto dK_dG = deriv[1] ? Scalar::zeros(K.options()) : Scalar();
      42              : 
      43            6 :   return {K, {dK_dK, dK_dG}};
      44            6 : }
      45              : 
      46              : IsotropicElasticityConverter::ConversionType
      47            3 : IsotropicElasticityConverter::K_G_to_G(const InputType & input, const DerivativeFlagType & deriv)
      48              : {
      49            3 :   const auto & G = input[1];
      50              : 
      51            3 :   const auto dG_dK = deriv[0] ? Scalar::zeros(G.options()) : Scalar();
      52            3 :   const auto dG_dG = deriv[1] ? Scalar::identity_map(G.options()) : Scalar();
      53              : 
      54            6 :   return {G, {dG_dK, dG_dG}};
      55            6 : }
      56              : 
      57              : IsotropicElasticityConverter::ConversionType
      58           29 : IsotropicElasticityConverter::E_nu_to_K(const InputType & input, const DerivativeFlagType & deriv)
      59              : {
      60           29 :   const auto & E = input[0];
      61           29 :   const auto & nu = input[1];
      62              : 
      63           29 :   const auto K = E / 3 / (1 - 2 * nu);
      64           29 :   const auto dK_dE = deriv[0] ? K / E : Scalar();
      65           29 :   const auto dK_dnu = deriv[1] ? 6 * K * K / E : Scalar();
      66              : 
      67           58 :   return {K, {dK_dE, dK_dnu}};
      68           58 : }
      69              : 
      70              : IsotropicElasticityConverter::ConversionType
      71           31 : IsotropicElasticityConverter::E_nu_to_G(const InputType & input, const DerivativeFlagType & deriv)
      72              : {
      73           31 :   const auto & E = input[0];
      74           31 :   const auto & nu = input[1];
      75              : 
      76           31 :   const auto G = E / (2 * (1 + nu));
      77           31 :   const auto dG_dE = deriv[0] ? G / E : Scalar();
      78           31 :   const auto dG_dnu = deriv[1] ? -G / (1 + nu) : Scalar();
      79              : 
      80           62 :   return {G, {dG_dE, dG_dnu}};
      81           62 : }
      82              : 
      83              : } // namespace neml2
        

Generated by: LCOV version 2.0-1