LCOV - code coverage report
Current view: top level - src/kernels - MomentBalancing.C (source / functions) Hit Total Coverage
Test: idaholab/moose tensor_mechanics: d6b47a Lines: 43 46 93.5 %
Date: 2024-02-27 11:53:14 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://www.mooseframework.org
       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 "MomentBalancing.h"
      11             : 
      12             : // MOOSE includes
      13             : #include "ElasticityTensorTools.h"
      14             : #include "Material.h"
      15             : #include "MooseVariable.h"
      16             : #include "PermutationTensor.h"
      17             : #include "RankFourTensor.h"
      18             : #include "RankTwoTensor.h"
      19             : 
      20             : registerMooseObject("TensorMechanicsApp", MomentBalancing);
      21             : 
      22             : InputParameters
      23         591 : MomentBalancing::validParams()
      24             : {
      25         591 :   InputParameters params = Kernel::validParams();
      26        1182 :   params.addRequiredRangeCheckedParam<unsigned int>(
      27             :       "component",
      28             :       "component<3",
      29             :       "An integer corresponding to the direction the variable this "
      30             :       "kernel acts in. (0 for x, 1 for y, 2 for z)");
      31        1182 :   params.addParam<std::string>(
      32             :       "appended_property_name", "", "Name appended to material properties to make them unique");
      33        1182 :   params.addRequiredCoupledVar("Cosserat_rotations", "The 3 Cosserat rotation variables");
      34        1182 :   params.addRequiredCoupledVar("displacements", "The 3 displacement variables");
      35         591 :   params.set<bool>("use_displaced_mesh") = false;
      36             : 
      37         591 :   return params;
      38           0 : }
      39             : 
      40         295 : MomentBalancing::MomentBalancing(const InputParameters & parameters)
      41             :   : Kernel(parameters),
      42         590 :     _stress(getMaterialProperty<RankTwoTensor>("stress" +
      43             :                                                getParam<std::string>("appended_property_name"))),
      44         295 :     _Jacobian_mult(getMaterialProperty<RankFourTensor>(
      45         590 :         "Jacobian_mult" + getParam<std::string>("appended_property_name"))),
      46         590 :     _component(getParam<unsigned int>("component")),
      47         295 :     _nrots(coupledComponents("Cosserat_rotations")),
      48         295 :     _wc_var(_nrots),
      49         295 :     _ndisp(coupledComponents("displacements")),
      50         590 :     _disp_var(_ndisp)
      51             : {
      52         295 :   if (_nrots != 3)
      53           0 :     mooseError("MomentBalancing: This Kernel is only defined for 3-dimensional simulations so 3 "
      54             :                "Cosserat rotation variables are needed");
      55        1180 :   for (unsigned i = 0; i < _nrots; ++i)
      56         885 :     _wc_var[i] = coupled("Cosserat_rotations", i);
      57             : 
      58         295 :   if (_ndisp != 3)
      59           0 :     mooseError("MomentBalancing: This Kernel is only defined for 3-dimensional simulations so 3 "
      60             :                "displacement variables are needed");
      61        1180 :   for (unsigned i = 0; i < _ndisp; ++i)
      62         885 :     _disp_var[i] = coupled("displacements", i);
      63             : 
      64             :   // Following check is necessary to ensure the correct Jacobian is calculated
      65         295 :   if (_wc_var[_component] != _var.number())
      66           1 :     mooseError("MomentBalancing: The variable for this Kernel must be equal to the Cosserat "
      67             :                "rotation variable defined by the \"component\" and the \"Cosserat_rotations\" "
      68             :                "parameters");
      69         294 : }
      70             : 
      71             : Real
      72     1045248 : MomentBalancing::computeQpResidual()
      73             : {
      74             :   Real the_sum = 0.0;
      75     4180992 :   for (const auto j : make_range(Moose::dim))
      76    12542976 :     for (const auto k : make_range(Moose::dim))
      77     9407232 :       the_sum += PermutationTensor::eps(_component, j, k) * _stress[_qp](j, k);
      78     1045248 :   return _test[_i][_qp] * the_sum;
      79             : }
      80             : 
      81             : Real
      82     2619392 : MomentBalancing::computeQpJacobian()
      83             : {
      84     2619392 :   return ElasticityTensorTools::momentJacobianWC(
      85     2619392 :       _Jacobian_mult[_qp], _component, _component, _test[_i][_qp], _phi[_j][_qp]);
      86             : }
      87             : 
      88             : Real
      89     8767488 : MomentBalancing::computeQpOffDiagJacobian(unsigned int jvar)
      90             : {
      91             :   // What does 2D look like here?
      92    22947840 :   for (unsigned v = 0; v < _ndisp; ++v)
      93    20840448 :     if (jvar == _disp_var[v])
      94     6660096 :       return ElasticityTensorTools::momentJacobian(
      95     6660096 :           _Jacobian_mult[_qp], _component, v, _test[_i][_qp], _grad_phi[_j][_qp]);
      96             : 
      97             :   // What does 2D look like here?
      98     3929088 :   for (unsigned v = 0; v < _nrots; ++v)
      99     3929088 :     if (jvar == _wc_var[v])
     100     2107392 :       return ElasticityTensorTools::momentJacobianWC(
     101     2107392 :           _Jacobian_mult[_qp], _component, v, _test[_i][_qp], _phi[_j][_qp]);
     102             : 
     103             :   return 0.0;
     104             : }

Generated by: LCOV version 1.14