https://mooseframework.inl.gov
Loading...
Searching...
No Matches
LinearFVGradientAux.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 "LinearFVGradientAux.h"
13
15
16namespace
17{
20requestGradient(LinearFVGradientAux & aux, MooseVariableFieldBase * const variable)
21{
22 auto * const linear_variable = dynamic_cast<MooseLinearVariableFVReal *>(variable);
23 if (!linear_variable)
24 aux.paramError("linear_fv_variable",
25 "The variable must be a scalar linear finite-volume variable.");
26
27 return aux.isParamValid("gradient_method")
28 ? linear_variable->requestCellGradients(
29 aux.getParam<GradientMethodName>("gradient_method"))
30 : linear_variable->requestCellGradients();
31}
32}
33
36{
38 params.addClassDescription("Copies the cell-centered gradient of a linear finite-volume "
39 "variable, computed with a selected gradient method, into a vector "
40 "auxiliary variable.");
41 params.addRequiredCoupledVar("linear_fv_variable",
42 "Linear finite-volume variable whose gradient is copied.");
43 params.addParam<GradientMethodName>(
44 "gradient_method",
45 "Gradient method whose result is copied. Defaults to the gradient method of the variable.");
46 return params;
47}
48
50 : VectorAuxKernel(parameters),
51 _gradient(requestGradient(*this, getFieldVar("linear_fv_variable", 0)))
52{
53 if (isNodal())
54 paramError("variable", "This AuxKernel only supports elemental fields.");
55}
56
57RealVectorValue
59{
60 mooseAssert(_qp == 0, "Only one quadrature point per element is expected.");
62}
registerMooseObject("MooseApp", LinearFVGradientAux)
MooseMesh & _mesh
Mesh this kernel is active on.
bool isNodal() const
Nodal or elemental kernel?
Definition AuxKernel.h:43
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
Definition AuxKernel.h:133
unsigned int _qp
Quadrature point index.
Definition AuxKernel.h:155
static InputParameters validParams()
Definition AuxKernel.C:27
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
Copies the cell-centered gradient of a linear finite-volume variable, computed with a selected gradie...
static InputParameters validParams()
const LinearFVGradientReader & _gradient
Reader for the gradient of the selected variable and gradient method.
LinearFVGradientAux(const InputParameters &parameters)
virtual RealVectorValue computeValue() override
Compute and return the value of the aux variable.
Read-only view of one variable's cell-centered linear finite-volume gradient values.
RealVectorValue gradient(const ElemInfo &elem_info) const
Read the full gradient at an element.
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition MooseBase.h:457
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition MooseBase.h:406
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition MooseBase.h:199
const ElemInfo & elemInfo(const dof_id_type id) const
Accessor for the elemInfo object for a given element ID.
Definition MooseMesh.C:3989
This class provides an interface for common operations on field variables of both FE and FV types wit...