https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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{
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
33void
38
39void
40OneDHeatFluxBase::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();
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}
void setCurrentNeighborSubdomainID(SubdomainID i)
void reinitNeighborAtPhysical(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points)
void copyNeighborShapes(MooseVariableField< T > &v)
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
static const std::string TEMPERATURE
Base class for caching heat flux between a flow channel and a heat structure.
const dof_id_type & getNearestElem(dof_id_type elem_id) const
Get the nearest element ID for given element ID.
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
const MooseArray< Real > & _coord
unsigned int _qp
const MooseArray< Point > & _q_point
const MooseArray< Real > & _JxW
const Elem *const & _current_elem
unsigned int _j
unsigned int _i
const QBase *const & _qrule
virtual void computeOffDiagJacobian(unsigned int jvar) override
MooseVariable & _var
virtual void computeJacobian() override
const VariableTestValue & _test
static InputParameters validParams()
std::vector< T > stdVector() const
virtual Elem * elemPtr(const dof_id_type i)
void scalingFactor(const std::vector< Real > &factor)
unsigned int number() const
const std::vector< dof_id_type > & dofIndices() const final
virtual void prepareNeighbor()=0
virtual const std::vector< dof_id_type > & dofIndicesNeighbor() const=0
virtual std::size_t phiNeighborSize() const=0
const HeatFluxFromHeatStructureBaseUserObject & _q_uo
User object that computes the heat flux.
static InputParameters validParams()
OneDHeatFluxBase(const InputParameters &parameters)
virtual void computeJacobian() override
virtual void computeOffDiagJacobian(unsigned jvar) override
virtual Real computeQpOffDiagJacobianNeighbor(unsigned int jvar)=0
THREAD_ID _tid
MooseMesh & _mesh
Assembly & _assembly
FEProblemBase & _fe_problem
void addJacobian(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)