19#include "libmesh/quadrature.h"
26 if (std::is_same<T, Real>::value)
28 else if (std::is_same<T, RealVectorValue>::value)
31 ::mooseError(
"unsupported ADInterfaceKernelTempl specialization");
40 Moose::VarKindType::VAR_SOLVER,
41 std::is_same<T, Real>::value
42 ?
Moose::VarFieldType::VAR_FIELD_STANDARD
43 :
Moose::VarFieldType::VAR_FIELD_VECTOR),
44 _var(*this->mooseVariable()),
45 _normals(_assembly.normals()),
47 _grad_u(_var.adGradSln()),
48 _ad_JxW(_assembly.adJxWFace()),
49 _ad_coord(_assembly.adCoordTransformation()),
50 _ad_q_point(_assembly.adQPoints()),
51 _phi(_assembly.phiFace(_var)),
52 _test(_var.phiFace()),
53 _grad_test(_var.adGradPhiFace()),
55 _neighbor_value(_neighbor_var.adSlnNeighbor()),
56 _grad_neighbor_value(_neighbor_var.adGradSlnNeighbor()),
57 _phi_neighbor(_assembly.phiFaceNeighbor(_neighbor_var)),
58 _test_neighbor(_neighbor_var.phiFaceNeighbor()),
59 _grad_test_neighbor(_neighbor_var.gradPhiFaceNeighbor())
68 "In order to use an interface kernel, you must specify a boundary where it will live.");
84 prepareVectorTag(_assembly, _var.number());
86 prepareVectorTagNeighbor(_assembly, _neighbor_var.number());
88 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
91 const auto jxw_p = _JxW[_qp] * _coord[_qp];
92 for (_i = 0; _i < test_space.size(); _i++)
93 _local_re(_i) += jxw_p * raw_value(computeQpResidual(type));
96 accumulateTaggedLocalResidual();
112 if (!_var.activeOnSubdomain(_current_elem->subdomain_id()) ||
113 !_neighbor_var.activeOnSubdomain(_neighbor_elem->subdomain_id()))
116 precalculateResidual();
130 "With AD you should need one call per side");
135 std::vector<ADReal> residuals(test_space.size(), 0);
155 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
157 initQpResidual(resid_type);
158 const auto jxw_c = _ad_JxW[_qp] * _ad_coord[_qp];
159 for (_i = 0; _i < test_space.size(); _i++)
160 residuals[_i] += jxw_c * computeQpResidual(resid_type);
164 addJacobian(_assembly,
166 element_var_is_var ? _var.dofIndices() : _neighbor_var.dofIndicesNeighbor(),
167 element_var_is_var ? _var.scalingFactor() : _neighbor_var.scalingFactor());
183 if (!_var.activeOnSubdomain(_current_elem->subdomain_id()) ||
184 !_neighbor_var.activeOnSubdomain(_neighbor_elem->subdomain_id()))
187 precalculateJacobian();
198 "With AD you should need one call per side");
208 std::vector<ADReal> residuals(test_space.size(), 0);
210 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
212 initQpResidual(resid_type);
213 const auto jxw_c = _ad_JxW[_qp] * _ad_coord[_qp];
214 for (_i = 0; _i < test_space.size(); _i++)
215 residuals[_i] += jxw_c * computeQpResidual(resid_type);
219 addJacobian(_assembly,
222 : _neighbor_var.dofIndicesNeighbor(),
239 if (!_var.activeOnSubdomain(_current_elem->subdomain_id()) ||
240 !_neighbor_var.activeOnSubdomain(_neighbor_elem->subdomain_id()))
243 if (jvar != _var.number())
248 precalculateOffDiagJacobian(jvar);
267 if (!_var.activeOnSubdomain(_current_elem->subdomain_id()) ||
268 !_neighbor_var.activeOnSubdomain(_neighbor_elem->subdomain_id()))
271 if (jvar != _neighbor_var.number())
276 precalculateOffDiagJacobian(jvar);
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
typename OutputTools< T >::VariableTestValue ADTemplateVariableTestValue
ADInterfaceKernel and ADVectorInterfaceKernel is responsible for interfacing physics across subdomain...
void computeOffDiagElemNeighJacobian(Moose::DGJacobianType type, unsigned int jvar)
Using the passed DGJacobian type, selects the correct test function and trial function spaces and jac...
void computeElemNeighResidual(Moose::DGResidualType type)
Using the passed DGResidual type, selects the correct test function space and residual block,...
virtual void computeNeighborOffDiagJacobian(unsigned int jvar) override final
Selects the correct Jacobian type and routine to call for the secondary variable jacobian.
void computeJacobian() override final
Computes the jacobian for the current side.
void computeResidual() override final
Computes the residual for the current side.
void computeElemNeighJacobian(Moose::DGJacobianType type)
Using the passed DGJacobian type, selects the correct test function and trial function spaces and jac...
ADInterfaceKernelTempl(const InputParameters ¶meters)
static InputParameters validParams()
virtual void computeElementOffDiagJacobian(unsigned int jvar) override final
Selects the correct Jacobian type and routine to call for the primary variable jacobian.
InterfaceKernelBase is the base class for all InterfaceKernel type classes.
static InputParameters validParams()
void addMooseVariableDependency(MooseVariableFieldBase *var)
Call this function to add the passed in MooseVariableFieldBase as a variable that this object depends...
Class for stuff related to variables.
MooseVariableFE< T > * mooseVariable() const
Return the MooseVariableFE object that this interface acts on.
Enhances MooseVariableInterface interface provide values from neighbor elements.
SubProblem & _subproblem
Reference to this kernel's SubProblem.
virtual void haveADObjects(bool have_ad_objects)
Method for setting whether we have any ad objects.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...