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 "AEFVUpwindInternalSideFlux.h" 11 : 12 : registerMooseObject("RdgApp", AEFVUpwindInternalSideFlux); 13 : 14 : InputParameters 15 116 : AEFVUpwindInternalSideFlux::validParams() 16 : { 17 116 : InputParameters params = InternalSideFluxBase::validParams(); 18 116 : params.addClassDescription("Upwind numerical flux scheme for the advection equation using a " 19 : "cell-centered finite volume method."); 20 232 : params.addParam<Real>("velocity", 1.0, "Advective velocity"); 21 116 : return params; 22 0 : } 23 : 24 67 : AEFVUpwindInternalSideFlux::AEFVUpwindInternalSideFlux(const InputParameters & parameters) 25 134 : : InternalSideFluxBase(parameters), _velocity(getParam<Real>("velocity")) 26 : { 27 67 : } 28 : 29 134 : AEFVUpwindInternalSideFlux::~AEFVUpwindInternalSideFlux() {} 30 : 31 : void 32 44926 : AEFVUpwindInternalSideFlux::calcFlux(unsigned int /*iside*/, 33 : dof_id_type /*ielem*/, 34 : dof_id_type /*ineig*/, 35 : const std::vector<Real> & uvec1, 36 : const std::vector<Real> & uvec2, 37 : const RealVectorValue & dwave, 38 : std::vector<Real> & flux) const 39 : { 40 : mooseAssert(uvec1.size() == 1, "Invalid size for uvec1. Must be single variable coupling."); 41 : mooseAssert(uvec2.size() == 1, "Invalid size for uvec1. Must be single variable coupling."); 42 : 43 : // assign the size of flux vector, e.g. = 1 for the advection equation 44 44926 : flux.resize(1); 45 : 46 : // assume a constant velocity on the left 47 : RealVectorValue uadv1(_velocity, 0.0, 0.0); 48 : 49 : // assume a constant velocity on the right 50 : RealVectorValue uadv2(_velocity, 0.0, 0.0); 51 : 52 : // normal velocity on the left and right 53 : Real vdon1 = uadv1 * dwave; 54 : Real vdon2 = uadv2 * dwave; 55 : 56 : // calculate the so-called a^plus and a^minus 57 44926 : Real aplus = 0.5 * (vdon1 + std::abs(vdon1)); 58 44926 : Real amins = 0.5 * (vdon2 - std::abs(vdon2)); 59 : 60 : // finally calculate the flux 61 44926 : flux[0] = aplus * uvec1[0] + amins * uvec2[0]; 62 44926 : } 63 : 64 : void 65 6039 : AEFVUpwindInternalSideFlux::calcJacobian(unsigned int /*iside*/, 66 : dof_id_type /*ielem*/, 67 : dof_id_type /*ineig*/, 68 : const std::vector<Real> & libmesh_dbg_var(uvec1), 69 : const std::vector<Real> & libmesh_dbg_var(uvec2), 70 : const RealVectorValue & dwave, 71 : DenseMatrix<Real> & jac1, 72 : DenseMatrix<Real> & jac2) const 73 : { 74 : mooseAssert(uvec1.size() == 1, "Invalid size for uvec1. Must be single variable coupling."); 75 : mooseAssert(uvec2.size() == 1, "Invalid size for uvec1. Must be single variable coupling."); 76 : 77 : // assign the size of Jacobian matrix, e.g. = (1, 1) for the advection equation 78 6039 : jac1.resize(1, 1); 79 6039 : jac2.resize(1, 1); 80 : 81 : // assume a constant velocity on the left 82 : RealVectorValue uadv1(_velocity, 0.0, 0.0); 83 : 84 : // assume a constant velocity on the right 85 : RealVectorValue uadv2(_velocity, 0.0, 0.0); 86 : 87 : // normal velocity on the left and right 88 : Real vdon1 = uadv1 * dwave; 89 : Real vdon2 = uadv2 * dwave; 90 : 91 : // calculate the so-called a^plus and a^minus 92 6039 : Real aplus = 0.5 * (vdon1 + std::abs(vdon1)); 93 6039 : Real amins = 0.5 * (vdon2 - std::abs(vdon2)); 94 : 95 : // finally calculate the Jacobian matrix 96 6039 : jac1(0, 0) = aplus; 97 6039 : jac2(0, 0) = amins; 98 6039 : }