https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ADHeatTransferFromHeatStructure3D1PhaseUserObject.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 "THMIndicesVACE.h"
12#include "THMUtils.h"
13
15
18{
20 params.addRequiredParam<MeshAlignment1D3D *>("_mesh_alignment", "Mesh alignment object");
21 params.addRequiredCoupledVar("P_hf", "Heat flux perimeter");
22 params.addRequiredParam<MaterialPropertyName>("T", "Fluid temperature");
23 params.addRequiredParam<MaterialPropertyName>("Hw", "Convective heat transfer coefficient");
24 params.addClassDescription("Caches heat flux information (fluid temperature and heat transfer "
25 "coefficient) between flow channel and 3D heat structure.");
26 return params;
27}
28
31 : ElementUserObject(parameters),
32 _mesh_alignment(*getParam<MeshAlignment1D3D *>("_mesh_alignment")),
33 _P_hf(adCoupledValue("P_hf")),
34 _Hw(getADMaterialProperty<Real>("Hw")),
35 _T(getADMaterialProperty<Real>("T"))
36{
38}
39
40void
47
48void
50{
51 const auto & primary_elem_id = _current_elem->id();
52
53 const auto & secondary_elem_ids = _mesh_alignment.getCoupledSecondaryElemIDs(primary_elem_id);
54 for (const auto & secondary_elem_id : secondary_elem_ids)
55 {
56 const auto secondary_n_qps = _mesh_alignment.getSecondaryNumberOfQuadraturePoints();
57
58 _T_fluid[secondary_elem_id].resize(secondary_n_qps);
59 _htc[secondary_elem_id].resize(secondary_n_qps);
60 _heated_perimeter[secondary_elem_id].resize(secondary_n_qps);
61
62 for (unsigned int secondary_qp = 0; secondary_qp < secondary_n_qps; secondary_qp++)
63 {
64 const auto primary_qp =
65 _mesh_alignment.getCoupledPrimaryElemQpIndex(secondary_elem_id, secondary_qp);
66
67 _T_fluid[secondary_elem_id][secondary_qp] = _T[primary_qp];
68 _htc[secondary_elem_id][secondary_qp] = _Hw[primary_qp];
69 _heated_perimeter[secondary_elem_id][secondary_qp] = _P_hf[primary_qp];
70 }
71 }
72}
73
74void
81
82void
84{
85 const auto & uo = static_cast<const ADHeatTransferFromHeatStructure3D1PhaseUserObject &>(y);
86 for (auto & it : uo._heated_perimeter)
87 _heated_perimeter[it.first] = it.second;
88 for (auto & it : uo._T_fluid)
89 _T_fluid[it.first] = it.second;
90 for (auto & it : uo._htc)
91 _htc[it.first] = it.second;
92}
93
94const std::vector<ADReal> &
96{
97 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
98 auto it = _heated_perimeter.find(element_id);
99 if (it != _heated_perimeter.end())
100 return it->second;
101 else
103 name(), ": Requested heated perimeter for element ", element_id, " was not computed.");
104}
105
106const std::vector<ADReal> &
108 dof_id_type element_id) const
109{
110 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
111 auto it = _htc.find(element_id);
112 if (it != _htc.end())
113 return it->second;
114 else
116 ": Requested heat transfer coefficient for element ",
117 element_id,
118 " was not computed.");
119}
120
121const std::vector<ADReal> &
123{
124 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
125 auto it = _T_fluid.find(element_id);
126 if (it != _T_fluid.end())
127 return it->second;
128 else
130 name(), ": Requested fluid temperature for element ", element_id, " was not computed.");
131}
registerMooseObject("ThermalHydraulicsApp", ADHeatTransferFromHeatStructure3D1PhaseUserObject)
const std::vector< double > y
Caching heat flux data (fluid temperature and heat transfer coefficient) between a flow channel and a...
const std::vector< ADReal > & getHeatedPerimeter(dof_id_type element_id) const
const std::vector< ADReal > & getHeatTransferCoeff(dof_id_type element_id) const
const ADMaterialProperty< Real > & _Hw
Heat transfer coefficient.
std::map< dof_id_type, std::vector< ADReal > > _heated_perimeter
Map of the element ID to the heated perimeter at the quadrature points.
const ADVariableValue & _P_hf
Coupled heated perimeter variable.
std::map< dof_id_type, std::vector< ADReal > > _T_fluid
Map of the element ID to the fluid temperature at the quadrature points.
std::map< dof_id_type, std::vector< ADReal > > _htc
Map of the element ID to the wall heat transfer coefficient at the quadrature points.
const std::vector< ADReal > & getTfluid(dof_id_type element_id) const
static InputParameters validParams()
const Elem *const & _current_elem
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
Builds mapping between a 1D subdomain and a 3D boundary.
void buildCoupledElemQpIndexMap(Assembly &assembly)
Builds the map used for getting the coupled quadrature point index.
unsigned int getSecondaryNumberOfQuadraturePoints() const
Gets the number of quadrature points for faces on the secondary boundary.
unsigned int getCoupledPrimaryElemQpIndex(const dof_id_type &secondary_elem_id, const unsigned int &secondary_qp) const
Gets the quadrature point index on the primary element corresponding to the quadrature point index on...
const std::vector< dof_id_type > & getCoupledSecondaryElemIDs(const dof_id_type &primary_elem_id) const
Gets the coupled secondary element IDs for a given primary element ID.
const std::string & name() const
void mooseError(Args &&... args) const
Assembly & _assembly
const Parallel::Communicator & comm() const
void allGatherADVectorMap(const Parallel::Communicator &comm, std::map< dof_id_type, std::vector< ADReal > > &this_map)
Parallel gather of a map of DoF ID to AD vector.
Definition THMUtils.C:47