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