forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request idaholab#20993 from joshuahansel/hs-coupling
Added component to couple 2D heat structures
- Loading branch information
Showing
19 changed files
with
1,004 additions
and
21 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...s/doc/content/modules/thermal_hydraulics/source/bcs/HeatStructure2DCouplerBC.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!template load file=stubs/moose_object.md.template name=HeatStructure2DCouplerBC syntax=/BCs/HeatStructure2DCouplerBC |
1 change: 1 addition & 0 deletions
1
...doc/content/modules/thermal_hydraulics/source/bcs/HeatStructure2DCouplerRZBC.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!template load file=stubs/moose_object.md.template name=HeatStructure2DCouplerRZBC syntax=/BCs/HeatStructure2DCouplerRZBC |
39 changes: 39 additions & 0 deletions
39
.../content/modules/thermal_hydraulics/source/components/HeatStructure2DCoupler.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# HeatStructure2DCoupler | ||
|
||
This component couples two [2D heat structures](component_groups/heat_structure_2d.md) | ||
via a heat transfer coefficient. | ||
|
||
## Usage | ||
|
||
This component has the following restrictions: | ||
|
||
- The coupled heat structures must be [2D heat structures](component_groups/heat_structure_2d.md). | ||
- The coupled heat structures must be of the same type. | ||
- Only one boundary name may be provided in each of the | ||
[!param](/Components/HeatStructure2DCoupler/primary_boundary) and | ||
[!param](/Components/HeatStructure2DCoupler/secondary_boundary) parameters. | ||
- The meshes along the coupled boundaries must be coincident, i.e., each node | ||
on each side must be at an identical location as a node on the other side. | ||
|
||
!syntax parameters /Components/HeatStructure2DCoupler | ||
|
||
## Formulation | ||
|
||
!include heat_structure_formulation.md | ||
|
||
!include heat_structure_boundary_formulation_neumann.md | ||
|
||
For the heat structure $k$, the incoming boundary heat flux $q_b$ is computed as | ||
|
||
\begin{equation} | ||
q_b = \mathcal{H} (T_j - T_k) \eqc | ||
\end{equation} | ||
where | ||
|
||
- $\mathcal{H}$ is the heat transfer coefficient, | ||
- $T_k$ is the surface temperature of the heat structure $k$, and | ||
- $T_j$ is the surface temperature of the coupled heat structure $j$. | ||
|
||
!syntax inputs /Components/HeatStructure2DCoupler | ||
|
||
!syntax children /Components/HeatStructure2DCoupler |
41 changes: 41 additions & 0 deletions
41
modules/thermal_hydraulics/include/bcs/HeatStructure2DCouplerBC.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//* 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 "ADIntegratedBC.h" | ||
|
||
class MeshAlignment2D2D; | ||
|
||
/** | ||
* Applies BC for HeatStructure2DCoupler for plate heat structure | ||
*/ | ||
class HeatStructure2DCouplerBC : public ADIntegratedBC | ||
{ | ||
public: | ||
HeatStructure2DCouplerBC(const InputParameters & parameters); | ||
|
||
virtual ADReal computeQpResidual() override; | ||
|
||
protected: | ||
/// Heat transfer coefficient | ||
const Function & _htc; | ||
/// Variable number of the variable to transfer | ||
const unsigned int _coupled_variable_number; | ||
/// Mesh alignment object | ||
const MeshAlignment2D2D & _mesh_alignment; | ||
|
||
/// Nonlinear system | ||
const SystemBase & _nl_sys; | ||
/// Solution vector | ||
const NumericVector<Number> * const & _serialized_solution; | ||
|
||
public: | ||
static InputParameters validParams(); | ||
}; |
28 changes: 28 additions & 0 deletions
28
modules/thermal_hydraulics/include/bcs/HeatStructure2DCouplerRZBC.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//* 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 "HeatStructure2DCouplerBC.h" | ||
#include "RZSymmetry.h" | ||
|
||
/** | ||
* Applies BC for HeatStructure2DCoupler for cylindrical heat structure | ||
*/ | ||
class HeatStructure2DCouplerRZBC : public HeatStructure2DCouplerBC, public RZSymmetry | ||
{ | ||
public: | ||
HeatStructure2DCouplerRZBC(const InputParameters & parameters); | ||
|
||
protected: | ||
virtual ADReal computeQpResidual() override; | ||
|
||
public: | ||
static InputParameters validParams(); | ||
}; |
43 changes: 43 additions & 0 deletions
43
modules/thermal_hydraulics/include/components/HeatStructure2DCoupler.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
#pragma once | ||
|
||
#include "BoundaryBase.h" | ||
#include "MeshAlignment2D2D.h" | ||
|
||
/** | ||
* Couples boundaries of two 2D heat structures via a heat transfer coefficient | ||
*/ | ||
class HeatStructure2DCoupler : public BoundaryBase | ||
{ | ||
public: | ||
HeatStructure2DCoupler(const InputParameters & parameters); | ||
|
||
virtual void addMooseObjects() override; | ||
|
||
protected: | ||
virtual void init() override; | ||
virtual void check() const override; | ||
|
||
/// Primary and secondary heat structure names | ||
const std::vector<std::string> _hs_names; | ||
/// Primary and secondary heat structure boundaries | ||
const std::vector<BoundaryName> _hs_boundaries; | ||
|
||
/// Mesh alignment | ||
MeshAlignment2D2D _mesh_alignment; | ||
/// Flag for each heat structure being HeatStructurePlate | ||
std::vector<bool> _is_plate; | ||
/// Flag for each heat structure deriving from HeatStructureCylindricalBase | ||
std::vector<bool> _is_cylindrical; | ||
|
||
public: | ||
static InputParameters validParams(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
modules/thermal_hydraulics/include/utils/MeshAlignment2D2D.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
//* 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/primary/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#pragma once | ||
|
||
#include "MooseMesh.h" | ||
|
||
class MooseMesh; | ||
|
||
/** | ||
* Builds mapping between two aligned 2D boundaries | ||
*/ | ||
class MeshAlignment2D2D | ||
{ | ||
public: | ||
/** | ||
* Constructor | ||
* | ||
* @param subproblem[in] Subproblem | ||
*/ | ||
MeshAlignment2D2D(const MooseMesh & mesh); | ||
|
||
/** | ||
* Builds the neighborhood information between primary and secondary side | ||
* | ||
* @param primary_boundary_info[in] List of tuples (elem_id, side_id) of the primary side | ||
* @param secondary_boundary_info[in] List of tuples (elem_id, side_id) of the secondary side | ||
*/ | ||
void initialize( | ||
const std::vector<std::tuple<dof_id_type, unsigned short int>> & primary_boundary_info, | ||
const std::vector<std::tuple<dof_id_type, unsigned short int>> & secondary_boundary_info); | ||
|
||
/** | ||
* Returns true if the primary and secondary boundaries are coincident | ||
*/ | ||
bool meshesAreCoincident() const { return _all_points_are_coincident; } | ||
|
||
/** | ||
* Returns the list of element IDs on the primary boundary | ||
*/ | ||
const std::vector<dof_id_type> & getPrimaryBoundaryElemIDs() const { return _primary_elem_ids; } | ||
|
||
/** | ||
* Gets the neighbor element ID for a given element ID | ||
* | ||
* @param[in] elem_id Element ID for which to find the neighbor element ID | ||
*/ | ||
dof_id_type getNeighborElemID(const dof_id_type & elem_id) const; | ||
|
||
/** | ||
* Returns true if the given node ID has a neighboring node | ||
* | ||
* @param[in] node_id Node ID for which to find the neighbor node ID | ||
*/ | ||
bool hasNeighborNode(const dof_id_type & node_id) const; | ||
|
||
/** | ||
* Gets the neighbor node ID for a given node ID | ||
* | ||
* @param[in] node_id Node ID for which to find the neighbor node ID | ||
*/ | ||
dof_id_type getNeighborNodeID(const dof_id_type & node_id) const; | ||
|
||
protected: | ||
/// Mesh | ||
const MooseMesh & _mesh; | ||
|
||
/// List of primary element IDs | ||
std::vector<dof_id_type> _primary_elem_ids; | ||
/// Map of element ID to neighboring element ID | ||
std::map<dof_id_type, dof_id_type> _elem_id_map; | ||
/// Map of node ID to neighboring node ID | ||
std::map<dof_id_type, dof_id_type> _node_id_map; | ||
/// Flag that all quadrature points are coincident between boundaries | ||
bool _all_points_are_coincident; | ||
}; |
68 changes: 68 additions & 0 deletions
68
modules/thermal_hydraulics/src/bcs/HeatStructure2DCouplerBC.C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//* 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 "HeatStructure2DCouplerBC.h" | ||
#include "MeshAlignment2D2D.h" | ||
#include "Function.h" | ||
|
||
registerMooseObject("ThermalHydraulicsApp", HeatStructure2DCouplerBC); | ||
|
||
InputParameters | ||
HeatStructure2DCouplerBC::validParams() | ||
{ | ||
InputParameters params = ADIntegratedBC::validParams(); | ||
|
||
params.addRequiredParam<FunctionName>("heat_transfer_coefficient", | ||
"Heat transfer coefficient function"); | ||
params.addRequiredParam<std::string>("coupled_variable", | ||
"The variable on the coupled heat structure boundary"); | ||
params.addRequiredParam<MeshAlignment2D2D *>("_mesh_alignment", "Mesh alignment object"); | ||
|
||
params.addClassDescription("Applies BC for HeatStructure2DCoupler for plate heat structure"); | ||
|
||
return params; | ||
} | ||
|
||
HeatStructure2DCouplerBC::HeatStructure2DCouplerBC(const InputParameters & parameters) | ||
: ADIntegratedBC(parameters), | ||
|
||
_htc(getFunction("heat_transfer_coefficient")), | ||
_coupled_variable_number( | ||
_subproblem | ||
.getVariable(_tid, getParam<std::string>("coupled_variable"), Moose::VAR_NONLINEAR) | ||
.number()), | ||
_mesh_alignment(*getParam<MeshAlignment2D2D *>("_mesh_alignment")), | ||
|
||
_nl_sys(_subproblem.systemBaseNonlinear()), | ||
_serialized_solution(_nl_sys.currentSolution()) | ||
{ | ||
} | ||
|
||
ADReal | ||
HeatStructure2DCouplerBC::computeQpResidual() | ||
{ | ||
// Compute temperature of neighboring side | ||
ADReal T_coupled_hs = 0; | ||
for (const auto j : _current_elem->node_index_range()) | ||
{ | ||
const auto node_id = (_current_elem->node_ref(j)).id(); | ||
if (_mesh_alignment.hasNeighborNode(node_id)) | ||
{ | ||
const auto neighbor_node_id = _mesh_alignment.getNeighborNodeID(node_id); | ||
const Node & neighbor_node = _mesh.nodeRef(neighbor_node_id); | ||
const auto dof_number = | ||
neighbor_node.dof_number(_nl_sys.number(), _coupled_variable_number, 0); | ||
ADReal T_node = (*_serialized_solution)(dof_number); | ||
Moose::derivInsert(T_node.derivatives(), dof_number, 1.0); | ||
T_coupled_hs += T_node * _test[j][_qp]; | ||
} | ||
} | ||
|
||
return _htc.value(_t, _q_point[_qp]) * (_u[_qp] - T_coupled_hs) * _test[_i][_qp]; | ||
} |
Oops, something went wrong.