LCOV - code coverage report
Current view: top level - src/postprocessors - AsymptoticExpansionHomogenizationElasticConstants.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 79 84 94.0 %
Date: 2025-07-25 05:00:39 Functions: 7 8 87.5 %
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 "AsymptoticExpansionHomogenizationElasticConstants.h"
      11             : #include "MooseMesh.h"
      12             : 
      13             : registerMooseObject("SolidMechanicsApp", AsymptoticExpansionHomogenizationElasticConstants);
      14             : 
      15             : InputParameters
      16         120 : AsymptoticExpansionHomogenizationElasticConstants::validParams()
      17             : {
      18         120 :   InputParameters params = ElementIntegralPostprocessor::validParams();
      19         120 :   params.addClassDescription(
      20             :       "Postprocessor for asymptotic expansion homogenization for elasticity");
      21         240 :   params.addRequiredCoupledVar("dx_xx", "solution in xx");
      22         240 :   params.addRequiredCoupledVar("dy_xx", "solution in xx");
      23         240 :   params.addCoupledVar("dz_xx", "solution in xx");
      24         240 :   params.addRequiredCoupledVar("dx_yy", "solution in yy");
      25         240 :   params.addRequiredCoupledVar("dy_yy", "solution in yy");
      26         240 :   params.addCoupledVar("dz_yy", "solution in yy");
      27         240 :   params.addCoupledVar("dx_zz", "solution in zz");
      28         240 :   params.addCoupledVar("dy_zz", "solution in zz");
      29         240 :   params.addCoupledVar("dz_zz", "solution in zz");
      30         240 :   params.addRequiredCoupledVar("dx_xy", "solution in xy");
      31         240 :   params.addRequiredCoupledVar("dy_xy", "solution in xy");
      32         240 :   params.addCoupledVar("dz_xy", "solution in xy");
      33         240 :   params.addCoupledVar("dx_yz", "solution in yz");
      34         240 :   params.addCoupledVar("dy_yz", "solution in yz");
      35         240 :   params.addCoupledVar("dz_yz", "solution in yz");
      36         240 :   params.addCoupledVar("dx_zx", "solution in zx");
      37         240 :   params.addCoupledVar("dy_zx", "solution in zx");
      38         240 :   params.addCoupledVar("dz_zx", "solution in zx");
      39         240 :   params.addParam<std::string>("base_name",
      40             :                                "Optional parameter that allows the user to define "
      41             :                                "multiple mechanics material systems on the same "
      42             :                                "block, i.e. for multiple phases");
      43         240 :   MooseEnum column("xx yy zz yz xz xy");
      44         240 :   params.addRequiredParam<MooseEnum>("column",
      45             :                                      column,
      46             :                                      "The column of the material matrix this kernel acts in. "
      47             :                                      "(xx, yy, zz, yz, xz, or xy)");
      48         240 :   params.addRequiredParam<MooseEnum>("row",
      49             :                                      column,
      50             :                                      "The row of the material matrix this kernel acts in. "
      51             :                                      "(xx, yy, zz, yz, xz, or xy)");
      52         120 :   return params;
      53         120 : }
      54             : 
      55          60 : AsymptoticExpansionHomogenizationElasticConstants::
      56          60 :     AsymptoticExpansionHomogenizationElasticConstants(const InputParameters & parameters)
      57             :   : ElementIntegralPostprocessor(parameters),
      58         180 :     _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
      59          60 :     _grad({{{{&coupledGradient("dx_xx"),
      60         120 :               &coupledGradient("dy_xx"),
      61         120 :               (_subproblem.mesh().dimension() == 3 ? &coupledGradient("dz_xx") : &_grad_zero)}},
      62         120 :             {{&coupledGradient("dx_yy"),
      63         120 :               &coupledGradient("dy_yy"),
      64         120 :               (_subproblem.mesh().dimension() == 3 ? &coupledGradient("dz_yy") : &_grad_zero)}},
      65         120 :             {{(_subproblem.mesh().dimension() == 3 ? &coupledGradient("dx_zz") : &_grad_zero),
      66         120 :               (_subproblem.mesh().dimension() == 3 ? &coupledGradient("dy_zz") : &_grad_zero),
      67         120 :               (_subproblem.mesh().dimension() == 3 ? &coupledGradient("dz_zz") : &_grad_zero)}},
      68         120 :             {{(_subproblem.mesh().dimension() == 3 ? &coupledGradient("dx_yz") : &_grad_zero),
      69         120 :               (_subproblem.mesh().dimension() == 3 ? &coupledGradient("dy_yz") : &_grad_zero),
      70         120 :               (_subproblem.mesh().dimension() == 3 ? &coupledGradient("dz_yz") : &_grad_zero)}},
      71         120 :             {{(_subproblem.mesh().dimension() == 3 ? &coupledGradient("dx_zx") : &_grad_zero),
      72         120 :               (_subproblem.mesh().dimension() == 3 ? &coupledGradient("dy_zx") : &_grad_zero),
      73         120 :               (_subproblem.mesh().dimension() == 3 ? &coupledGradient("dz_zx") : &_grad_zero)}},
      74         120 :             {{(&coupledGradient("dx_xy")),
      75         120 :               (&coupledGradient("dy_xy")),
      76          60 :               (_subproblem.mesh().dimension() == 3 ? &coupledGradient("dz_xy") : &_grad_zero)}}}}),
      77         120 :     _elasticity_tensor(getMaterialPropertyByName<RankFourTensor>(_base_name + "elasticity_tensor")),
      78         120 :     _column(getParam<MooseEnum>("column")),
      79         120 :     _row(getParam<MooseEnum>("row")),
      80          60 :     _ik_index({{0, 1, 2, 1, 0, 0}}),
      81          60 :     _jl_index({{0, 1, 2, 2, 2, 1}}),
      82          60 :     _i(_ik_index[_row]),
      83          60 :     _j(_jl_index[_row]),
      84          60 :     _k(_ik_index[_column]),
      85          60 :     _l(_jl_index[_column]),
      86          60 :     _volume(0),
      87          60 :     _integral_value(0)
      88             : {
      89          60 : }
      90             : 
      91             : void
      92         120 : AsymptoticExpansionHomogenizationElasticConstants::initialize()
      93             : {
      94         120 :   _integral_value = 0;
      95         120 :   _volume = 0;
      96         120 : }
      97             : 
      98             : void
      99       20480 : AsymptoticExpansionHomogenizationElasticConstants::execute()
     100             : {
     101       20480 :   _integral_value += computeIntegral();
     102       20480 :   _volume += _current_elem_volume;
     103       20480 : }
     104             : 
     105             : Real
     106         120 : AsymptoticExpansionHomogenizationElasticConstants::getValue() const
     107             : {
     108         120 :   return (_integral_value / _volume);
     109             : }
     110             : 
     111             : void
     112         120 : AsymptoticExpansionHomogenizationElasticConstants::finalize()
     113             : {
     114         120 :   gatherSum(_integral_value);
     115         120 :   gatherSum(_volume);
     116         120 : }
     117             : 
     118             : void
     119           0 : AsymptoticExpansionHomogenizationElasticConstants::threadJoin(const UserObject & y)
     120             : {
     121             :   const AsymptoticExpansionHomogenizationElasticConstants & pps =
     122           0 :       dynamic_cast<const AsymptoticExpansionHomogenizationElasticConstants &>(y);
     123             : 
     124           0 :   _integral_value += pps._integral_value;
     125           0 :   _volume += pps._volume;
     126           0 : }
     127             : 
     128             : Real
     129       81920 : AsymptoticExpansionHomogenizationElasticConstants::computeQpIntegral()
     130             : {
     131             :   Real value = 0;
     132      327680 :   for (unsigned p = 0; p < 3; ++p)
     133      983040 :     for (unsigned q = 0; q < 3; ++q)
     134      737280 :       value += _elasticity_tensor[_qp](_i, _j, p, q) * (*_grad[_column][p])[_qp](q);
     135             : 
     136       81920 :   return _elasticity_tensor[_qp](_i, _j, _k, _l) + value;
     137             : }

Generated by: LCOV version 1.14