https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ArrayDGDiffusion.C
Go to the documentation of this file.
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 "ArrayDGDiffusion.h"
11#include "FEProblemBase.h"
13
14// MOOSE includes
15#include "MooseVariableFE.h"
16
17#include "libmesh/utility.h"
18
20
23{
25 params.addRequiredParam<MaterialPropertyName>(
26 "diff", "The diffusion (or thermal conductivity or viscosity) coefficient.");
27 params.addParam<Real>("sigma", 4, "sigma");
28 params.addParam<Real>("epsilon", 1, "epsilon");
29 params.addClassDescription("Implements interior penalty method for array diffusion equations.");
30 return params;
31}
32
34 : ArrayDGKernel(parameters),
35 _epsilon(getParam<Real>("epsilon")),
36 _sigma(getParam<Real>("sigma")),
37 _diff(getMaterialProperty<RealEigenVector>("diff")),
38 _diff_neighbor(getNeighborMaterialProperty<RealEigenVector>("diff")),
39 _res1(_count),
40 _res2(_count)
41{
42}
43
44void
54
55void
57{
58 mooseAssert(_diff[_qp].size() == _count && _diff_neighbor[_qp].size() == _count,
59 "'diff' size is inconsistent with the number of components of array "
60 "variable");
61
62 const int elem_b_order = std::max(libMesh::Order(1), _var.order());
63 const Real h_elem =
64 _current_elem_volume / _current_side_volume * 1.0 / Utility::pow<2>(elem_b_order);
65
66 // WARNING: use noalias() syntax with caution. See ArrayDiffusion.C for more details.
67 _res1.noalias() = _diff[_qp].asDiagonal() * _grad_u[_qp] * _array_normals[_qp];
68 _res1.noalias() += _diff_neighbor[_qp].asDiagonal() * _grad_u_neighbor[_qp] * _array_normals[_qp];
69 _res1 *= 0.5;
70 _res1 -= (_u[_qp] - _u_neighbor[_qp]) * _sigma / h_elem;
71
72 switch (type)
73 {
74 case Moose::Element:
75 _res2.noalias() = _diff[_qp].asDiagonal() * (_u[_qp] - _u_neighbor[_qp]) * _epsilon * 0.5;
76 break;
77
78 case Moose::Neighbor:
79 _res2.noalias() =
80 _diff_neighbor[_qp].asDiagonal() * (_u[_qp] - _u_neighbor[_qp]) * _epsilon * 0.5;
81 break;
82 }
83}
84
85void
87{
88 switch (type)
89 {
90 case Moose::Element:
91 residual = -_res1 * _test[_i][_qp] + _res2 * (_grad_test[_i][_qp] * _normals[_qp]);
92 break;
93
94 case Moose::Neighbor:
95 residual =
97 break;
98 }
99}
100
101RealEigenVector
103{
104 RealEigenVector r = RealEigenVector::Zero(_count);
105
106 const int elem_b_order = std::max(libMesh::Order(1), _var.order());
107 const Real h_elem =
108 _current_elem_volume / _current_side_volume * 1.0 / Utility::pow<2>(elem_b_order);
109
110 switch (type)
111 {
113 r -= _grad_phi[_j][_qp] * _normals[_qp] * _test[_i][_qp] * 0.5 * _diff[_qp];
114 r += _grad_test[_i][_qp] * _normals[_qp] * _epsilon * 0.5 * _phi[_j][_qp] * _diff[_qp];
115 r += RealEigenVector::Constant(_count, _sigma / h_elem * _phi[_j][_qp] * _test[_i][_qp]);
116 break;
117
120 r -= _grad_test[_i][_qp] * _normals[_qp] * _epsilon * 0.5 * _phi_neighbor[_j][_qp] *
121 _diff[_qp];
122 r -= RealEigenVector::Constant(_count,
123 _sigma / h_elem * _phi_neighbor[_j][_qp] * _test[_i][_qp]);
124 break;
125
127 r += _grad_phi[_j][_qp] * _normals[_qp] * _test_neighbor[_i][_qp] * 0.5 * _diff[_qp];
128 r += _grad_test_neighbor[_i][_qp] * _normals[_qp] * _epsilon * 0.5 * _phi[_j][_qp] *
130 r -= RealEigenVector::Constant(_count,
131 _sigma / h_elem * _phi[_j][_qp] * _test_neighbor[_i][_qp]);
132 break;
133
139 r += RealEigenVector::Constant(
141 break;
142 }
143
144 return r;
145}
registerMooseObject("MooseApp", ArrayDGDiffusion)
Array version of DGDiffusion.
virtual void initQpResidual(Moose::DGResidualType type) override
Put necessary evaluations depending on qp but independent on test functions here.
const MaterialProperty< RealEigenVector > & _diff_neighbor
virtual void computeQpResidual(Moose::DGResidualType type, RealEigenVector &residual) override
This is the virtual that derived classes should override for computing the residual on neighboring el...
RealEigenVector _res2
static InputParameters validParams()
const MaterialProperty< RealEigenVector > & _diff
RealEigenVector _res1
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
virtual RealEigenVector computeQpJacobian(Moose::DGJacobianType type) override
This is the virtual that derived classes should override for computing the Jacobian on neighboring el...
ArrayDGDiffusion(const InputParameters &parameters)
The DGKernel class is responsible for calculating the residuals for various physics on internal sides...
const ArrayVariableTestGradient & _grad_test_neighbor
Gradient of side shape function.
const std::vector< Eigen::Map< RealDIMValue > > & _array_normals
Normals in type of Eigen map.
const ArrayVariablePhiValue & _phi_neighbor
Side shape function.
const ArrayVariableValue & _u
Holds the current solution at the current quadrature point on the face.
const ArrayVariableGradient & _grad_u
Holds the current solution gradient at the current quadrature point on the face.
ArrayMooseVariable & _var
Variable this kernel operates on.
const ArrayVariableTestValue & _test
test functions
const ArrayVariableTestValue & _test_neighbor
Side test function.
const ArrayVariablePhiValue & _phi
Shape functions.
const ArrayVariablePhiGradient & _grad_phi_neighbor
Gradient of side shape function.
const ArrayVariablePhiGradient & _grad_phi
Gradient of shape function.
const ArrayVariableGradient & _grad_u_neighbor
Holds the current solution gradient at the current quadrature point.
const unsigned int _count
Number of components of the array variable.
const ArrayVariableValue & _u_neighbor
Holds the current solution at the current quadrature point.
const ArrayVariableTestGradient & _grad_test
Gradient of side shape function.
static InputParameters validParams()
Factory constructor initializes all internal references needed for residual computation.
virtual const std::set< SubdomainID > & blockIDs() const
Return the block subdomain ids for this object Note, if this is not block restricted,...
const std::set< SubdomainID > & meshBlockIDs() const
Return all of the SubdomainIDs for the mesh.
virtual bool blockRestricted() const
Returns true if this object has been restricted to a block.
unsigned int _i
unsigned int _qp
const Real & _current_elem_volume
The volume (or length) of the current element.
unsigned int _j
const Real & _current_side_volume
The volume (or length) of the current side.
const MooseArray< Point > & _normals
Normal vectors at the quadrature points.
const MaterialWarehouse & getMaterialWarehouse() const
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
const std::string & type() const
Get the type of this class.
Definition MooseBase.h:93
libMesh::Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int.
FEProblemBase & _fe_problem
Reference to this kernel's FEProblemBase.
DGResidualType
Definition MooseTypes.h:798
@ Element
Definition MooseTypes.h:799
@ Neighbor
Definition MooseTypes.h:800
void checkArrayMaterialPropertySize(const MooseObject &object, const MaterialWarehouse &warehouse, const std::set< SubdomainID > &blocks, const std::string &param_name, std::size_t count, bool is_matrix)
Check during setup that an array material property used as a coefficient has one entry per component ...
DGJacobianType
Definition MooseTypes.h:804
@ NeighborNeighbor
Definition MooseTypes.h:808
@ ElementElement
Definition MooseTypes.h:805
@ NeighborElement
Definition MooseTypes.h:807
@ ElementNeighbor
Definition MooseTypes.h:806