https://mooseframework.inl.gov
FVFunctorDirichletBC.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "FVFunctorDirichletBC.h"
11 
14 
15 template <bool is_ad>
18 {
20  params.addClassDescription("Uses the value of a functor to set a Dirichlet boundary value.");
21  params.addRequiredParam<MooseFunctorName>(
22  "functor", "The name of the functor whose value is imposed on the boundary");
23  params.addParam<bool>(
24  "functor_only_defined_on_other_side",
25  false,
26  "Whether to evaluate the functor on the other side of the boundary. Note that depending on "
27  "the functor type, this may require the 'ghost_layers' parameter to be set. For a FV "
28  "variable with two term expansion, three ghost layers are needed.");
29  params.addParam<unsigned int>("ghost_layers", 0, "Number of ghost layers needed");
30 
31  // We need to add ghosting if we are going to use values from the other side
33  "ElementSideNeighborLayers",
36  [](const InputParameters & obj_params, InputParameters & rm_params)
37  {
38  rm_params.set<unsigned short>("layers") = obj_params.get<unsigned int>("ghost_layers");
39  rm_params.set<bool>("use_point_neighbors") = false;
40  });
41 
42  return params;
43 }
44 
45 template <bool is_ad>
47  : FVDirichletBCBase(parameters),
48  _functor(getFunctor<GenericReal<is_ad>>("functor")),
49  _use_other_side(getParam<bool>("functor_only_defined_on_other_side"))
50 {
51 }
52 
53 template <bool is_ad>
54 ADReal
56  const Moose::StateArg & state) const
57 {
58  auto sfa = singleSidedFaceArg(&fi);
59  if (!_use_other_side)
60  return _functor(sfa, state);
61  else if (fi.elemPtr() == sfa.face_side)
62  return _functor(
63  {&fi, Moose::FV::LimiterType::CentralDifference, true, false, fi.neighborPtr(), nullptr},
64  state);
65  else
66  return _functor(
67  {&fi, Moose::FV::LimiterType::CentralDifference, true, false, fi.elemPtr(), nullptr},
68  state);
69 }
70 
72 template class FVFunctorDirichletBCTempl<true>;
Moose::GenericType< Real, is_ad > GenericReal
Definition: MooseTypes.h:648
ADReal boundaryValue(const FaceInfo &fi, const Moose::StateArg &state) const override
A template class for finite volume dirichlet boundary conditions.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
Base class for finite volume Dirichlet boundaray conditions.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void addRelationshipManager(const std::string &name, Moose::RelationshipManagerType rm_type, Moose::RelationshipManagerInputParameterCallback input_parameter_callback=nullptr)
Tells MOOSE about a RelationshipManager that this object needs.
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:47
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
static InputParameters validParams()
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition: FaceInfo.h:36
const Elem * neighborPtr() const
Definition: FaceInfo.h:84
static InputParameters validParams()
FVFunctorDirichletBCTempl(const InputParameters &parameters)
const Elem * elemPtr() const
Definition: FaceInfo.h:82
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
State argument for evaluating functors.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
registerMooseObject("MooseApp", FVFunctorDirichletBC)