www.mooseframework.org
InternalSideFluxBase.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 "InternalSideFluxBase.h"
9 
10 // Static mutex definition
11 Threads::spin_mutex InternalSideFluxBase::_mutex;
12 
13 template <>
14 InputParameters
16 {
17  InputParameters params = validParams<GeneralUserObject>();
18  params.addClassDescription("A base class for computing and caching internal side flux.");
19  return params;
20 }
21 
22 InternalSideFluxBase::InternalSideFluxBase(const InputParameters & parameters)
23  : GeneralUserObject(parameters)
24 {
25  _flux.resize(libMesh::n_threads());
26  _jac1.resize(libMesh::n_threads());
27  _jac2.resize(libMesh::n_threads());
28 }
29 
30 void
32 {
33  _cached_elem_id = 0;
34  _cached_neig_id = 0;
35 }
36 
37 void
39 {
40 }
41 
42 void
44 {
45 }
46 
47 const std::vector<Real> &
48 InternalSideFluxBase::getFlux(unsigned int iside,
49  dof_id_type ielem,
50  dof_id_type ineig,
51  const std::vector<Real> & uvec1,
52  const std::vector<Real> & uvec2,
53  const RealVectorValue & dwave,
54  THREAD_ID tid) const
55 {
56  Threads::spin_mutex::scoped_lock lock(_mutex);
57  if (_cached_elem_id != ielem || _cached_neig_id != ineig)
58  {
59  _cached_elem_id = ielem;
60  _cached_neig_id = ineig;
61 
62  calcFlux(iside, ielem, ineig, uvec1, uvec2, dwave, _flux[tid]);
63  }
64  return _flux[tid];
65 }
66 
67 const DenseMatrix<Real> &
68 InternalSideFluxBase::getJacobian(Moose::DGResidualType type,
69  unsigned int iside,
70  dof_id_type ielem,
71  dof_id_type ineig,
72  const std::vector<Real> & uvec1,
73  const std::vector<Real> & uvec2,
74  const RealVectorValue & dwave,
75  THREAD_ID tid) const
76 {
77  Threads::spin_mutex::scoped_lock lock(_mutex);
78  if (_cached_elem_id != ielem || _cached_neig_id != ineig)
79  {
80  _cached_elem_id = ielem;
81  _cached_neig_id = ineig;
82 
83  calcJacobian(iside, ielem, ineig, uvec1, uvec2, dwave, _jac1[tid], _jac2[tid]);
84  }
85 
86  if (type == Moose::Element)
87  return _jac1[tid];
88  else
89  return _jac2[tid];
90 }
InternalSideFluxBase(const InputParameters &parameters)
static Threads::spin_mutex _mutex
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.
std::vector< DenseMatrix< Real > > _jac1
Jacobian matrix contribution to the "left" cell.
std::vector< DenseMatrix< Real > > _jac2
Jacobian matrix contribution to the "right" cell.
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.
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 =0
Solve the Riemann problem.
std::vector< std::vector< Real > > _flux
flux vector of this side
InputParameters validParams< InternalSideFluxBase >()
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 =0
Compute the Jacobian matrix.