https://mooseframework.inl.gov
Loading...
Searching...
No Matches
FVDiffusionInterface.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
11#include "MathFVUtils.h"
12
14
17{
19 params.addClassDescription("Computes the residual for diffusion operator across an interface for "
20 "the finite volume method.");
21 params.addRequiredParam<MaterialPropertyName>("coeff1",
22 "The diffusion coefficient on the 1st subdomain");
23 params.addRequiredParam<MaterialPropertyName>("coeff2",
24 "The diffusion coefficient on the 2nd subdomain");
25 MooseEnum coeff_interp_method("average harmonic", "harmonic");
26 params.addParam<MooseEnum>(
27 "coeff_interp_method",
28 coeff_interp_method,
29 "Switch that can select face interpolation method for diffusion coefficients.");
30 return params;
31}
32
34 : FVInterfaceKernel(params),
35 _coeff1(getFunctor<ADReal>("coeff1")),
36 _coeff2(getFunctor<ADReal>("coeff2"))
37{
38 const auto & interp_method = getParam<MooseEnum>("coeff_interp_method");
39 if (interp_method == "average")
41 else if (interp_method == "harmonic")
43}
44
47{
48 const auto & coef_elem = elemIsOne() ? _coeff1 : _coeff2;
49 const auto & coef_neighbor = elemIsOne() ? _coeff2 : _coeff1;
50
51 // Form a finite difference gradient across the interface
52 Point one_over_gradient_support = _face_info->elemCentroid() - _face_info->neighborCentroid();
53 one_over_gradient_support /= (one_over_gradient_support * one_over_gradient_support);
54 const auto state = determineState();
55 const auto gradient = elemIsOne() ? (var1().getElemValue(&_face_info->elem(), state) -
57 one_over_gradient_support
58 : (var1().getElemValue(_face_info->neighborPtr(), state) -
59 var2().getElemValue(&_face_info->elem(), state)) *
60 -one_over_gradient_support;
61
62 ADReal diffusivity;
63 interpolate(_coeff_interp_method,
64 diffusivity,
65 coef_elem(elemArg(), determineState()),
66 coef_neighbor(neighborArg(), determineState()),
68 true);
69
70 return -diffusivity * _normal * gradient;
71}
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("MooseApp", FVDiffusionInterface)
static InputParameters validParams()
const Moose::Functor< ADReal > & _coeff2
FVDiffusionInterface(const InputParameters &params)
Moose::FV::InterpMethod _coeff_interp_method
Decides if a geometric arithmetic or harmonic average is used for the face interpolation of the diffu...
const Moose::Functor< ADReal > & _coeff1
ADReal computeQpResidual() override
Base class for creating kernels that interface physics between subdomains.
virtual bool elemIsOne() const
Moose::ElemArg elemArg(bool correct_skewness=false) const
ADRealVectorValue _normal
The normal.
static InputParameters validParams()
const FaceInfo * _face_info
The face that this object is currently operating on.
Moose::ElemArg neighborArg(bool correct_skenewss=false) const
const MooseVariableFV< Real > & var1() const
const MooseVariableFV< Real > & var2() const
const Elem & elem() const
Definition FaceInfo.h:85
const Elem * neighborPtr() const
Definition FaceInfo.h:88
const Point & neighborCentroid() const
Definition FaceInfo.h:247
const Point & elemCentroid() const
Returns the element centroids of the elements on the elem and neighbor sides of the face.
Definition FaceInfo.h:99
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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 addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
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.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
ADReal getElemValue(const Elem *elem, const StateArg &state) const
Get the solution value for the provided element and seed the derivative for the corresponding dof ind...
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
@ HarmonicAverage
1/(gc/elem+(1-gc)/neighbor)
@ Average
gc*elem+(1-gc)*neighbor