https://mooseframework.inl.gov
Loading...
Searching...
No Matches
FVInterfaceKernel.h
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#pragma once
11
12// MOOSE
13#include "MooseObject.h"
14#include "SetupInterface.h"
15#include "ParallelUniqueId.h"
16#include "FunctionInterface.h"
18#include "UserObjectInterface.h"
19#include "TransientInterface.h"
25#include "TaggingInterface.h"
28#include "ADFunctorInterface.h"
30#include "FaceArgInterface.h"
31
32#include <set>
33
34class MooseMesh;
35class SubProblem;
36class FEProblemBase;
37class SystemBase;
38class Assembly;
39template <typename>
40class MooseVariableFV;
41
47 public SetupInterface,
48 public FunctionInterface,
51 public TransientInterface,
56 public TaggingInterface,
59 public ADFunctorInterface,
62{
63public:
69
71
76 const SubProblem & subProblem() const { return _subproblem; }
77
78 void computeResidual(const FaceInfo & fi) override;
79 void computeJacobian(const FaceInfo & fi) override;
80 void computeResidualAndJacobian(const FaceInfo & fi) override;
81
87 bool checkFaceIntegrity(const FaceInfo & fi) const;
88
89 bool hasFaceSide(const FaceInfo & fi, bool fi_elem_side) const override;
90
91protected:
98
103 const std::set<SubdomainID> & sub1() const { return _subdomain1; }
104
109 const std::set<SubdomainID> & sub2() const { return _subdomain2; }
110
114 const MooseVariableFV<Real> & var1() const { return _var1; }
115
119 const MooseVariableFV<Real> & var2() const { return _var2; }
120
124 const MooseMesh & mesh() const { return _mesh; }
125
129 void setupData(const FaceInfo & fi);
130
134 void addResidualToVariable1(Real residual);
135
139 void addResidualToVariable2(Real residual);
140
144 void addResidualAndJacobianToVariable1(const ADReal & residual);
145
149 void addResidualAndJacobianToVariable2(const ADReal & residual);
150
154 Point normal() const;
155
157
160 const Elem & elem1() const;
161 const Elem & elem2() const;
163
165
168 const Point & centroid1() const;
169 const Point & centroid2() const;
171
173
176 Moose::ElemArg elemArg1(bool correct_skewness = false) const;
177 Moose::ElemArg elemArg2(bool correct_skewness = false) const;
179
181
186 bool correct_skewness = false,
187 const Moose::StateArg * state_limiter = nullptr) const;
190 bool correct_skewness = false,
191 const Moose::StateArg * state_limiter = nullptr) const;
193
195
204 template <typename FunctorType>
206 faceArg1(const FunctorType & functor,
208 bool correct_skewness = false,
209 const Moose::StateArg * state_limiter = nullptr) const;
210
211 template <typename FunctorType>
213 faceArg2(const FunctorType & functor,
215 bool correct_skewness = false,
216 const Moose::StateArg * state_limiter = nullptr) const;
218
223 const ADReal & value1,
224 const ADReal & value2) const;
225
229 const unsigned int _qp = 0;
230
233 const FaceInfo * _face_info = nullptr;
234
237
240
243
246
247private:
251 void addResidual(Real residual, unsigned int var_num, bool neighbor);
252
256 void addResidualAndJacobian(const ADReal & residual,
257 const MooseVariableFV<Real> & variable,
258 bool side_is_one);
259
260 std::set<SubdomainID> _subdomain1;
261 std::set<SubdomainID> _subdomain2;
262
265
267};
268
269template <typename FunctorType>
270inline Moose::FaceArg
271FVInterfaceKernel::faceArg1(const FunctorType & functor,
272 const Moose::FV::LimiterType limiter_type,
273 const bool correct_skewness,
274 const Moose::StateArg * state_limiter) const
275{
276 if (!functor.hasFaceSide(*_face_info, _face_info_elem_on_side1))
277 mooseError("The functor '",
278 functor.functorName(),
279 "' is not defined on side 1 of FVInterfaceKernel '",
280 name(),
281 "' at face centroid ",
283 ".");
284
285 return faceArg1(limiter_type, correct_skewness, state_limiter);
286}
287
288template <typename FunctorType>
289inline Moose::FaceArg
290FVInterfaceKernel::faceArg2(const FunctorType & functor,
291 const Moose::FV::LimiterType limiter_type,
292 const bool correct_skewness,
293 const Moose::StateArg * state_limiter) const
294{
295 if (!functor.hasFaceSide(*_face_info, !_face_info_elem_on_side1))
296 mooseError("The functor '",
297 functor.functorName(),
298 "' is not defined on side 2 of FVInterfaceKernel '",
299 name(),
300 "' at face centroid ",
302 ".");
303
304 return faceArg2(limiter_type, correct_skewness, state_limiter);
305}
DualNumber< Real, DNDerivativeType, true > ADReal
unsigned int THREAD_ID
Definition MooseTypes.h:237
An interface for accessing Moose::Functors for systems that care about automatic differentiation,...
Keeps track of stuff related to assembling.
Definition Assembly.h:101
A class for requiring an object to be boundary restricted.
Interface for objects that need to use distributions.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Interface class for a finite volume residual object whose residuals are based on faces.
Base class for creating kernels that interface physics between subdomains.
Moose::FaceArg faceArg2(Moose::FV::LimiterType limiter_type=Moose::FV::LimiterType::CentralDifference, bool correct_skewness=false, const Moose::StateArg *state_limiter=nullptr) const
const THREAD_ID _tid
Thread id.
void addResidualAndJacobianToVariable1(const ADReal &residual)
Add a residual and its Jacobian contribution to variable1 on subdomain1.
void computeResidual(const FaceInfo &fi) override
Compute the residual on the supplied face.
const Elem & elem2() const
const Elem & elem1() const
std::set< SubdomainID > _subdomain1
const MooseMesh & _mesh
MooseVariableFV< Real > & _var2
bool checkFaceIntegrity(const FaceInfo &fi) const
Check that the face connects the two user-defined sides of this interface.
const unsigned int _qp
To be consistent with FE interfaces we introduce this quadrature point member.
static InputParameters validParams()
Moose::FaceArg faceArg1(Moose::FV::LimiterType limiter_type=Moose::FV::LimiterType::CentralDifference, bool correct_skewness=false, const Moose::StateArg *state_limiter=nullptr) const
void addResidualAndJacobianToVariable2(const ADReal &residual)
Add a residual and its Jacobian contribution to variable2 on subdomain2.
Moose::ElemArg elemArg2(bool correct_skewness=false) const
void addResidual(Real residual, unsigned int var_num, bool neighbor)
Process the provided residual given var_num and whether this is on the neighbor side.
Moose::ElemArg elemArg1(bool correct_skewness=false) const
void addResidualAndJacobian(const ADReal &residual, const MooseVariableFV< Real > &variable, bool side_is_one)
Process the provided residual and its derivatives for a variable on a user-defined side.
const FaceInfo * _face_info
The face that this object is currently operating on.
const std::set< SubdomainID > & sub2() const
ADReal interpolateValue(Moose::FV::InterpMethod method, const ADReal &value1, const ADReal &value2) const
Interpolate values from the two user-defined sides to the face.
const MooseMesh & mesh() const
MooseVariableFV< Real > & _var1
const std::set< SubdomainID > & sub1() const
void addResidualToVariable2(Real residual)
Add a residual contribution to variable2 on subdomain2.
const Point & centroid1() const
bool hasFaceSide(const FaceInfo &fi, bool fi_elem_side) const override
void computeResidualAndJacobian(const FaceInfo &fi) override
Compute the residual and Jacobian on the supplied face.
void setupData(const FaceInfo &fi)
setup data useful for this object
bool _face_info_elem_on_side1
Whether the current FaceInfo element is on the user-defined first side.
virtual ADReal computeQpResidual()=0
const MooseVariableFV< Real > & var1() const
Assembly & _assembly
The Assembly object.
void computeJacobian(const FaceInfo &fi) override
Compute the jacobian on the supplied face.
std::set< SubdomainID > _subdomain2
const Point & centroid2() const
const SubProblem & subProblem() const
Get a reference to the subproblem.
SubProblem & _subproblem
The SubProblem.
void addResidualToVariable1(Real residual)
Add a residual contribution to variable1 on subdomain1.
const MooseVariableFV< Real > & var2() const
An interface for producers of functor face arguments, e.g.
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition FaceInfo.h:38
const Point & faceCentroid() const
Returns the coordinates of the face centroid.
Definition FaceInfo.h:75
Interface for objects that need to use functions.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Interface for notifications that the mesh has changed.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
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:271
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition MooseMesh.h:95
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
This class provides variable solution values for other classes/objects to bind to when looping over f...
Intermediate base class that ties together all the interfaces for getting MooseVariables with the Moo...
Interface class for classes which interact with Postprocessors.
Generic class for solving transient nonlinear problems.
Definition SubProblem.h:79
Base class for a system (of equations)
Definition SystemBase.h:87
Interface for objects that needs transient capabilities.
This interface is designed for DGKernel, InternalSideUserObject, InterfaceUserObject,...
Interface for objects that need to use UserObjects.
InterpMethod
This codifies a set of available ways to interpolate with elem+neighbor solution information to calcu...
Definition MathFVUtils.h:39
A structure that is used to evaluate Moose functors logically at an element/cell center.
A structure defining a "face" evaluation calling argument for Moose functors.
State argument for evaluating functors.