LCOV - code coverage report
Current view: top level - include/interfaces - GradientOperator.h (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #31405 (292dce) with base fef103 Lines: 15 15 100.0 %
Date: 2025-09-04 07:57:23 Functions: 2 2 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             : #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       77248 :   gradOp(unsigned int component, const RealVectorValue & g, const Real & v, const Point & p)
      24             :   {
      25  3462690670 :     RankTwoTensor G;
      26    11197958 :     this->addGradOp(G, component, g, v, p);
      27       77248 :     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 14676192148 :     for (auto j : make_range(3))
      44 11007144111 :       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    11942042 :   void addGradOp(RankTwoTensor & G,
      53             :                  unsigned int component,
      54             :                  const RealVectorValue & g,
      55             :                  const Real & v,
      56             :                  const Point & p)
      57             :   {
      58    35826126 :     for (auto j : make_range(2))
      59    23884084 :       G(component, j) += g(j);
      60             : 
      61             :     // R
      62    11942042 :     if (component == 0)
      63     5971021 :       G(2, 2) += v / p(0);
      64    11942042 :   }
      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      103578 :     G(0, 0) += g(0);
      78      103578 :     G(1, 1) += v / p(0);
      79      103578 :     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;

Generated by: LCOV version 1.14