Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cll.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file cll.h
1 /******************************************************************************
2 * *
3 * vHLLE : a 3D viscous hydrodynamic code *
4 * version 1.0, November 2013 *
5 * by Iurii Karpenko *
6 * contact: yu.karpenko@gmail.com *
7 * For the detailed description please refer to: *
8 * http://arxiv.org/abs/1312.4160 *
9 * *
10 * This code can be freely used and redistributed, provided that this *
11 * copyright appear in all the copies. If you decide to make modifications *
12 * to the code, please contact the authors, especially if you plan to publish *
13 * the results obtained with such modified code. Any publication of results *
14 * obtained using this code must include the reference to *
15 * arXiv:1312.4160 [nucl-th] or the published version of it, when available. *
16 * *
17 *******************************************************************************/
18 
19 #pragma once
20 #include <iosfwd>
21 #include <algorithm>
22 #include "inc.h"
23 class EoS;
24 
25 // returns an index of pi^{mu nu} mu,nu component in a plain 1D array
26 int index44(const int &i, const int &j);
27 
28 // this class stores the information about an individual hydro cell
29 class Cell {
30  private:
31  // Q usually denotes the conserved quantities, T^{0i}
32  // here, Q, Qh, Qprev etc. ~tau*T^{0i}, like Hirano'01
33  double Q[7]; // final values at a given timestep
34  double Qh[7]; // half-step updated values
35  double Qprev[7]; // values at the end of previous timestep
36  double pi[10], piH[10]; // pi^{mu nu}, WITHOUT tau factor, final (pi) and
37  // half-step updated (piH)
38  double Pi,
39  PiH; // Pi, WITHOUT tau factor, final (Pi) and half-step updated (PiH)
40  double pi0[10], piH0[10]; // // pi^{mu nu}, WITHOUT tau factor, auxiliary
41  double Pi0, PiH0; // viscous, WITHOUT tau factor, auxiliary
42  double flux[7]; // cumulative fluxes
43  Cell *next[3]; // pointer to the next cell in a given direction
44  Cell *prev[3]; // pointer to the previous cell in a given direction
45  double m[3]; // extend of matter propagation inside cell [0...1]
46  double dm[3]; // auxiliary
47  int ix, iy, iz; // cell coordinate on the grid
48  // viscCorrCut: flag if the viscous corrections are cut for this cell:
49  // 1.0 = uncut, < 1 : cut by this factor
50  double viscCorrCut;
51 
52  public:
53  Cell();
54  ~Cell() {};
55  inline void setPos(int iix, int iiy, int iiz) {
56  ix = iix;
57  iy = iiy;
58  iz = iiz;
59  }
60  inline int getX(void) { return ix; }
61  inline int getY(void) { return iy; }
62  inline int getZ(void) { return iz; }
63 
64  inline void setQ(double *_Q) {
65  for (int i = 0; i < 7; i++) Q[i] = _Q[i];
66  if (Q[T_] < 0.) {
67  for (int i = 0; i < 7; i++) Q[i] = 0.;
68  }
69  }
70  inline void setQh(double *_Qh) {
71  for (int i = 0; i < 7; i++) Qh[i] = _Qh[i];
72  if (Qh[T_] < 0.) {
73  for (int i = 0; i < 7; i++) Qh[i] = 0.;
74  }
75  }
76 
77  // getter and setter methods for the class members
78  inline double getpi(const int &i, const int &j) { return pi[index44(i, j)]; }
79  inline double getpiH(const int &i, const int &j) {
80  return piH[index44(i, j)];
81  }
82  inline double getpi0(const int &i, const int &j) {
83  return pi0[index44(i, j)];
84  }
85  inline double getpiH0(const int &i, const int &j) {
86  return piH0[index44(i, j)];
87  }
88  inline double getPi(void) { return Pi; }
89  inline double getPiH(void) { return PiH; }
90  inline double getPi0(void) { return Pi0; }
91  inline double getPiH0(void) { return PiH0; }
92 
93  inline void setpi(const int &i, const int &j, const double &val) {
94  pi[index44(i, j)] = val;
95  }
96  inline void setpiH(const int &i, const int &j, const double &val) {
97  piH[index44(i, j)] = val;
98  }
99  inline void setpi0(const int &i, const int &j, const double &val) {
100  pi0[index44(i, j)] = val;
101  }
102  inline void setpiH0(const int &i, const int &j, const double &val) {
103  piH0[index44(i, j)] = val;
104  }
105  inline void addpi0(const int &i, const int &j, const double &val) {
106  pi0[index44(i, j)] += val;
107  }
108  inline void addpiH0(const int &i, const int &j, const double &val) {
109  piH0[index44(i, j)] += val;
110  }
111  inline void setPi(const double &val) { Pi = val; }
112  inline void setPiH(const double &val) { PiH = val; }
113  inline void setPi0(const double &val) { Pi0 = val; }
114  inline void setPiH0(const double &val) { PiH0 = val; }
115  inline void addPi0(const double &val) { Pi0 += val; }
116  inline void addPiH0(const double &val) { PiH0 += val; }
117 
118  inline void getQ(double *_Q) {
119  for (int i = 0; i < 7; i++) _Q[i] = Q[i];
120  }
121  inline void getQh(double *_Qh) {
122  for (int i = 0; i < 7; i++) _Qh[i] = Qh[i];
123  }
124  inline void saveQprev(void) {
125  for (int i = 0; i < 7; i++) Qprev[i] = Q[i];
126  }
127  inline void setNext(int i, Cell *c) { next[i - 1] = c; }
128  inline void setPrev(int i, Cell *c) { prev[i - 1] = c; }
129  inline Cell *getNext(int i) { return next[i - 1]; }
130  inline Cell *getPrev(int i) { return prev[i - 1]; }
131 
132  inline void setAllM(double value) { m[0] = m[1] = m[2] = value; }
133  inline void addM(int dir, double inc) {
134  m[dir - 1] += inc;
135  if (m[dir - 1] > 0.9)
136  for (int i = 0; i < 3; i++) m[i] = 1.;
137  }
138  inline double getM(int dir) { return m[dir - 1]; }
139  inline double getMaxM(void) { return std::max(m[0], std::max(m[1], m[2])); }
140  inline void setDM(int dir, double value) { dm[dir - 1] = value; }
141  inline double getDM(int dir) { return dm[dir - 1]; }
142 
143  inline void setpi0(double values[4][4]) {
144  for (int i = 0; i < 4; i++)
145  for (int j = 0; j < 4; j++) pi0[index44(i, j)] = values[i][j];
146  }
147  inline void setpiH0(double values[4][4]) {
148  for (int i = 0; i < 4; i++)
149  for (int j = 0; j < 4; j++) piH0[index44(i, j)] = values[i][j];
150  }
151 
152  // get the energy density, pressure, charge densities and flow velocity
153  // components (e,p,n,v) from conserved quantities Q in the centre of the cell
154  void getPrimVar(EoS *eos, double tau, double &_e, double &_p, double &_nb,
155  double &_nq, double &_ns, double &_vx, double &_vy,
156  double &_vz);
157  // (e,p,n,v) at cell's left boundary in a given direction dir
158  void getPrimVarLeft(EoS *eos, double tau, double &_e, double &_p, double &_nb,
159  double &_nq, double &_ns, double &_vx, double &_vy,
160  double &_vz, int dir);
161  // (e,p,n,v) at cell's right boundary in a given direction dir
162  void getPrimVarRight(EoS *eos, double tau, double &_e, double &_p,
163  double &_nb, double &_nq, double &_ns, double &_vx,
164  double &_vy, double &_vz, int dir);
165 
166  // (e,p,n,v) from half-step updated Qh at cell's left boundary in a given
167  // direction
168  void getPrimVarHLeft(EoS *eos, double tau, double &_e, double &_p,
169  double &_nb, double &_nq, double &_ns, double &_vx,
170  double &_vy, double &_vz, int dir);
171  // (e,p,n,v) from half-step updated Qh at cell's right boundary in a given
172  // direction
173  void getPrimVarHRight(EoS *eos, double tau, double &_e, double &_p,
174  double &_nb, double &_nq, double &_ns, double &_vx,
175  double &_vy, double &_vz, int dir);
176  // (e,p,n,v) from half-step updated Qh at cell's centre
177  void getPrimVarHCenter(EoS *eos, double tau, double &_e, double &_p,
178  double &_nb, double &_nq, double &_ns, double &_vx,
179  double &_vy, double &_vz);
180  // (e,p,n,v) at the previous timestep and cell's centre
181  void getPrimVarPrev(EoS *eos, double tau, double &_e, double &_p, double &_nb,
182  double &_nq, double &_ns, double &_vx, double &_vy,
183  double &_vz);
184  // calculate and set Q from (e,n,v)
185  void setPrimVar(EoS *eos, double tau, double _e, double _nb, double _nq,
186  double _ns, double _vx, double _vy, double _vz);
187 
188  // update the cumulative fluxes through the cell
189  inline void addFlux(double Ft, double Fx, double Fy, double Fz, double Fnb,
190  double Fnq, double Fns) {
191  flux[T_] += Ft;
192  flux[X_] += Fx;
193  flux[Y_] += Fy;
194  flux[Z_] += Fz;
195  flux[NB_] += Fnb;
196  flux[NQ_] += Fnq;
197  flux[NS_] += Fns;
198  }
199  inline void clearFlux(void) {
200  for (int i = 0; i < 7; i++) flux[i] = 0.;
201  }
202  void updateByFlux(); // Q = Q + flux
203  void updateQtoQhByFlux(); // Qh = Q + flux
204  inline void setViscCorrCutFlag(double value) { viscCorrCut = value; }
205  inline double getViscCorrCutFlag(void) { return viscCorrCut; }
206  void Dump(double tau); // dump the contents of the cell into dump.dat
207 };