1 #ifndef SRC_SNAP_IMPLICIT_FORWARD_BACKWARD_HPP_
2 #define SRC_SNAP_IMPLICIT_FORWARD_BACKWARD_HPP_
14 template <
typename T1,
typename T2>
16 std::vector<T1> &c, std::vector<T2> &delta,
17 std::vector<T2> &corr, Real dt,
int k,
int j,
22 if (T2::RowsAtCompileTime == 3) {
23 rhs(0) =
du_(IDN, k,
j, il);
24 for (
int n = 1; n <= NVAPOR; ++n) rhs(0) +=
du_(n, k,
j, il);
27 rhs(2) =
du_(IEN, k,
j, il) / dt;
30 rhs(0) =
du_(IDN, k,
j, il);
31 for (
int n = 1; n <= NVAPOR; ++n) rhs(0) +=
du_(n, k,
j, il);
34 rhs(2) =
du_(IVX + (IVY - IVX +
mydir_) % 3, k,
j, il) / dt;
35 rhs(3) =
du_(IVX + (IVZ - IVX +
mydir_) % 3, k,
j, il) / dt;
36 rhs(4) =
du_(IEN, k,
j, il) / dt;
45 a[il] = (
a[il] -
b[il] *
a[il - 1]).inverse().eval();
46 delta[il] =
a[il] * (rhs -
b[il] * delta[il - 1]);
49 a[il] =
a[il].inverse().eval();
50 delta[il] =
a[il] * rhs;
54 for (
int i = il + 1; i <= iu; ++i) {
55 if (T2::RowsAtCompileTime == 3) {
56 rhs(0) =
du_(IDN, k,
j, i);
57 for (
int n = 1; n <= NVAPOR; ++n) rhs(0) +=
du_(n, k,
j, i);
60 rhs(2) =
du_(IEN, k,
j, i) / dt;
63 rhs(0) =
du_(IDN, k,
j, i);
64 for (
int n = 1; n <= NVAPOR; ++n) rhs(0) +=
du_(n, k,
j, i);
67 rhs(2) =
du_(IVX + (IVY - IVX +
mydir_) % 3, k,
j, i) / dt;
68 rhs(3) =
du_(IVX + (IVZ - IVX +
mydir_) % 3, k,
j, i) / dt;
69 rhs(4) =
du_(IEN, k,
j, i) / dt;
76 a[i] = (
a[i] -
b[i] *
a[i - 1]).inverse().eval();
77 delta[i] =
a[i] * (rhs -
b[i] * delta[i - 1]);
86 template <
typename T1,
typename T2>
88 std::vector<T2> &delta,
int kl,
89 int ku,
int jl,
int ju,
int il,
91 for (
int k = kl; k <= ku; ++k)
92 for (
int j = jl;
j <= ju; ++
j) {
96 delta[iu] -=
a[iu] * delta[iu + 1];
100 for (
int i = iu - 1; i >= il; --i) delta[i] -=
a[i] * delta[i + 1];
103 for (
int i = il; i <= iu; ++i) {
104 if (T2::RowsAtCompileTime == 3) {
105 du_(IDN, k,
j, i) = delta[i](0);
107 du_(IEN, k,
j, i) = delta[i](2);
109 du_(IDN, k,
j, i) = delta[i](0);
111 du_(IVX + (IVY - IVX +
mydir_) % 3, k,
j, i) = delta[i](2);
112 du_(IVX + (IVZ - IVX +
mydir_) % 3, k,
j, i) = delta[i](3);
113 du_(IEN, k,
j, i) = delta[i](4);
115 for (
int n = 1; n <= NVAPOR; ++n)
du_(IDN, k,
j, i) -=
du_(n, k,
j, i);
125 for (
int k = kl; k <= ku; ++k)
126 for (
int j = jl;
j <= ju; ++
j) MPI_Wait(&req_send_data2_[k][
j], &status);
130 for (
int k = kl; k <= ku; ++k)
131 for (
int j = jl;
j <= ju; ++
j) MPI_Wait(&req_send_data1_[k][
j], &status);
void ForwardSweep(std::vector< T1 > &a, std::vector< T1 > &b, std::vector< T1 > &c, std::vector< T2 > &delta, std::vector< T2 > &corr, Real dt, int k, int j, int il, int iu)
void RecvBuffer(T &a, int k, int j, NeighborBlock nb)
CoordinateDirection mydir_
void BackwardSubstitution(std::vector< T1 > &a, std::vector< T2 > &delta, int kl, int ku, int jl, int ju, int il, int iu)
void LoadCoefficients(std::vector< T1 > &a, std::vector< T2 > &b, int k, int j, int il, int iu)
void SaveCoefficients(std::vector< T1 > &a, std::vector< T2 > &b, int k, int j, int il, int iu)
void SendBuffer(T const &a, int k, int j, NeighborBlock nb)