19#include "libmesh/dof_map.h"
20#include "libmesh/dense_vector.h"
21#include "libmesh/numeric_vector.h"
22#include "libmesh/dense_subvector.h"
23#include "libmesh/libmesh_common.h"
24#include "libmesh/quadrature.h"
36 this, false,
Moose::VarKindType::VAR_SOLVER,
Moose::VarFieldType::VAR_FIELD_ARRAY),
37 _var(*mooseVariable()),
38 _u(_is_implicit ? _var.sln() : _var.slnOld()),
39 _grad_u(_is_implicit ? _var.gradSln() : _var.gradSlnOld()),
42 _grad_phi(_var.gradPhiFace()),
43 _array_grad_phi(_var.arrayGradPhiFace()),
45 _test(_var.phiFace()),
46 _grad_test(_var.gradPhiFace()),
47 _array_grad_test(_var.arrayGradPhiFace()),
49 _phi_neighbor(_var.phiFaceNeighbor()),
50 _grad_phi_neighbor(_var.gradPhiFaceNeighbor()),
51 _array_grad_phi_neighbor(_var.arrayGradPhiFaceNeighbor()),
53 _test_neighbor(_var.phiFaceNeighbor()),
54 _grad_test_neighbor(_var.gradPhiFaceNeighbor()),
55 _array_grad_test_neighbor(_var.arrayGradPhiFaceNeighbor()),
57 _u_neighbor(_is_implicit ? _var.slnNeighbor() : _var.slnOldNeighbor()),
58 _grad_u_neighbor(_is_implicit ? _var.gradSlnNeighbor() : _var.gradSlnOldNeighbor()),
60 _array_normals(_assembly.mappedNormals()),
79 " as a save_in variable in " +
name());
84 "saved-in auxiliary variable is incompatible with the object's nonlinear variable: ",
103 " as a diag_save_in variable in " +
name());
108 "saved-in auxiliary variable is incompatible with the object's nonlinear variable: ",
138 for (
_i = 0;
_i < test_space.size();
_i++)
143 "Size of local residual is not equal to the number of array variable compoments");
156 mooseError(
"Save-in variable for an array kernel must be an array variable");
181 for (
_i = 0;
_i < test_space.size();
_i++)
182 for (
_j = 0;
_j < loc_phi.size();
_j++)
199 mooseError(
"Save-in variable for an array kernel must be an array variable");
202 avar->addSolution(diag);
204 avar->addSolutionNeighbor(diag);
212 return RealEigenVector::Zero(
_count);
258 : jv0.phiFaceNeighbor();
263 for (
_i = 0;
_i < test_space.size();
_i++)
264 for (
_j = 0;
_j < loc_phi.size();
_j++)
283 : jv1.phiFaceNeighbor();
288 for (
_i = 0;
_i < test_space.size();
_i++)
289 for (
_j = 0;
_j < loc_phi.size();
_j++)
304 mooseError(
"Vector variable cannot be coupled into array DG kernel currently");
316 mooseError(
"Save-in variable for an array kernel must be an array variable");
319 avar->addSolution(diag);
321 avar->addSolutionNeighbor(diag);
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
OutputTools< Real >::VariableTestValue VariableTestValue
OutputTools< RealEigenVector >::VariableTestValue ArrayVariableTestValue
virtual void computeQpResidual(Moose::DGResidualType type, RealEigenVector &residual)=0
This is the virtual that derived classes should override for computing the residual on neighboring el...
const ArrayVariablePhiValue & _phi_neighbor
Side shape function.
virtual void initQpResidual(Moose::DGResidualType)
Put necessary evaluations depending on qp but independent on test functions here.
ArrayMooseVariable & _var
Variable this kernel operates on.
const ArrayVariableTestValue & _test
test functions
virtual void computeElemNeighResidual(Moose::DGResidualType type) override
Computes the residual for this element or the neighbor.
const ArrayVariableTestValue & _test_neighbor
Side test function.
virtual void computeElemNeighJacobian(Moose::DGJacobianType type) override
Computes the element/neighbor-element/neighbor Jacobian.
const ArrayVariablePhiValue & _phi
Shape functions.
virtual RealEigenVector computeQpJacobian(Moose::DGJacobianType)
This is the virtual that derived classes should override for computing the Jacobian on neighboring el...
RealEigenVector _work_vector
Work vector for residual computation.
ArrayDGKernel(const InputParameters ¶meters)
const unsigned int _count
Number of components of the array variable.
virtual void initQpJacobian(Moose::DGJacobianType)
Put necessary evaluations depending on qp but independent on test and shape functions here.
virtual void computeOffDiagJacobian(unsigned int jvar) override
Override this function to consider couplings of components of the array variable.
virtual void computeOffDiagElemNeighJacobian(Moose::DGJacobianType type, const MooseVariableFEBase &jvar) override
Computes the element-element off-diagonal Jacobian.
static InputParameters validParams()
Factory constructor initializes all internal references needed for residual computation.
virtual RealEigenMatrix computeQpOffDiagJacobian(Moose::DGJacobianType type, const MooseVariableFEBase &jvar)
This is the virtual that derived classes should override for computing the off-diag Jacobian.
virtual void initQpOffDiagJacobian(Moose::DGJacobianType, const MooseVariableFEBase &)
Put necessary evaluations depending on qp but independent on test and shape functions here for off-di...
void saveFullLocalArrayJacobian(DenseMatrix< Number > &ke, unsigned int i, unsigned int ntest, unsigned int j, unsigned int nphi, unsigned int ivar, unsigned int jvar, const RealEigenMatrix &v) const
Helper function for assembling full Jacobian contriubutions on local quadrature points for an array k...
void saveLocalArrayResidual(DenseVector< Number > &re, unsigned int i, unsigned int ntest, const RealEigenVector &v) const
Helper function for assembling residual contriubutions on local quadrature points for an array kernel...
DenseVector< Real > getJacobianDiagonal(const DenseMatrix< Number > &ke)
void saveDiagLocalArrayJacobian(DenseMatrix< Number > &ke, unsigned int i, unsigned int ntest, unsigned int j, unsigned int nphi, unsigned int ivar, const RealEigenVector &v) const
Helper function for assembling diagonal Jacobian contriubutions on local quadrature points for an arr...
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.
SystemBase & sys()
Get the system this variable is part of.
unsigned int number() const
Get variable number coming from libMesh.
unsigned int count() const
Get the number of components Note: For standard and vector variables, the number is one.
void addMooseVariableDependency(MooseVariableFieldBase *var)
Call this function to add the passed in MooseVariableFieldBase as a variable that this object depends...
const FieldVariablePhiValue & phiFace() const override final
Return the variable's shape functions on an element face.
This class provides an interface for common operations on field variables of both FE and FV types wit...
virtual Moose::VarFieldType fieldType() const =0
Field type of this variable.
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 precalculateOffDiagJacobian(unsigned int)
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 accumulateTaggedLocalMatrix()
Local Jacobian blocks will be appended by adding the current local kernel Jacobian.
void prepareMatrixTag(Assembly &assembly, unsigned int ivar, unsigned int jvar)
Prepare data for computing element jacobian according to the active tags.
void accumulateTaggedLocalResidual()
Local residual blocks will be appended by adding the current local kernel residual.
void prepareMatrixTagNeighbor(Assembly &assembly, unsigned int ivar, unsigned int jvar, Moose::DGJacobianType type)
Prepare data for computing element jacobian according to the active tags for DG and interface kernels...
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.
virtual unsigned int size() const override final
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: