LCOV - code coverage report
Current view: top level - models/solid_mechanics - ThermalEigenstrain.cxx (source / functions) Coverage Total Hit
Test: coverage.info Lines: 83.9 % 31 26
Test Date: 2025-10-02 16:03:03 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/ThermalEigenstrain.h"
      26              : #include "neml2/tensors/Scalar.h"
      27              : #include "neml2/tensors/SR2.h"
      28              : 
      29              : namespace neml2
      30              : {
      31              : register_NEML2_object(ThermalEigenstrain);
      32              : 
      33              : OptionSet
      34            2 : ThermalEigenstrain::expected_options()
      35              : {
      36            2 :   OptionSet options = Eigenstrain::expected_options();
      37            2 :   options.doc() =
      38              :       "Define the (cummulative, as opposed to instantaneous) linear isotropic thermal eigenstrain, "
      39              :       "i.e. \\f$ \\boldsymbol{\\varepsilon}_T = \\alpha (T - T_0) \\boldsymbol{I} \\f$, where \\f$ "
      40              :       "\\alpha \\f$ is the coefficient of thermal expansion (CTE), \\f$ T \\f$ is the temperature, "
      41            2 :       "and \\f$ T_0 \\f$ is the reference (stress-free) temperature.";
      42              : 
      43            6 :   options.set_input("temperature") = VariableName(FORCES, "T");
      44            4 :   options.set("temperature").doc() = "Temperature";
      45              : 
      46            4 :   options.set_buffer<TensorName<Scalar>>("reference_temperature");
      47            4 :   options.set("reference_temperature").doc() = "Reference (stress-free) temperature";
      48              : 
      49            4 :   options.set_parameter<TensorName<Scalar>>("CTE");
      50            2 :   options.set("CTE").doc() = "Coefficient of thermal expansion";
      51              : 
      52            2 :   return options;
      53            0 : }
      54              : 
      55            2 : ThermalEigenstrain::ThermalEigenstrain(const OptionSet & options)
      56              :   : Eigenstrain(options),
      57            2 :     _T(declare_input_variable<Scalar>("temperature")),
      58            8 :     _T0(declare_buffer<Scalar>("T0", "reference_temperature")),
      59           10 :     _alpha(declare_parameter<Scalar>("alpha", "CTE", true))
      60              : {
      61            2 : }
      62              : 
      63              : void
      64            4 : ThermalEigenstrain::set_value(bool out, bool dout_din, bool d2out_din2)
      65              : {
      66            4 :   if (out)
      67            3 :     _eg = _alpha * (_T - _T0) * SR2::identity(_T.options());
      68              : 
      69            4 :   if (dout_din)
      70              :   {
      71            2 :     if (_T.is_dependent())
      72            2 :       _eg.d(_T) = _alpha * SR2::identity(_T.options());
      73              : 
      74            6 :     if (const auto * const alpha = nl_param("alpha"))
      75            1 :       _eg.d(*alpha) = (_T - _T0) * SR2::identity(_T.options());
      76              :   }
      77              : 
      78            4 :   if (d2out_din2)
      79              :   {
      80            0 :     if (_T.is_dependent())
      81            0 :       if (const auto * const alpha = nl_param("alpha"))
      82              :       {
      83            0 :         _eg.d(_T, *alpha) = SR2::identity(_T.options());
      84            0 :         _eg.d(*alpha, _T) = SR2::identity(_T.options());
      85              :       }
      86              :   }
      87            4 : }
      88              : } // namespace neml2
        

Generated by: LCOV version 2.0-1