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 class RingFilter;
27 
28 // TODO(felker): consider adding a struct FaceFlux w/ overloaded ctor in athena.hpp, or:
29 // using FaceFlux = AthenaArray<Real>[3];
30 
32 // \brief hydro data and functions
33 
34 class Hydro {
35  friend class Field;
36  friend class EquationOfState;
37  public:
38  Hydro(MeshBlock *pmb, ParameterInput *pin);
39  ~Hydro();
40 
41  // data
42  // TODO(KGF): make this private, if possible
43  MeshBlock* pmy_block; // ptr to MeshBlock containing this Hydro
44 
45  // conserved and primitive variables
46  AthenaArray<Real> u, w; // time-integrator memory register #1
47  AthenaArray<Real> u1, w1; // time-integrator memory register #2
48  AthenaArray<Real> u2; // time-integrator memory register #3
49  // (no more than MAX_NREGISTER allowed)
50 
51  AthenaArray<Real> flux[3]; // face-averaged flux vector
52  AthenaArray<Real> du; // du stores the change of the conservative variable in a substep
53  // implicit correction
57 
58  // hydrostatic option variables
61 
62  // storage for SMR/AMR
63  // TODO(KGF): remove trailing underscore or revert to private:
65  int refinement_idx{-1};
66 
67  // fourth-order intermediate quantities
68  AthenaArray<Real> u_cc, w_cc; // cell-centered approximations
69 
72  HydroDiffusion hdif;
76 
77  // functions
78  void NewBlockTimeStep(); // computes new timestep on a MeshBlock
79  void AddFluxDivergence(const Real wght, AthenaArray<Real> &u_out);
81  AthenaArray<Real> &bcc, const int order);
82  void CalculateFluxes_STS();
83 #if !MAGNETIC_FIELDS_ENABLED // Hydro:
84  void RiemannSolver(
85  const int k, const int j, const int il, const int iu,
86  const int ivx,
88  const AthenaArray<Real> &dxw);
89 #else // MHD:
90  void RiemannSolver(
91  const int k, const int j, const int il, const int iu,
92  const int ivx, const AthenaArray<Real> &bx,
95  AthenaArray<Real> &wct, const AthenaArray<Real> &dxw);
96 #endif
97 
101 
102  // support functions
103  void CheckHydro();
105 
106  private:
107  AthenaArray<Real> dt1_, dt2_, dt3_; // scratch arrays used in NewTimeStep
108  // scratch space used to compute fluxes
113  // 2D
116  AthenaArray<Real> bb_normal_; // normal magnetic field, for (SR/GR)MHD
117  AthenaArray<Real> lambdas_p_l_; // most positive wavespeeds in left state
118  AthenaArray<Real> lambdas_m_l_; // most negative wavespeeds in left state
119  AthenaArray<Real> lambdas_p_r_; // most positive wavespeeds in right state
120  AthenaArray<Real> lambdas_m_r_; // most negative wavespeeds in right state
121  // 2D GR
122  AthenaArray<Real> g_, gi_; // metric and inverse, for some GR Riemann solvers
123  AthenaArray<Real> cons_; // conserved state, for some GR Riemann solvers
124 
125  // self-gravity
126  AthenaArray<Real> gflx[3], gflx_old[3]; // gravity tensor (old Athena style)
127 
128  // fourth-order hydro
129  // 4D scratch arrays
132  // 1D scratch arrays
134 
136 
137  void AddDiffusionFluxes();
138  Real GetWeightForCT(Real dflx, Real rhol, Real rhor, Real dx, Real dt);
139 };
140 #endif // HYDRO_HYDRO_HPP_
double Real
Definition: athena.hpp:29
Real(*)(MeshBlock *pmb) TimeStepFunc
Definition: athena.hpp:182
Definition: hydro.hpp:34
AthenaArray< Real > lambdas_m_l_
Definition: hydro.hpp:118
AthenaArray< Real > gflx[3]
Definition: hydro.hpp:126
AthenaArray< Real > cell_volume_
Definition: hydro.hpp:112
bool limit_to_advection
Definition: hydro.hpp:55
HydroSourceTerms hsrc
Definition: hydro.hpp:71
AthenaArray< Real > coarse_prim_
Definition: hydro.hpp:64
int implicit_flag
Definition: hydro.hpp:54
void AddGravityFlux()
AthenaArray< Real > scr1_nkji_
Definition: hydro.hpp:130
Real scale_height
Definition: hydro.hpp:59
AthenaArray< Real > u1
Definition: hydro.hpp:47
Real reference_pressure
Definition: hydro.hpp:60
AthenaArray< Real > dxw_
Definition: hydro.hpp:109
AthenaArray< Real > dt3_
Definition: hydro.hpp:107
AthenaArray< Real > x1face_area_
Definition: hydro.hpp:110
AthenaArray< Real > cons_
Definition: hydro.hpp:123
~Hydro()
Definition: hydro.cpp:200
void AddGravityFluxWithGflx()
AthenaArray< Real > lambdas_p_l_
Definition: hydro.hpp:117
AthenaArray< Real > w
Definition: hydro.hpp:46
MeshBlock * pmy_block
Definition: hydro.hpp:43
HydroDiffusion hdif
Definition: hydro.hpp:72
AthenaArray< Real > x3face_area_
Definition: hydro.hpp:110
AthenaArray< Real > bb_normal_
Definition: hydro.hpp:116
AthenaArray< Real > u
Definition: hydro.hpp:46
Decomposition * pdec
Definition: hydro.hpp:73
AthenaArray< Real > scr2_nkji_
Definition: hydro.hpp:130
void CalculateGravityFlux(AthenaArray< Real > &phi_in)
AthenaArray< Real > w_cc
Definition: hydro.hpp:68
AthenaArray< Real > wr_
Definition: hydro.hpp:114
ImplicitSolver * pimp
Definition: hydro.hpp:74
HydroBoundaryVariable hbvar
Definition: hydro.hpp:70
AthenaArray< Real > w1
Definition: hydro.hpp:47
AthenaArray< Real > lambdas_p_r_
Definition: hydro.hpp:119
AthenaArray< Real > x3face_area_p1_
Definition: hydro.hpp:111
AthenaArray< Real > u_cc
Definition: hydro.hpp:68
Real min_tem
Definition: hydro.hpp:56
void CalculateFluxes(AthenaArray< Real > &w, FaceField &b, AthenaArray< Real > &bcc, const int order)
void CalculateFluxes_STS()
int refinement_idx
Definition: hydro.hpp:65
AthenaArray< Real > du
Definition: hydro.hpp:52
Hydro(MeshBlock *pmb, ParameterInput *pin)
Definition: hydro.cpp:36
void AddFluxDivergence(const Real wght, AthenaArray< Real > &u_out)
void CheckHydro()
Definition: hydro.cpp:206
AthenaArray< Real > gi_
Definition: hydro.hpp:122
AthenaArray< Real > dt2_
Definition: hydro.hpp:107
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)
The HLLC Riemann solver for adiabatic hydrodynamics (use HLLE for isothermal)
Definition: hllc.cpp:34
AthenaArray< Real > wl3d_
Definition: hydro.hpp:131
friend class Field
Definition: hydro.hpp:35
void AddDiffusionFluxes()
AthenaArray< Real > laplacian_l_fc_
Definition: hydro.hpp:133
AthenaArray< Real > wr3d_
Definition: hydro.hpp:131
AthenaArray< Real > wlb_
Definition: hydro.hpp:114
AthenaArray< Real > dt1_
Definition: hydro.hpp:107
Real GetWeightForCT(Real dflx, Real rhol, Real rhor, Real dx, Real dt)
Definition: hydro.cpp:194
AthenaArray< Real > laplacian_r_fc_
Definition: hydro.hpp:133
AthenaArray< Real > x2face_area_
Definition: hydro.hpp:110
AthenaArray< Real > flux[3]
Definition: hydro.hpp:51
AthenaArray< Real > coarse_cons_
Definition: hydro.hpp:64
AthenaArray< Real > g_
Definition: hydro.hpp:122
AthenaArray< Real > x2face_area_p1_
Definition: hydro.hpp:111
TimeStepFunc UserTimeStep_
Definition: hydro.hpp:135
AthenaArray< Real > u2
Definition: hydro.hpp:48
AthenaArray< Real > wl_
Definition: hydro.hpp:114
AthenaArray< Real > dflx_
Definition: hydro.hpp:115
AthenaArray< Real > gflx_old[3]
Definition: hydro.hpp:126
void VaporConcentrationLimiter(AthenaArray< Real > &u)
RingFilter * pfilter
Definition: hydro.hpp:75
AthenaArray< Real > lambdas_m_r_
Definition: hydro.hpp:120
double wght[2]