Skip to content

Commit

Permalink
Added FVFunctorConvectiveHeatFluxBC test and documentation for FVFunc…
Browse files Browse the repository at this point in the history
…torConvectiveHeatFluxBC and FVFunctorNeumannBC (#21632)
  • Loading branch information
CooperTrucks authored and GiudGiud committed Jan 3, 2023
1 parent aca37ef commit 7fa4324
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@

# Description

This boundary condition computes convective heat flux $q'' = H \cdot (T - T_{inf})$, where $H$ is convective heat transfer coefficient,
$T$ is the temperature, and $T_{inf}$ is far field temperature. Both $H$ and $T_{inf}$ are coupled as functors.
The domain can be specified as either a fluid or a solid using $is_solid$. For a solid domain, the equation above is applied.
For a fluid domain, the negative of the heat flux is applied. This allows for easier implementation of a double Robin
boundary condition.

See [CoupledConvectiveHeatFluxBC](CoupledConvectiveHeatFluxBC.md) for a similar boundary condition coupled to variables, and see [FunctorThermalResistanceBC](FunctorThermalResistanceBC.md) for a combined conduction, convection, and radiative boundary condition
with functor material properties.

!syntax parameters /FVBCs/FVFunctorConvectiveHeatFluxBC

!syntax inputs /FVBCs/FVFunctorConvectiveHeatFluxBC

!syntax children /FVBCs/FVFunctorConvectiveHeatFluxBC

!bibtex bibliography
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
#include "FVFluxBC.h"

/**
* Neumann boundary (== inflow) condition for finite volume scheme
* where the inflow is given as a functor
* Robin boundary condition (temperatures) for finite volume scheme between
* a solid and fluid where the temperatures and heat transfer coefficient
* is given as a functor
*/
class FVFunctorConvectiveHeatFluxBC : public FVFluxBC
{
Expand All @@ -25,15 +26,15 @@ class FVFunctorConvectiveHeatFluxBC : public FVFluxBC
protected:
virtual ADReal computeQpResidual() override;

/// Walltemperature variable
/// Wall temperature functor
const Moose::Functor<ADReal> & _T_wall;

/// Far-field temperature variable
/// Far-field temperature functor
const Moose::Functor<ADReal> & _T_infinity;

/// Convective heat transfer coefficient
/// Convective heat transfer coefficient functor
const Moose::Functor<ADReal> & _htc;

/// Boolean specifying if domain is solid or fluid
const bool _is_solid;
// unsigned int _t
};
36 changes: 12 additions & 24 deletions modules/heat_conduction/src/fvbcs/FVFunctorConvectiveHeatFluxBC.C
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,32 @@ FVFunctorConvectiveHeatFluxBC::validParams()
InputParameters params = FVFluxBC::validParams();
params.addClassDescription(
"Convective heat transfer boundary condition with temperature and heat "
"transfer coefficent given by material properties.");
params.addRequiredParam<MooseFunctorName>("T_wall",
"Functor for wall temperature");
params.addRequiredParam<MooseFunctorName>("T_infinity",
"Functor for far-field temperature");
"transfer coefficent given by functors.");
params.addRequiredParam<MooseFunctorName>("T_wall", "Functor for wall temperature");
params.addRequiredParam<MooseFunctorName>("T_infinity", "Functor for far-field temperature");
params.addRequiredParam<MooseFunctorName>("heat_transfer_coefficient",
"Functor for heat transfer coefficient");
"Functor for heat transfer coefficient");
params.addRequiredParam<bool>("is_solid", "Whether this kernel acts on the solid temperature");
// params.addParam<MaterialPropertyName>(
// "heat_transfer_coefficient_dT",
// "0",
// "Material property for derivative of heat transfer coefficient with respect to temperature");

return params;
}

FVFunctorConvectiveHeatFluxBC::FVFunctorConvectiveHeatFluxBC(const InputParameters & parameters)
: FVFluxBC(parameters),
_T_wall(getFunctor<ADReal>("T_wall")),
_T_infinity(getFunctor<ADReal>("T_infinity")),
_htc(getFunctor<ADReal>("heat_transfer_coefficient")),
_is_solid(getParam<bool>("is_solid"))
// _htc_dT(getMaterialProperty<ADReal>("heat_transfer_coefficient_dT"))
_T_wall(getFunctor<ADReal>("T_wall")),
_T_infinity(getFunctor<ADReal>("T_infinity")),
_htc(getFunctor<ADReal>("heat_transfer_coefficient")),
_is_solid(getParam<bool>("is_solid"))
{
}

