www.mooseframework.org
AEFVKernel.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 #include "AEFVKernel.h"
9 
10 template <>
11 InputParameters
13 {
14  InputParameters params = validParams<DGKernel>();
15  params.addClassDescription(
16  "A dgkernel for the advection equation using a cell-centered finite volume method.");
17  MooseEnum component("concentration");
18  params.addParam<MooseEnum>("component", component, "Choose one of the equations");
19  params.addRequiredCoupledVar("u", "Name of the variable to use");
20  params.addRequiredParam<UserObjectName>("flux", "Name of the internal side flux object to use");
21  return params;
22 }
23 
24 AEFVKernel::AEFVKernel(const InputParameters & parameters)
25  : DGKernel(parameters),
26  _component(getParam<MooseEnum>("component")),
27  _uc1(coupledValue("u")),
28  _uc2(coupledNeighborValue("u")),
29  _u1(getMaterialProperty<Real>("u")),
30  _u2(getNeighborMaterialProperty<Real>("u")),
31  _flux(getUserObject<InternalSideFluxBase>("flux"))
32 {
33 }
34 
36 
37 Real
38 AEFVKernel::computeQpResidual(Moose::DGResidualType type)
39 {
40  // assemble the input vectors, which are
41  // the reconstructed linear monomial
42  // extrapolated at side center from the current and neighbor elements
43  std::vector<Real> uvec1 = {_u1[_qp]};
44  std::vector<Real> uvec2 = {_u2[_qp]};
45 
46  // calculate the flux
47  const auto & flux = _flux.getFlux(
48  _current_side, _current_elem->id(), _neighbor_elem->id(), uvec1, uvec2, _normals[_qp], _tid);
49 
50  // distribute the contribution to the current and neighbor elements
51  switch (type)
52  {
53  case Moose::Element:
54  return flux[_component] * _test[_i][_qp];
55 
56  case Moose::Neighbor:
57  return -flux[_component] * _test_neighbor[_i][_qp];
58  }
59 
60  return 0.0;
61 }
62 
63 Real
64 AEFVKernel::computeQpJacobian(Moose::DGJacobianType type)
65 {
66  // assemble the input vectors, which are
67  // the constant monomial from the current and neighbor elements
68  std::vector<Real> uvec1 = {_uc1[_qp]};
69  std::vector<Real> uvec2 = {_uc2[_qp]};
70 
71  // calculate the Jacobian matrices
72  const auto & fjac1 = _flux.getJacobian(Moose::Element,
73  _current_side,
74  _current_elem->id(),
75  _neighbor_elem->id(),
76  uvec1,
77  uvec2,
78  _normals[_qp],
79  _tid);
80 
81  const auto & fjac2 = _flux.getJacobian(Moose::Neighbor,
82  _current_side,
83  _current_elem->id(),
84  _neighbor_elem->id(),
85  uvec1,
86  uvec2,
87  _normals[_qp],
88  _tid);
89 
90  // distribute the contribution to the current and neighbor elements
91  switch (type)
92  {
93  case Moose::ElementElement:
94  return fjac1(_component, _component) * _phi[_j][_qp] * _test[_i][_qp];
95 
96  case Moose::ElementNeighbor:
97  return fjac2(_component, _component) * _phi_neighbor[_j][_qp] * _test[_i][_qp];
98 
99  case Moose::NeighborElement:
100  return -fjac1(_component, _component) * _phi[_j][_qp] * _test_neighbor[_i][_qp];
101 
102  case Moose::NeighborNeighbor:
103  return -fjac2(_component, _component) * _phi_neighbor[_j][_qp] * _test_neighbor[_i][_qp];
104  }
105 
106  return 0.0;
107 }
Real component(const SymmTensor &symm_tensor, unsigned int index)
virtual const DenseMatrix< Real > & getJacobian(Moose::DGResidualType type, unsigned int iside, dof_id_type ielem, dof_id_type ineig, const std::vector< Real > &uvec1, const std::vector< Real > &uvec2, const RealVectorValue &dwave, THREAD_ID tid) const
Get the Jacobian matrix.
virtual Real computeQpJacobian(Moose::DGJacobianType type)
Definition: AEFVKernel.C:64
const InternalSideFluxBase & _flux
flux user object
Definition: AEFVKernel.h:67
const MaterialProperty< Real > & _u2
Definition: AEFVKernel.h:64
const MaterialProperty< Real > & _u1
extrapolated variable values at side center
Definition: AEFVKernel.h:63
virtual const std::vector< Real > & getFlux(unsigned int iside, dof_id_type ielem, dof_id_type ineig, const std::vector< Real > &uvec1, const std::vector< Real > &uvec2, const RealVectorValue &dwave, THREAD_ID tid) const
Get the flux vector.
const VariableValue & _uc1
piecewise constant variable values in cells
Definition: AEFVKernel.h:59
AEFVKernel(const InputParameters &parameters)
Definition: AEFVKernel.C:24
const VariableValue & _uc2
Definition: AEFVKernel.h:60
MooseEnum _component
choose an equation
Definition: AEFVKernel.h:53
virtual Real computeQpResidual(Moose::DGResidualType type)
Definition: AEFVKernel.C:38
A base class for computing and caching internal side flux.
InputParameters validParams< AEFVKernel >()
Definition: AEFVKernel.C:12
virtual ~AEFVKernel()
Definition: AEFVKernel.C:35