LCOV - code coverage report
Current view: top level - models/porous_flow - BrooksCoreyCapillaryPressure.cxx (source / functions) Coverage Total Hit
Test: coverage.info Lines: 95.2 % 21 20
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/porous_flow/BrooksCoreyCapillaryPressure.h"
      26              : #include "neml2/tensors/functions/pow.h"
      27              : 
      28              : namespace neml2
      29              : {
      30              : register_NEML2_object(BrooksCoreyCapillaryPressure);
      31              : OptionSet
      32            2 : BrooksCoreyCapillaryPressure::expected_options()
      33              : {
      34            2 :   OptionSet options = CapillaryPressure::expected_options();
      35            2 :   options.doc() +=
      36              :       " using the Brooks Corey correlation taking the form of \\f$ P_c = P_t S_e^{-\\frac{1}{p}} "
      37              :       "\\f$. Here \\f$ S_e \\f$ is the effective saturation,\\f$ P_t \\f$ is the threshold "
      38            2 :       "pressure at zero saturation, and \\f$ p \\f$ is the shape parameter";
      39              : 
      40            4 :   options.set<bool>("define_second_derivatives") = true;
      41              : 
      42            4 :   options.set_parameter<TensorName<Scalar>>("threshold_pressure");
      43            4 :   options.set("threshold_pressure").doc() = "The threshold entry pressure";
      44              : 
      45            4 :   options.set_parameter<TensorName<Scalar>>("exponent");
      46            2 :   options.set("exponent").doc() = "The shape parameter p";
      47              : 
      48            2 :   return options;
      49            0 : }
      50              : 
      51            1 : BrooksCoreyCapillaryPressure::BrooksCoreyCapillaryPressure(const OptionSet & options)
      52              :   : CapillaryPressure(options),
      53            3 :     _Pt(declare_parameter<Scalar>("threshold", "threshold_pressure")),
      54            5 :     _p(declare_parameter<Scalar>("p", "exponent"))
      55              : {
      56            1 : }
      57              : 
      58              : std::tuple<Scalar, Scalar, Scalar>
      59            6 : BrooksCoreyCapillaryPressure::calculate_pressure(const Scalar & S,
      60              :                                                  bool out,
      61              :                                                  bool dout_din,
      62              :                                                  bool d2out_din2) const
      63              : {
      64            6 :   auto Pc = out ? _Pt * pow(S, -1.0 / _p) : Scalar();
      65            6 :   auto dPc_dS = dout_din ? -_Pt / _p * pow(S, -1.0 / _p - 1.0) : Scalar();
      66            6 :   auto d2Pc_dS2 = d2out_din2 ? -_Pt / _p * (-1.0 / _p - 1.0) * pow(S, -1.0 / _p - 2.0) : Scalar();
      67              : 
      68           12 :   return std::make_tuple(Pc, dPc_dS, d2Pc_dS2);
      69            6 : }
      70              : }
        

Generated by: LCOV version 2.0-1