LCOV - code coverage report
Current view: top level - src/materials - DerivativeMaterialPropertyNameInterface.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 29 29 100.0 %
Date: 2025-07-17 01:28:37 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #include "DerivativeMaterialPropertyNameInterface.h"
      11             : 
      12             : #include <sstream>
      13             : #include <algorithm>
      14             : 
      15             : const MaterialPropertyName
      16       35058 : DerivativeMaterialPropertyNameInterface::derivativePropertyName(
      17             :     const MaterialPropertyName & base, const std::vector<SymbolName> & c) const
      18             : {
      19             :   // to obtain well defined names we sort alphabetically
      20       35058 :   std::vector<SymbolName> a(c);
      21       35058 :   std::sort(a.begin(), a.end());
      22             : 
      23             :   // derivative order
      24       35058 :   unsigned int order = a.size();
      25       35058 :   if (order == 0)
      26        4691 :     return base;
      27             : 
      28             :   // build the property name as a stringstream
      29       30367 :   std::stringstream name;
      30             : 
      31             :   // build numerator
      32       30367 :   name << 'd';
      33       30367 :   if (order > 1)
      34       12798 :     name << '^' << order;
      35       30367 :   name << base << '/';
      36             : 
      37             :   // build denominator with 'pretty' names using exponents rather than repeat multiplication
      38       30367 :   unsigned int exponent = 1;
      39       81758 :   for (unsigned i = 1; i <= order; ++i)
      40             :   {
      41       51391 :     if (i == order || a[i - 1] != a[i])
      42             :     {
      43       33400 :       name << 'd' << a[i - 1];
      44       33400 :       if (exponent > 1)
      45       10923 :         name << '^' << exponent;
      46       33400 :       exponent = 1;
      47             :     }
      48             :     else
      49       17991 :       exponent++;
      50             :   }
      51             : 
      52       60734 :   return name.str();
      53       35058 : }
      54             : 
      55             : const MaterialPropertyName
      56        4723 : DerivativeMaterialPropertyNameInterface::derivativePropertyNameFirst(
      57             :     const MaterialPropertyName & base, const SymbolName & c1) const
      58             : {
      59        9446 :   return "d" + base + "/d" + c1;
      60             : }
      61             : 
      62             : const MaterialPropertyName
      63        2229 : DerivativeMaterialPropertyNameInterface::derivativePropertyNameSecond(
      64             :     const MaterialPropertyName & base, const SymbolName & c1, const SymbolName & c2) const
      65             : {
      66        6687 :   return derivativePropertyName(base, {c1, c2});
      67        2229 : }
      68             : 
      69             : const MaterialPropertyName
      70         984 : DerivativeMaterialPropertyNameInterface::derivativePropertyNameThird(
      71             :     const MaterialPropertyName & base,
      72             :     const SymbolName & c1,
      73             :     const SymbolName & c2,
      74             :     const SymbolName & c3) const
      75             : {
      76        3936 :   return derivativePropertyName(base, {c1, c2, c3});
      77         984 : }

Generated by: LCOV version 1.14