LCOV - code coverage report
Current view: top level - models/solid_mechanics - ThermalDeformationJacobian.cxx (source / functions) Coverage Total Hit
Test: coverage.info Lines: 93.1 % 29 27
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/ThermalDeformationJacobian.h"
      26              : #include "neml2/tensors/Scalar.h"
      27              : 
      28              : namespace neml2
      29              : {
      30              : register_NEML2_object(ThermalDeformationJacobian);
      31              : 
      32              : OptionSet
      33            2 : ThermalDeformationJacobian::expected_options()
      34              : {
      35            2 :   OptionSet options = Model::expected_options();
      36            2 :   options.doc() =
      37              :       "Define the linear isotropic thermal deformation Jacobian, i.e. \\f$ J = 1 + \\alpha (T - "
      38              :       "T_0) \\f$, where \\f$ \\alpha \\f$ is the coefficient of thermal expansion (CTE), \\f$ T "
      39            2 :       "\\f$ is the temperature, and \\f$ T_0 \\f$ is the reference (stress-free) temperature.";
      40              : 
      41            6 :   options.set_input("temperature") = VariableName(FORCES, "T");
      42            4 :   options.set("temperature").doc() = "Temperature";
      43              : 
      44            4 :   options.set_buffer<TensorName<Scalar>>("reference_temperature");
      45            4 :   options.set("reference_temperature").doc() = "Reference (stress-free) temperature";
      46              : 
      47            4 :   options.set_parameter<TensorName<Scalar>>("CTE");
      48            2 :   options.set("CTE").doc() = "Coefficient of thermal expansion";
      49              : 
      50            6 :   options.set<VariableName>("jacobian") = VariableName(STATE, "J");
      51            2 :   options.set("jacobian").doc() = "Thermal deformation Jacobian";
      52              : 
      53            2 :   return options;
      54            0 : }
      55              : 
      56            1 : ThermalDeformationJacobian::ThermalDeformationJacobian(const OptionSet & options)
      57              :   : Model(options),
      58            1 :     _T(declare_input_variable<Scalar>("temperature")),
      59            4 :     _T0(declare_buffer<Scalar>("T0", "reference_temperature")),
      60            4 :     _alpha(declare_parameter<Scalar>("alpha", "CTE", true)),
      61            2 :     _J(declare_output_variable<Scalar>("jacobian"))
      62              : {
      63            1 : }
      64              : 
      65              : void
      66            2 : ThermalDeformationJacobian::set_value(bool out, bool dout_din, bool /*d2out_din2*/)
      67              : {
      68            2 :   if (out)
      69            1 :     _J = 1.0 + _alpha * (_T - _T0);
      70              : 
      71            2 :   if (dout_din)
      72              :   {
      73            1 :     if (_T.is_dependent())
      74            1 :       _J.d(_T) = _alpha;
      75              : 
      76            3 :     if (const auto * const alpha = nl_param("alpha"))
      77            0 :       _J.d(*alpha) = (_T - _T0);
      78              :   }
      79            2 : }
      80              : } // namespace neml2
        

Generated by: LCOV version 2.0-1