13 #include <debugger.hpp>
17 #include <coordinates/coordinates.hpp>
18 #include <hydro/hydro.hpp>
19 #include <hydro/srcterms/hydro_srcterms.hpp>
20 #include <mesh/mesh.hpp>
27 MeshBlock *pmb = pmy_hydro_->pmy_block;
28 pdebug->Enter(
"HydroSourceTerms::Coriolis123");
30 if (omega1_ != 0.0 || omega2_ != 0.0 || omega3_ != 0.0) {
31 for (
int k = pmb->ks; k <= pmb->ke; ++k) {
32 #pragma omp parallel for schedule(static)
33 for (
int j = pmb->js; j <= pmb->je; ++
j) {
34 for (
int i = pmb->is; i <= pmb->ie; ++i) {
35 Real m1 = prim(IDN, k,
j, i) * prim(IM1, k,
j, i),
36 m2 = prim(IDN, k,
j, i) * prim(IM2, k,
j, i),
37 m3 = prim(IDN, k,
j, i) * prim(IM3, k,
j, i);
38 cons(IM1, k,
j, i) += 2. * dt * (omega3_ * m2 - omega2_ * m3);
39 cons(IM2, k,
j, i) += 2. * dt * (omega1_ * m3 - omega3_ * m1);
40 if (pmb->ke > pmb->ks)
41 cons(IM3, k,
j, i) += 2. * dt * (omega2_ * m1 - omega1_ * m2);
56 MeshBlock *pmb = pmy_hydro_->pmy_block;
57 pdebug->Enter(
"HydroSourceTerms::CoriolisXYZ");
59 Real omega1, omega2, omega3,
theta, phi;
61 if (omegax_ != 0.0 || omegay_ != 0.0 || omegaz_ != 0.0) {
62 for (
int k = pmb->ks; k <= pmb->ke; ++k) {
63 #pragma omp parallel for schedule(static)
64 for (
int j = pmb->js; j <= pmb->je; ++
j)
65 for (
int i = pmb->is; i <= pmb->ie; ++i) {
66 if (strcmp(COORDINATE_SYSTEM,
"cartesian") == 0) {
70 }
else if (strcmp(COORDINATE_SYSTEM,
"cylindrical") == 0) {
71 theta = pmb->pcoord->x2v(
j);
73 omega1 = cos(
theta) * omegax_ + sin(
theta) * omegay_;
74 omega2 = -sin(
theta) * omegax_ + cos(
theta) * omegay_;
76 }
else if (strcmp(COORDINATE_SYSTEM,
"spherical_polar") == 0) {
77 theta = pmb->pcoord->x2v(
j);
78 phi = pmb->pcoord->x3v(k);
80 omega1 = sin(
theta) * cos(phi) * omegax_ +
81 sin(
theta) * sin(phi) * omegay_ + cos(
theta) * omegaz_;
82 omega2 = cos(
theta) * cos(phi) * omegax_ +
83 cos(
theta) * sin(phi) * omegay_ - sin(
theta) * omegaz_;
84 omega3 = -sin(phi) * omegax_ + cos(phi) * omegay_;
86 std::stringstream msg;
87 msg <<
"### FATAL ERROR in HydroSourceTerms::CoriolisXYZ"
89 <<
"Unrecognized coordinate system" << std::endl;
93 Real m1 = prim(IDN, k,
j, i) * prim(IM1, k,
j, i),
94 m2 = prim(IDN, k,
j, i) * prim(IM2, k,
j, i),
95 m3 = prim(IDN, k,
j, i) * prim(IM3, k,
j, i);
96 cons(IM1, k,
j, i) += 2. * dt * (omega3 * m2 - omega2 * m3);
97 cons(IM2, k,
j, i) += 2. * dt * (omega1 * m3 - omega3 * m1);
98 cons(IM3, k,
j, i) += 2. * dt * (omega2 * m1 - omega1 * m2);