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