https://mooseframework.inl.gov
Loading...
Searching...
No Matches
HeatFluxFromHeatStructureBaseUserObject.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
14{
16 params.addRequiredParam<MeshAlignment *>("_mesh_alignment", "Mesh alignment object");
17 params.addRequiredCoupledVar("P_hf", "Heat flux perimeter");
19 "Base class for caching heat flux between flow channels and heat structures.");
20 return params;
21}
22
24 const InputParameters & parameters)
25 : ElementUserObject(parameters),
26 _mesh_alignment(*getParam<MeshAlignment *>("_mesh_alignment")),
27 _P_hf(coupledValue("P_hf"))
28{
30}
31
32void
36
37void
39{
40 unsigned int n_qpts = _qrule->n_points();
41 const dof_id_type & nearest_elem_id = _mesh_alignment.getCoupledElemID(_current_elem->id());
42
43 _heated_perimeter[_current_elem->id()].resize(n_qpts);
44 _heated_perimeter[nearest_elem_id].resize(n_qpts);
45
46 _heat_flux[_current_elem->id()].resize(n_qpts);
47 _heat_flux[nearest_elem_id].resize(n_qpts);
48 for (_qp = 0; _qp < n_qpts; _qp++)
49 {
50 unsigned int nearest_qp = _mesh_alignment.getCoupledElemQpIndex(_current_elem->id(), _qp);
51 Real q_wall = computeQpHeatFlux();
52
53 _heat_flux[_current_elem->id()][_qp] = q_wall;
54 _heat_flux[nearest_elem_id][nearest_qp] = q_wall;
55
57 _heated_perimeter[nearest_elem_id][nearest_qp] = _P_hf[_qp];
58 }
59
61 {
62 _heat_flux_jacobian[_current_elem->id()].resize(n_qpts);
63 _heat_flux_jacobian[nearest_elem_id].resize(n_qpts);
64 for (_qp = 0; _qp < n_qpts; _qp++)
65 {
66 unsigned int nearest_qp = _mesh_alignment.getCoupledElemQpIndex(_current_elem->id(), _qp);
67 DenseVector<Real> jac = computeQpHeatFluxJacobian();
68
70 _heat_flux_jacobian[nearest_elem_id][nearest_qp] = jac;
71 }
72 }
73}
74
75void
79
80void
82{
83 const auto & uo = static_cast<const HeatFluxFromHeatStructureBaseUserObject &>(y);
84 for (auto & it : uo._heated_perimeter)
85 _heated_perimeter[it.first] = it.second;
86 for (auto & it : uo._heat_flux)
87 _heat_flux[it.first] = it.second;
88 for (auto & it : uo._heat_flux_jacobian)
89 _heat_flux_jacobian[it.first] = it.second;
90}
91
92const std::vector<Real> &
94{
95 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
96 auto it = _heated_perimeter.find(element_id);
97 if (it != _heated_perimeter.end())
98 return it->second;
99 else
101 name(), ": Requested heated perimeter for element ", element_id, " was not computed.");
102}
103
104const std::vector<Real> &
106{
107 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
108 auto it = _heat_flux.find(element_id);
109 if (it != _heat_flux.end())
110 return it->second;
111 else
112 mooseError(name(), ": Requested heat flux for element ", element_id, " was not computed.");
113}
114
115const std::vector<DenseVector<Real>> &
117{
118 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
119 auto it = _heat_flux_jacobian.find(element_id);
120 if (it != _heat_flux_jacobian.end())
121 return it->second;
122 else
124 name(), ": Requested heat flux jacobian for element ", element_id, " was not computed.");
125}
const std::vector< double > y
static InputParameters validParams()
const QBase *const & _qrule
const Elem *const & _current_elem
Base class for caching heat flux between a flow channel and a heat structure.
const std::vector< Real > & getHeatedPerimeter(dof_id_type element_id) const
std::map< dof_id_type, std::vector< Real > > _heated_perimeter
Cached heated perimeter.
std::map< dof_id_type, std::vector< Real > > _heat_flux
Cached heat flux.
const VariableValue & _P_hf
Coupled heated perimeter variable.
HeatFluxFromHeatStructureBaseUserObject(const InputParameters &parameters)
const std::vector< DenseVector< Real > > & getHeatFluxJacobian(dof_id_type element_id) const
const std::vector< Real > & getHeatFlux(dof_id_type element_id) const
virtual void threadJoin(const UserObject &y) override
std::map< dof_id_type, std::vector< DenseVector< Real > > > _heat_flux_jacobian
Cached heat flux jacobians.
virtual DenseVector< Real > computeQpHeatFluxJacobian()=0
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 two aligned subdomains/boundaries.
void buildCoupledElemQpIndexMap(Assembly &assembly)
Builds the map used for getting the coupled quadrature point index.
unsigned int getCoupledElemQpIndex(const dof_id_type &elem_id, const unsigned int &qp) const
Gets the quadrature point index on the coupled element corresponding to the quadrature point index on...
const dof_id_type & getCoupledElemID(const dof_id_type &elem_id) const
Gets the coupled element ID for a given element ID.
const std::string & name() const
void mooseError(Args &&... args) const
const bool & currentlyComputingJacobian() const
Assembly & _assembly
FEProblemBase & _fe_problem