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 "HomogenizedTotalLagrangianStressDivergence.h" 11 : 12 : registerMooseObject("SolidMechanicsApp", HomogenizedTotalLagrangianStressDivergence); 13 : 14 : InputParameters 15 708 : HomogenizedTotalLagrangianStressDivergence::validParams() 16 : { 17 708 : InputParameters params = TotalLagrangianStressDivergence::validParams(); 18 708 : params.addClassDescription("Total Lagrangian stress equilibrium kernel with " 19 : "homogenization constraint Jacobian terms"); 20 1416 : params.addRequiredCoupledVar("macro_gradient", "Optional scalar field with the macro gradient"); 21 1416 : params.addRequiredParam<UserObjectName>("homogenization_constraint", 22 : "The UserObject defining the homogenization constraint"); 23 : 24 708 : return params; 25 0 : } 26 : 27 354 : HomogenizedTotalLagrangianStressDivergence::HomogenizedTotalLagrangianStressDivergence( 28 354 : const InputParameters & parameters) 29 : : TotalLagrangianStressDivergence(parameters), 30 354 : _macro_gradient_num(coupledScalar("macro_gradient")), 31 354 : _constraint(getUserObject<HomogenizationConstraint>("homogenization_constraint")), 32 708 : _cmap(_constraint.getConstraintMap()) 33 : { 34 354 : } 35 : 36 : void 37 124784 : HomogenizedTotalLagrangianStressDivergence::computeOffDiagJacobianScalar(unsigned int jvar) 38 : { 39 124784 : if (jvar == _macro_gradient_num) 40 : { 41 124784 : prepareMatrixTag(_assembly, _var.number(), jvar, _ken); 42 124784 : prepareMatrixTag(_assembly, jvar, _var.number(), _kne); 43 : 44 929456 : for (_qp = 0; _qp < _qrule->n_points(); _qp++) 45 : { 46 804672 : const Real dV = _JxW[_qp] * _coord[_qp]; 47 : unsigned int h = 0; 48 6439808 : for (auto && [indices, constraint] : _cmap) 49 : { 50 : auto && [i, j] = indices; 51 : auto && ctype = constraint.first; 52 48297024 : for (_i = 0; _i < _test.size(); _i++) 53 : { 54 : // This assumes Galerkin, i.e. the test and trial functions are the same 55 42661888 : _j = _i; 56 : 57 : // Base Jacobian 58 42661888 : _ken(_i, h) += _dpk1[_qp].contractionKl(i, j, gradTest(_alpha)) * dV; 59 : 60 : // Constraint Jacobian 61 42661888 : if (ctype == Homogenization::ConstraintType::Stress) 62 14917248 : _kne(h, _i) += _dpk1[_qp].contractionIj(i, j, gradTrial(_alpha)) * dV; 63 27744640 : else if (ctype == Homogenization::ConstraintType::Strain) 64 27744640 : if (_large_kinematics) 65 39154240 : _kne(h, _i) += Real(i == _alpha) * gradTrial(_alpha)(i, j) * dV; 66 : else 67 4155456 : _kne(h, _i) += 0.5 * 68 11026816 : (Real(i == _alpha) * gradTrial(_alpha)(i, j) + 69 6871360 : Real(j == _alpha) * gradTrial(_alpha)(j, i)) * 70 : dV; 71 : else 72 0 : mooseError("Unknown constraint type in kernel calculation!"); 73 : } 74 5635136 : h++; 75 : } 76 : } 77 124784 : accumulateTaggedLocalMatrix(_assembly, _var.number(), jvar, _ken); 78 124784 : accumulateTaggedLocalMatrix(_assembly, jvar, _var.number(), _kne); 79 : } 80 124784 : }