Line data Source code
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" 17 : #include "DistributionInterface.h" 18 : #include "UserObjectInterface.h" 19 : #include "TransientInterface.h" 20 : #include "PostprocessorInterface.h" 21 : #include "VectorPostprocessorInterface.h" 22 : #include "GeometricSearchInterface.h" 23 : #include "BoundaryRestrictableRequired.h" 24 : #include "MeshChangedInterface.h" 25 : #include "TaggingInterface.h" 26 : #include "NeighborCoupleableMooseVariableDependencyIntermediateInterface.h" 27 : #include "TwoMaterialPropertyInterface.h" 28 : #include "ADFunctorInterface.h" 29 : #include "FVFaceResidualObject.h" 30 : #include "FaceArgInterface.h" 31 : 32 : #include <set> 33 : 34 : class MooseMesh; 35 : class SubProblem; 36 : class FEProblemBase; 37 : class SystemBase; 38 : class Assembly; 39 : template <typename> 40 : class MooseVariableFV; 41 : 42 : /** 43 : * Base class for creating kernels that interface physics between subdomains 44 : */ 45 : class FVInterfaceKernel : public MooseObject, 46 : public BoundaryRestrictableRequired, 47 : public SetupInterface, 48 : public FunctionInterface, 49 : public DistributionInterface, 50 : public UserObjectInterface, 51 : public TransientInterface, 52 : public PostprocessorInterface, 53 : public VectorPostprocessorInterface, 54 : public GeometricSearchInterface, 55 : public MeshChangedInterface, 56 : public TaggingInterface, 57 : public NeighborCoupleableMooseVariableDependencyIntermediateInterface, 58 : public TwoMaterialPropertyInterface, 59 : public ADFunctorInterface, 60 : public FVFaceResidualObject, 61 : public FaceArgProducerInterface 62 : { 63 : public: 64 : /** 65 : * Class constructor. 66 : * @param parameters The InputParameters for the object 67 : */ 68 : FVInterfaceKernel(const InputParameters & parameters); 69 : 70 : static InputParameters validParams(); 71 : 72 : /** 73 : * Get a reference to the subproblem 74 : * @return Reference to SubProblem 75 : */ 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 : 82 : bool hasFaceSide(const FaceInfo & fi, bool fi_elem_side) const override; 83 : 84 : protected: 85 : /** 86 : * @return Interface residual terms. The result will be multiplied by the face area 87 : */ 88 : virtual ADReal computeQpResidual() = 0; 89 : 90 : /** 91 : * @return The subdomains on the 1st side of this interface kernel. These are chosen by the user. 92 : * Variable 1 and any other data associated with the 1st side should exist on these subdomains 93 : */ 94 : const std::set<SubdomainID> & sub1() const { return _subdomain1; } 95 : 96 : /** 97 : * @return The subdomains on the 2nd side of this interface kernel. These are chosen by the user. 98 : * Variable 2 and any other data associated with the 2nd side should exist on these subdomains 99 : */ 100 : const std::set<SubdomainID> & sub2() const { return _subdomain2; } 101 : 102 : /** 103 : * @return Whether the \p FaceInfo element is on the 1st side of the interface 104 : */ 105 40392 : virtual bool elemIsOne() const { return _elem_is_one; } 106 : 107 : /** 108 : * @return Variable 1 109 : */ 110 14224 : const MooseVariableFV<Real> & var1() const { return _var1; } 111 : 112 : /** 113 : * @return Variable 2 114 : */ 115 14480 : const MooseVariableFV<Real> & var2() const { return _var2; } 116 : 117 : /** 118 : * @return The mesh this object lives on. Either undisplaced or displaced 119 : */ 120 : const MooseMesh & mesh() const { return _mesh; } 121 : 122 : /** 123 : * setup data useful for this object 124 : */ 125 : void setupData(const FaceInfo & fi); 126 : 127 : /** 128 : * Process the provided residual given \p var_num and whether this is on the neighbor side 129 : */ 130 : void addResidual(Real resid, unsigned int var_num, bool neighbor); 131 : 132 : using TaggingInterface::addJacobian; 133 : /** 134 : * Process the derivatives for the provided residual and dof index 135 : */ 136 : void addJacobian(const ADReal & resid, dof_id_type dof_index, Real scaling_factor); 137 : 138 : /** 139 : * @return A structure that contains information about the face info element and skewness 140 : * correction for use with functors 141 : */ 142 : Moose::ElemArg elemArg(bool correct_skewness = false) const; 143 : 144 : /** 145 : * @return A structure that contains information about the face info neighbor and skewness 146 : * correction for use with functors 147 : */ 148 : Moose::ElemArg neighborArg(bool correct_skenewss = false) const; 149 : 150 : /** 151 : * Determine the single sided face argument when evaluating a functor on a face. 152 : * This is used to perform evaluations of material properties with the actual face values of 153 : * their dependences, rather than interpolate the material property to the boundary. 154 : * @param fi the FaceInfo for this face 155 : * @param limiter_type the limiter type, to be specified if more than the default average 156 : * interpolation is required for the parameters of the functor 157 : * @param correct_skewness whether to perform skew correction at the face 158 : */ 159 : Moose::FaceArg singleSidedFaceArg( 160 : const MooseVariableFV<Real> & variable, 161 : const FaceInfo * fi = nullptr, 162 : Moose::FV::LimiterType limiter_type = Moose::FV::LimiterType::CentralDifference, 163 : bool correct_skewness = false, 164 : const Moose::StateArg * state_limiter = nullptr) const; 165 : 166 : /// To be consistent with FE interfaces we introduce this quadrature point member. However, for FV 167 : /// calculations there should every only be one qudrature point and it should be located at the 168 : /// face centroid 169 : const unsigned int _qp = 0; 170 : 171 : /// The normal. This always points out of the \p FaceInfo element. Note, however that we multiply 172 : /// the result of \p computeQpResidual by -1 before summing into the \p FaceInfo neighbor residual 173 : /// such that the neighbor residual feels as if this data member is pointing out of the neighbor 174 : /// element 175 : ADRealVectorValue _normal; 176 : 177 : /// The face that this object is currently operating on. Always set to something non-null before 178 : /// calling \p computeQpResidual 179 : const FaceInfo * _face_info = nullptr; 180 : 181 : /// Thread id 182 : const THREAD_ID _tid; 183 : 184 : /// Whether the current element is associated with variable/subdomain 1 or 2 185 : bool _elem_is_one; 186 : 187 : /// The SubProblem 188 : SubProblem & _subproblem; 189 : 190 : MooseVariableFV<Real> & _var1; 191 : MooseVariableFV<Real> & _var2; 192 : 193 : /// The Assembly object 194 : Assembly & _assembly; 195 : 196 : private: 197 : std::set<SubdomainID> _subdomain1; 198 : std::set<SubdomainID> _subdomain2; 199 : 200 : const MooseMesh & _mesh; 201 : };