forked from idaholab/moose
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add FVFunctorDirichletBC with doco and test (idaholab#21374)
- Loading branch information
Sebastian Schunert
committed
Jun 21, 2022
1 parent
e747af6
commit 1bd5fad
Showing
6 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
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,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 |
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<ADReal> & _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<ADReal>("functor")) | ||
{ | ||
} | ||
|
||
Real | ||
FVFunctorDirichletBC::boundaryValue(const FaceInfo & fi) const | ||
{ | ||
return MetaPhysicL::raw_value(_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 = 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 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' | ||
[] | ||
[] |