20 #include "libmesh/quadrature.h" 41 _var(*this->mooseVariable()),
42 _normals(_assembly.adNormals()),
43 _ad_q_points(_assembly.adQPointsFace()),
44 _test(_var.phiFace()),
45 _grad_test(_var.adGradPhiFace()),
47 _grad_u(_var.adGradSln()),
48 _ad_JxW(_assembly.adJxWFace()),
49 _ad_coord(_assembly.adCoordTransformation()),
50 _phi(_assembly.phi(_var)),
51 _use_displaced_mesh(getParam<bool>(
"use_displaced_mesh"))
67 "saved-in auxiliary variable is incompatible with the object's nonlinear variable: ",
83 "saved-in auxiliary variable is incompatible with the object's nonlinear variable: ",
98 _residuals.resize(_test.size(), 0);
99 for (
auto & r : _residuals)
102 if (_use_displaced_mesh)
103 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
104 for (_i = 0; _i < _test.size(); _i++)
105 _residuals[_i] +=
raw_value(_ad_JxW[_qp] * _ad_coord[_qp] * computeQpResidual());
107 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
108 for (_i = 0; _i < _test.size(); _i++)
109 _residuals[_i] +=
raw_value(_JxW[_qp] * _coord[_qp] * computeQpResidual());
111 addResiduals(_assembly, _residuals, _var.dofIndices(), _var.scalingFactor());
114 for (
unsigned int i = 0; i < _save_in.size(); i++)
115 _save_in[i]->sys().solution().add_vector(_residuals.data(), _save_in[i]->dofIndices());
118 template <
typename T>
122 if (_residuals_and_jacobians.size() != _test.size())
123 _residuals_and_jacobians.resize(_test.size(), 0);
124 for (
auto & r : _residuals_and_jacobians)
127 if (_use_displaced_mesh)
128 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
131 _r *= _ad_coord[_qp];
132 for (_i = 0; _i < _test.size(); _i++)
133 _residuals_and_jacobians[_i] += _r * computeQpResidual();
136 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
137 for (_i = 0; _i < _test.size(); _i++)
138 _residuals_and_jacobians[_i] += _JxW[_qp] * _coord[_qp] * computeQpResidual();
141 template <
typename T>
145 computeResidualsForJacobian();
146 addResidualsAndJacobian(
147 _assembly, _residuals_and_jacobians, _var.dofIndices(), _var.scalingFactor());
150 template <
typename T>
156 if (_has_diag_save_in && !_sys.computingScalingJacobian())
157 mooseError(
"_local_ke not computed for global AD indexing. Save-in is deprecated anyway. Use " 158 "the tagging system instead.");
161 template <
typename T>
165 computeResidualsForJacobian();
166 addJacobian(_assembly, _residuals_and_jacobians, _var.dofIndices(), _var.scalingFactor());
169 template <
typename T>
174 if (jvar == _var.number())
178 template <
typename T>
virtual void haveADObjects(bool have_ad_objects)
Method for setting whether we have any ad objects.
std::vector< MooseVariableFEBase * > _diag_save_in
std::string incompatVarMsg(MooseVariableFieldBase &var1, MooseVariableFieldBase &var2)
Builds and returns a string of the form:
std::vector< MooseVariableFEBase * > _save_in
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
void computeResidual() override
Compute this object's contribution to the residual.
static InputParameters validParams()
THREAD_ID _tid
The thread ID for this kernel.
static InputParameters validParams()
const FEType & feType() const
Get the type of finite element object.
An interface for accessing Moose::Functors for systems that care about automatic differentiation, e.g.
ADIntegratedBCTempl(const InputParameters ¶meters)
MooseVariableFE< T > * mooseVariable() const
void computeADJacobian()
compute all the Jacobian entries
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
std::vector< AuxVariableName > _save_in_strings
SubProblem & _subproblem
Reference to this kernel's SubProblem.
VarKindType
Framework-wide stuff.
Base class for deriving any boundary condition of a integrated type.
virtual MooseVariable & getStandardVariable(const THREAD_ID tid, const std::string &var_name)=0
Returns the variable reference for requested MooseVariable which may be in any system.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
MooseVariableFE< T > & _var
The variable that this IntegratedBC operates on.
bool _has_save_in
The aux variables to save the residual contributions to.
void computeOffDiagJacobian(unsigned int jvar) override
Computes this object's contribution to off-diagonal blocks of the system Jacobian matrix...
void computeResidualAndJacobian() override
Compute this object's contribution to the residual and Jacobian simultaneously.
void addMooseVariableDependency(MooseVariableFieldBase *var)
Call this function to add the passed in MooseVariableFieldBase as a variable that this object depends...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< AuxVariableName > _diag_save_in_strings
virtual void addVariableToZeroOnResidual(std::string var_name)
Adds this variable to the list of variables to be zeroed during each residual evaluation.
static InputParameters validParams()
Interface for objects that need to get values of MooseVariables.
Base class for deriving any boundary condition of a integrated type.
virtual void addVariableToZeroOnJacobian(std::string var_name)
Adds this variable to the list of variables to be zeroed during each Jacobian evaluation.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
bool _has_diag_save_in
The aux variables to save the diagonal Jacobian contributions to.
SystemBase & sys()
Get the system this variable is part of.
virtual void computeResidualsForJacobian()
compute the _residuals member for filling the Jacobian.
void computeOffDiagJacobianScalar(unsigned int jvar) override
Computes jacobian block with respect to a scalar variable.
void computeJacobian() override
Compute this object's contribution to the diagonal Jacobian entries.