1 #ifndef SRC_TRANSPORT_RECTGRID_H_
2 #define SRC_TRANSPORT_RECTGRID_H_
3 #include <deal.II/lac/sparse_matrix.h>
7 template <
typename _Scalar,
int _Dim>
10 template <
typename _Scalar>
14 enum { Dimension = 2 };
16 int m_nrows,
m_ncols, m_nhalo, m_nrowsh, m_ncolsh;
22 Eigen::Matrix<Scalar, Eigen::Dynamic, 1> m_row_map,
m_row_axis;
24 Eigen::Matrix<Scalar, 1, Eigen::Dynamic> m_col_map,
m_col_axis;
26 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>
m_rowcol_map;
35 m_nrowsh(nrows + 2 * nhalo),
36 m_ncolsh(ncols + 2 * nhalo),
37 m_rank(nrows * ncols),
38 m_rankh(m_nrowsh * m_ncolsh),
43 m_rowcol_map(nrows, ncols),
44 m_pattern(m_rank, m_rankh, 9) {
45 for (
int i = 0; i < m_nrows; i++)
46 for (
int j = 0;
j < m_ncols;
j++) {
47 int64_t k = global(i,
j);
48 m_pattern.add(k, globalh(i,
j));
49 m_pattern.add(k, globalh(i - 1,
j));
50 m_pattern.add(k, globalh(i,
j - 1));
51 m_pattern.add(k, globalh(i + 1,
j));
52 m_pattern.add(k, globalh(i,
j + 1));
53 m_pattern.add(k, globalh(i - 1,
j - 1));
54 m_pattern.add(k, globalh(i - 1,
j + 1));
55 m_pattern.add(k, globalh(i + 1,
j - 1));
56 m_pattern.add(k, globalh(i + 1,
j + 1));
61 m_dd = 1. / (nrows + 1);
64 inline const dealii::SparsityPattern&
pattern()
const {
return m_pattern; }
66 inline int64_t
global(
int i,
int j)
const {
return i * m_ncols +
j; }
69 return (i + m_nhalo) * m_ncolsh + (
j + m_nhalo);
72 inline int rows()
const {
return m_nrows; }
74 inline int rowsh()
const {
return m_nrowsh; }
76 inline int cols()
const {
return m_ncols; }
78 inline int colsh()
const {
return m_ncolsh; }
80 inline int halo()
const {
return m_nhalo; }
82 inline int64_t
rank()
const {
return m_rank; }
84 inline int64_t
rankh()
const {
return m_rankh; }
dealii::SparsityPattern m_pattern
RectGrid(int nrows, int ncols, int nhalo)
const dealii::SparsityPattern & pattern() const
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > m_rowcol_map
Eigen::Matrix< Scalar, 1, Eigen::Dynamic > m_col_axis
int64_t globalh(int i, int j) const
int64_t global(int i, int j) const
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > m_row_axis