https://mooseframework.inl.gov
LinearFVBoundaryCondition.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 
11 #include "Problem.h"
12 #include "SystemBase.h"
13 #include "MooseVariableFV.h"
14 
17 {
24 
25  MultiMooseEnum vtags("rhs time", "rhs", true);
26  auto & vector_tag_enum = params.set<MultiMooseEnum>("vector_tags", true);
27  vector_tag_enum = vtags;
28 
29  params.addRequiredParam<LinearVariableName>(
30  "variable", "The name of the variable that this boundary condition applies to");
31  params.declareControllable("enable");
32  params.registerBase("LinearFVBoundaryCondition");
33  params.registerSystemAttributeName("LinearFVBoundaryCondition");
34  return params;
35 }
36 
38  : MooseObject(parameters),
39  BoundaryRestrictableRequired(this, false),
40  SetupInterface(this),
41  FunctionInterface(this),
43  UserObjectInterface(this),
44  TransientInterface(this),
48  MeshChangedInterface(parameters),
49  TaggingInterface(this),
51  false,
52  "variable",
58  _tid(parameters.get<THREAD_ID>("_tid")),
59  _subproblem(*getCheckedPointerParam<SubProblem *>("_subproblem")),
60  _mesh(_subproblem.mesh()),
61  _fv_problem(*getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
62  _var(*mooseLinearVariableFV()),
63  _sys(_var.sys()),
64  _var_num(_var.number()),
65  _sys_num(_sys.number())
66 {
68 }
69 
70 bool
71 LinearFVBoundaryCondition::hasFaceSide(const FaceInfo & fi, bool fi_elem_side) const
72 {
73  const auto ft = fi.faceType(std::make_pair(_var_num, _sys_num));
74  if (fi_elem_side)
76  else
78 }
79 
82  const Moose::FV::LimiterType limiter_type,
83  const bool correct_skewness) const
84 {
85  mooseAssert(fi, "FaceInfo should not be null!");
86  return makeFace(*fi, limiter_type, true, correct_skewness);
87 }
88 
89 Real
91 {
92  const auto cell_to_face_vector = computeCellToFaceVector();
93  return std::abs(cell_to_face_vector * _current_face_info->normal());
94 }
95 
98 {
99  const auto defined_on_elem = _current_face_type == FaceInfo::VarFaceNeighbors::ELEM;
100  return (_current_face_info->faceCentroid() - (defined_on_elem
103 }
104 
105 template <typename FunctorType>
107 LinearFVBoundaryCondition::functorFaceArg(const FunctorType & functor,
108  const FaceInfo * fi,
109  const Moose::FV::LimiterType limiter_type,
110  const bool correct_skewness) const
111 {
112  auto face = singleSidedFaceArg(fi, limiter_type, correct_skewness);
113  const auto on_elem = functor.hasFaceSide(*fi, true);
114  const auto on_neighbor = functor.hasFaceSide(*fi, false);
115 
116  if (on_elem && on_neighbor)
117  face.face_side = nullptr;
118  else if (on_elem)
119  face.face_side = fi->elemPtr();
120  else if (on_neighbor)
121  face.face_side = fi->neighborPtr();
122  else
123  mooseError(
124  "The functor '", functor.functorName(), "' is not defined on either side of the face.");
125 
126  return face;
127 }
128 
129 // For now this assume reals only, considering this system doesn't support AD. If we need
130 // vectors/tensors we might add it here later.
131 template Moose::FaceArg LinearFVBoundaryCondition::functorFaceArg<Moose::Functor<Real>>(
132  const Moose::Functor<Real> &, const FaceInfo *, Moose::FV::LimiterType, bool) const;
An interface for accessing Moose::Functors for systems that do not care about automatic differentiati...
VarFieldType
Definition: MooseTypes.h:770
virtual bool hasFaceSide(const FaceInfo &fi, bool fi_elem_side) const override
RealVectorValue computeCellToFaceVector() const
Computes the vector connecting the cell and boundary face centers.
MetaPhysicL::DualNumber< V, D, asd > abs(const MetaPhysicL::DualNumber< V, D, asd > &a)
Definition: EigenADReal.h:50
A class for requiring an object to be boundary restricted.
Moose::FaceArg functorFaceArg(const FunctorType &functor, const FaceInfo *fi, Moose::FV::LimiterType limiter_type=Moose::FV::LimiterType::CentralDifference, bool correct_skewness=false) const
Determine a face argument for evaluating a functor on a face.
Real computeCellToFaceDistance() const
Compute the distance between the cell center and the face.
const unsigned int _sys_num
Cache for the system number.
const Point & faceCentroid() const
Returns the coordinates of the face centroid.
Definition: FaceInfo.h:75
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
This is a wrapper that forwards calls to the implementation, which can be switched out at any time wi...
MeshBase & mesh
void registerSystemAttributeName(const std::string &value)
This method is used to define the MOOSE system name that is used by the TheWarehouse object for stori...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const Point & neighborCentroid() const
Definition: FaceInfo.h:247
static InputParameters validParams()
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
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()
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System...
Interface for objects that needs transient capabilities.
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition: FaceInfo.h:37
const Elem * neighborPtr() const
Definition: FaceInfo.h:88
Interface for notifications that the mesh has changed.
const Point & elemCentroid() const
Returns the element centroids of the elements on the elem and neighbor sides of the face...
Definition: FaceInfo.h:99
A structure defining a "face" evaluation calling argument for Moose functors.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:28
An interface for producers of functor face arguments, e.g.
Interface for objects that need to use distributions.
VarKindType
Framework-wide stuff.
Definition: MooseTypes.h:763
LinearFVBoundaryCondition(const InputParameters &parameters)
Class constructor.
FaceInfo::VarFaceNeighbors _current_face_type
Face ownership information for the current face.
LimiterType
Definition: Limiter.h:26
const unsigned int _var_num
Cache for the variable number.
Interface for objects that need to use UserObjects.
const Point & normal() const
Returns the unit normal vector for the face oriented outward from the face&#39;s elem element...
Definition: FaceInfo.h:72
MooseLinearVariableFV< Real > & _var
Reference to the linear finite volume variable object.
const Elem * elemPtr() const
Definition: FaceInfo.h:86
void addMooseVariableDependency(MooseVariableFieldBase *var)
Call this function to add the passed in MooseVariableFieldBase as a variable that this object depends...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:78
const FaceInfo * _current_face_info
Pointer to the face info we are operating on right now.
Interface for objects that need to get values of MooseVariables.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:281
static InputParameters validParams()
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type...
Moose::FaceArg singleSidedFaceArg(const FaceInfo *fi, Moose::FV::LimiterType limiter_type=Moose::FV::LimiterType::CentralDifference, bool correct_skewness=false) const
Determine the single sided face argument when evaluating a functor on a face.
static InputParameters validParams()
Definition: MooseObject.C:25
static InputParameters validParams()
static InputParameters validParams()
Interface for objects that need to use functions.
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
Declare the given parameters as controllable.
const Elem & get(const ElemType type_in)
Moose::FaceArg makeFace(const FaceInfo &fi, const Moose::FV::LimiterType limiter_type, const bool elem_is_upwind, const bool correct_skewness=false, const Moose::StateArg *state_limiter=nullptr) const
Create a functor face argument from provided component arguments.
Interface class for classes which interact with Postprocessors.
unsigned int THREAD_ID
Definition: MooseTypes.h:237
VarFaceNeighbors faceType(const std::pair< unsigned int, unsigned int > &var_sys) const
Returns which side(s) the given variable-system number pair is defined on for this face...
Definition: FaceInfo.h:229