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 "KokkosKernel.h" 11 : 12 : namespace Moose 13 : { 14 : namespace Kokkos 15 : { 16 : 17 : InputParameters 18 121036 : Kernel::validParams() 19 : { 20 121036 : InputParameters params = KernelBase::validParams(); 21 121036 : return params; 22 : } 23 : 24 1299 : Kernel::Kernel(const InputParameters & parameters) 25 : : KernelBase(parameters, Moose::VarFieldType::VAR_FIELD_STANDARD), 26 : _test(), 27 : _grad_test(), 28 : _phi(), 29 : _grad_phi(), 30 994 : _u(_var), 31 994 : _grad_u(_var) 32 : { 33 1299 : addMooseVariableDependency(&_var); 34 1299 : } 35 : 36 : void 37 54261 : Kernel::computeResidual() 38 : { 39 54261 : Policy policy(0, numKokkosBlockElements()); 40 : 41 54261 : if (!_residual_dispatcher) 42 1125 : _residual_dispatcher = DispatcherRegistry::build<ResidualLoop>(this, type()); 43 : 44 54261 : _residual_dispatcher->parallelFor(policy); 45 54261 : } 46 : 47 : void 48 9965 : Kernel::computeJacobian() 49 : { 50 9965 : if (DispatcherRegistry::hasUserMethod<JacobianLoop>(type())) 51 : { 52 8234 : Policy policy(0, numKokkosBlockElements()); 53 : 54 8234 : if (!_jacobian_dispatcher) 55 960 : _jacobian_dispatcher = DispatcherRegistry::build<JacobianLoop>(this, type()); 56 : 57 8234 : _jacobian_dispatcher->parallelFor(policy); 58 8234 : } 59 : 60 9965 : if (DispatcherRegistry::hasUserMethod<OffDiagJacobianLoop>(type())) 61 : { 62 48 : auto & sys = kokkosSystem(_kokkos_var.sys()); 63 : 64 96 : _thread.resize({sys.getCoupling(_kokkos_var.var()).size(), numKokkosBlockElements()}); 65 : 66 48 : Policy policy(0, _thread.size()); 67 : 68 48 : if (!_offdiag_jacobian_dispatcher) 69 27 : _offdiag_jacobian_dispatcher = DispatcherRegistry::build<OffDiagJacobianLoop>(this, type()); 70 : 71 48 : _offdiag_jacobian_dispatcher->parallelFor(policy); 72 48 : } 73 9965 : } 74 : 75 : } // namespace Kokkos 76 : } // namespace Moose