Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FVFunctorDirichletBC #21377

Merged
merged 2 commits into from Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions framework/doc/content/source/fvbcs/FVFunctorDirichletBC.md
@@ -0,0 +1,24 @@
# FVFunctorDirichletBC

## Description

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

!alert note
This boundary condition will only accept regular functors. ADFunctors (such as variables) must be
converted to regular functors using a [FunctorADConverter.md].

## Example Syntax

In this example the functor, a constant value of 10, is defined using a [GenericFunctorMaterial.md].

!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<Real> & _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<Real>("functor"))
{
}

Real
FVFunctorDirichletBC::boundaryValue(const FaceInfo & fi) const
{
return _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 = GenericFunctorMaterial
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'
[]
[]