https://mooseframework.inl.gov
HeatFluxBaseBC.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 
10 #include "HeatFluxBaseBC.h"
12 #include "THMIndicesVACE.h"
13 #include "Assembly.h"
14 #include "NonlinearSystemBase.h"
15 
18 {
20  params.addRequiredParam<UserObjectName>(
21  "q_uo", "The name of the user object that computes the heat flux");
22  params.addRequiredParam<Real>("P_hs_unit", "Perimeter of a single unit of heat structure");
23  params.addRequiredParam<unsigned int>("n_unit", "Number of units of heat structure");
24  params.addRequiredParam<bool>("hs_coord_system_is_cylindrical",
25  "Is the heat structure coordinate system cylindrical?");
26  params.addClassDescription("Base class for heat flux boundary conditions");
27  return params;
28 }
29 
31  : IntegratedBC(parameters),
32  _phi_neighbor(_assembly.phiNeighbor(_var)),
33  _q_uo(getUserObject<HeatFluxFromHeatStructureBaseUserObject>("q_uo")),
34  _P_hs_unit(getParam<Real>("P_hs_unit")),
35  _n_unit(getParam<unsigned int>("n_unit")),
36  _hs_coord_system_is_cylindrical(getParam<bool>("hs_coord_system_is_cylindrical")),
37  _hs_coord(_hs_coord_system_is_cylindrical ? _P_hs_unit : 1.0),
38  _hs_scale(-_hs_coord / (_n_unit * _P_hs_unit))
39 {
40 }
41 
42 void
44 {
46 }
47 
48 void
50 {
52 }
53 
54 void
55 HeatFluxBaseBC::computeOffDiagJacobian(const unsigned int jvar_num)
56 {
58 
59  if (jvar_num == _var.number())
60  {
61  // when doing the diagonal part, also take care of the off-diag jacobian
62  // wrt the heat structure side
63  std::vector<dof_id_type> idofs = _var.dofIndices();
64 
65  const dof_id_type & pipe_elem_id = _q_uo.getNearestElem(_current_elem->id());
66  const Elem * neighbor = _mesh.elemPtr(pipe_elem_id);
67 
68  _assembly.setCurrentNeighborSubdomainID(neighbor->subdomain_id());
70 
71  for (std::size_t i = 0; i < _off_diag_var_nums.size(); i++)
72  {
73  unsigned int jvar_num = _off_diag_var_nums[i];
74  MooseVariableFEBase & jvar =
76  jvar.prepareNeighbor();
77  _assembly.copyNeighborShapes(jvar_num);
78 
79  auto & jdofs = jvar.dofIndicesNeighbor();
80 
81  DenseMatrix<Number> Ke(_test.size(), jvar.phiNeighborSize());
82  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
83  for (_i = 0; _i < _test.size(); _i++)
84  for (_j = 0; _j < jvar.phiNeighborSize(); _j++)
85  Ke(_i, _j) += _JxW[_qp] * _coord[_qp] * computeQpOffDiagJacobianNeighbor(jvar_num);
86 
87  addJacobian(_assembly, Ke, idofs, jdofs, _var.scalingFactor());
88  }
89  }
90 }
MooseMesh & _mesh
const VariableTestValue & _test
const dof_id_type & getNearestElem(dof_id_type elem_id) const
Get the nearest element ID for given element ID.
unsigned int _j
virtual void computeOffDiagJacobian(unsigned int jvar) override
virtual Elem * elemPtr(const dof_id_type i)
virtual void prepareNeighbor()=0
unsigned int number() const
const Elem *const & _current_elem
static InputParameters validParams()
unsigned int _i
void reinitNeighborAtPhysical(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points)
virtual void initialSetup() override
THREAD_ID _tid
virtual void computeJacobian() override
const MooseVariableFieldBase & getVariable(unsigned int jvar_num) const
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)
unsigned int _qp
static InputParameters validParams()
SystemBase & _sys
virtual void computeJacobian() override
const MooseArray< Point > & _q_point
void addJacobian(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
virtual const std::vector< dof_id_type > & dofIndicesNeighbor() const=0
virtual Real computeQpOffDiagJacobianNeighbor(unsigned int jvar)=0
Compute the off-diagonal Jacobian w.r.t.
const std::vector< dof_id_type > & dofIndices() const final
virtual std::size_t phiNeighborSize() const=0
FEProblemBase & _fe_problem
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
unsigned int number() const
std::vector< Point > stdVector() const
virtual std::vector< unsigned int > getOffDiagVariableNumbers()=0
Get the list of variable numbers that are used in off-diagonal Jacobian blocks.
const MooseArray< Real > & _coord
Assembly & _assembly
MooseVariable & _var
const QBase *const & _qrule
virtual void computeOffDiagJacobian(unsigned jvar) override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< unsigned int > _off_diag_var_nums
Variable numbers for the off-diagonal jacobian computation.
void addClassDescription(const std::string &doc_string)
const HeatFluxFromHeatStructureBaseUserObject & _q_uo
User object that computes the heat flux.
HeatFluxBaseBC(const InputParameters &parameters)
void setCurrentNeighborSubdomainID(SubdomainID i)
void copyNeighborShapes(MooseVariableField< T > &v)
void ErrorVector unsigned int
const MooseArray< Real > & _JxW
void scalingFactor(const std::vector< Real > &factor)
uint8_t dof_id_type