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
44{
45 const auto face_type = fi.faceType(std::make_pair(_var.number(), _var.sys().number()));
46
47 if (face_type == FaceInfo::VarFaceNeighbors::BOTH)
48 mooseError("FVFluxBC '",
49 name(),
50 "' for variable '",
51 _var.name(),
52 "' is being triggered on an internal face with centroid ",
53 fi.faceCentroid(),
54 " where the variable is defined on both sides.");
55 else if (face_type == FaceInfo::VarFaceNeighbors::NEITHER)
56 mooseError("FVFluxBC '",
57 name(),
58 "' for variable '",
59 _var.name(),
60 "' is being triggered on a face with centroid ",
61 fi.faceCentroid(),
62 " where the variable is defined on neither side.");
63
64 return face_type;
65}
66
67void
69{
70 _face_info = &fi;
71 _normal = fi.normal();
73
74 // For FV flux kernels, the normal is always oriented outward from the lower-id
75 // element's perspective. But for BCs, there is only a residual
76 // contribution to one element (one side of the face). Because of this, we
77 // make an exception and orient the normal to point outward from whichever
78 // side of the face the BC's variable is defined on; we flip it if this
79 // variable is defined on the neighbor side of the face (instead of elem) since
80 // the FaceInfo normal polarity is always oriented with respect to the lower-id element.
83}
84
85void
87{
89
91
92 // This could be an "internal" boundary - one created by variable block
93 // restriction where the var is only defined on one side of the face. We
94 // need to make sure that we add the residual contribution to the correct
95 // side - the one where the variable is defined.
100
101 _local_re(0) = r;
103}
104
105void
110
111void
113{
115
116 ADReal r = fi.faceArea() * fi.faceCoord() * computeQpResidual();
117
118 const auto & dof_indices = (_face_type == FaceInfo::VarFaceNeighbors::ELEM)
119 ? _var.dofIndices()
121
122 mooseAssert(dof_indices.size() == 1, "We're currently built to use CONSTANT MONOMIALS");
123
124 addResidualsAndJacobian(_assembly, std::array<ADReal, 1>{{r}}, dof_indices, _var.scalingFactor());
125}
126
128FVFluxBC::elemArg(const bool correct_skewness) const
129{
130 return {&_face_info->elem(), correct_skewness};
131}
132
134FVFluxBC::neighborArg(const bool correct_skewness) const
135{
136 return {_face_info->neighborPtr(), correct_skewness};
137}
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:134
void computeJacobian(const FaceInfo &fi) override
Compute the jacobian on the supplied face.
Definition FVFluxBC.C:112
void computeResidual(const FaceInfo &fi) override
Compute the residual on the supplied face.
Definition FVFluxBC.C:86
ADRealVectorValue _normal
Definition FVFluxBC.h:54
FaceInfo::VarFaceNeighbors checkFaceIntegrity(const FaceInfo &fi) const
Check that this boundary condition's variable is defined on exactly one side of the face.
Definition FVFluxBC.C:43
void updateCurrentFace(const FaceInfo &fi)
Update internal structures (normal, face type, etc) for the given face.
Definition FVFluxBC.C:68
FaceInfo::VarFaceNeighbors _face_type
The variable face type.
Definition FVFluxBC.h:67
Moose::ElemArg elemArg(bool correct_skewness=false) const
Definition FVFluxBC.C:128
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:106
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
VarFaceNeighbors
This enum is used to indicate which side(s) of a face a particular variable is defined on.
Definition FaceInfo.h:53
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.
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
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.