Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21377 from snschune/fv_functor_bc_21374
Add FVFunctorDirichletBC
- Loading branch information
Showing
6 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
framework/doc/content/source/fvbcs/FVFunctorDirichletBC.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
56
test/tests/fvbcs/fv_functor_dirichlet/fv_functor_dirichlet.i
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 added
BIN
+32.8 KB
test/tests/fvbcs/fv_functor_dirichlet/gold/fv_functor_dirichlet_out.e
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
[] | ||
[] |