Skip to content

Commit

Permalink
Add FVFunctorDirichletBC with doco and test (idaholab#21374)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Schunert committed Jun 21, 2022
1 parent e747af6 commit 1bd5fad
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 0 deletions.
18 changes: 18 additions & 0 deletions framework/doc/content/source/fvbcs/FVFunctorDirichletBC.md
@@ -0,0 +1,18 @@
# FVFunctorDirichletBC

## Description

`FVFunctorDirichletBC` will specify the value of a field at the boundary.
The value will be determined by a `Functor`

## Example Syntax

!listing test/tests/fvbcs/fv_functor_dirichlet/fv_functor_dirichlet.i block=Materials

!listing test/tests/fvbcs/fv_functor_dirichlet/fv_functor_dirichlet.i block=FVBCs

!syntax parameters /FVBCs/FVFunctorDirichletBC

!syntax inputs /FVBCs/FVFunctorDirichletBC

!syntax children /FVBCs/FVFunctorDirichletBC
26 changes: 26 additions & 0 deletions framework/include/fvbcs/FVFunctorDirichletBC.h
@@ -0,0 +1,26 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#pragma once

#include "FVDirichletBCBase.h"

class FVFunctorDirichletBC : public FVDirichletBCBase
{
public:
FVFunctorDirichletBC(const InputParameters & parameters);

static InputParameters validParams();

Real boundaryValue(const FaceInfo & fi) const override;

private:
/// The value for this BC
const Moose::Functor<ADReal> & _functor;
};
33 changes: 33 additions & 0 deletions framework/src/fvbcs/FVFunctorDirichletBC.C
@@ -0,0 +1,33 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#include "FVFunctorDirichletBC.h"

registerMooseObject("MooseApp", FVFunctorDirichletBC);

InputParameters
FVFunctorDirichletBC::validParams()
{
InputParameters params = FVDirichletBCBase::validParams();
params.addClassDescription("Uses the value of a functor to set a Dirichlet boundary value.");
params.addRequiredParam<MooseFunctorName>(
"functor", "The name of the functor whose value is imposed on the boundary");
return params;
}

FVFunctorDirichletBC::FVFunctorDirichletBC(const InputParameters & parameters)
: FVDirichletBCBase(parameters), _functor(getFunctor<ADReal>("functor"))
{
}

Real
FVFunctorDirichletBC::boundaryValue(const FaceInfo & fi) const
{
return MetaPhysicL::raw_value(_functor(singleSidedFaceArg(&fi)));
}
56 changes: 56 additions & 0 deletions test/tests/fvbcs/fv_functor_dirichlet/fv_functor_dirichlet.i
@@ -0,0 +1,56 @@
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 4
[]

[Variables]
[u]
family = MONOMIAL
order = CONSTANT
fv = true
[]
[]

[FVKernels]
[diff]
type = FVDiffusion
variable = u
coeff = 1
[]
[]

[FVBCs]
[left]
type = FVFunctorDirichletBC
variable = u
boundary = left
functor = bc_value
[]
[right]
type = FVDirichletBC
variable = u
boundary = right
value = 0
[]
[]

[Materials]
[bc_value]
type = ADGenericFunctorMaterial
prop_names = bc_value
prop_values = 10
[]
[]

[Executioner]
type = Steady
solve_type = 'Newton'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]

[Outputs]
exodus = true
[]
Binary file not shown.
11 changes: 11 additions & 0 deletions test/tests/fvbcs/fv_functor_dirichlet/tests
@@ -0,0 +1,11 @@
[Tests]
design = 'FVFunctorDirichletBC.md'
issues = '#21374'
[fv_functor_dirichlet]
type = 'Exodiff'
input = 'fv_functor_dirichlet.i'
exodiff = 'fv_functor_dirichlet_out.e'
requirement = 'The system shall allow the use of functors to set Dirichlet boundary values for FV.'
ad_indexing_type = 'global'
[]
[]

0 comments on commit 1bd5fad

Please sign in to comment.