LCOV - code coverage report
Current view: top level - models/solid_mechanics - VolumeAdjustDeformationGradient.cxx (source / functions) Coverage Total Hit
Test: coverage.info Lines: 96.6 % 29 28
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/VolumeAdjustDeformationGradient.h"
      26              : #include "neml2/tensors/R2.h"
      27              : #include "neml2/tensors/Scalar.h"
      28              : #include "neml2/tensors/functions/pow.h"
      29              : 
      30              : namespace neml2
      31              : {
      32              : register_NEML2_object(VolumeAdjustDeformationGradient);
      33              : 
      34              : OptionSet
      35            2 : VolumeAdjustDeformationGradient::expected_options()
      36              : {
      37            2 :   OptionSet options = Model::expected_options();
      38            2 :   options.doc() = "Calculate the volume-adjusted deformation gradient, i.e. \\f$ F_e = "
      39              :                   "J^{-\\frac{1}/{3}} F \\f$, where \\f$ F \\f$ is the pre-adjusted deformation "
      40              :                   "gradient and \\f$ J \\f$ is the total jacobian of the volumetric deformation "
      41            2 :                   "gradients to be removed.";
      42              : 
      43            4 :   options.set_input("input");
      44            4 :   options.set("input").doc() = "Input deformation gradient";
      45              : 
      46            4 :   options.set_input("jacobian");
      47            6 :   options.set("jacobian").doc() =
      48            2 :       "The jacobian that controls the volume adjustment of the input deformation gradient";
      49              : 
      50            4 :   options.set_output("output");
      51            2 :   options.set("output").doc() = "Output adjusted deformation gradient";
      52              : 
      53            2 :   return options;
      54            0 : }
      55              : 
      56            1 : VolumeAdjustDeformationGradient::VolumeAdjustDeformationGradient(const OptionSet & options)
      57              :   : Model(options),
      58            1 :     _F(declare_input_variable<R2>("input")),
      59            1 :     _J(declare_input_variable<Scalar>("jacobian")),
      60            2 :     _Fe(declare_output_variable<R2>("output"))
      61              : {
      62            1 : }
      63              : 
      64              : void
      65            2 : VolumeAdjustDeformationGradient::set_value(bool out, bool dout_din, bool /*d2out_din2*/)
      66              : {
      67            2 :   if (out)
      68            1 :     _Fe = _F * pow(_J, -1.0 / 3.0);
      69              : 
      70            2 :   if (dout_din)
      71              :   {
      72            1 :     if (_J.is_dependent())
      73            1 :       _Fe.d(_J) = _F * -1.0 / 3.0 * pow(_J, -4.0 / 3.0);
      74              : 
      75            1 :     if (_F.is_dependent())
      76              :     {
      77            1 :       auto I = R2::identity_map(_F.options());
      78            1 :       _Fe.d(_F) = pow(_J, -1.0 / 3.0) * I;
      79            1 :     }
      80              :   }
      81            2 : }
      82              : } // namespace neml2
        

Generated by: LCOV version 2.0-1