https://mooseframework.inl.gov
Loading...
Searching...
No Matches
FVFluxBC.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 "FVFluxBC.h"
11#include "MooseVariableFV.h"
12#include "SystemBase.h"
13#include "Assembly.h"
14#include "ADUtils.h"
15
18{
21 params.registerSystemAttributeName("FVFluxBC");
22
23 // FVFluxBCs always rely on Boundary MaterialData
24 params.set<Moose::MaterialDataType>("_material_data_type") = Moose::BOUNDARY_MATERIAL_DATA;
25 params.set<bool>("_residual_object") = true;
26
27 return params;
28}
29
31 : FVBoundaryCondition(parameters),
33 this, /*nodal=*/false, /*neighbor_nodal=*/false, /*is_fv=*/true),
34 TwoMaterialPropertyInterface(this, Moose::EMPTY_BLOCK_IDS, boundaryIDs())
35{
37 paramError("variable",
38 "There should not be a need to specify a flux "
39 "boundary condition for an auxiliary variable.");
40}
41
42void
44{
45 _face_info = &fi;
46 _normal = fi.normal();
47 _face_type = fi.faceType(std::make_pair(_var.number(), _var.sys().number()));
48
49 // For FV flux kernels, the normal is always oriented outward from the lower-id
50 // element's perspective. But for BCs, there is only a residual
51 // contribution to one element (one side of the face). Because of this, we
52 // make an exception and orient the normal to point outward from whichever
53 // side of the face the BC's variable is defined on; we flip it if this
54 // variable is defined on the neighbor side of the face (instead of elem) since
55 // the FaceInfo normal polarity is always oriented with respect to the lower-id element.
58}
59
60void
62{
64
66 mooseError("A FVFluxBC is being triggered on an internal face with centroid: ",
67 fi.faceCentroid());
69 mooseError("A FVFluxBC is being triggered on a face which does not connect to a block ",
70 "with the relevant finite volume variable. Its centroid: ",
71 fi.faceCentroid());
72
74
75 // This could be an "internal" boundary - one created by variable block
76 // restriction where the var is only defined on one side of the face. We
77 // need to make sure that we add the residual contribution to the correct
78 // side - the one where the variable is defined.
83
84 _local_re(0) = r;
86}
87
88void
93
94void
96{
97 _face_info = &fi;
98 _normal = fi.normal();
99 _face_type = fi.faceType(std::make_pair(_var.number(), _var.sys().number()));
100
101 // For FV flux kernels, the normal is always oriented outward from the lower-id
102 // element's perspective. But for BCs, there is only a Jacobian
103 // contribution to one element (one side of the face). Because of this, we
104 // make an exception and orient the normal to point outward from whichever
105 // side of the face the BC's variable is defined on; we flip it if this
106 // variable is defined on the neighbor side of the face (instead of elem) since
107 // the FaceInfo normal polarity is always oriented with respect to the lower-id element.
109 _normal = -_normal;
110
111 ADReal r = fi.faceArea() * fi.faceCoord() * computeQpResidual();
112
113 const auto & dof_indices = (_face_type == FaceInfo::VarFaceNeighbors::ELEM)
114 ? _var.dofIndices()
116
117 mooseAssert(dof_indices.size() == 1, "We're currently built to use CONSTANT MONOMIALS");
118
119 addResidualsAndJacobian(_assembly, std::array<ADReal, 1>{{r}}, dof_indices, _var.scalingFactor());
120}
121
123FVFluxBC::elemArg(const bool correct_skewness) const
124{
125 return {&_face_info->elem(), correct_skewness};
126}
127
129FVFluxBC::neighborArg(const bool correct_skewness) const
130{
131 return {_face_info->neighborPtr(), correct_skewness};
132}
DualNumber< Real, DNDerivativeType, true > ADReal
Base class for creating new types of boundary conditions.
static InputParameters validParams()
MooseVariableFV< Real > & _var
const FaceInfo * _face_info
Holds information for the face we are currently examining.
Assembly & _assembly
Reference to assembly.
FVFluxBC(const InputParameters &parameters)
Definition FVFluxBC.C:30
Moose::ElemArg neighborArg(bool correct_skewness=false) const
Definition FVFluxBC.C:129
void computeJacobian(const FaceInfo &fi) override
Compute the jacobian on the supplied face.
Definition FVFluxBC.C:95
void computeResidual(const FaceInfo &fi) override
Compute the residual on the supplied face.
Definition FVFluxBC.C:61
ADRealVectorValue _normal
Definition FVFluxBC.h:47
void updateCurrentFace(const FaceInfo &fi)
Update internal structures (normal, face type, etc) for the given face.
Definition FVFluxBC.C:43
FaceInfo::VarFaceNeighbors _face_type
The variable face type.
Definition FVFluxBC.h:60
Moose::ElemArg elemArg(bool correct_skewness=false) const
Definition FVFluxBC.C:123
virtual ADReal computeQpResidual()=0
static InputParameters validParams()
Definition FVFluxBC.C:17
void computeResidualAndJacobian(const FaceInfo &fi) override
Compute the residual and Jacobian on the supplied face.
Definition FVFluxBC.C:89
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 & elem() const
Definition FaceInfo.h:85
const Elem * neighborPtr() const
Definition FaceInfo.h:88
Real faceArea() const
Returns the face area of face id.
Definition FaceInfo.h:64
Real & faceCoord()
Sets/gets the coordinate transformation factor (for e.g.
Definition FaceInfo.h:68
const Point & faceCentroid() const
Returns the coordinates of the face centroid.
Definition FaceInfo.h:75
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...
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition MooseBase.h:457
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
void scalingFactor(const std::vector< Real > &factor)
Set the scaling factor for this variable.
SystemBase & sys()
Get the system this variable is part of.
Moose::VarKindType kind() const
Kind of the variable (Nonlinear, Auxiliary, ...)
unsigned int number() const
Get variable number coming from libMesh.
virtual const std::vector< dof_id_type > & dofIndices() const final
Get local DoF indices.
virtual const std::vector< dof_id_type > & dofIndicesNeighbor() const final
Get neighbor DOF indices for currently selected element.
Intermediate base class that ties together all the interfaces for getting MooseVariables with the Moo...
unsigned int number() const
Gets the number of this system.
void accumulateTaggedLocalResidual()
Local residual blocks will be appended by adding the current local kernel residual.
void addResidualsAndJacobian(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
Add the provided incoming residuals and derivatives for the Jacobian, corresponding to the provided d...
void prepareVectorTagNeighbor(Assembly &assembly, unsigned int ivar)
Prepare data for computing element residual the according to active tags for DG and interface kernels...
void prepareVectorTag(Assembly &assembly, unsigned int ivar)
Prepare data for computing element residual according to active tags.
DenseVector< Number > _local_re
Holds local residual entries as they are accumulated by this Kernel.
This interface is designed for DGKernel, InternalSideUserObject, InterfaceUserObject,...
auto raw_value(const Eigen::Map< T > &in)
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
MaterialDataType
MaterialData types.
Definition MooseTypes.h:746
@ BOUNDARY_MATERIAL_DATA
Definition MooseTypes.h:748
@ VAR_AUXILIARY
Definition MooseTypes.h:771
A structure that is used to evaluate Moose functors logically at an element/cell center.