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 37841 : DerivativeMaterialPropertyNameInterface::derivativePropertyName( 17 : const MaterialPropertyName & base, const std::vector<SymbolName> & c) const 18 : { 19 : // to obtain well defined names we sort alphabetically 20 37841 : std::vector<SymbolName> a(c); 21 37841 : std::sort(a.begin(), a.end()); 22 : 23 : // derivative order 24 37841 : unsigned int order = a.size(); 25 37841 : if (order == 0) 26 5009 : return base; 27 : 28 : // build the property name as a stringstream 29 32832 : std::stringstream name; 30 : 31 : // build numerator 32 32832 : name << 'd'; 33 32832 : if (order > 1) 34 13884 : name << '^' << order; 35 32832 : name << base << '/'; 36 : 37 : // build denominator with 'pretty' names using exponents rather than repeat multiplication 38 32832 : unsigned int exponent = 1; 39 88509 : for (unsigned i = 1; i <= order; ++i) 40 : { 41 55677 : if (i == order || a[i - 1] != a[i]) 42 : { 43 36102 : name << 'd' << a[i - 1]; 44 36102 : if (exponent > 1) 45 11862 : name << '^' << exponent; 46 36102 : exponent = 1; 47 : } 48 : else 49 19575 : exponent++; 50 : } 51 : 52 65664 : return name.str(); 53 37841 : } 54 : 55 : const MaterialPropertyName 56 5019 : DerivativeMaterialPropertyNameInterface::derivativePropertyNameFirst( 57 : const MaterialPropertyName & base, const SymbolName & c1) const 58 : { 59 10038 : return "d" + base + "/d" + c1; 60 : } 61 : 62 : const MaterialPropertyName 63 2409 : DerivativeMaterialPropertyNameInterface::derivativePropertyNameSecond( 64 : const MaterialPropertyName & base, const SymbolName & c1, const SymbolName & c2) const 65 : { 66 7227 : return derivativePropertyName(base, {c1, c2}); 67 2409 : } 68 : 69 : const MaterialPropertyName 70 1068 : DerivativeMaterialPropertyNameInterface::derivativePropertyNameThird( 71 : const MaterialPropertyName & base, 72 : const SymbolName & c1, 73 : const SymbolName & c2, 74 : const SymbolName & c3) const 75 : { 76 4272 : return derivativePropertyName(base, {c1, c2, c3}); 77 1068 : }