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