https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NSFVFunctorHeatFluxBC.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 "NS.h"
12#include "NSEnums.h"
13
15
18{
20
21 params.addRequiredParam<Real>("value", "total heat flux");
23 "phase", getPhaseEnum(), "'fluid' or 'solid' phase to which this BC is applied.");
24
25 params.addRequiredParam<MooseEnum>("splitting", getSplittingEnum(), "type of splitting");
26
28 "locality",
30 "whether to use local (at the boundary) or global (domain-averaged) "
31 "parameter values");
32
33 params.addParam<MooseFunctorName>(NS::porosity, "porosity");
34 params.addParam<PostprocessorName>("average_porosity",
35 "postprocessor that provides domain-averaged proosity");
36
37 // Name of the material properties, useful if not following the NS namespace conventions
38 params.addParam<MooseFunctorName>(NS::k, NS::k, "Fluid phase thermal conductivity");
39 params.addParam<MooseFunctorName>(NS::k_s, NS::k_s, "Solid phase thermal conductivity");
40 params.addParam<MooseFunctorName>(
41 NS::kappa, NS::kappa, "Fluid phase effective thermal conductivity");
42 params.addParam<MooseFunctorName>(
43 NS::kappa_s, NS::kappa_s, "Solid phase effective thermal conductivity");
44
45 params.addParam<PostprocessorName>(
46 "average_k_fluid", "postprocessor that provides domain-averaged fluid thermal conductivity");
47 params.addParam<PostprocessorName>(
48 "average_kappa", "postprocessor that provides domain-averaged fluid thermal dispersion");
49 params.addParam<PostprocessorName>(
50 "average_k_solid", "postprocessor that provides domain-averaged solid thermal conductivity");
51 params.addParam<PostprocessorName>(
52 "average_kappa_solid",
53 "postprocessor that provides domain-averaged solid effective thermal "
54 "conductivity");
55 params.addClassDescription("Constant heat flux boundary condition with phase splitting "
56 "for fluid and solid energy equations");
57 return params;
58}
59
61 : FVFluxBC(parameters),
62 _value(getParam<Real>("value")),
63 _phase(getParam<MooseEnum>("phase").getEnum<NS::phase::PhaseEnum>()),
64 _split_type(getParam<MooseEnum>("splitting").getEnum<NS::splitting::SplittingEnum>()),
65 _locality(getParam<MooseEnum>("locality").getEnum<NS::settings::LocalityEnum>()),
66 // quantities needed for global evaluations
67 _average_eps(_locality == NS::settings::global &&
68 _split_type != NS::splitting::thermal_conductivity
69 ? &getPostprocessorValue("average_porosity")
70 : nullptr),
71 _average_k_f(_locality == NS::settings::global && _split_type != NS::splitting::porosity
72 ? &getPostprocessorValue("average_k_fluid")
73 : nullptr),
74 _average_k_s(_locality == NS::settings::global &&
75 _split_type == NS::splitting::thermal_conductivity
76 ? &getPostprocessorValue("average_k_solid")
77 : nullptr),
78 _average_kappa_s(_locality == NS::settings::global &&
79 _split_type == NS::splitting::effective_thermal_conductivity
80 ? &getPostprocessorValue("average_kappa_solid")
81 : nullptr),
82 _average_kappa(_locality == NS::settings::global &&
83 _split_type == NS::splitting::effective_thermal_conductivity
84 ? &getPostprocessorValue("average_kappa")
85 : nullptr),
86 // quantities needed for local evaluations
87 _eps(_locality == NS::settings::local && _split_type != NS::splitting::thermal_conductivity
88 ? &getFunctor<ADReal>(NS::porosity)
89 : nullptr),
90 _k_f(_locality == NS::settings::local && _split_type != NS::splitting::porosity
91 ? &getFunctor<ADReal>(NS::k)
92 : nullptr),
93 _k_s(_locality == NS::settings::local && _split_type == NS::splitting::thermal_conductivity
94 ? &getFunctor<ADReal>(NS::k_s)
95 : nullptr),
96 _kappa(_locality == NS::settings::local &&
97 _split_type == NS::splitting::effective_thermal_conductivity
98 ? &getFunctor<ADRealVectorValue>(NS::kappa)
99 : nullptr),
100 _kappa_s(_locality == NS::settings::local &&
101 _split_type == NS::splitting::effective_thermal_conductivity
102 ? &getFunctor<ADReal>(NS::kappa_s)
103 : nullptr)
104{
105}
106
107ADReal
109{
110 // we don't need default statements in the switch-case statements for
111 // the SplittingEnum because we by default set the fraction to zero such that
112 // all of the heat flux enters the solid phase (though this default is never
113 // reached since the InputParameters class requires the MooseEnum to be
114 // one of 'porosity', 'thermal_conductivity', or 'effective_thermal_conductivity'
115 ADReal fraction = 0.0;
117
118 // Get the functor argument for the face
119 const auto face_arg = singleSidedFaceArg();
120 const auto state = determineState();
121
123 {
124 switch (_split_type)
125 {
127 {
128 fraction = (*_eps)(face_arg, state);
129 break;
130 }
132 {
133 ADReal d = (*_k_f)(face_arg, state) + (*_k_s)(face_arg, state);
134 fraction = d > tol ? (*_k_f)(face_arg, state) / d : 0.5;
135 break;
136 }
138 {
139 // TODO: for the case of an anisotropic conductivity, we technically should
140 // grab the component of kappa perpendicular to the boundary.
141
142 // Need this logic to avoid AD failures when taking norms of zero. The
143 // division by sqrt(3) ensures equivalence with a non-vector form of kappa with
144 // 3 components
145 ADReal kappa;
146 if ((MooseUtils::absoluteFuzzyEqual((*_kappa)(face_arg, state)(0), 0)) &&
147 (MooseUtils::absoluteFuzzyEqual((*_kappa)(face_arg, state)(1), 0)) &&
148 (MooseUtils::absoluteFuzzyEqual((*_kappa)(face_arg, state)(2), 0)))
149 kappa = 1e-42;
150 else
151 kappa = (*_kappa)(face_arg, state).norm() / std::sqrt(3.0);
152
153 ADReal d = (*_eps)(face_arg, state) * kappa + (*_kappa_s)(face_arg, state);
154 fraction = d > tol ? (*_eps)(face_arg, state) * kappa / d : 0.5;
155 break;
156 }
157 }
158 }
159 else
160 {
161 switch (_split_type)
162 {
164 {
165 fraction = *_average_eps;
166 break;
167 }
169 {
171 fraction = d > tol ? *_average_k_f / d : 0.5;
172 break;
173 }
175 {
176 ADReal d = (*_average_eps) * (*_average_kappa) + (*_average_kappa_s);
177 fraction = d > tol ? (*_average_eps) * (*_average_kappa) / d : 0.5;
178 break;
179 }
180 }
181 }
182
184 return (1.0 - fraction) * -_value;
185 else
186 return fraction * -_value;
187}
DualNumber< Real, DNDerivativeType, true > ADReal
const double tol
MooseEnum getLocalityEnum()
Definition NSEnums.C:19
MooseEnum getPhaseEnum()
Definition NSEnums.C:13
MooseEnum getSplittingEnum()
Definition NSEnums.C:25
registerADMooseObject("NavierStokesApp", NSFVFunctorHeatFluxBC)
Moose::FaceArg singleSidedFaceArg(const FaceInfo *fi=nullptr, Moose::FV::LimiterType limiter_type=Moose::FV::LimiterType::CentralDifference, bool correct_skewness=false, const Moose::StateArg *state_limiter=nullptr) const
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
This boundary condition sets a constant heat flux with a splitting between the fluid and solid phases...
const PostprocessorValue * _average_k_s
Domain-average solid thermal conductivity.
const Moose::Functor< ADRealVectorValue > * _kappa
Fluid effective thermal conductivity.
const Moose::Functor< ADReal > * _kappa_s
Solid effective thermal conductivity.
const NS::phase::PhaseEnum _phase
Which phase this boundary condition is applied to, i.e. 'fluid' or 'solid'.
virtual ADReal computeQpResidual() override
const PostprocessorValue * _average_eps
Domain-average porosity.
const PostprocessorValue * _average_k_f
Domain-average fluid thermal conductivity.
const NS::settings::LocalityEnum _locality
Where the values used in computing the splitting are pulled from, i.e.
const NS::splitting::SplittingEnum _split_type
What parameters are used to split the heat flux, i.e.
static InputParameters validParams()
const Moose::Functor< ADReal > * _k_s
Solid thermal conductivity.
const Real & _value
Value of the heat flux.
NSFVFunctorHeatFluxBC(const InputParameters &parameters)
Moose::StateArg determineState() const
@ thermal_conductivity
Definition NSEnums.h:49
@ effective_thermal_conductivity
Definition NSEnums.h:50
static const Real k_epsilon
Definition NS.h:230
static const std::string kappa_s
Definition NS.h:121
static const std::string k_s
Definition NS.h:124
static const std::string k
Definition NS.h:134
static const std::string kappa
Definition NS.h:120
static const std::string porosity
Definition NS.h:108