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