https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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",
35 Moose::VarKindType::VAR_SOLVER,
36 Moose::VarFieldType::VAR_FIELD_STANDARD),
38 MaterialPropertyInterface(this, blockIDs(), Moose::EMPTY_BOUNDARY_IDS),
39 _var(*mooseVariableFV()),
40 _u_functor(getFunctor<ADReal>(_var.name())),
41 _current_elem(_assembly.elem()),
42 _q_point(_assembly.qPoints())
43{
45}
46
47// Note the lack of quadrature point loops in the residual/jacobian compute
48// functions. This is because finite volumes currently only works with
49// constant monomial elements. We only have one quadrature point regardless of
50// problem dimension and just multiply by the element volume.
51
52void
59
60void
67
68void
70{
71 const auto r = computeQpResidual() * _assembly.elemVolume();
72
73 mooseAssert(_var.dofIndices().size() == 1, "We're currently built to use CONSTANT MONOMIALS");
74
75 addJacobian(_assembly, std::array<ADReal, 1>{{r}}, _var.dofIndices(), _var.scalingFactor());
76}
77
78void
83
84void
86{
87 mooseError("FVElementalKernel::computeOffDiagJacobian should be called with no arguments");
88}
DualNumber< Real, DNDerivativeType, true > ADReal
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
const Real & elemVolume() const
Returns the reference to the current element volume.
Definition Assembly.h:440
Intermediate base class that ties together all the interfaces for getting MooseVariableFEBases with t...
static InputParameters validParams()
MooseVariableFV< Real > & _var
virtual ADReal computeQpResidual()=0
This is the primary function that must be implemented for flux kernel terms.
void computeResidualAndJacobian() override
Compute this object's contribution to the residual and Jacobian simultaneously.
void computeJacobian() override
Compute this object's contribution to the diagonal Jacobian entries.
void computeResidual() override
Usually you should not override these functions - they have some tricky stuff in them that you don't ...
FVElementalKernel(const InputParameters &parameters)
virtual void computeOffDiagJacobian()
FVKernel is a base class for all finite volume method kernels.
Definition FVKernel.h:36
static InputParameters validParams()
Definition FVKernel.C:15
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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...
An interface for accessing Materials.
static InputParameters validParams()
void scalingFactor(const std::vector< Real > &factor)
Set the scaling factor for this variable.
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...
virtual const std::vector< dof_id_type > & dofIndices() const final
Get local DoF indices.
Interface for objects that need to get values of MooseVariables.
Assembly & _assembly
Reference to this Kernel's assembly object.
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 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 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.
auto raw_value(const Eigen::Map< T > &in)
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...