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 : #pragma once 11 : 12 : #include "Moose.h" 13 : #include "MooseTypes.h" 14 : #include "libmesh/vector_value.h" 15 : #include "RankTwoTensor.h" 16 : 17 : template <class C> 18 : class GradientOperator : public C 19 : { 20 : protected: 21 : /// Returns the gradient operator in a given direction 22 : RankTwoTensor 23 70592 : gradOp(unsigned int component, const RealVectorValue & g, const Real & v, const Point & p) 24 : { 25 3053457512 : RankTwoTensor G; 26 8232248 : this->addGradOp(G, component, g, v, p); 27 70592 : return G; 28 : } 29 : }; 30 : 31 : namespace GradientOperatorCoordinates 32 : { 33 : class Cartesian 34 : { 35 : protected: 36 : /// Accumulate the contribution of the gradient operator in a given direction for a given tensor 37 : void addGradOp(RankTwoTensor & G, 38 : unsigned int component, 39 : const RealVectorValue & g, 40 : const Real & /*v*/, 41 : const Point & /*p*/) 42 : { 43 13186985248 : for (auto j : make_range(3)) 44 9890238936 : G(component, j) += g(j); 45 : } 46 : }; 47 : 48 : class AxisymmetricCylindrical 49 : { 50 : protected: 51 : /// Accumulate the contribution of the gradient operator in a given direction for a given tensor 52 8806984 : void addGradOp(RankTwoTensor & G, 53 : unsigned int component, 54 : const RealVectorValue & g, 55 : const Real & v, 56 : const Point & p) 57 : { 58 26420952 : for (auto j : make_range(2)) 59 17613968 : G(component, j) += g(j); 60 : 61 : // R 62 8806984 : if (component == 0) 63 4403492 : G(2, 2) += v / p(0); 64 8806984 : } 65 : }; 66 : 67 : class CentrosymmetricSpherical 68 : { 69 : protected: 70 : /// Accumulate the contribution of the gradient operator in a given direction for a given tensor 71 : void addGradOp(RankTwoTensor & G, 72 : unsigned int /*component*/, 73 : const RealVectorValue & g, 74 : const Real & v, 75 : const Point & p) 76 : { 77 94860 : G(0, 0) += g(0); 78 94860 : G(1, 1) += v / p(0); 79 94860 : G(2, 2) += v / p(0); 80 : } 81 : }; 82 : } 83 : 84 : typedef GradientOperator<GradientOperatorCoordinates::Cartesian> GradientOperatorCartesian; 85 : typedef GradientOperator<GradientOperatorCoordinates::AxisymmetricCylindrical> 86 : GradientOperatorAxisymmetricCylindrical; 87 : typedef GradientOperator<GradientOperatorCoordinates::CentrosymmetricSpherical> 88 : GradientOperatorCentrosymmetricSpherical;