13 #include <application/application.hpp>
16 #include <athena/eos/eos.hpp>
17 #include <athena/hydro/hydro.hpp>
18 #include <athena/mesh/mesh.hpp>
21 #include "../thermodynamics/thermodynamics.hpp"
28 int is, ie, js, je, ks, ke;
29 int idn = 0, ivx = 1, ivy = 2, ivz = 3, ien = 4;
34 ks = pmb->ks, js = pmb->js, is = pmb->is;
35 ke = pmb->ke, je = pmb->je, ie = pmb->ie;
36 for (
int n = 0; n < NHYDRO; ++n)
37 for (
int k = ks; k <= ke; ++k)
38 for (
int j = js;
j <= je; ++
j)
39 for (
int i = is; i <= ie; ++i)
du_(n, k,
j, i) = du(n, k,
j, i);
40 }
else if (
mydir_ == X2DIR) {
41 ks = pmb->is, js = pmb->ks, is = pmb->js;
42 ke = pmb->ie, je = pmb->ke, ie = pmb->je;
43 for (
int n = 0; n < NHYDRO; ++n)
44 for (
int k = ks; k <= ke; ++k)
45 for (
int j = js;
j <= je; ++
j)
46 for (
int i = is; i <= ie; ++i)
du_(n, k,
j, i) = du(n,
j, i, k);
48 ks = pmb->js, js = pmb->is, is = pmb->ks;
49 ke = pmb->je, je = pmb->ie, ie = pmb->ke;
50 for (
int n = 0; n < NHYDRO; ++n)
51 for (
int k = ks; k <= ke; ++k)
52 for (
int j = js;
j <= je; ++
j)
53 for (
int i = is; i <= ie; ++i)
du_(n, k,
j, i) = du(n, i, k,
j);
57 Eigen::Matrix<Real, 5, 5> Rmat, Lambda, Rimat;
60 Eigen::Matrix<Real, 5, 5> Am, Ap, dfdq;
61 Eigen::Matrix<Real, 3, 2> Am1, Ap1;
62 Eigen::Matrix<Real, 3, 3> Am2, Ap2;
63 Eigen::Matrix<Real, 3, 1> sm, sp;
64 Eigen::Matrix<Real, 2, 1> dqm, dqp;
68 int nc = ie - is + 1 + 2 * NGHOST;
69 std::vector<Eigen::Matrix<Real, 3, 3>>
a(nc),
b(nc), c(nc);
70 std::vector<Eigen::Matrix<Real, 3, 1>> delta(nc);
71 std::vector<Eigen::Matrix<Real, 3, 2>> dfdq1(nc);
72 std::vector<Eigen::Matrix<Real, 3, 3>> dfdq2(nc);
73 std::vector<Eigen::Matrix<Real, 3, 1>> corr(nc);
75 Real* gamma_m1 =
new Real[nc];
84 Eigen::Matrix<Real, 3, 3> Phi, Dt, Bnd;
86 Phi << 0., 0., 0., grav, 0., 0., 0., grav, 0.;
88 Phi << 0., 0., 0., 0., 0., 0., 0., 0., 0.;
91 Dt << 1. / dt, 0., 0., 0., 1. / dt, 0., 0., 0., 1. / dt;
93 Bnd << 1., 0., 0., 0., -1., 0., 0., 0., 1.;
95 Real wl[NHYDRO], wr[NHYDRO];
98 for (
int k = ks; k <= ke; ++k)
99 for (
int j = js;
j <= je; ++
j) {
101 for (
int i = is - 2; i <= ie + 1; ++i) {
102 Real fsig = 1., feps = 1.;
104 for (
int n = 1; n <= NVAPOR; ++n) {
105 fsig += wr[n] * (pthermo->GetCvRatioMass(n) - 1.);
106 feps += wr[n] * (pthermo->GetInvMuRatio(n) - 1.);
109 gamma_m1[i] = (gamma - 1.) * feps / fsig;
112 dfdq1[i] << dfdq(idn, ivy), dfdq(idn, ivz), dfdq(ivx, ivy),
113 dfdq(ivx, ivz), dfdq(ien, ivy), dfdq(ien, ivz);
114 dfdq2[i] << dfdq(idn, idn), dfdq(idn, ivx), dfdq(idn, ien),
115 dfdq(ivx, idn), dfdq(ivx, ivx), dfdq(ivx, ien), dfdq(ien, idn),
116 dfdq(ien, ivx), dfdq(ien, ien);
122 Real gm1 = 0.5 * (gamma_m1[is - 2] + gamma_m1[is - 1]);
127 Am = Rmat * Lambda * Rimat;
128 Am1 << Am(idn, ivy), Am(idn, ivz), Am(ivx, ivy), Am(ivx, ivz),
129 Am(ien, ivy), Am(ien, ivz);
130 Am2 << Am(idn, idn), Am(idn, ivx), Am(idn, ien), Am(ivx, idn),
131 Am(ivx, ivx), Am(ivx, ien), Am(ien, idn), Am(ien, ivx), Am(ien, ien);
133 for (
int i = is - 1; i <= ie; ++i) {
135 gm1 = 0.5 * (gamma_m1[i] + gamma_m1[i + 1]);
140 Ap = Rmat * Lambda * Rimat;
141 Ap1 << Ap(idn, ivy), Ap(idn, ivz), Ap(ivx, ivy), Ap(ivx, ivz),
142 Ap(ien, ivy), Ap(ien, ivz);
143 Ap2 << Ap(idn, idn), Ap(idn, ivx), Ap(idn, ien), Ap(ivx, idn),
144 Ap(ivx, ivx), Ap(ivx, ien), Ap(ien, idn), Ap(ien, ivx),
148 Real aleft, aright, vol;
151 aleft = pcoord->GetFace1Area(k,
j, i);
152 aright = pcoord->GetFace1Area(k,
j, i + 1);
153 vol = pcoord->GetCellVolume(k,
j, i);
154 }
else if (
mydir_ == X2DIR) {
155 aleft = pcoord->GetFace2Area(
j, i, k);
156 aright = pcoord->GetFace2Area(
j, i + 1, k);
157 vol = pcoord->GetCellVolume(
j, i, k);
159 aleft = pcoord->GetFace3Area(i, k,
j);
160 aright = pcoord->GetFace3Area(i + 1, k,
j);
161 vol = pcoord->GetCellVolume(i, k,
j);
163 a[i] = (Am2 * aleft + Ap2 * aright + (aright - aleft) * dfdq2[i]) /
166 b[i] = -(Am2 + dfdq2[i - 1]) * aleft / (2. * vol);
167 c[i] = -(Ap2 - dfdq2[i + 1]) * aright / (2. * vol);
200 for (
int k = ks; k <= ke; ++k)
201 for (
int j = js;
j <= je; ++
j)
202 for (
int i = is; i <= ie; ++i) {
203 du(IDN, k,
j, i) =
du_(IDN, k,
j, i);
204 du(IVX, k,
j, i) =
du_(IVX, k,
j, i);
205 du(IEN, k,
j, i) =
du_(IEN, k,
j, i);
207 }
else if (
mydir_ == X2DIR) {
208 for (
int k = ks; k <= ke; ++k)
209 for (
int j = js;
j <= je; ++
j)
210 for (
int i = is; i <= ie; ++i) {
211 du(IDN,
j, i, k) =
du_(IDN, k,
j, i);
212 du(IVY,
j, i, k) =
du_(IVY, k,
j, i);
213 du(IEN,
j, i, k) =
du_(IEN, k,
j, i);
216 for (
int k = ks; k <= ke; ++k)
217 for (
int j = js;
j <= je; ++
j)
218 for (
int i = is; i <= ie; ++i) {
219 du(IDN, i, k,
j) =
du_(IDN, k,
j, i);
220 du(IVZ, i, k,
j) =
du_(IVZ, k,
j, i);
221 du(IEN, i, k,
j) =
du_(IEN, k,
j, i);
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 PartialCorrection(AthenaArray< Real > &du, AthenaArray< Real > const &w, Real dt)
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)