1 #ifndef SRC_TRANSPORT_DIFFUSION_H_
2 #define SRC_TRANSPORT_DIFFUSION_H_
4 #include <deal.II/lac/sparse_matrix.h>
6 template <
typename _Scalar,
int _Dim,
int _Order = 4>
9 template <
typename _Scalar>
13 enum { Dimension = 2 };
24 : m_grid(grid), m_eddy(eddy), m_jacobian(grid.pattern()) {}
27 for (
int i = 0; i < m_grid.rows(); i++)
28 for (
int j = 0;
j < m_grid.cols();
j++) {
29 int64_t k = m_grid.global(i,
j);
30 m_jacobian.set(k, m_grid.globalh(i,
j), -4.);
31 m_jacobian.set(k, m_grid.globalh(i - 1,
j), 1.);
32 m_jacobian.set(k, m_grid.globalh(i + 1,
j), 1.);
33 m_jacobian.set(k, m_grid.globalh(i,
j - 1), 1.);
34 m_jacobian.set(k, m_grid.globalh(i,
j + 1), 1.);
36 m_jacobian *= m_eddy.val(0, 0) / (m_grid.dd() * m_grid.dd());
39 inline dealii::SparseMatrix<Scalar>&
operator()() {
return m_jacobian; }
41 inline const dealii::SparseMatrix<Scalar>&
operator()()
const {
46 template <
typename _Scalar>
50 enum { Dimension = 2 };
61 : m_grid(grid), m_eddy(eddy), m_jacobian(grid.pattern()) {}
64 for (
int i = 0; i < m_grid.rows(); i++)
65 for (
int j = 0;
j < m_grid.cols();
j++) {
66 int64_t k = m_grid.global(i,
j);
67 m_jacobian.set(k, m_grid.globalh(i,
j), -10. / 3.);
68 m_jacobian.set(k, m_grid.globalh(i - 1,
j), 2. / 3.);
69 m_jacobian.set(k, m_grid.globalh(i,
j - 1), 2. / 3.);
70 m_jacobian.set(k, m_grid.globalh(i + 1,
j), 2. / 3.);
71 m_jacobian.set(k, m_grid.globalh(i,
j + 1), 2. / 3.);
72 m_jacobian.set(k, m_grid.globalh(i - 1,
j - 1), 1. / 6.);
73 m_jacobian.set(k, m_grid.globalh(i - 1,
j + 1), 1. / 6.);
74 m_jacobian.set(k, m_grid.globalh(i + 1,
j - 1), 1. / 6.);
75 m_jacobian.set(k, m_grid.globalh(i + 1,
j + 1), 1. / 6.);
77 m_jacobian *= m_eddy.val(0, 0) / (m_grid.dd() * m_grid.dd());
80 inline dealii::SparseMatrix<Scalar>&
operator()() {
return m_jacobian; }
82 inline const dealii::SparseMatrix<Scalar>&
operator()()
const {
const RectGrid< Scalar, Dimension > & m_grid
dealii::SparseMatrix< Scalar > & operator()()
const dealii::SparseMatrix< Scalar > & operator()() const
Diffusion(const RectGrid< Scalar, Dimension > &grid, const Variable< Scalar, Dimension > &eddy)
dealii::SparseMatrix< Scalar > m_jacobian
const Variable< Scalar, Dimension > & m_eddy
const Variable< Scalar, Dimension > & m_eddy
Diffusion(const RectGrid< Scalar, Dimension > &grid, const Variable< Scalar, Dimension > &eddy)
const RectGrid< Scalar, Dimension > & m_grid
dealii::SparseMatrix< Scalar > m_jacobian
dealii::SparseMatrix< Scalar > & operator()()
const dealii::SparseMatrix< Scalar > & operator()() const