https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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),
40 SetupInterface(this),
48 MeshChangedInterface(parameters),
49 TaggingInterface(this),
51 false,
52 "variable",
53 Moose::VarKindType::VAR_ANY,
54 Moose::VarFieldType::VAR_FIELD_STANDARD),
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
70bool
71LinearFVBoundaryCondition::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
89Real
91{
92 const auto cell_to_face_vector = computeCellToFaceVector();
93 return std::abs(cell_to_face_vector * _current_face_info->normal());
94}
95
96RealVectorValue
104
105template <typename FunctorType>
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
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.
131template Moose::FaceArg LinearFVBoundaryCondition::functorFaceArg<Moose::Functor<Real>>(
132 const Moose::Functor<Real> &, const FaceInfo *, Moose::FV::LimiterType, bool) const;
unsigned int THREAD_ID
Definition MooseTypes.h:237
A class for requiring an object to be boundary restricted.
Interface for objects that need to use distributions.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
An interface for producers of functor face arguments, e.g.
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.
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition FaceInfo.h:38
const Point & normal() const
Returns the unit normal vector for the face oriented outward from the face's elem element.
Definition FaceInfo.h:72
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
const Elem * neighborPtr() const
Definition FaceInfo.h:88
const Elem * elemPtr() const
Definition FaceInfo.h:86
const Point & neighborCentroid() const
Definition FaceInfo.h:247
const Point & elemCentroid() const
Returns the element centroids of the elements on the elem and neighbor sides of the face.
Definition FaceInfo.h:99
const Point & faceCentroid() const
Returns the coordinates of the face centroid.
Definition FaceInfo.h:75
Interface for objects that need to use functions.
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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...
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
Declare the given parameters as controllable.
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...
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
const FaceInfo * _current_face_info
Pointer to the face info we are operating on right now.
const unsigned int _sys_num
Cache for the system number.
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.
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.
FaceInfo::VarFaceNeighbors _current_face_type
Face ownership information for the current face.
RealVectorValue computeCellToFaceVector() const
Computes the vector connecting the cell and boundary face centers.
MooseLinearVariableFV< Real > & _var
Reference to the linear finite volume variable object.
static InputParameters validParams()
LinearFVBoundaryCondition(const InputParameters &parameters)
Class constructor.
virtual bool hasFaceSide(const FaceInfo &fi, bool fi_elem_side) const override
const unsigned int _var_num
Cache for the variable number.
Interface for notifications that the mesh has changed.
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:271
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
static InputParameters validParams()
Definition MooseObject.C:25
void addMooseVariableDependency(MooseVariableFieldBase *var)
Call this function to add the passed in MooseVariableFieldBase as a variable that this object depends...
Interface for objects that need to get values of MooseVariables.
This is a wrapper that forwards calls to the implementation, which can be switched out at any time wi...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type.
An interface for accessing Moose::Functors for systems that do not care about automatic differentiati...
static InputParameters validParams()
Interface class for classes which interact with Postprocessors.
Generic class for solving transient nonlinear problems.
Definition SubProblem.h:79
static InputParameters validParams()
Interface for objects that needs transient capabilities.
static InputParameters validParams()
Interface for objects that need to use UserObjects.
MeshBase & mesh
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
A structure defining a "face" evaluation calling argument for Moose functors.