ADReal
FVFunctorConvectiveHeatFluxBC::computeQpResidual()
{
if (_is_solid)
return -_htc(singleSidedFaceArg()) * (_T_infinity(singleSidedFaceArg()) - _T_wall(singleSidedFaceArg()) );
return -_htc(singleSidedFaceArg()) *
(_T_infinity(singleSidedFaceArg()) - _T_wall(singleSidedFaceArg()));
else
return _htc(singleSidedFaceArg()) * (_T_infinity(singleSidedFaceArg()) - _T_wall(singleSidedFaceArg()) );
return _htc(singleSidedFaceArg()) *
(_T_infinity(singleSidedFaceArg()) - _T_wall(singleSidedFaceArg()));
}
//
// ADReal
// FVFunctorConvectiveHeatFluxBC::computeQpJacobian()
// {
// return -_test[_i][_qp] * _phi[_j][_qp] *
// (-_htc[_qp] + _htc_dT[_qp] * (_T_infinity[_qp] - _u[_qp]));
// }
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
[Mesh]
[gen]
type = GeneratedMeshGenerator
dim = 2
nx = 5
ny = 5
xmax = 2
[]
[]

[Variables]
[T_fluid]
type = MooseVariableFVReal
initial_condition = 0
[]
[]

[AuxVariables]
[T_wall]
type = MooseVariableFVReal
initial_condition = 1
[]
[]

[AuxKernels]
[wall_temp]
type = ConstantAux
variable = T_wall
value = 1
[]
[]

[FVKernels]
[diff_left]
type = FVDiffusion
variable = T_fluid
coeff = 4
[]
[gradient_creating]
type = FVBodyForce
variable = T_fluid
[]
[]

[FVBCs]
[top]
type = FVFunctorConvectiveHeatFluxBC
boundary = 'top'
variable = T_fluid
T_infinity = T_fluid
T_wall = T_wall
is_solid = false
heat_transfer_coefficient = 'htc'
[]
[other]
type = FVDirichletBC
variable = T_fluid
boundary = 'bottom'
value = 0
[]
[]

[Materials]
[cht]
type = ADGenericFunctorMaterial
prop_names = 'htc'
prop_values = '1'
[]
[]

[Executioner]
type = Steady
solve_type = NEWTON
[]

[Outputs]
exodus = true
[]
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Tests]
[FVFunctorConvectiveHeatFlux]
issues = '#21632'
design = 'FVFunctorConvectiveHeatFlux.md'
requirement = 'The system shall provide a convective heat flux boundary condition which uses functors as heat transfer coefficients and far-field temperature values'
type = Exodiff
input = fv_functor_convective_heat_flux.i
exodiff = 'fv_functor_convective_heat_flux_out.e'
ad_indexing_type = 'global'
[]
[]
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

# Description

This object is equivalent to [FVNeumannBC.md] with the exception that the
constant `value` parameter is replaced by the `functor` parameter.

!syntax parameters /FVBCs/FVFunctorNeumannBC

Expand Down
2 changes: 1 addition & 1 deletion modules/navier_stokes/include/fvbcs/FVFunctorNeumannBC.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ class FVFunctorNeumannBC : public FVFluxBC
virtual ADReal computeQpResidual() override;

const Moose::Functor<ADReal> & _functor;
const Real _factor;
const Moose::Functor<ADReal> & _factor;
};
56 changes: 0 additions & 56 deletions modules/navier_stokes/src/fvbcs/FVFunctorConvectiveHeatFluxBC.C

This file was deleted.

15 changes: 9 additions & 6 deletions modules/navier_stokes/src/fvbcs/FVFunctorNeumannBC.C
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@ FVFunctorNeumannBC::validParams()
{
InputParameters params = FVFluxBC::validParams();
params.addClassDescription("Neumann boundary condition for finite volume method.");
params.addParam<Real>("factor",
1.,
"A factor for multiplying the function. This could be useful for flipping "
"the sign of the function for example based off the normal");
params.addParam<MooseFunctorName>("factor",
1.,
"A factor in the form of a functor for multiplying the "
"function. This could be useful for flipping "
"the sign of the function for example based off the normal");
params.addRequiredParam<MooseFunctorName>("functor",
"The value of the flux crossing the boundary.");
return params;
}

FVFunctorNeumannBC::FVFunctorNeumannBC(const InputParameters & parameters)
: FVFluxBC(parameters), _functor(getFunctor<ADReal>("functor")), _factor(getParam<Real>("factor"))
: FVFluxBC(parameters),
_functor(getFunctor<ADReal>("functor")),
_factor(getFunctor<ADReal>("factor"))
{
}

ADReal
FVFunctorNeumannBC::computeQpResidual()
{
return -_factor * _functor(singleSidedFaceArg());
return -_factor(singleSidedFaceArg()) * _functor(singleSidedFaceArg());
}

0 comments on commit 7fa4324

Please sign in to comment.