LCOV - code coverage report
Current view: top level - src/materials - ComputeCosseratIncrementalSmallStrain.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 45 47 95.7 %
Date: 2025-07-25 05:00:39 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 "ComputeCosseratIncrementalSmallStrain.h"
      11             : 
      12             : // MOOSE includes
      13             : #include "PermutationTensor.h"
      14             : 
      15             : #include "libmesh/quadrature.h"
      16             : 
      17             : registerMooseObject("SolidMechanicsApp", ComputeCosseratIncrementalSmallStrain);
      18             : 
      19             : InputParameters
      20         696 : ComputeCosseratIncrementalSmallStrain::validParams()
      21             : {
      22         696 :   InputParameters params = ComputeIncrementalStrainBase::validParams();
      23         696 :   params.addClassDescription("Compute incremental small Cosserat strains");
      24        1392 :   params.addRequiredCoupledVar("Cosserat_rotations", "The 3 Cosserat rotation variables");
      25         696 :   return params;
      26           0 : }
      27             : 
      28         522 : ComputeCosseratIncrementalSmallStrain::ComputeCosseratIncrementalSmallStrain(
      29         522 :     const InputParameters & parameters)
      30             :   : ComputeIncrementalStrainBase(parameters),
      31         522 :     _curvature(declareProperty<RankTwoTensor>("curvature")),
      32         522 :     _nrots(coupledComponents("Cosserat_rotations")),
      33         522 :     _wc(coupledValues("Cosserat_rotations")),
      34         522 :     _wc_old(coupledValuesOld("Cosserat_rotations")),
      35         522 :     _grad_wc(coupledGradients("Cosserat_rotations")),
      36         522 :     _grad_wc_old(coupledGradientsOld("Cosserat_rotations")),
      37        1044 :     _curvature_old(getMaterialPropertyOld<RankTwoTensor>("curvature")),
      38        1044 :     _curvature_increment(declareProperty<RankTwoTensor>("curvature_increment"))
      39             : {
      40         522 :   if (_nrots != 3)
      41           0 :     mooseError("ComputeCosseratSmallStrain: This Material is only defined for 3-dimensional "
      42             :                "simulations so 3 Cosserat rotation variables are needed");
      43         522 : }
      44             : 
      45             : void
      46       82688 : ComputeCosseratIncrementalSmallStrain::initQpStatefulProperties()
      47             : {
      48       82688 :   ComputeIncrementalStrainBase::initQpStatefulProperties();
      49             : 
      50       82688 :   _curvature[_qp].zero();
      51       82688 : }
      52             : 
      53             : void
      54      193056 : ComputeCosseratIncrementalSmallStrain::computeQpProperties()
      55             : {
      56             :   auto strain = RankTwoTensor::initializeFromRows(
      57      193056 :       (*_grad_disp[0])[_qp], (*_grad_disp[1])[_qp], (*_grad_disp[2])[_qp]);
      58             :   auto strain_old = RankTwoTensor::initializeFromRows(
      59      193056 :       (*_grad_disp_old[0])[_qp], (*_grad_disp_old[1])[_qp], (*_grad_disp_old[2])[_qp]);
      60      193056 :   RealVectorValue wc_vector((*_wc[0])[_qp], (*_wc[1])[_qp], (*_wc[2])[_qp]);
      61      193056 :   RealVectorValue wc_vector_old((*_wc_old[0])[_qp], (*_wc_old[1])[_qp], (*_wc_old[2])[_qp]);
      62             : 
      63      772224 :   for (unsigned i = 0; i < LIBMESH_DIM; ++i)
      64     2316672 :     for (unsigned j = 0; j < LIBMESH_DIM; ++j)
      65     6950016 :       for (unsigned k = 0; k < LIBMESH_DIM; ++k)
      66             :       {
      67     5212512 :         strain(i, j) += PermutationTensor::eps(i, j, k) * wc_vector(k);
      68     5212512 :         strain_old(i, j) += PermutationTensor::eps(i, j, k) * wc_vector_old(k);
      69             :       }
      70             : 
      71             :   // Gauss point deformation gradient
      72      193056 :   _deformation_gradient[_qp] = strain;
      73      193056 :   _deformation_gradient[_qp].addIa(1.0);
      74             : 
      75      193056 :   const RankTwoTensor total_strain_increment = strain - strain_old;
      76             : 
      77      193056 :   _strain_increment[_qp] = total_strain_increment;
      78             : 
      79             :   // Remove the eigenstrain increment
      80      193056 :   subtractEigenstrainIncrementFromStrain(_strain_increment[_qp]);
      81             : 
      82      193056 :   _strain_rate[_qp] = _strain_increment[_qp] / _dt;
      83             : 
      84      193056 :   _total_strain[_qp] = _total_strain_old[_qp] + total_strain_increment;
      85      193056 :   _mechanical_strain[_qp] = _mechanical_strain_old[_qp] + _strain_increment[_qp];
      86             : 
      87             :   auto curv = RankTwoTensor::initializeFromRows(
      88      193056 :       (*_grad_wc[0])[_qp], (*_grad_wc[1])[_qp], (*_grad_wc[2])[_qp]);
      89             :   auto curv_old = RankTwoTensor::initializeFromRows(
      90      193056 :       (*_grad_wc_old[0])[_qp], (*_grad_wc_old[1])[_qp], (*_grad_wc_old[2])[_qp]);
      91      193056 :   _curvature_increment[_qp] = curv - curv_old;
      92      193056 :   _curvature[_qp] = _curvature_old[_qp] + _curvature_increment[_qp];
      93             : 
      94             :   // incremental small strain does not include rotation
      95      193056 :   _rotation_increment[_qp].setToIdentity();
      96      193056 : }

Generated by: LCOV version 1.14