https://mooseframework.inl.gov
FVElementalKernel.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 "FVElementalKernel.h"
11 #include "MooseVariableFV.h"
12 #include "Assembly.h"
13 #include "SubProblem.h"
14 #include "NonlinearSystemBase.h"
15 #include "ADUtils.h"
16 
17 #include "libmesh/elem.h"
18 
19 #include "metaphysicl/raw_type.h"
20 
23 {
25  params.registerSystemAttributeName("FVElementalKernel");
27  return params;
28 }
29 
31  : FVKernel(parameters),
33  false,
34  "variable",
37  CoupleableMooseVariableDependencyIntermediateInterface(this, false, /*is_fv=*/true),
39  _var(*mooseVariableFV()),
40  _u(_var.adSln()),
41  _u_functor(getFunctor<ADReal>(_var.name())),
42  _current_elem(_assembly.elem()),
43  _q_point(_assembly.qPoints())
44 {
46 }
47 
48 // Note the lack of quadrature point loops in the residual/jacobian compute
49 // functions. This is because finite volumes currently only works with
50 // constant monomial elements. We only have one quadrature point regardless of
51 // problem dimension and just multiply by the element volume.
52 
53 void
55 {
59 }
60 
61 void
63 {
64  const auto r = computeQpResidual() * _assembly.elemVolume();
66  _assembly, std::array<ADReal, 1>{{r}}, _var.dofIndices(), _var.scalingFactor());
67 }
68 
69 void
71 {
72  const auto r = computeQpResidual() * _assembly.elemVolume();
73 
74  mooseAssert(_var.dofIndices().size() == 1, "We're currently built to use CONSTANT MONOMIALS");
75 
76  addJacobian(_assembly, std::array<ADReal, 1>{{r}}, _var.dofIndices(), _var.scalingFactor());
77 }
78 
79 void
81 {
83 }
84 
85 void
87 {
88  mooseError("FVElementalKernel::computeOffDiagJacobian should be called with no arguments");
89 }
std::string name(const ElemQuality q)
VarFieldType
Definition: MooseTypes.h:722
virtual void computeOffDiagJacobian()
void addResidualsAndJacobian(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
Add the provided incoming residuals and derivatives for the Jacobian, corresponding to the provided d...
void accumulateTaggedLocalResidual()
Local residual blocks will be appended by adding the current local kernel residual.
void computeResidual() override
Usually you should not override these functions - they have some tricky stuff in them that you don&#39;t ...
static InputParameters validParams()
Definition: FVKernel.C:15
unsigned int number() const
Get variable number coming from libMesh.
auto raw_value(const Eigen::Map< T > &in)
Definition: EigenADReal.h:73
void registerSystemAttributeName(const std::string &value)
This method is used to define the MOOSE system name that is used by the TheWarehouse object for stori...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
virtual ADReal computeQpResidual()=0
This is the primary function that must be implemented for flux kernel terms.
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:46
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.
FVElementalKernel(const InputParameters &parameters)
VarKindType
Framework-wide stuff.
Definition: MooseTypes.h:715
static InputParameters validParams()
void computeResidualAndJacobian() override
Compute this object&#39;s contribution to the residual and Jacobian simultaneously.
void computeJacobian() override
Compute this object&#39;s contribution to the diagonal Jacobian entries.
Assembly & _assembly
Reference to this Kernel&#39;s assembly object.
FVKernel is a base class for all finite volume method kernels.
Definition: FVKernel.h:32
void addMooseVariableDependency(MooseVariableFieldBase *var)
Call this function to add the passed in MooseVariableFieldBase as a variable that this object depends...
An interface for accessing Materials.
const std::set< BoundaryID > EMPTY_BOUNDARY_IDS
Definition: MooseTypes.h:685
DenseVector< Number > _local_re
Holds local residual entries as they are accumulated by this Kernel.
Intermediate base class that ties together all the interfaces for getting MooseVariableFEBases with t...
Interface for objects that need to get values of MooseVariables.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:267
const Real & elemVolume() const
Returns the reference to the current element volume.
Definition: Assembly.h:401
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
void prepareVectorTag(Assembly &assembly, unsigned int ivar)
Prepare data for computing element residual according to active tags.
void scalingFactor(const std::vector< Real > &factor)
Set the scaling factor for this variable.
virtual const std::vector< dof_id_type > & dofIndices() const final
Get local DoF indices.
MooseVariableFV< Real > & _var