Skip to content

Commit

Permalink
Move GapPerfectConductance from BISON to MOOSE. Closes #28963.
Browse files Browse the repository at this point in the history
  • Loading branch information
gambka committed Oct 31, 2024
1 parent b8db753 commit 81b1e02
Show file tree
Hide file tree
Showing 9 changed files with 467 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# GapPerfectConductance

!syntax description /BCs/GapPerfectConductance

!alert note title=Often Created by an Action
This object can be set up automatically by using the [ThermalContact](syntax/ThermalContact/index.md) action.

## Description

This class enforces that temperatures match across the gap. Specifically, the temperature on the secondary surface will match the temperature on the primary surface. This is accomplished through a penalty constraint. The residual is
\begin{equation}
r = k (T_s - T_p)
\end{equation}
where $k$ is the penalty value, $T_s$ is the temperature on the secondary surface, and $T_p$ is the temperature on the primary surface.

## Example Input Syntax

!listing test/tests/gap_perfect_transfer/gap_perfect_transfer.i block=ThermalContact

!syntax parameters /BCs/GapPerfectConductance

!syntax inputs /BCs/GapPerfectConductance

!syntax children /BCs/GapPerfectConductance
33 changes: 33 additions & 0 deletions modules/heat_transfer/include/bcs/GapPerfectConductance.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#pragma once

#include "IntegratedBC.h"

class GapPerfectConductance : public IntegratedBC
{
public:
static InputParameters validParams();
GapPerfectConductance(const InputParameters & parameters);

virtual ~GapPerfectConductance() {}

protected:
virtual Real computeQpResidual();
virtual Real computeQpJacobian();

/// AuxVariable holding the gap_distance
const VariableValue & _gap_distance;

/// AuxVariable holding the temperature on the secondary surface
const VariableValue & _gap_temp;

const Real _penalty;
};
50 changes: 33 additions & 17 deletions modules/heat_transfer/src/actions/ThermalContactAction.C
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ ThermalContactAction::validParams()
"warnings", false, "Whether to output warning messages concerning nodes not being found");
params.addParam<bool>(
"quadrature", false, "Whether or not to use quadrature point based gap heat transfer");

