https://mooseframework.inl.gov
Loading...
Searching...
No Matches
INSFVTurbulentAdvection.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 "NavierStokesMethods.h"
12#include "NS.h"
13
15
18{
20 params.addClassDescription(
21 "Advects an arbitrary turbulent quantity, the associated nonlinear 'variable'.");
22 params.addRequiredParam<MooseFunctorName>(NS::density, "fluid density");
23 params.addParam<std::vector<BoundaryName>>(
24 "walls", {}, "Boundaries that correspond to solid walls.");
25 params.addParam<bool>("neglect_advection_derivatives",
26 true,
27 "Whether to remove automatic differentiation derivative terms "
28 "for velocity in the advection term");
29 return params;
30}
31
33 : INSFVAdvectionKernel(params),
34 _rho(getFunctor<ADReal>(NS::density)),
35 _wall_boundary_names(getParam<std::vector<BoundaryName>>("walls")),
36 _neglect_advection_derivatives(getParam<bool>("neglect_advection_derivatives"))
37{
38}
39
40void
47
50{
51 const auto v = _rc_vel_provider.getVelocity(
53 const auto var_face = _var(makeFace(*_face_info,
54 limiterType(_advected_interp_method),
57 const auto rho_face = _rho(makeFace(*_face_info,
58 limiterType(_advected_interp_method),
62 return _normal * v * rho_face * var_face;
63 else
64 return _normal * MetaPhysicL::raw_value(v) * rho_face * var_face;
65}
66
67void
69{
70 if (skipForBoundary(fi))
71 return;
72
73 _face_info = &fi;
74 _normal = fi.normal();
75 _face_type = _face_info->faceType(std::make_pair(_var.number(), _var.sys().number()));
77
78 const Elem * elem = fi.elemPtr();
79 const Elem * neighbor = fi.neighborPtr();
80 const auto bounded_elem = _wall_bounded.find(elem) != _wall_bounded.end();
81 const auto bounded_neigh = _wall_bounded.find(neighbor) != _wall_bounded.end();
82
83 if ((_face_type == FaceInfo::VarFaceNeighbors::ELEM ||
84 _face_type == FaceInfo::VarFaceNeighbors::BOTH) &&
85 (!bounded_elem))
86 {
87 // residual contribution of this kernel to the elem element
89 _local_re(0) = r;
91 }
92 if ((_face_type == FaceInfo::VarFaceNeighbors::NEIGHBOR ||
93 _face_type == FaceInfo::VarFaceNeighbors::BOTH) &&
94 (!bounded_neigh))
95 {
96 // residual contribution of this kernel to the neighbor element
98 _local_re(0) = -r;
100 }
101}
102
103void
105{
106 if (skipForBoundary(fi))
107 return;
108
109 _face_info = &fi;
110 _normal = fi.normal();
111 _face_type = _face_info->faceType(std::make_pair(_var.number(), _var.sys().number()));
112 const ADReal r = fi.faceArea() * fi.faceCoord() * computeQpResidual();
113
114 const Elem * elem = fi.elemPtr();
115 const Elem * neighbor = fi.neighborPtr();
116 const auto bounded_elem = _wall_bounded.find(elem) != _wall_bounded.end();
117 const auto bounded_neigh = _wall_bounded.find(neighbor) != _wall_bounded.end();
118
119 if ((_face_type == FaceInfo::VarFaceNeighbors::ELEM ||
120 _face_type == FaceInfo::VarFaceNeighbors::BOTH) &&
121 (!bounded_elem))
122 {
123 mooseAssert(_var.dofIndices().size() == 1, "We're currently built to use CONSTANT MONOMIALS");
124
126 _assembly, std::array<ADReal, 1>{{r}}, _var.dofIndices(), _var.scalingFactor());
127 }
128
129 if ((_face_type == FaceInfo::VarFaceNeighbors::NEIGHBOR ||
130 _face_type == FaceInfo::VarFaceNeighbors::BOTH) &&
131 (!bounded_neigh))
132 {
133 mooseAssert((_face_type == FaceInfo::VarFaceNeighbors::NEIGHBOR) ==
134 (_var.dofIndices().size() == 0),
135 "If the variable is only defined on the neighbor hand side of the face, then that "
136 "means it should have no dof indices on the elem element. Conversely if "
137 "the variable is defined on both sides of the face, then it should have a non-zero "
138 "number of degrees of freedom on the elem element");
139
140 // We switch the sign for the neighbor residual
141 ADReal neighbor_r = -r;
142
143 mooseAssert(_var.dofIndicesNeighbor().size() == 1,
144 "We're currently built to use CONSTANT MONOMIALS");
145
147 std::array<ADReal, 1>{{neighbor_r}},
150 }
151}
DualNumber< Real, DNDerivativeType, true > ADReal
const double v
registerMooseObject("NavierStokesApp", INSFVTurbulentAdvection)
virtual const std::set< SubdomainID > & blockIDs() const
RealVectorValue _normal
void computeJacobian() override
MooseVariableFV< Real > & _var
void computeResidual() override
const FaceInfo * _face_info
FaceInfo::VarFaceNeighbors _face_type
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
const Point & normal() const
VarFaceNeighbors faceType(const std::pair< unsigned int, unsigned int > &var_sys) const
const Elem * neighborPtr() const
Real faceArea() const
Real & faceCoord()
const Elem * elemPtr() const
An advection kernel that implements interpolation schemes specific to Navier-Stokes flow physics.
bool skipForBoundary(const FaceInfo &fi) const override
Moose::FV::InterpMethod _velocity_interp_method
The interpolation method to use for the velocity.
Moose::FV::InterpMethod _advected_interp_method
The interpolation method to use for the advected quantity.
static InputParameters validParams()
const RhieChowInterpolatorBase & _rc_vel_provider
The Rhie-Chow user object that provides us with the velocity.
Computes the advection term with the assumption that the advected quantity will have special wall tre...
static InputParameters validParams()
const Moose::Functor< ADReal > & _rho
std::unordered_set< const Elem * > _wall_bounded
List for wall treatment.
const bool _neglect_advection_derivatives
Whether to remove the derivative of this term wrt to velocity.
INSFVTurbulentAdvection(const InputParameters &params)
virtual void initialSetup() override
const std::vector< BoundaryName > & _wall_boundary_names
Wall boundaries.
void scalingFactor(const std::vector< Real > &factor)
SystemBase & sys()
unsigned int number() const
virtual const std::vector< dof_id_type > & dofIndices() const final
virtual const std::vector< dof_id_type > & dofIndicesNeighbor() const final
THREAD_ID _tid
Assembly & _assembly
SubProblem & _subproblem
FEProblemBase & _fe_problem
virtual VectorValue< ADReal > getVelocity(const Moose::FV::InterpMethod m, const FaceInfo &fi, const Moose::StateArg &time, const THREAD_ID tid, bool subtract_mesh_velocity) const =0
Retrieve a face velocity.
unsigned int number() const
void accumulateTaggedLocalResidual()
void addResidualsAndJacobian(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
void prepareVectorTagNeighbor(Assembly &assembly, unsigned int ivar)
void prepareVectorTag(Assembly &assembly, unsigned int ivar)
DenseVector< Number > _local_re
Moose::StateArg determineState() const
auto raw_value(const Eigen::Map< T > &in)
void getWallBoundedElements(const std::vector< BoundaryName > &wall_boundary_name, const FEProblemBase &fe_problem, const SubProblem &subproblem, const std::set< SubdomainID > &block_ids, std::unordered_set< const Elem * > &wall_bounded)
Map marking wall bounded elements The map passed in wall_bounded_map gets cleared and re-populated.
static const std::string density
Definition NS.h:34