https://mooseframework.inl.gov
INSFVOutletPressureBC.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 "INSFVOutletPressureBC.h"
11 #include "INSFVPressureVariable.h"
12 #include "Function.h"
13 
14 registerMooseObject("NavierStokesApp", INSFVOutletPressureBC);
15 
16 template <class T>
19 {
21  params += T::validParams();
22 
23  // Value may be specified by a AD functor (typically a variable), a function or a postprocessor
24  params.addParam<FunctionName>("function", "The boundary pressure as a regular function");
25  params.addParam<MooseFunctorName>("functor", "The boundary pressure as an AD functor");
26  params.addParam<PostprocessorName>("postprocessor", "The boundary pressure as a postprocessor");
27 
28  return params;
29 }
30 
31 template <class T>
33  : FVDirichletBCBase(params),
34  T(params),
35  _functor(isParamValid("functor") ? &this->template getFunctor<ADReal>("functor") : nullptr),
36  _function(isParamValid("function") ? &getFunction("function") : nullptr),
37  _pp_value(isParamValid("postprocessor") ? &getPostprocessorValue("postprocessor") : nullptr)
38 {
39  if (!dynamic_cast<INSFVPressureVariable *>(&_var))
40  paramError(
41  "variable",
42  "The variable argument to INSFVOutletPressureBC must be of type INSFVPressureVariable");
43 
44  // Check parameters
45  if ((_functor && (_pp_value || _function)) || (_function && _pp_value) ||
46  (!_functor && !_pp_value && !_function))
47  mooseError("One and only one of function/functor/postprocessor may be specified for the outlet "
48  "pressure");
49 }
50 
51 template <class T>
52 ADReal
54  const Moose::StateArg & state) const
55 {
56  if (_functor)
57  return (*_functor)(singleSidedFaceArg(&fi), state);
58  else if (_function)
59  {
60  if (state.state != 0 && state.iteration_type == Moose::SolutionIterationType::Time)
61  {
62  mooseAssert(state.state == 1, "We cannot access values beyond the previous time step.");
63  return _function->value(_t_old, fi.faceCentroid());
64  }
65  else
66  return _function->value(_t, fi.faceCentroid());
67  }
68  else
69  return *_pp_value;
70 }
71 
A class for setting the value of the pressure at an outlet of the system.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const PostprocessorValue *const _pp_value
Postprocessor that gives the uniform value of pressure on the boundary.
const Point & faceCentroid() const
MooseVariableFV< Real > & _var
DualNumber< Real, DNDerivativeType, true > ADReal
static InputParameters validParams()
InputParameters validParams()
SolutionIterationType iteration_type
ADReal boundaryValue(const FaceInfo &, const Moose::StateArg &) const override
void paramError(const std::string &param, Args... args) const
registerMooseObject("NavierStokesApp", INSFVOutletPressureBC)
const Moose::Functor< ADReal > *const _functor
AD Functor that gives the distribution of pressure on the boundary.
INSFVOutletPressureBCTempl(const InputParameters &params)
void mooseError(Args &&... args) const
const Function *const _function
Regular function that gives the distribution of pressure on the boundary.
static InputParameters validParams()
unsigned int state