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 : //* This file is part of the MOOSE framework 11 : //* https://www.mooseframework.org 12 : //* 13 : //* All rights reserved, see COPYRIGHT for full restrictions 14 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 15 : //* 16 : //* Licensed under LGPL 2.1, please see LICENSE for details 17 : //* https://www.gnu.org/licenses/lgpl-2.1.html 18 : 19 : #include "HomogenizationConstraintScalarKernel.h" 20 : 21 : // MOOSE includes 22 : #include "Assembly.h" 23 : #include "MooseVariableScalar.h" 24 : #include "Function.h" 25 : 26 : registerMooseObject("TensorMechanicsApp", HomogenizationConstraintScalarKernel); 27 : 28 : InputParameters 29 148 : HomogenizationConstraintScalarKernel::validParams() 30 : { 31 148 : InputParameters params = ScalarKernel::validParams(); 32 296 : params.addRequiredParam<UserObjectName>("homogenization_constraint", 33 : "The UserObject defining the homogenization constraint"); 34 : 35 148 : return params; 36 0 : } 37 : 38 74 : HomogenizationConstraintScalarKernel::HomogenizationConstraintScalarKernel( 39 74 : const InputParameters & parameters) 40 : : ScalarKernel(parameters), 41 74 : _constraint(getUserObject<HomogenizationConstraint>("homogenization_constraint")), 42 74 : _residual(_constraint.getResidual()), 43 74 : _jacobian(_constraint.getJacobian()), 44 148 : _cmap(_constraint.getConstraintMap()) 45 : { 46 74 : if (_var.order() != _cmap.size()) 47 0 : mooseError("Homogenization kernel requires a variable of order ", _cmap.size()); 48 74 : } 49 : 50 : void 51 12282 : HomogenizationConstraintScalarKernel::reinit() 52 : { 53 12282 : } 54 : 55 : void 56 8206 : HomogenizationConstraintScalarKernel::computeResidual() 57 : { 58 8206 : prepareVectorTag(_assembly, _var.number()); 59 8206 : _i = 0; 60 65946 : for (auto && indices : _cmap) 61 : { 62 : auto && [i, j] = indices.first; 63 57740 : _local_re(_i++) += _residual(i, j); 64 : } 65 8206 : accumulateTaggedLocalResidual(); 66 8206 : } 67 : 68 : void 69 342 : HomogenizationConstraintScalarKernel::computeJacobian() 70 : { 71 342 : prepareMatrixTag(_assembly, _var.number(), _var.number()); 72 342 : _i = 0; 73 1902 : for (auto && indices1 : _cmap) 74 : { 75 : auto && [i, j] = indices1.first; 76 1560 : _j = 0; 77 12132 : for (auto && indices2 : _cmap) 78 : { 79 : auto && [a, b] = indices2.first; 80 10572 : _local_ke(_i, _j++) += _jacobian(i, j, a, b); 81 : } 82 1560 : _i++; 83 : } 84 342 : accumulateTaggedLocalMatrix(); 85 342 : }