https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
12#include "Function.h"
13
15
16template <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
31template <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))
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
51template <class T>
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
DualNumber< Real, DNDerivativeType, true > ADReal
const double T
registerMooseObject("NavierStokesApp", INSFVOutletPressureBC)
static InputParameters validParams()
const Point & faceCentroid() const
A class for setting the value of the pressure at an outlet of the system.
MooseVariableFV< Real > & _var
const PostprocessorValue *const _pp_value
Postprocessor that gives the uniform value of pressure on the boundary.
static InputParameters validParams()
void paramError(const std::string &param, Args... args) const
INSFVOutletPressureBCTempl(const InputParameters &params)
ADReal boundaryValue(const FaceInfo &, const Moose::StateArg &) const override
const Moose::Functor< ADReal > *const _functor
AD Functor that gives the distribution of pressure on the boundary.
const Function *const _function
Regular function that gives the distribution of pressure on the boundary.
void mooseError(Args &&... args) const
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
SolutionIterationType iteration_type
unsigned int state