Canoe
Comprehensive Atmosphere N' Ocean Engine
check_hydro_variables.cpp
Go to the documentation of this file.
1 // canoe
2 #include <configure.hpp>
3 #include <impl.hpp>
4 
5 // athena
6 #include <athena/athena.hpp>
7 #include <athena/coordinates/coordinates.hpp>
8 #include <athena/hydro/hydro.hpp>
9 #include <athena/hydro/srcterms/hydro_srcterms.hpp>
10 #include <athena/mesh/mesh.hpp>
11 #include <athena/stride_iterator.hpp>
12 
13 // application
14 #include <application/application.hpp>
15 
16 // snap
17 #include "../thermodynamics/thermodynamics.hpp"
18 
19 void check_hydro_variables(MeshBlock *pmb) {
20  Application::Logger app("snap");
21  auto pthermo = Thermodynamics::GetInstance();
22  auto &w = pmb->phydro->w;
23 
24  for (int k = pmb->ks; k <= pmb->ke; ++k)
25  for (int j = pmb->js; j <= pmb->je; ++j)
26  for (int i = pmb->is; i <= pmb->ie; ++i) {
27  for (int n = 0; n <= NHYDRO; ++n) {
28  if (w(n, k, j, i) < 0.) {
29  app->Error("density is negative at (" + std::to_string(k) + ", " +
30  std::to_string(j) + ", " + std::to_string(i) + ")");
31  }
32  }
33 
34  if (NON_BAROTROPIC_EOS) {
35  if (w(IPR, k, j, i) < 0.) {
36  app->Error("pressure is negative at (" + std::to_string(k) + ", " +
37  std::to_string(j) + ", " + std::to_string(i) + ")");
38  }
39  }
40 
41  Real temp = pthermo->GetTemp(pmb, k, j, i);
42  Real grav = -pmb->phydro->hsrc.GetG1();
43  if (grav != 0) {
44  Real Tmin = grav * pmb->pcoord->dx1f(i) / pthermo->GetRd();
45  if (temp < Tmin) {
46  app->Error("temperature is less than minimum temperature at (" +
47  std::to_string(k) + ", " + std::to_string(j) + ", " +
48  std::to_string(i) + ")");
49  }
50  }
51  }
52 
53  // make a copy of w, needed for outflow boundary condition
54  // w1 = w;
55  app->Log("Hydro check passed.");
56 }
void check_hydro_variables(MeshBlock *pmb)
static Thermodynamics const * GetInstance()
Return a pointer to the one and only instance of Thermodynamics.
float temp
Definition: fit_ammonia.py:6