https://mooseframework.inl.gov
OneDHeatFluxBase.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 "OneDHeatFluxBase.h"
12 #include "HeatConductionModel.h"
13 #include "Assembly.h"
14 
17 {
19  params.addClassDescription(
20  "Base class for a one-dimensional heat flux term in an energy equation");
21  params.addRequiredParam<UserObjectName>(
22  "q_uo", "The name of the user object that computed the heat flux");
23  return params;
24 }
25 
27  : Kernel(parameters),
28  _phi_neighbor(_assembly.phiNeighbor(_var)),
29  _q_uo(getUserObject<HeatFluxFromHeatStructureBaseUserObject>("q_uo"))
30 {
31 }
32 
33 void
35 {
37 }
38 
39 void
40 OneDHeatFluxBase::computeOffDiagJacobian(const unsigned int jvar_num)
41 {
43 
44  if (jvar_num == _var.number())
45  {
46  // when doing the diagonal part, also take care of the off-diag jacobian
47  // wrt the heat structure side
48  std::vector<dof_id_type> idofs = _var.dofIndices();
49 
50  const dof_id_type & hs_elem_id = _q_uo.getNearestElem(_current_elem->id());
51  const Elem * neighbor = _mesh.elemPtr(hs_elem_id);
52 
53  _assembly.setCurrentNeighborSubdomainID(neighbor->subdomain_id());
55 
56  std::vector<std::string> var_names = {HeatConductionModel::TEMPERATURE};
57  for (std::size_t i = 0; i < var_names.size(); i++)
58  {
59  MooseVariableFEBase & jvar = _fe_problem.getVariable(_tid, var_names[i]);
60  unsigned int jvar_num = jvar.number();
61  jvar.prepareNeighbor();
62  _assembly.copyNeighborShapes(jvar_num);
63 
64  auto & jdofs = jvar.dofIndicesNeighbor();
65  DenseMatrix<Number> Ke(_test.size(), jvar.phiNeighborSize());
66  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
67  for (_i = 0; _i < _test.size(); _i++)
68  for (_j = 0; _j < jvar.phiNeighborSize(); _j++)
69  Ke(_i, _j) += _JxW[_qp] * _coord[_qp] * computeQpOffDiagJacobianNeighbor(jvar_num);
70 
71  addJacobian(_assembly, Ke, idofs, jdofs, _var.scalingFactor());
72  }
73  }
74 }
MooseMesh & _mesh
const dof_id_type & getNearestElem(dof_id_type elem_id) const
Get the nearest element ID for given element ID.
static InputParameters validParams()
OneDHeatFluxBase(const InputParameters &parameters)
static InputParameters validParams()
MooseVariable & _var
virtual Elem * elemPtr(const dof_id_type i)
const MooseArray< Real > & _JxW
virtual void prepareNeighbor()=0
unsigned int number() const
void reinitNeighborAtPhysical(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points)
THREAD_ID _tid
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)
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const override
void addJacobian(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
virtual const std::vector< dof_id_type > & dofIndicesNeighbor() const=0
const VariableTestValue & _test
virtual void computeJacobian() override
const std::vector< dof_id_type > & dofIndices() const final
static const std::string TEMPERATURE
const QBase *const & _qrule
virtual std::size_t phiNeighborSize() const=0
FEProblemBase & _fe_problem
unsigned int _i
std::vector< Point > stdVector() const
const MooseArray< Real > & _coord
Assembly & _assembly
virtual void computeJacobian() override
unsigned int _j
virtual Real computeQpOffDiagJacobianNeighbor(unsigned int jvar)=0
void addClassDescription(const std::string &doc_string)
const HeatFluxFromHeatStructureBaseUserObject & _q_uo
User object that computes the heat flux.
const Elem *const & _current_elem
virtual void computeOffDiagJacobian(unsigned int jvar) override
void setCurrentNeighborSubdomainID(SubdomainID i)
void copyNeighborShapes(MooseVariableField< T > &v)
virtual void computeOffDiagJacobian(unsigned jvar) override
const MooseArray< Point > & _q_point
void scalingFactor(const std::vector< Real > &factor)
unsigned int _qp
uint8_t dof_id_type