https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
42void
47
48void
53
54void
55HeatFluxBaseBC::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();
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}
void ErrorVector unsigned int
void setCurrentNeighborSubdomainID(SubdomainID i)
void reinitNeighborAtPhysical(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points)
void copyNeighborShapes(MooseVariableField< T > &v)
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
virtual void computeJacobian() override
const HeatFluxFromHeatStructureBaseUserObject & _q_uo
User object that computes the heat flux.
static InputParameters validParams()
virtual void computeOffDiagJacobian(unsigned jvar) override
virtual Real computeQpOffDiagJacobianNeighbor(unsigned int jvar)=0
Compute the off-diagonal Jacobian w.r.t.
virtual void initialSetup() override
virtual std::vector< unsigned int > getOffDiagVariableNumbers()=0
Get the list of variable numbers that are used in off-diagonal Jacobian blocks.
HeatFluxBaseBC(const InputParameters &parameters)
std::vector< unsigned int > _off_diag_var_nums
Variable numbers for the off-diagonal jacobian computation.
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 QBase *const & _qrule
unsigned int _qp
const MooseArray< Real > & _JxW
unsigned int _i
const Elem *const & _current_elem
unsigned int _j
const MooseArray< Real > & _coord
const MooseArray< Point > & _q_point
MooseVariable & _var
virtual void computeOffDiagJacobian(unsigned int jvar) override
static InputParameters validParams()
virtual void computeJacobian() override
const VariableTestValue & _test
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
THREAD_ID _tid
MooseMesh & _mesh
Assembly & _assembly
SystemBase & _sys
FEProblemBase & _fe_problem
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
unsigned int number() const
void addJacobian(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)