Athena++/Atmosphere
Planetary Atmosphere Simulator
hydro.hpp
Go to the documentation of this file.
1 #ifndef HYDRO_HYDRO_HPP_
2 #define HYDRO_HYDRO_HPP_
3 //========================================================================================
4 // Athena++ astrophysical MHD code
5 // Copyright(C) 2014 James M. Stone <jmstone@princeton.edu> and other code contributors
6 // Licensed under the 3-clause BSD License, see LICENSE file for details
7 //========================================================================================
9 // \brief definitions for Hydro class
10 
11 // C headers
12 
13 // C++ headers
14 
15 // Athena++ headers
16 #include "../athena.hpp"
17 #include "../athena_arrays.hpp"
18 #include "../bvals/cc/hydro/bvals_hydro.hpp"
19 #include "hydro_diffusion/hydro_diffusion.hpp"
21 
22 class MeshBlock;
23 class ParameterInput;
24 class Decomposition;
25 class ImplicitSolver;
26 
27 // TODO(felker): consider adding a struct FaceFlux w/ overloaded ctor in athena.hpp, or:
28 // using FaceFlux = AthenaArray<Real>[3];
29 
31 // \brief hydro data and functions
32 
33 class Hydro {
34  friend class Field;
35  friend class EquationOfState;
36  public:
37  Hydro(MeshBlock *pmb, ParameterInput *pin);
38  ~Hydro();
39 
40  // data
41  // TODO(KGF): make this private, if possible
42  MeshBlock* pmy_block; // ptr to MeshBlock containing this Hydro
43 
44  // conserved and primitive variables
45  AthenaArray<Real> u, w; // time-integrator memory register #1
46  AthenaArray<Real> u1, w1; // time-integrator memory register #2
47  AthenaArray<Real> u2; // time-integrator memory register #3
48  // (no more than MAX_NREGISTER allowed)
49 
50  AthenaArray<Real> flux[3]; // face-averaged flux vector
51  AthenaArray<Real> du; // du stores the change of the conservative variable in a substep
52  // implicit correction
56 
57  // storage for SMR/AMR
58  // TODO(KGF): remove trailing underscore or revert to private:
60  int refinement_idx{-1};
61 
62  // fourth-order intermediate quantities
63  AthenaArray<Real> u_cc, w_cc; // cell-centered approximations
64 
67  HydroDiffusion hdif;
70 
71  // functions
72  void NewBlockTimeStep(); // computes new timestep on a MeshBlock
75  AthenaArray<Real> &bcc, const int order);
76  void CalculateFluxes_STS();
77 #if !MAGNETIC_FIELDS_ENABLED // Hydro:
78  void RiemannSolver(
79  const int k, const int j, const int il, const int iu,
80  const int ivx,
82  const AthenaArray<Real> &dxw);
83 #else // MHD:
84  void RiemannSolver(
85  const int k, const int j, const int il, const int iu,
86  const int ivx, const AthenaArray<Real> &bx,
89  AthenaArray<Real> &wct, const AthenaArray<Real> &dxw);
90 #endif
91 
95 
96  void CheckHydro();
97 
98  private:
99  AthenaArray<Real> dt1_, dt2_, dt3_; // scratch arrays used in NewTimeStep
100  // scratch space used to compute fluxes
105  // 2D
108  AthenaArray<Real> bb_normal_; // normal magnetic field, for (SR/GR)MHD
109  AthenaArray<Real> lambdas_p_l_; // most positive wavespeeds in left state
110  AthenaArray<Real> lambdas_m_l_; // most negative wavespeeds in left state
111  AthenaArray<Real> lambdas_p_r_; // most positive wavespeeds in right state
112  AthenaArray<Real> lambdas_m_r_; // most negative wavespeeds in right state
113  // 2D GR
114  AthenaArray<Real> g_, gi_; // metric and inverse, for some GR Riemann solvers
115  AthenaArray<Real> cons_; // conserved state, for some GR Riemann solvers
116 
117  // self-gravity
118  AthenaArray<Real> gflx[3], gflx_old[3]; // gravity tensor (old Athena style)
119 
120  // fourth-order hydro
121  // 4D scratch arrays
124  // 1D scratch arrays
126 
128 
129  void AddDiffusionFluxes();
130  Real GetWeightForCT(Real dflx, Real rhol, Real rhor, Real dx, Real dt);
131 };
132 #endif // HYDRO_HYDRO_HPP_
double Real
Definition: athena.hpp:29
Real(*)(MeshBlock *pmb) TimeStepFunc
Definition: athena.hpp:182
Definition: hydro.hpp:33
AthenaArray< Real > lambdas_m_l_
Definition: hydro.hpp:110
AthenaArray< Real > gflx[3]
Definition: hydro.hpp:118
AthenaArray< Real > cell_volume_
Definition: hydro.hpp:104
bool limit_to_advection
Definition: hydro.hpp:54
HydroSourceTerms hsrc
Definition: hydro.hpp:66
AthenaArray< Real > coarse_prim_
Definition: hydro.hpp:59
int implicit_flag
Definition: hydro.hpp:53
void AddGravityFlux()
AthenaArray< Real > scr1_nkji_
Definition: hydro.hpp:122
AthenaArray< Real > u1
Definition: hydro.hpp:46
AthenaArray< Real > dxw_
Definition: hydro.hpp:101
AthenaArray< Real > dt3_
Definition: hydro.hpp:99
AthenaArray< Real > x1face_area_
Definition: hydro.hpp:102
AthenaArray< Real > cons_
Definition: hydro.hpp:115
~Hydro()
Definition: hydro.cpp:183
void AddGravityFluxWithGflx()
AthenaArray< Real > lambdas_p_l_
Definition: hydro.hpp:109
AthenaArray< Real > w
Definition: hydro.hpp:45
MeshBlock * pmy_block
Definition: hydro.hpp:42
HydroDiffusion hdif
Definition: hydro.hpp:67
AthenaArray< Real > x3face_area_
Definition: hydro.hpp:102
AthenaArray< Real > bb_normal_
Definition: hydro.hpp:108
AthenaArray< Real > u
Definition: hydro.hpp:45
Decomposition * pdec
Definition: hydro.hpp:68
AthenaArray< Real > scr2_nkji_
Definition: hydro.hpp:122
void CalculateGravityFlux(AthenaArray< Real > &phi_in)
AthenaArray< Real > w_cc
Definition: hydro.hpp:63
AthenaArray< Real > wr_
Definition: hydro.hpp:106
ImplicitSolver * pimp
Definition: hydro.hpp:69
HydroBoundaryVariable hbvar
Definition: hydro.hpp:65
AthenaArray< Real > w1
Definition: hydro.hpp:46
AthenaArray< Real > lambdas_p_r_
Definition: hydro.hpp:111
AthenaArray< Real > x3face_area_p1_
Definition: hydro.hpp:103
AthenaArray< Real > u_cc
Definition: hydro.hpp:63
Real min_tem
Definition: hydro.hpp:55
void CalculateFluxes(AthenaArray< Real > &w, FaceField &b, AthenaArray< Real > &bcc, const int order)
void CalculateFluxes_STS()
int refinement_idx
Definition: hydro.hpp:60
AthenaArray< Real > du
Definition: hydro.hpp:51
Hydro(MeshBlock *pmb, ParameterInput *pin)
Definition: hydro.cpp:35
void AddFluxDivergence(const Real wght, AthenaArray< Real > &u_out)
void CheckHydro()
Definition: hydro.cpp:188
AthenaArray< Real > gi_
Definition: hydro.hpp:114
AthenaArray< Real > dt2_
Definition: hydro.hpp:99
void NewBlockTimeStep()
Definition: new_blockdt.cpp:41
void RiemannSolver(const int k, const int j, const int il, const int iu, const int ivx, AthenaArray< Real > &wl, AthenaArray< Real > &wr, AthenaArray< Real > &flx, const AthenaArray< Real > &dxw)
Definition: lmars.cpp:17
AthenaArray< Real > wl3d_
Definition: hydro.hpp:123
friend class Field
Definition: hydro.hpp:34
void AddDiffusionFluxes()
AthenaArray< Real > laplacian_l_fc_
Definition: hydro.hpp:125
AthenaArray< Real > wr3d_
Definition: hydro.hpp:123
AthenaArray< Real > wlb_
Definition: hydro.hpp:106
AthenaArray< Real > dt1_
Definition: hydro.hpp:99
Real GetWeightForCT(Real dflx, Real rhol, Real rhor, Real dx, Real dt)
Definition: hydro.cpp:177
AthenaArray< Real > laplacian_r_fc_
Definition: hydro.hpp:125
AthenaArray< Real > x2face_area_
Definition: hydro.hpp:102
AthenaArray< Real > flux[3]
Definition: hydro.hpp:50
AthenaArray< Real > coarse_cons_
Definition: hydro.hpp:59
AthenaArray< Real > g_
Definition: hydro.hpp:114
AthenaArray< Real > x2face_area_p1_
Definition: hydro.hpp:103
TimeStepFunc UserTimeStep_
Definition: hydro.hpp:127
AthenaArray< Real > u2
Definition: hydro.hpp:47
AthenaArray< Real > wl_
Definition: hydro.hpp:106
AthenaArray< Real > dflx_
Definition: hydro.hpp:107
AthenaArray< Real > gflx_old[3]
Definition: hydro.hpp:118
AthenaArray< Real > lambdas_m_r_
Definition: hydro.hpp:112
double wght[2]