params.addRangeCheckedParam<Real>("penalty",
1.0,
"penalty>0",
"The penalty used in the residual and Jacobian calculations "
"when using the GapPerfectConductance model");
params.addParam<std::string>(
"appended_property_name", "", "Name appended to material properties to make them unique");
params.addRequiredParam<std::string>(
Expand Down Expand Up @@ -267,30 +271,42 @@ ThermalContactAction::addBCs()
InputParameters params = _factory.getValidParams(object_name);
params.applyParameters(parameters());

if (_quadrature)
{
params.set<BoundaryName>("paired_boundary") = contact_pair.first;
params.set<bool>("use_displaced_mesh") = true;
}
else
if (object_name == "GapPerfectConductance")
{
params.set<Real>("penalty") = getParam<Real>("penalty");
params.set<std::vector<VariableName>>("gap_distance") = {"penetration"};
params.set<std::vector<VariableName>>("gap_temp") = {_gap_value_name};
params.set<std::vector<BoundaryName>>("boundary") = {contact_pair.second};
_problem->addBoundaryCondition(
object_name, "gap_bc_" + name() + "_" + Moose::stringify(bcs_counter), params);
}
else
{
if (_quadrature)
{
params.set<BoundaryName>("paired_boundary") = contact_pair.first;
params.set<bool>("use_displaced_mesh") = true;
}
else
{
params.set<std::vector<VariableName>>("gap_distance") = {"penetration"};
params.set<std::vector<VariableName>>("gap_temp") = {_gap_value_name};
}

params.set<std::vector<BoundaryName>>("boundary") = {contact_pair.second};
params.set<std::vector<BoundaryName>>("boundary") = {contact_pair.second};

_problem->addBoundaryCondition(
object_name, "gap_bc_" + name() + "_" + Moose::stringify(bcs_counter), params);
_problem->addBoundaryCondition(
object_name, "gap_bc_" + name() + "_" + Moose::stringify(bcs_counter), params);

if (_quadrature)
{
// Swap primary and secondary for this one
params.set<std::vector<BoundaryName>>("boundary") = {contact_pair.first};
params.set<BoundaryName>("paired_boundary") = contact_pair.second;
if (_quadrature)
{
// Swap primary and secondary for this one
params.set<std::vector<BoundaryName>>("boundary") = {contact_pair.first};
params.set<BoundaryName>("paired_boundary") = contact_pair.second;

_problem->addBoundaryCondition(
object_name, "gap_bc_primary_" + name() + "_" + Moose::stringify(bcs_counter), params);
_problem->addBoundaryCondition(
object_name, "gap_bc_primary_" + name() + "_" + Moose::stringify(bcs_counter), params);
}
}
bcs_counter++;
}
Expand Down
43 changes: 43 additions & 0 deletions modules/heat_transfer/src/bcs/GapPerfectConductance.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#include "GapPerfectConductance.h"

registerMooseObject("HeatTransferApp", GapPerfectConductance);

InputParameters
GapPerfectConductance::validParams()
{
InputParameters params = IntegratedBC::validParams();
params.addClassDescription("Enforces equal temperatures across the gap.");
params.addRequiredCoupledVar("gap_distance", "Distance across the gap.");
params.addRequiredCoupledVar("gap_temp", "Temperature on the other side of the gap.");
params.addParam<Real>("penalty", 1, "Penalty value to be applied to the constraint.");
return params;
}

GapPerfectConductance::GapPerfectConductance(const InputParameters & parameters)
: IntegratedBC(parameters),
_gap_distance(coupledValue("gap_distance")),
_gap_temp(coupledValue("gap_temp")),
_penalty(getParam<Real>("penalty"))
{
}

Real
GapPerfectConductance::computeQpResidual()
{
return _penalty * (_u[_qp] - _gap_temp[_qp]);
}

Real
GapPerfectConductance::computeQpJacobian()
{
return _penalty;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#
# 1-D Gap Perfect Heat Transfer
#
# The mesh consists of two element blocks containing one element each. Each
# element is a unit line. They sit next to one another with a unit between
# them.
#
# The temperature of the far left boundary is ramped from 100 to 200 over one
# second and then held fixed. The temperature of the far right boundary
# follows due to the perfect heat transfer.
#

[Mesh]
[left]
type = GeneratedMeshGenerator
dim = 1
boundary_name_prefix = left
[]
[right]
type = GeneratedMeshGenerator
dim = 1
xmin = 2
boundary_name_prefix = right
boundary_id_offset = 2
[]
[right_block]
type = SubdomainIDGenerator
input = right
subdomain_id = 1
[]
[collect]
type = CombinerGenerator
inputs = 'left right_block'
[]
[]

[Functions]
[temperature]
type = PiecewiseLinear
x = '0 1 2'
y = '100 200 200'
[]
[]

[Variables]
[temperature]
order = FIRST
family = LAGRANGE
initial_condition = 100
[]
[]

[Kernels]
[heat]
type = HeatConduction
variable = temperature
[]
[]

[BCs]
[temp_far_left]
type = FunctionDirichletBC
boundary = 0
variable = temperature
function = temperature
[]
[]

[ThermalContact]
[thermal_contact_1]
type = GapPerfectConductance
variable = temperature
primary = 1
secondary = 2
[]
[]

[Materials]
[heat1]
type = HeatConductionMaterial
block = 0
specific_heat = 1.0
thermal_conductivity = 1.0
[]
[heat2]
type = HeatConductionMaterial
block = 1
specific_heat = 1.0
thermal_conductivity = 10.0
[]
[]

[Executioner]
type = Transient

solve_type = 'PJFNK'

petsc_options_iname = '-pc_type -pc_factor_mat_solver_package'
petsc_options_value = 'lu superlu_dist'

line_search = 'none'

nl_abs_tol = 1e-8
nl_rel_tol = 1e-14

l_tol = 1e-3
l_max_its = 100

start_time = 0.0
dt = 1e-1
end_time = 2.0
num_steps = 50
[]

[Postprocessors]
[aveTempLeft]
type = SideAverageValue
boundary = 0
variable = temperature
execute_on = 'initial timestep_end'
[]
[aveTempRight]
type = SideAverageValue
boundary = 3
variable = temperature
execute_on = 'initial timestep_end'
[]
[]

[Outputs]
csv = true
[]
Loading

0 comments on commit 81b1e02

Please sign in to comment.