19#include "libmesh/threads.h"
26 "Base class for all DG kernels making use of automatic differentiation");
33 this, false,
Moose::VarKindType::VAR_SOLVER,
Moose::VarFieldType::VAR_FIELD_STANDARD),
34 _var(*mooseVariable()),
35 _phi(_assembly.phiFace(_var)),
36 _grad_phi(_assembly.gradPhiFace(_var)),
38 _test(_var.phiFace()),
39 _grad_test(_var.gradPhiFace()),
41 _phi_neighbor(_assembly.phiFaceNeighbor(_var)),
42 _grad_phi_neighbor(_assembly.gradPhiFaceNeighbor(_var)),
44 _test_neighbor(_var.phiFaceNeighbor()),
45 _grad_test_neighbor(_var.gradPhiFaceNeighbor()),
48 _grad_u(_var.adGradSln()),
49 _u_neighbor(_var.adSlnNeighbor()),
50 _grad_u_neighbor(_var.adGradSlnNeighbor())
68 " as a save_in variable in " +
name());
73 "saved-in auxiliary variable is incompatible with the object's nonlinear variable: ",
92 " as a diag_save_in variable in " +
name());
97 "saved-in auxiliary variable is incompatible with the object's nonlinear variable: ",
126 for (
_i = 0;
_i < test_space.size();
_i++)
134 const std::vector<dof_id_type> & dof_indices =
135 is_elem ? var->dofIndices() : var->dofIndicesNeighbor();
136 var->sys().solution().add_vector(
_local_re, dof_indices);
156 "With AD you should need one call per side");
160 std::vector<ADReal> residuals(test_space.size(), 0);
164 for (
_i = 0;
_i < test_space.size();
_i++)
177 DenseVector<Number> diag(rows);
178 for (
unsigned int i = 0; i < rows; i++)
184 var->sys().solution().add_vector(diag, var->dofIndices());
186 var->sys().solution().add_vector(diag, var->dofIndicesNeighbor());
208 "With AD you should need one call per side");
212 std::vector<ADReal> residuals(test_space.size(), 0);
216 for (
_i = 0;
_i < test_space.size();
_i++)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
OutputTools< Real >::VariableTestValue VariableTestValue
MooseVariable & _var
Variable this kernel operates on.
const VariableTestValue & _test_neighbor
Side test function.
static InputParameters validParams()
const VariableTestValue & _test
test functions
void computeElemNeighJacobian(Moose::DGJacobianType type) override final
Computes the element/neighbor-element/neighbor Jacobian.
virtual ADReal computeQpResidual(Moose::DGResidualType type)=0
Compute this Kernel's contribution to the residual at the current quadrature point.
void computeElemNeighResidual(Moose::DGResidualType type) override final
Computes the residual for this element or the neighbor.
void computeJacobian() override final
Computes the jacobian for the current side.
void computeOffDiagElemNeighJacobian(Moose::DGJacobianType type, const MooseVariableFEBase &jvar) override final
Computes the element-element off-diagonal Jacobian.
void computeOffDiagJacobian(unsigned int jvar) override final
Computes d-residual / d-jvar...
Serves as a base class for DGKernel and ADDGKernel.
const QBase *const & _qrule
Quadrature rule.
std::vector< AuxVariableName > _save_in_strings
std::vector< MooseVariableFEBase * > _diag_save_in
const MooseArray< Real > & _JxW
Jacobian det times quadrature weighting on quadrature points.
std::vector< AuxVariableName > _diag_save_in_strings
bool _has_diag_save_in
The aux variables to save the diagonal Jacobian contributions to.
bool excludeBoundary() const
Check current element if it contains broken boundary.
std::vector< MooseVariableFEBase * > _save_in
static InputParameters validParams()
Factory constructor initializes all internal references needed for residual computation.
const MooseArray< Real > & _coord
Coordinate transform mainly for curvilinear coordinates.
bool _has_save_in
The aux variables to save the residual contributions to.
const std::string & type() const
Get the type of this class.
const std::string & name() const
Get the name of the class.
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 ...
const libMesh::FEType & feType() const
Get the type of finite element object.
void scalingFactor(const std::vector< Real > &factor)
Set the scaling factor for this variable.
SystemBase & sys()
Get the system this variable is part of.
unsigned int number() const
Get variable number coming from libMesh.
void addMooseVariableDependency(MooseVariableFieldBase *var)
Call this function to add the passed in MooseVariableFieldBase as a variable that this object depends...
const std::vector< dof_id_type > & dofIndicesNeighbor() const final
Get neighbor DOF indices for currently selected element.
const std::vector< dof_id_type > & dofIndices() const final
Get local DoF indices.
This class provides an interface for common operations on field variables of both FE and FV types wit...
MooseVariableFE< T > * mooseVariable() const
Return the MooseVariableFE object that this interface acts on.
Enhances MooseVariableInterface interface provide values from neighbor elements.
THREAD_ID _tid
The thread ID for this kernel.
Assembly & _assembly
Reference to this Kernel's assembly object.
const MooseVariableFieldBase & getVariable(unsigned int jvar_num) const
Retrieve the variable object from our system associated with jvar_num.
SubProblem & _subproblem
Reference to this kernel's SubProblem.
SystemBase & _sys
Reference to the EquationSystem object.
virtual void precalculateResidual()
virtual void haveADObjects(bool have_ad_objects)
Method for setting whether we have any ad objects.
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 =0
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
virtual void addVariableToZeroOnJacobian(std::string var_name)
Adds this variable to the list of variables to be zeroed during each Jacobian evaluation.
virtual void addVariableToZeroOnResidual(std::string var_name)
Adds this variable to the list of variables to be zeroed during each residual evaluation.
virtual bool hasVariable(const std::string &var_name) const
Query a system for a variable.
DenseMatrix< Number > _local_ke
Holds local Jacobian entries as they are accumulated by this Kernel.
void addJacobian(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
Add the provided residual derivatives into the Jacobian for the provided dof indices.
void accumulateTaggedLocalResidual()
Local residual blocks will be appended by adding the current local kernel residual.
void prepareVectorTagNeighbor(Assembly &assembly, unsigned int ivar)
Prepare data for computing element residual the according to active tags for DG and interface kernels...
void prepareVectorTag(Assembly &assembly, unsigned int ivar)
Prepare data for computing element residual according to active tags.
DenseVector< Number > _local_re
Holds local residual entries as they are accumulated by this Kernel.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
std::string incompatVarMsg(MooseVariableFieldBase &var1, MooseVariableFieldBase &var2)
Builds and returns a string of the form: