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 "KernelBase.h" 11 : #include "Assembly.h" 12 : #include "MooseVariableFE.h" 13 : #include "Problem.h" 14 : #include "SubProblem.h" 15 : #include "SystemBase.h" 16 : #include "NonlinearSystem.h" 17 : 18 : #include "libmesh/threads.h" 19 : 20 : InputParameters 21 2446078 : KernelBase::validParams() 22 : { 23 2446078 : auto params = ResidualObject::validParams(); 24 2446078 : params += BlockRestrictable::validParams(); 25 2446078 : params += MaterialPropertyInterface::validParams(); 26 2446078 : params.registerSystemAttributeName("Kernel"); 27 : 28 2446078 : params.addParam<std::vector<AuxVariableName>>( 29 : "save_in", 30 : {}, 31 : "The name of auxiliary variables to save this Kernel's residual contributions to. " 32 : " Everything about that variable must match everything about this variable (the " 33 : "type, what blocks it's on, etc.)"); 34 2446078 : params.addParam<std::vector<AuxVariableName>>( 35 : "diag_save_in", 36 : {}, 37 : "The name of auxiliary variables to save this Kernel's diagonal Jacobian " 38 : "contributions to. Everything about that variable must match everything " 39 : "about this variable (the type, what blocks it's on, etc.)"); 40 : 41 7338234 : params.addParam<bool>("use_displaced_mesh", 42 4892156 : false, 43 : "Whether or not this object should use the " 44 : "displaced mesh for computation. Note that in " 45 : "the case this is true but no displacements " 46 : "are provided in the Mesh block the " 47 : "undisplaced mesh will still be used."); 48 : 49 2446078 : params.addParamNamesToGroup("diag_save_in save_in use_displaced_mesh", "Advanced"); 50 2446078 : params.addCoupledVar("displacements", "The displacements"); 51 : 52 : // Kernels always couple within their element 53 2446078 : params.addRelationshipManager("ElementSideNeighborLayers", 54 : Moose::RelationshipManagerType::COUPLING, 55 0 : [](const InputParameters &, InputParameters & rm_params) 56 230125 : { rm_params.set<unsigned short>("layers") = 0; }); 57 2446078 : return params; 58 0 : } 59 : 60 84801 : KernelBase::KernelBase(const InputParameters & parameters) 61 : : ResidualObject(parameters), 62 : BlockRestrictable(this), 63 : CoupleableMooseVariableDependencyIntermediateInterface(this, false), 64 : MaterialPropertyInterface(this, blockIDs(), Moose::EMPTY_BOUNDARY_IDS), 65 : GeometricSearchInterface(this), 66 : ElementIDInterface(this), 67 169498 : _current_elem(_assembly.elem()), 68 84749 : _current_elem_volume(_assembly.elemVolume()), 69 84749 : _q_point(_assembly.qPoints()), 70 84749 : _qrule(_assembly.qRule()), 71 84749 : _JxW(_assembly.JxW()), 72 84749 : _coord(_assembly.coordTransformation()), 73 84749 : _has_save_in(false), 74 84749 : _save_in_strings(parameters.get<std::vector<AuxVariableName>>("save_in")), 75 84749 : _has_diag_save_in(false), 76 84749 : _diag_save_in_strings(parameters.get<std::vector<AuxVariableName>>("diag_save_in")), 77 339048 : _use_displaced_mesh(getParam<bool>("use_displaced_mesh")) 78 : { 79 84749 : auto num_disp = coupledComponents("displacements"); 80 86762 : for (decltype(num_disp) i = 0; i < num_disp; ++i) 81 2013 : _displacements.push_back(coupled("displacements", i)); 82 84749 : }