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 : #include "LinearFVAdvectionDiffusionFunctorRobinBCBase.h" 11 : 12 : InputParameters 13 3233 : LinearFVAdvectionDiffusionFunctorRobinBCBase::validParams() 14 : { 15 3233 : InputParameters params = LinearFVAdvectionDiffusionBC::validParams(); 16 3233 : return params; 17 : } 18 : 19 72 : LinearFVAdvectionDiffusionFunctorRobinBCBase::LinearFVAdvectionDiffusionFunctorRobinBCBase( 20 72 : const InputParameters & parameters) 21 72 : : LinearFVAdvectionDiffusionBC(parameters) 22 : { 23 72 : } 24 : 25 : Real 26 1788 : LinearFVAdvectionDiffusionFunctorRobinBCBase::computeBoundaryValue() const 27 : { 28 1788 : const auto face = singleSidedFaceArg(_current_face_info); 29 : mooseAssert(_current_face_type != FaceInfo::VarFaceNeighbors::BOTH, 30 : "This should not be assigned on an internal face!"); 31 1788 : const auto & elem_info = _current_face_type == FaceInfo::VarFaceNeighbors::ELEM 32 1788 : ? _current_face_info->elemInfo() 33 0 : : _current_face_info->neighborInfo(); 34 1788 : const auto state = determineState(); 35 : 36 1788 : const auto alpha = getAlpha(face, state); 37 1788 : const auto beta = getBeta(face, state); 38 1788 : const auto gamma = getGamma(face, state); 39 : 40 1788 : const auto phi = _var.getElemValue(*elem_info, state); 41 1788 : const auto grad_phi = _var.gradSln(*elem_info, state); 42 : 43 1788 : const auto & nhat = _current_face_info->normal(); 44 : 45 1788 : const auto d_cf = computeCellToFaceVector(); // vector from boundary cell centre to boundary face 46 1788 : const auto projection = d_cf * nhat; 47 1788 : const auto vc = d_cf - (projection * nhat); 48 1788 : return ((alpha * phi) + (alpha * grad_phi * vc) + (gamma * projection)) / 49 1788 : (alpha + (beta * projection)); 50 : } 51 : 52 : Real 53 0 : LinearFVAdvectionDiffusionFunctorRobinBCBase::computeBoundaryNormalGradient() const 54 : { 55 0 : const auto face = singleSidedFaceArg(_current_face_info); 56 0 : const auto state = determineState(); 57 0 : const auto alpha = getAlpha(face, state); 58 : mooseAssert(!MooseUtils::isZero(alpha), "Alpha should not be 0!"); 59 0 : const auto beta = getBeta(face, state); 60 0 : const auto gamma = getGamma(face, state); 61 0 : return (gamma - beta * computeBoundaryValue()) / alpha; 62 : } 63 : 64 : // implicit terms for advection kernel 65 : Real 66 192 : LinearFVAdvectionDiffusionFunctorRobinBCBase::computeBoundaryValueMatrixContribution() const 67 : { 68 192 : const auto face = singleSidedFaceArg(_current_face_info); 69 192 : const auto state = determineState(); 70 192 : const auto alpha = getAlpha(face, state); 71 192 : const auto beta = getBeta(face, state); 72 192 : const auto & nhat = _current_face_info->normal(); 73 : 74 192 : return alpha / (alpha + (beta * computeCellToFaceVector() * nhat)); 75 : } 76 : 77 : // explicit terms for advection kernel 78 : Real 79 192 : LinearFVAdvectionDiffusionFunctorRobinBCBase::computeBoundaryValueRHSContribution() const 80 : { 81 192 : const auto face = singleSidedFaceArg(_current_face_info); 82 192 : const auto state = determineState(); 83 : mooseAssert(_current_face_type != FaceInfo::VarFaceNeighbors::BOTH, 84 : "This should not be assigned on an internal face!"); 85 192 : const auto & elem_info = _current_face_type == FaceInfo::VarFaceNeighbors::ELEM 86 192 : ? _current_face_info->elemInfo() 87 0 : : _current_face_info->neighborInfo(); 88 : 89 192 : const auto alpha = getAlpha(face, state); 90 192 : const auto beta = getBeta(face, state); 91 192 : const auto gamma = getGamma(face, state); 92 : 93 192 : const auto & grad_phi = _var.gradSln(*elem_info, state); 94 : 95 192 : const auto & nhat = _current_face_info->normal(); 96 : 97 192 : const auto d_cf = computeCellToFaceVector(); // vector from boundary cell centre to boundary face 98 192 : const auto projection = d_cf * nhat; 99 192 : const auto vc = d_cf - (projection * nhat); // correction vector for non-orthogonal cells 100 : 101 192 : return (gamma * projection / (alpha + (beta * projection))) + 102 192 : (alpha * grad_phi * vc / (alpha + (beta * projection))); 103 : } 104 : 105 : // implicit terms for diffusion kernel 106 : Real 107 708 : LinearFVAdvectionDiffusionFunctorRobinBCBase::computeBoundaryGradientMatrixContribution() const 108 : { 109 708 : const auto face = singleSidedFaceArg(_current_face_info); 110 708 : const auto state = determineState(); 111 : 112 708 : const auto alpha = getAlpha(face, state); 113 708 : const auto beta = getBeta(face, state); 114 : 115 708 : const auto & nhat = _current_face_info->normal(); 116 : 117 708 : return beta / (alpha + (beta * computeCellToFaceVector() * nhat)); 118 : } 119 : 120 : // explicit terms for diffusion kernel 121 : Real 122 708 : LinearFVAdvectionDiffusionFunctorRobinBCBase::computeBoundaryGradientRHSContribution() const 123 : { 124 : mooseAssert(_current_face_type != FaceInfo::VarFaceNeighbors::BOTH, 125 : "This should not be assigned on an internal face!"); 126 708 : const auto & elem_info = _current_face_type == FaceInfo::VarFaceNeighbors::ELEM 127 708 : ? _current_face_info->elemInfo() 128 0 : : _current_face_info->neighborInfo(); 129 708 : const auto face = singleSidedFaceArg(_current_face_info); 130 708 : const auto state = determineState(); 131 708 : const auto & grad_phi = _var.gradSln(*elem_info, state); 132 : 133 708 : const auto alpha = getAlpha(face, state); 134 708 : const auto beta = getBeta(face, state); 135 708 : const auto gamma = getGamma(face, state); 136 : 137 708 : const auto & nhat = _current_face_info->normal(); 138 : 139 708 : const auto d_cf = computeCellToFaceVector(); // vector from boundary cell centre to boundary face 140 708 : const auto projection = d_cf * nhat; 141 708 : const auto vc = d_cf - (projection * nhat); // correction vector for non-orthogonal cells 142 : 143 708 : return (gamma / alpha) + (-beta * gamma * projection / alpha / (alpha + (beta * projection))) + 144 708 : (-beta * grad_phi * vc / (alpha + (beta * projection))); 145 : }