https://mooseframework.inl.gov
NSFVHeatFluxBC.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 "NSFVHeatFluxBC.h"
11 #include "NS.h"
12 #include "NSEnums.h"
13 
14 registerADMooseObject("NavierStokesApp", NSFVHeatFluxBC);
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.addCoupledVar(NS::porosity, "porosity");
34  params.addParam<PostprocessorName>("average_porosity",
35  "postprocessor that provides domain-averaged porosity");
36  params.addParam<PostprocessorName>(
37  "average_k_fluid", "postprocessor that provides domain-averaged fluid thermal conductivity");
38  params.addParam<PostprocessorName>(
39  "average_kappa", "postprocessor that provides domain-averaged fluid thermal dispersion");
40  params.addParam<PostprocessorName>(
41  "average_k_solid", "postprocessor that provides domain-averaged solid thermal conductivity");
42  params.addParam<PostprocessorName>(
43  "average_kappa_solid",
44  "postprocessor that provides domain-averaged solid effective thermal "
45  "conductivity");
46  params.addClassDescription("Constant heat flux boundary condition with phase splitting "
47  "for fluid and solid energy equations");
48  return params;
49 }
50 
52  : FVFluxBC(parameters),
53  _value(getParam<Real>("value")),
54  _phase(getParam<MooseEnum>("phase").getEnum<NS::phase::PhaseEnum>()),
55  _split_type(getParam<MooseEnum>("splitting").getEnum<NS::splitting::SplittingEnum>()),
56  _locality(getParam<MooseEnum>("locality").getEnum<NS::settings::LocalityEnum>()),
57  // quantities needed for global evaluations
58  _average_eps(_locality == NS::settings::global &&
59  _split_type != NS::splitting::thermal_conductivity
60  ? &getPostprocessorValue("average_porosity")
61  : nullptr),
62  _average_k_f(_locality == NS::settings::global && _split_type != NS::splitting::porosity
63  ? &getPostprocessorValue("average_k_fluid")
64  : nullptr),
65  _average_k_s(_locality == NS::settings::global &&
66  _split_type == NS::splitting::thermal_conductivity
67  ? &getPostprocessorValue("average_k_solid")
68  : nullptr),
69  _average_kappa_s(_locality == NS::settings::global &&
70  _split_type == NS::splitting::effective_thermal_conductivity
71  ? &getPostprocessorValue("average_kappa_solid")
72  : nullptr),
73  _average_kappa(_locality == NS::settings::global &&
74  _split_type == NS::splitting::effective_thermal_conductivity
75  ? &getPostprocessorValue("average_kappa")
76  : nullptr),
77  // quantities needed for local evaluations
78  _eps(_locality == NS::settings::local && _split_type != NS::splitting::thermal_conductivity
79  ? coupledValue(NS::porosity)
80  : _zero),
81  _k_f(_locality == NS::settings::local && _split_type != NS::splitting::porosity
82  ? &getADMaterialProperty<Real>(NS::k)
83  : nullptr),
84  _k_s(_locality == NS::settings::local && _split_type == NS::splitting::thermal_conductivity
85  ? &getADMaterialProperty<Real>(NS::k_s)
86  : nullptr),
87  _kappa(_locality == NS::settings::local &&
88  _split_type == NS::splitting::effective_thermal_conductivity
89  ? &getADMaterialProperty<RealVectorValue>(NS::kappa)
90  : nullptr),
91  _kappa_s(_locality == NS::settings::local &&
92  _split_type == NS::splitting::effective_thermal_conductivity
93  ? &getADMaterialProperty<Real>(NS::kappa_s)
94  : nullptr)
95 {
96 }
97 
98 ADReal
100 {
101  // we don't need default statements in the switch-case statements for
102  // the SplittingEnum because we by default set the fraction to zero such that
103  // all of the heat flux enters the solid phase (though this default is never
104  // reached since the InputParameters class requires the MooseEnum to be
105  // one of 'porosity', 'thermal_conductivity', or 'effective_thermal_conductivity'
106  ADReal fraction = 0.0;
108 
110  {
111  switch (_split_type)
112  {
114  {
115  fraction = _eps[_qp];
116  break;
117  }
119  {
120  ADReal d = (*_k_f)[_qp] + (*_k_s)[_qp];
121  fraction = d > tol ? (*_k_f)[_qp] / d : 0.5;
122  break;
123  }
125  {
126  // TODO: for the case of an anisotropic conductivity, we technically should
127  // grab the component of kappa perpendicular to the boundary.
128 
129  // Need this logic to avoid AD failures when taking norms of zero. The
130  // division by sqrt(3) ensures equivalence with a non-vector form of kappa with
131  // 3 components
132  ADReal kappa;
133  if ((MooseUtils::absoluteFuzzyEqual((*_kappa)[_qp](0), 0)) &&
136  kappa = 1e-42;
137  else
138  kappa = (*_kappa)[_qp].norm() / std::sqrt(3.0);
139 
140  ADReal d = _eps[_qp] * kappa + (*_kappa_s)[_qp];
141  fraction = d > tol ? _eps[_qp] * kappa / d : 0.5;
142  break;
143  }
144  }
145  }
146  else
147  {
148  switch (_split_type)
149  {
151  {
152  fraction = *_average_eps;
153  break;
154  }
156  {
158  fraction = d > tol ? *_average_k_f / d : 0.5;
159  break;
160  }
162  {
163  ADReal d = (*_average_eps) * (*_average_kappa) + (*_average_kappa_s);
164  fraction = d > tol ? (*_average_eps) * (*_average_kappa) / d : 0.5;
165  break;
166  }
167  }
168  }
169 
170  if (_phase == NS::phase::solid)
171  return (1.0 - fraction) * -_value;
172  else
173  return fraction * -_value;
174 }
const PostprocessorValue * _average_k_s
Domain-average solid thermal conductivity.
static const std::string kappa_s
Definition: NS.h:117
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
static InputParameters validParams()
static InputParameters validParams()
const PostprocessorValue * _average_k_f
Domain-average fluid thermal conductivity.
const double tol
NSFVHeatFluxBC(const InputParameters &parameters)
DualNumber< Real, DNDerivativeType, true > ADReal
void addRequiredParam(const std::string &name, const std::string &doc_string)
virtual ADReal computeQpResidual() override
const PostprocessorValue * _average_eps
Domain-average porosity.
const unsigned int _qp
static const std::string k_s
Definition: NS.h:120
const NS::splitting::SplittingEnum _split_type
What parameters are used to split the heat flux, i.e.
static const std::string porosity
Definition: NS.h:104
const NS::phase::PhaseEnum _phase
Which phase this boundary condition is applied to, i.e. &#39;fluid&#39; or &#39;solid&#39;.
This boundary condition sets a constant heat flux with a splitting between the fluid and solid phases...
registerADMooseObject("NavierStokesApp", NSFVHeatFluxBC)
MooseEnum getLocalityEnum()
Definition: NSEnums.C:19
const NS::settings::LocalityEnum _locality
Where the values used in computing the splitting are pulled from, i.e.
void addCoupledVar(const std::string &name, const std::string &doc_string)
static const std::string kappa
Definition: NS.h:116
const ADMaterialProperty< RealVectorValue > * _kappa
Fluid effective thermal conductivity.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
MooseEnum getPhaseEnum()
Definition: NSEnums.C:13
static const Real k_epsilon
Definition: NS.h:207
MooseEnum getSplittingEnum()
Definition: NSEnums.C:25
const Real & _value
Value of the heat flux.
static const std::string k
Definition: NS.h:130
const VariableValue & _eps
Porosity.