6 #include <configure.hpp>
11 #include <Eigen/Dense>
17 #include <athena/eos/eos.hpp>
18 #include <athena/hydro/hydro.hpp>
19 #include <athena/mesh/mesh.hpp>
22 #include <application/application.hpp>
25 #include "../thermodynamics/thermodynamics.hpp"
35 int is, ie, js, je, ks, ke;
36 int idn = 0, ivx = 1, ivy = 2, ivz = 3, ien = 4;
38 ks = pmb->ks, js = pmb->js, is = pmb->is;
39 ke = pmb->ke, je = pmb->je, ie = pmb->ie;
40 for (
int n = 0; n < NHYDRO; ++n)
41 for (
int k = ks; k <= ke; ++k)
42 for (
int j = js;
j <= je; ++
j)
43 for (
int i = is; i <= ie; ++i)
du_(n, k,
j, i) = du(n, k,
j, i);
44 }
else if (
mydir_ == X2DIR) {
45 ks = pmb->is, js = pmb->ks, is = pmb->js;
46 ke = pmb->ie, je = pmb->ke, ie = pmb->je;
47 for (
int n = 0; n < NHYDRO; ++n)
48 for (
int k = ks; k <= ke; ++k)
49 for (
int j = js;
j <= je; ++
j)
50 for (
int i = is; i <= ie; ++i)
du_(n, k,
j, i) = du(n,
j, i, k);
52 ks = pmb->js, js = pmb->is, is = pmb->ks;
53 ke = pmb->je, je = pmb->ie, ie = pmb->ke;
54 for (
int n = 0; n < NHYDRO; ++n)
55 for (
int k = ks; k <= ke; ++k)
56 for (
int j = js;
j <= je; ++
j)
57 for (
int i = is; i <= ie; ++i)
du_(n, k,
j, i) = du(n, i, k,
j);
61 Eigen::Matrix<Real, 5, 5> Rmat, Lambda, Rimat;
64 Eigen::Matrix<Real, 5, 5> Am, Ap;
68 int nc = ie - is + 1 + 2 * NGHOST;
69 std::vector<Eigen::Matrix<Real, 5, 1>> rhs(nc);
70 std::vector<Eigen::Matrix<Real, 5, 5>>
a(nc),
b(nc), c(nc);
71 std::vector<Eigen::Matrix<Real, 5, 1>> delta(nc);
72 std::vector<Eigen::Matrix<Real, 5, 5>> dfdq(nc);
73 std::vector<Eigen::Matrix<Real, 5, 1>> corr(nc);
79 Eigen::Matrix<Real, 5, 5> Phi, Dt, Bnds, Bnde, tmp;
92 Real* gamma_m1 =
new Real[nc];
94 Real wl[NHYDRO], wr[NHYDRO];
97 for (
int k = ks; k <= ke; ++k)
98 for (
int j = js;
j <= je; ++
j) {
100 for (
int i = is - 2; i <= ie + 1; ++i) {
101 Real fsig = 1., feps = 1.;
103 for (
int n = 1; n <= NVAPOR; ++n) {
104 fsig += w(n, k,
j, i) * (pthermo->GetCvRatioMass(n) - 1.);
105 feps += w(n, k,
j, i) * (pthermo->GetInvMuRatio(n) - 1.);
108 gamma_m1[i] = (gamma - 1.) * feps / fsig;
113 Real gm1 = 0.5 * (gamma_m1[is - 2] + gamma_m1[is - 1]);
118 Am = Rmat * Lambda * Rimat;
121 for (
int i = is - 1; i <= ie; ++i) {
124 gm1 = 0.5 * (gamma_m1[i] + gamma_m1[i + 1]);
129 Ap = Rmat * Lambda * Rimat;
132 Real aleft, aright, vol;
134 aleft = pcoord->GetFace1Area(k,
j, i);
135 aright = pcoord->GetFace1Area(k,
j, i + 1);
136 vol = pcoord->GetCellVolume(k,
j, i);
139 }
else if (
mydir_ == X2DIR) {
140 aleft = pcoord->GetFace2Area(
j, i, k);
141 aright = pcoord->GetFace2Area(
j, i + 1, k);
142 vol = pcoord->GetCellVolume(
j, i, k);
148 aleft = pcoord->GetFace3Area(i, k,
j);
149 aright = pcoord->GetFace3Area(i + 1, k,
j);
150 vol = pcoord->GetCellVolume(i, k,
j);
157 a[i] = (Am * aleft + Ap * aright + (aright - aleft) * dfdq[i]) /
160 b[i] = -(Am + dfdq[i - 1]) * aleft / (2. * vol);
161 c[i] = -(Ap - dfdq[i + 1]) * aright / (2. * vol);
185 for (
int k = ks; k <= ke; ++k)
186 for (
int j = js;
j <= je; ++
j)
187 for (
int i = is; i <= ie; ++i) {
188 du(IDN, k,
j, i) =
du_(IDN, k,
j, i);
189 for (
int n = IVX; n < NHYDRO; ++n) du(n, k,
j, i) =
du_(n, k,
j, i);
191 }
else if (
mydir_ == X2DIR) {
192 for (
int k = ks; k <= ke; ++k)
193 for (
int j = js;
j <= je; ++
j)
194 for (
int i = is; i <= ie; ++i) {
195 du(IDN,
j, i, k) =
du_(IDN, k,
j, i);
196 for (
int n = IVX; n < NHYDRO; ++n) du(n,
j, i, k) =
du_(n, k,
j, i);
199 for (
int k = ks; k <= ke; ++k)
200 for (
int j = js;
j <= je; ++
j)
201 for (
int i = is; i <= ie; ++i) {
202 du(IDN, i, k,
j) =
du_(IDN, k,
j, i);
203 for (
int n = IVX; n < NHYDRO; ++n) du(n, i, k,
j) =
du_(n, k,
j, i);
void FullCorrection(AthenaArray< Real > &du, AthenaArray< Real > const &w, Real dt)
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)
CoordinateDirection mydir_
void PeriodicBackwardSubstitution(std::vector< T1 > &a, std::vector< T1 > &c, std::vector< T2 > &delta, int kl, int ku, int jl, int ju, int il, int iu)
void BackwardSubstitution(std::vector< T1 > &a, std::vector< T2 > &delta, int kl, int ku, int jl, int ju, int il, int iu)
void PeriodicForwardSweep(std::vector< T1 > &a, std::vector< T1 > &b, std::vector< T1 > &c, std::vector< T2 > &corr, Real dt, int k, int j, int il, int iu)
MeshBlock const * pmy_block_
static Thermodynamics const * GetInstance()
Return a pointer to the one and only instance of Thermodynamics.
void Eigenvector(Eigen::DenseBase< Derived1 > &Rmat, Eigen::DenseBase< Derived2 > &Rimat, Real prim[], Real cs, Real gm1, CoordinateDirection dir)
void CopyPrimitives(Real wl[], Real wr[], AthenaArray< Real > const &w, int k, int j, int i, CoordinateDirection dir)
void FluxJacobian(Eigen::DenseBase< Derived1 > &dfdq, Real gm1, Real w[], CoordinateDirection dir)
void RoeAverage(Real prim[], Real gm1, Real wl[], Real wr[])
void Eigenvalue(Eigen::MatrixBase< Derived > &Lambda, Real u, Real cs)