https://mooseframework.inl.gov
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");
18  params.addClassDescription(
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 
32 void
34 {
35 }
36 
37 void
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 
75 void
77 {
78 }
79 
80 void
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 
92 const 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
100  mooseError(
101  name(), ": Requested heated perimeter for element ", element_id, " was not computed.");
102 }
103 
104 const 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 
115 const 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
123  mooseError(
124  name(), ": Requested heat flux jacobian for element ", element_id, " was not computed.");
125 }
Assembly & _assembly
virtual void threadJoin(const UserObject &y) override
static InputParameters validParams()
const std::vector< Real > & getHeatedPerimeter(dof_id_type element_id) const
Builds mapping between two aligned subdomains/boundaries.
Definition: MeshAlignment.h:24
const std::vector< double > y
virtual const std::string & name() const
std::map< dof_id_type, std::vector< Real > > _heat_flux
Cached heat flux.
Base class for caching heat flux between a flow channel and a heat structure.
void addRequiredParam(const std::string &name, const std::string &doc_string)
HeatFluxFromHeatStructureBaseUserObject(const InputParameters &parameters)
const dof_id_type & getCoupledElemID(const dof_id_type &elem_id) const
Gets the coupled element ID for a given element ID.
std::map< dof_id_type, std::vector< DenseVector< Real > > > _heat_flux_jacobian
Cached heat flux jacobians.
std::map< dof_id_type, std::vector< Real > > _heated_perimeter
Cached heated perimeter.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void buildCoupledElemQpIndexMap(Assembly &assembly)
Builds the map used for getting the coupled quadrature point index.
const std::vector< Real > & getHeatFlux(dof_id_type element_id) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const QBase *const & _qrule
const Elem *const & _current_elem
FEProblemBase & _fe_problem
const VariableValue & _P_hf
Coupled heated perimeter variable.
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
virtual DenseVector< Real > computeQpHeatFluxJacobian()=0
const bool & currentlyComputingJacobian() const
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 std::vector< DenseVector< Real > > & getHeatFluxJacobian(dof_id_type element_id) const
uint8_t dof_id_type