Line data Source code
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 "LinearFVBoundaryCondition.h"
11 : #include "Problem.h"
12 : #include "SystemBase.h"
13 : #include "MooseVariableFV.h"
14 :
15 : InputParameters
16 22494 : LinearFVBoundaryCondition::validParams()
17 : {
18 22494 : InputParameters params = MooseObject::validParams();
19 22494 : params += TransientInterface::validParams();
20 22494 : params += BoundaryRestrictableRequired::validParams();
21 22494 : params += GeometricSearchInterface::validParams();
22 22494 : params += TaggingInterface::validParams();
23 22494 : params += NonADFunctorInterface::validParams();
24 :
25 44988 : MultiMooseEnum vtags("rhs time", "rhs", true);
26 22494 : auto & vector_tag_enum = params.set<MultiMooseEnum>("vector_tags", true);
27 22494 : vector_tag_enum = vtags;
28 :
29 67482 : params.addRequiredParam<LinearVariableName>(
30 : "variable", "The name of the variable that this boundary condition applies to");
31 67482 : params.declareControllable("enable");
32 44988 : params.registerBase("LinearFVBoundaryCondition");
33 22494 : params.registerSystemAttributeName("LinearFVBoundaryCondition");
34 44988 : return params;
35 22494 : }
36 :
37 2064 : LinearFVBoundaryCondition::LinearFVBoundaryCondition(const InputParameters & parameters)
38 : : MooseObject(parameters),
39 : BoundaryRestrictableRequired(this, false),
40 : SetupInterface(this),
41 : FunctionInterface(this),
42 : DistributionInterface(this),
43 : UserObjectInterface(this),
44 : TransientInterface(this),
45 : PostprocessorInterface(this),
46 : VectorPostprocessorInterface(this),
47 : GeometricSearchInterface(this),
48 : MeshChangedInterface(parameters),
49 : TaggingInterface(this),
50 : MooseVariableInterface(this,
51 : false,
52 : "variable",
53 : Moose::VarKindType::VAR_ANY,
54 : Moose::VarFieldType::VAR_FIELD_STANDARD),
55 : MooseVariableDependencyInterface(this),
56 : NonADFunctorInterface(this),
57 : FaceArgProducerInterface(),
58 2064 : _tid(parameters.get<THREAD_ID>("_tid")),
59 8256 : _subproblem(*getCheckedPointerParam<SubProblem *>("_subproblem")),
60 2064 : _mesh(_subproblem.mesh()),
61 8256 : _fv_problem(*getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
62 2064 : _var(*mooseLinearVariableFV()),
63 2064 : _sys(_var.sys()),
64 2064 : _var_num(_var.number()),
65 8256 : _sys_num(_sys.number())
66 : {
67 2064 : addMooseVariableDependency(&_var);
68 2064 : }
69 :
70 : bool
71 4279634 : LinearFVBoundaryCondition::hasFaceSide(const FaceInfo & fi, bool fi_elem_side) const
72 : {
73 4279634 : const auto ft = fi.faceType(std::make_pair(_var_num, _sys_num));
74 4279634 : if (fi_elem_side)
75 2139817 : return ft == FaceInfo::VarFaceNeighbors::ELEM || ft == FaceInfo::VarFaceNeighbors::BOTH;
76 : else
77 2139817 : return ft == FaceInfo::VarFaceNeighbors::NEIGHBOR || ft == FaceInfo::VarFaceNeighbors::BOTH;
78 : }
79 :
80 : Moose::FaceArg
81 2127733 : LinearFVBoundaryCondition::singleSidedFaceArg(const FaceInfo * fi,
82 : const Moose::FV::LimiterType limiter_type,
83 : const bool correct_skewness) const
84 : {
85 : mooseAssert(fi, "FaceInfo should not be null!");
86 2127733 : return makeFace(*fi, limiter_type, true, correct_skewness);
87 : }
88 :
89 : Real
90 99334 : LinearFVBoundaryCondition::computeCellToFaceDistance() const
91 : {
92 99334 : const auto cell_to_face_vector = computeCellToFaceVector();
93 198668 : return std::abs(cell_to_face_vector * _current_face_info->normal());
94 : }
95 :
96 : RealVectorValue
97 1534699 : LinearFVBoundaryCondition::computeCellToFaceVector() const
98 : {
99 1534699 : const auto defined_on_elem = _current_face_type == FaceInfo::VarFaceNeighbors::ELEM;
100 1534699 : return (_current_face_info->faceCentroid() - (defined_on_elem
101 1534699 : ? _current_face_info->elemCentroid()
102 3069398 : : _current_face_info->neighborCentroid()));
103 : }
104 :
105 : template <typename FunctorType>
106 : Moose::FaceArg
107 2105743 : LinearFVBoundaryCondition::functorFaceArg(const FunctorType & functor,
108 : const FaceInfo * fi,
109 : const Moose::FV::LimiterType limiter_type,
110 : const bool correct_skewness) const
111 : {
112 2105743 : auto face = singleSidedFaceArg(fi, limiter_type, correct_skewness);
113 2105743 : const auto on_elem = functor.hasFaceSide(*fi, true);
114 2105743 : const auto on_neighbor = functor.hasFaceSide(*fi, false);
115 :
116 2105743 : if (on_elem && on_neighbor)
117 3348 : face.face_side = nullptr;
118 2102395 : else if (on_elem)
119 2102395 : face.face_side = fi->elemPtr();
120 0 : else if (on_neighbor)
121 0 : face.face_side = fi->neighborPtr();
122 : else
123 0 : mooseError(
124 : "The functor '", functor.functorName(), "' is not defined on either side of the face.");
125 :
126 2105743 : 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;
|