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