KokkosLinearFVFunctorNeumannBC
This object provides prescribed outward normal gradient data for Kokkos linear finite volume kernels. The outward normal gradient is supplied through a KokkosParsedFunction via the "functor" parameter.
The primitive relation supplied by this BC is
where is the prescribed outward normal gradient. Kernels apply their own physics coefficients when consuming this relation; for example, a diffusion kernel multiplies by its diffusion coefficient and face area. This BC therefore prescribes a normal gradient, not a total diffusive flux.
For kernels that need a boundary value, this object also supplies the orthogonal extrapolation
where is the cell value and is the cell-center-to-face-center distance.
functor
C++ Type:FunctionName
Unit:(no unit assumed)
Controllable:No
Description:The prescribed outward normal gradient functor on the boundary.
(test/tests/kokkos/linearfvkernels/diffusion/kokkos_diffusion-2d-neumann.i)
# 2D diffusion MMS test with mixed Dirichlet (left/right) and Neumann (top/bottom) BCs.
# Exact solution: u = (1.5 - x^2)(1.5 - y^2)
# Diffusion coeff: D = 1 + 0.5*x*y
# Neumann normal gradient on bottom (n = -y): -du/dy|_{y=0} = 0 (du/dy = 0 at y=0)
# Neumann normal gradient on top (n = +y): du/dy|_{y=ymax}
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 2
ny = 2
ymax = 0.5
[]
[]
[Problem]
linear_sys_names = 'u_sys'
[]
[Variables]
[u]
type = MooseLinearVariableFVReal
solver_sys = 'u_sys'
[]
[]
[LinearFVKernels]
[diffusion]
type = KokkosLinearFVDiffusion
variable = u
diffusion_coeff = coeff_func_kokkos
[]
[source]
type = KokkosLinearFVSource
variable = u
source_density = source_func_kokkos
scaling_factor = unit_fn
[]
[]
[LinearFVBCs]
[dirichlet_lr]
type = KokkosLinearFVFunctorDirichletBC
variable = u
boundary = 'left right'
functor = analytic_solution_kokkos
[]
[neumann_bottom]
type = KokkosLinearFVFunctorNeumannBC
variable = u
boundary = 'bottom'
functor = neumann_bottom_gradient
[]
[neumann_top]
type = KokkosLinearFVFunctorNeumannBC
variable = u
boundary = 'top'
functor = neumann_top_gradient
[]
[]
[Functions]
[unit_fn]
type = KokkosParsedFunction
expression = 1.0
[]
[coeff_func_kokkos]
type = KokkosParsedFunction
expression = '1.0 + 0.5*x*y'
[]
[source_func_kokkos]
type = KokkosParsedFunction
expression = '2*(1.5-y*y) + 2*x*y*(1.5-y*y) + 2*(1.5-x*x) + 2*x*y*(1.5-x*x)'
[]
[analytic_solution_kokkos]
type = KokkosParsedFunction
expression = '(1.5-x*x)*(1.5-y*y)'
[]
[analytic_solution]
type = ParsedFunction
expression = '(1.5-x*x)*(1.5-y*y)'
[]
# Outward normal gradient on bottom (n = -y): -du/dy|_{y=0} = 0
[neumann_bottom_gradient]
type = KokkosParsedFunction
expression = 0.0
[]
# Outward normal gradient on top (n = +y): du/dy|_{y=ymax}
# du/dy = (1.5-x^2)*(-2*ymax)
[neumann_top_gradient]
type = KokkosParsedFunction
expression = '(1.5-x*x)*(-2.0*0.5)'
[]
[]
[Postprocessors]
[h]
type = AverageElementSize
execute_on = FINAL
[]
[error]
type = ElementL2FunctorError
approximate = u
exact = analytic_solution
execute_on = FINAL
[]
[]
[Executioner]
type = Steady
system_names = u_sys
l_tol = 1e-10
petsc_options_iname = '-pc_type -pc_hypre_type'
petsc_options_value = 'hypre boomeramg'
[]
[Outputs]
[csv]
type = CSV
execute_on = FINAL
[]
[console]
type = Console
execute_postprocessors_on = 'FINAL'
[]
[]
(test/tests/kokkos/linearfvkernels/diffusion/kokkos_diffusion-2d-internal-neumann.i)
# 2D diffusion MMS test with Neumann normal-gradient BCs on internal block boundaries.
# Exact solution: u = v = 1.5 - x^2
# Diffusion coeff: D = 1 + 0.5*x*y
[Mesh]
[cmg]
type = CartesianMeshGenerator
dim = 2
dx = '0.5 0.5'
ix = '2 2'
dy = '0.5'
iy = '2'
subdomain_id = '1 2'
[]
[left_internal]
type = SideSetsBetweenSubdomainsGenerator
input = cmg
new_boundary = left_internal
primary_block = 1
paired_block = 2
[]
[right_internal]
type = SideSetsBetweenSubdomainsGenerator
input = left_internal
new_boundary = right_internal
primary_block = 2
paired_block = 1
[]
[]
[Problem]
linear_sys_names = 'u_sys'
[]
[Variables]
[u]
type = MooseLinearVariableFVReal
solver_sys = 'u_sys'
block = 1
[]
[v]
type = MooseLinearVariableFVReal
solver_sys = 'u_sys'
block = 2
[]
[]
[LinearFVKernels]
[diffusion_left]
type = KokkosLinearFVDiffusion
variable = u
diffusion_coeff = coeff_func_kokkos
block = 1
[]
[source_left]
type = KokkosLinearFVSource
variable = u
source_density = source_func_kokkos
scaling_factor = unit_fn
block = 1
[]
[diffusion_right]
type = KokkosLinearFVDiffusion
variable = v
diffusion_coeff = coeff_func_kokkos
block = 2
[]
[source_right]
type = KokkosLinearFVSource
variable = v
source_density = source_func_kokkos
scaling_factor = unit_fn
block = 2
[]
[]
[LinearFVBCs]
[dirichlet_left]
type = KokkosLinearFVFunctorDirichletBC
variable = u
boundary = left
functor = analytic_solution_kokkos
[]
[neumann_left_internal]
type = KokkosLinearFVFunctorNeumannBC
variable = u
boundary = left_internal
functor = left_internal_gradient
[]
[dirichlet_right]
type = KokkosLinearFVFunctorDirichletBC
variable = v
boundary = right
functor = analytic_solution_kokkos
[]
[neumann_right_internal]
type = KokkosLinearFVFunctorNeumannBC
variable = v
boundary = right_internal
functor = right_internal_gradient
[]
[]
[Functions]
[unit_fn]
type = KokkosParsedFunction
expression = 1.0
[]
[coeff_func_kokkos]
type = KokkosParsedFunction
expression = '1.0 + 0.5*x*y'
[]
[source_func_kokkos]
type = KokkosParsedFunction
expression = '2.0 + 2.0*x*y'
[]
[analytic_solution_kokkos]
type = KokkosParsedFunction
expression = '1.5 - x*x'
[]
[analytic_solution]
type = ParsedFunction
expression = '1.5 - x*x'
[]
[left_internal_gradient]
type = KokkosParsedFunction
expression = '-1.0'
[]
[right_internal_gradient]
type = KokkosParsedFunction
expression = '1.0'
[]
[]
[Postprocessors]
[h]
type = AverageElementSize
execute_on = FINAL
[]
[left_error]
type = ElementL2FunctorError
approximate = u
exact = analytic_solution
execute_on = FINAL
block = 1
[]
[right_error]
type = ElementL2FunctorError
approximate = v
exact = analytic_solution
execute_on = FINAL
block = 2
[]
[error]
type = ParsedPostprocessor
expression = 'sqrt(left*left + right*right)'
pp_names = 'left_error right_error'
pp_symbols = 'left right'
execute_on = FINAL
[]
[]
[Executioner]
type = Steady
system_names = u_sys
l_tol = 1e-10
petsc_options_iname = '-pc_type -pc_hypre_type'
petsc_options_value = 'hypre boomeramg'
[]
[Outputs]
[csv]
type = CSV
execute_on = FINAL
[]
[console]
type = Console
execute_postprocessors_on = 'FINAL'
[]
[]
(test/tests/kokkos/linearfvkernels/diffusion/kokkos_diffusion-2d-neumann.i)
# 2D diffusion MMS test with mixed Dirichlet (left/right) and Neumann (top/bottom) BCs.
# Exact solution: u = (1.5 - x^2)(1.5 - y^2)
# Diffusion coeff: D = 1 + 0.5*x*y
# Neumann normal gradient on bottom (n = -y): -du/dy|_{y=0} = 0 (du/dy = 0 at y=0)
# Neumann normal gradient on top (n = +y): du/dy|_{y=ymax}
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 2
ny = 2
ymax = 0.5
[]
[]
[Problem]
linear_sys_names = 'u_sys'
[]
[Variables]
[u]
type = MooseLinearVariableFVReal
solver_sys = 'u_sys'
[]
[]
[LinearFVKernels]
[diffusion]
type = KokkosLinearFVDiffusion
variable = u
diffusion_coeff = coeff_func_kokkos
[]
[source]
type = KokkosLinearFVSource
variable = u
source_density = source_func_kokkos
scaling_factor = unit_fn
[]
[]
[LinearFVBCs]
[dirichlet_lr]
type = KokkosLinearFVFunctorDirichletBC
variable = u
boundary = 'left right'
functor = analytic_solution_kokkos
[]
[neumann_bottom]
type = KokkosLinearFVFunctorNeumannBC
variable = u
boundary = 'bottom'
functor = neumann_bottom_gradient
[]
[neumann_top]
type = KokkosLinearFVFunctorNeumannBC
variable = u
boundary = 'top'
functor = neumann_top_gradient
[]
[]
[Functions]
[unit_fn]
type = KokkosParsedFunction
expression = 1.0
[]
[coeff_func_kokkos]
type = KokkosParsedFunction
expression = '1.0 + 0.5*x*y'
[]
[source_func_kokkos]
type = KokkosParsedFunction
expression = '2*(1.5-y*y) + 2*x*y*(1.5-y*y) + 2*(1.5-x*x) + 2*x*y*(1.5-x*x)'
[]
[analytic_solution_kokkos]
type = KokkosParsedFunction
expression = '(1.5-x*x)*(1.5-y*y)'
[]
[analytic_solution]
type = ParsedFunction
expression = '(1.5-x*x)*(1.5-y*y)'
[]
# Outward normal gradient on bottom (n = -y): -du/dy|_{y=0} = 0
[neumann_bottom_gradient]
type = KokkosParsedFunction
expression = 0.0
[]
# Outward normal gradient on top (n = +y): du/dy|_{y=ymax}
# du/dy = (1.5-x^2)*(-2*ymax)
[neumann_top_gradient]
type = KokkosParsedFunction
expression = '(1.5-x*x)*(-2.0*0.5)'
[]
[]
[Postprocessors]
[h]
type = AverageElementSize
execute_on = FINAL
[]
[error]
type = ElementL2FunctorError
approximate = u
exact = analytic_solution
execute_on = FINAL
[]
[]
[Executioner]
type = Steady
system_names = u_sys
l_tol = 1e-10
petsc_options_iname = '-pc_type -pc_hypre_type'
petsc_options_value = 'hypre boomeramg'
[]
[Outputs]
[csv]
type = CSV
execute_on = FINAL
[]
[console]
type = Console
execute_postprocessors_on = 'FINAL'
[]
[]
(test/tests/kokkos/linearfvkernels/advection-diffusion/kokkos_advection_diffusion-1d.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 1
nx = 2
[]
[]
[Problem]
linear_sys_names = 'u_sys'
[]
[Variables]
[u]
type = MooseLinearVariableFVReal
solver_sys = 'u_sys'
[]
[]
[LinearFVKernels]
[advection]
type = KokkosLinearFVAdvection
variable = u
velocity = '0.5 0 0'
[]
[diffusion]
type = KokkosLinearFVDiffusion
variable = u
diffusion_coeff = unit_fn
[]
[source]
type = KokkosLinearFVSource
variable = u
source_density = source_func_kokkos
scaling_factor = unit_fn
[]
[]
[LinearFVBCs]
[inflow]
type = KokkosLinearFVFunctorDirichletBC
variable = u
boundary = left
functor = analytic_solution_kokkos
[]
[outflow]
type = KokkosLinearFVFunctorNeumannBC
variable = u
boundary = right
functor = zero_fn
[]
[]
[Functions]
[unit_fn]
type = KokkosParsedFunction
expression = 1.0
[]
[zero_fn]
type = KokkosParsedFunction
expression = 0.0
[]
[source_func_kokkos]
type = KokkosParsedFunction
expression = 'x - 3.0'
[]
[analytic_solution_kokkos]
type = KokkosParsedFunction
expression = '1.0 + (1.0 - x) * (1.0 - x)'
[]
[analytic_solution]
type = ParsedFunction
expression = '1.0 + (1.0 - x) * (1.0 - x)'
[]
[]
[Postprocessors]
[h]
type = AverageElementSize
execute_on = FINAL
[]
[error]
type = ElementL2FunctorError
approximate = u
exact = analytic_solution
execute_on = FINAL
[]
[]
[Executioner]
type = Steady
system_names = u_sys
l_tol = 1e-10
petsc_options_iname = '-pc_type -pc_factor_shift_type -pc_factor_shift_amount -pc_factor_mat_solver_type -mat_mumps_icntl_14'
petsc_options_value = 'lu NONZERO 1e-12 mumps 50'
[]
[Outputs]
[csv]
type = CSV
execute_on = FINAL
[]
[console]
type = Console
execute_postprocessors_on = 'FINAL'
[]
[]