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 : #pragma once 11 : 12 : #include "KokkosLinearFVBoundaryCondition.h" 13 : #include "KokkosParsedFunction.h" 14 : 15 : /** 16 : * Provides Dirichlet boundary value and normal-gradient relations for Kokkos linear finite volume 17 : * kernels. The boundary value is supplied through a Kokkos-compatible functor. 18 : */ 19 : class KokkosLinearFVFunctorDirichletBC : public Moose::Kokkos::LinearFVBoundaryCondition 20 : { 21 : public: 22 : static InputParameters validParams(); 23 : 24 : KokkosLinearFVFunctorDirichletBC(const InputParameters & parameters); 25 : 26 : template <typename Derived> 27 : KOKKOS_FUNCTION BoundaryRelation computeBoundaryValue(const FVDatum & datum) const; 28 : template <typename Derived> 29 : KOKKOS_FUNCTION BoundaryRelation computeBoundaryNormalGradient(const FVDatum & datum) const; 30 : 31 : private: 32 : /// The functor providing the Dirichlet value on the boundary 33 : const Moose::Kokkos::ReferenceWrapper<const KokkosParsedFunction> _functor; 34 : }; 35 : 36 : template <typename Derived> 37 : KOKKOS_FUNCTION KokkosLinearFVFunctorDirichletBC::BoundaryRelation 38 14 : KokkosLinearFVFunctorDirichletBC::computeBoundaryValue(const FVDatum & datum) const 39 : { 40 14 : return {0, _functor->value(_t, datum.faceCentroid())}; 41 : } 42 : 43 : template <typename Derived> 44 : KOKKOS_FUNCTION KokkosLinearFVFunctorDirichletBC::BoundaryRelation 45 1060 : KokkosLinearFVFunctorDirichletBC::computeBoundaryNormalGradient(const FVDatum & datum) const 46 : { 47 1060 : const auto distance = datum.faceDCFMag(); 48 1060 : return {-1 / distance, _functor->value(_t, datum.faceCentroid()) / distance}; 49 : }