Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SurfaceFinder.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SurfaceFinder.cc
1 /*******************************************************************************
2  * Copyright (c) The JETSCAPE Collaboration, 2018
3  *
4  * Modular, task-based framework for simulating all aspects of heavy-ion collisions
5  *
6  * For the list of contributors see AUTHORS.
7  *
8  * Report issues at https://github.com/JETSCAPE/JETSCAPE/issues
9  *
10  * or via email to bugs.jetscape@gmail.com
11  *
12  * Distributed under the GNU General Public License 3.0 (GPLv3 or later).
13  * See COPYING for details.
14  ******************************************************************************/
15 // This is a general basic class for a hyper-surface finder
16 
17 #include <cmath>
18 #include "RealType.h"
19 #include "SurfaceFinder.h"
20 #include "cornelius.h"
21 #include "FluidEvolutionHistory.h"
22 #include "JetScapeLogger.h"
23 
24 namespace Jetscape {
25 
27  const EvolutionHistory &bulk_data)
28  : bulk_info(bulk_data) {
29 
30  T_cut = T_in;
31  JSINFO << "Find a surface with temperature T = " << T_cut;
33  if (boost_invariant) {
34  JSINFO << "Hydro medium is boost invariant.";
35  } else {
36  JSINFO << "Hydro medium is not boost invariant.";
37  }
38  JSINFO << "Number of fluid cells = " << bulk_info.get_data_size();
39 }
40 
42 
44  if (boost_invariant) {
45  JSINFO << "Finding a 2+1D hyper-surface at T = " << T_cut << " GeV ...";
47  } else {
48  JSINFO << "Finding a 3+1D hyper-surface at T = " << T_cut << " GeV ...";
50  }
51 }
52 
56  double ***cube) {
57  bool intersect = true;
58 
59  auto tau_low = tau - dt / 2.;
60  auto tau_high = tau + dt / 2.;
61  auto x_left = x - dx / 2.;
62  auto x_right = x + dx / 2.;
63  auto y_left = y - dy / 2.;
64  auto y_right = y + dy / 2.;
65 
66  auto fluid_cell = bulk_info.get(tau_low, x_left, y_left, 0.0);
67  cube[0][0][0] = fluid_cell.temperature;
68  fluid_cell = bulk_info.get(tau_low, x_left, y_right, 0.0);
69  cube[0][0][1] = fluid_cell.temperature;
70  fluid_cell = bulk_info.get(tau_low, x_right, y_left, 0.0);
71  cube[0][1][0] = fluid_cell.temperature;
72  fluid_cell = bulk_info.get(tau_low, x_right, y_right, 0.0);
73  cube[0][1][1] = fluid_cell.temperature;
74  fluid_cell = bulk_info.get(tau_high, x_left, y_left, 0.0);
75  cube[1][0][0] = fluid_cell.temperature;
76  fluid_cell = bulk_info.get(tau_high, x_left, y_right, 0.0);
77  cube[1][0][1] = fluid_cell.temperature;
78  fluid_cell = bulk_info.get(tau_high, x_right, y_left, 0.0);
79  cube[1][1][0] = fluid_cell.temperature;
80  fluid_cell = bulk_info.get(tau_high, x_right, y_right, 0.0);
81  cube[1][1][1] = fluid_cell.temperature;
82 
83  if ((T_cut - cube[0][0][0]) * (cube[1][1][1] - T_cut) < 0.0)
84  if ((T_cut - cube[0][1][0]) * (cube[1][0][1] - T_cut) < 0.0)
85  if ((T_cut - cube[0][1][1]) * (cube[1][0][0] - T_cut) < 0.0)
86  if ((T_cut - cube[0][0][1]) * (cube[1][1][0] - T_cut) < 0.0)
87  intersect = false;
88 
89  return (intersect);
90 }
91 
93  auto grid_tau0 = bulk_info.Tau0();
94  auto grid_tauf = bulk_info.TauMax();
95  auto grid_x0 = bulk_info.XMin();
96  auto grid_y0 = bulk_info.YMin();
97  ;
98 
99  Jetscape::real grid_dt = 0.1;
100  Jetscape::real grid_dx = 0.2;
101  Jetscape::real grid_dy = 0.2;
102 
103  const int dim = 3;
104  double lattice_spacing[dim];
105  lattice_spacing[0] = grid_dt;
106  lattice_spacing[1] = grid_dx;
107  lattice_spacing[2] = grid_dy;
108 
109  std::unique_ptr<Cornelius> cornelius_ptr(new Cornelius());
110  cornelius_ptr->init(dim, T_cut, lattice_spacing);
111 
112  const int ntime = static_cast<int>((grid_tauf - grid_tau0) / grid_dt);
113  const int nx = static_cast<int>(std::abs(2. * grid_x0) / grid_dx);
114  const int ny = static_cast<int>(std::abs(2. * grid_y0) / grid_dy);
115 
116  double ***cube = new double **[2];
117  for (int i = 0; i < 2; i++) {
118  cube[i] = new double *[2];
119  for (int j = 0; j < 2; j++) {
120  cube[i][j] = new double[2];
121  for (int k = 0; k < 2; k++)
122  cube[i][j][k] = 0.0;
123  }
124  }
125 
126  for (int itime = 0; itime < ntime; itime++) {
127  // loop over time evolution
128  auto tau_local = grid_tau0 + (itime + 0.5) * grid_dt;
129  for (int i = 0; i < nx; i++) {
130  // loops over the transverse plane
131  auto x_local = grid_x0 + (i + 0.5) * grid_dx;
132  for (int j = 0; j < ny; j++) {
133  auto y_local = grid_y0 + (j + 0.5) * grid_dy;
134  bool intersect = check_intersect_3D(tau_local, x_local, y_local,
135  grid_dt, grid_dx, grid_dy, cube);
136  if (intersect) {
137  cornelius_ptr->find_surface_3d(cube);
138  for (int isurf = 0; isurf < cornelius_ptr->get_Nelements(); isurf++) {
139  auto tau_center = (cornelius_ptr->get_centroid_elem(isurf, 0) +
140  tau_local - grid_dt / 2.);
141  auto x_center = (cornelius_ptr->get_centroid_elem(isurf, 1) +
142  x_local - grid_dx / 2.);
143  auto y_center = (cornelius_ptr->get_centroid_elem(isurf, 2) +
144  y_local - grid_dy / 2.);
145 
146  auto da_tau = cornelius_ptr->get_normal_elem(isurf, 0);
147  auto da_x = cornelius_ptr->get_normal_elem(isurf, 1);
148  auto da_y = cornelius_ptr->get_normal_elem(isurf, 2);
149 
150  auto fluid_cell =
151  bulk_info.get(tau_center, x_center, y_center, 0.0);
152  auto surface_cell =
153  PrepareASurfaceCell(tau_center, x_center, y_center, 0.0, da_tau,
154  da_x, da_y, 0.0, fluid_cell);
155  surface_cell_list.push_back(surface_cell);
156  }
157  }
158  }
159  }
160  }
161 
162  for (int i = 0; i < 2; i++) {
163  for (int j = 0; j < 2; j++)
164  delete[] cube[i][j];
165  delete[] cube[i];
166  }
167  delete[] cube;
168 }
169 
174  double ****cube) {
175 
176  bool intersect = true;
177 
178  auto tau_low = tau - dt / 2.;
179  auto tau_high = tau + dt / 2.;
180  auto x_left = x - dx / 2.;
181  auto x_right = x + dx / 2.;
182  auto y_left = y - dy / 2.;
183  auto y_right = y + dy / 2.;
184  auto eta_left = eta - deta / 2.;
185  auto eta_right = eta + deta / 2.;
186 
187  auto fluid_cell = bulk_info.get(tau_low, x_left, y_left, eta_left);
188  cube[0][0][0][0] = fluid_cell.temperature;
189  fluid_cell = bulk_info.get(tau_low, x_left, y_left, eta_right);
190  cube[0][0][0][1] = fluid_cell.temperature;
191  fluid_cell = bulk_info.get(tau_low, x_left, y_right, eta_left);
192  cube[0][0][1][0] = fluid_cell.temperature;
193  fluid_cell = bulk_info.get(tau_low, x_left, y_right, eta_right);
194  cube[0][0][1][1] = fluid_cell.temperature;
195  fluid_cell = bulk_info.get(tau_low, x_right, y_left, eta_left);
196  cube[0][1][0][0] = fluid_cell.temperature;
197  fluid_cell = bulk_info.get(tau_low, x_right, y_left, eta_right);
198  cube[0][1][0][1] = fluid_cell.temperature;
199  fluid_cell = bulk_info.get(tau_low, x_right, y_right, eta_left);
200  cube[0][1][1][0] = fluid_cell.temperature;
201  fluid_cell = bulk_info.get(tau_low, x_right, y_right, eta_right);
202  cube[0][1][1][1] = fluid_cell.temperature;
203  fluid_cell = bulk_info.get(tau_high, x_left, y_left, eta_left);
204  cube[1][0][0][0] = fluid_cell.temperature;
205  fluid_cell = bulk_info.get(tau_high, x_left, y_left, eta_right);
206  cube[1][0][0][1] = fluid_cell.temperature;
207  fluid_cell = bulk_info.get(tau_high, x_left, y_right, eta_left);
208  cube[1][0][1][0] = fluid_cell.temperature;
209  fluid_cell = bulk_info.get(tau_high, x_left, y_right, eta_right);
210  cube[1][0][1][1] = fluid_cell.temperature;
211  fluid_cell = bulk_info.get(tau_high, x_right, y_left, eta_left);
212  cube[1][1][0][0] = fluid_cell.temperature;
213  fluid_cell = bulk_info.get(tau_high, x_right, y_left, eta_right);
214  cube[1][1][0][1] = fluid_cell.temperature;
215  fluid_cell = bulk_info.get(tau_high, x_right, y_right, eta_left);
216  cube[1][1][1][0] = fluid_cell.temperature;
217  fluid_cell = bulk_info.get(tau_high, x_right, y_right, eta_right);
218  cube[1][1][1][1] = fluid_cell.temperature;
219 
220  if ((T_cut - cube[0][0][0][0]) * (cube[1][1][1][1] - T_cut) < 0.0)
221  if ((T_cut - cube[0][0][1][1]) * (cube[1][1][0][0] - T_cut) < 0.0)
222  if ((T_cut - cube[0][1][0][1]) * (cube[1][0][1][0] - T_cut) < 0.0)
223  if ((T_cut - cube[0][1][1][0]) * (cube[1][0][0][1] - T_cut) < 0.0)
224  if ((T_cut - cube[0][0][0][1]) * (cube[1][1][1][0] - T_cut) < 0.0)
225  if ((T_cut - cube[0][0][1][0]) * (cube[1][1][0][1] - T_cut) < 0.0)
226  if ((T_cut - cube[0][1][0][0]) * (cube[1][0][1][1] - T_cut) < 0.0)
227  if ((T_cut - cube[0][1][1][1]) * (cube[1][0][0][0] - T_cut) <
228  0.0)
229  intersect = false;
230 
231  return (intersect);
232 }
233 
235  auto grid_tau0 = bulk_info.Tau0();
236  auto grid_tauf = bulk_info.TauMax();
237  auto grid_x0 = bulk_info.XMin();
238  auto grid_y0 = bulk_info.YMin();
239  ;
240  auto grid_eta0 = bulk_info.EtaMin();
241  ;
242 
243  Jetscape::real grid_dt = 0.1;
244  Jetscape::real grid_dx = 0.2;
245  Jetscape::real grid_dy = 0.2;
246  Jetscape::real grid_deta = 0.2;
247 
248  const int dim = 4;
249  double lattice_spacing[dim];
250  lattice_spacing[0] = grid_dt;
251  lattice_spacing[1] = grid_dx;
252  lattice_spacing[2] = grid_dy;
253  lattice_spacing[3] = grid_deta;
254 
255  std::unique_ptr<Cornelius> cornelius_ptr(new Cornelius());
256  cornelius_ptr->init(dim, T_cut, lattice_spacing);
257 
258  const int ntime = static_cast<int>((grid_tauf - grid_tau0) / grid_dt);
259  const int nx = static_cast<int>(std::abs(2. * grid_x0) / grid_dx);
260  const int ny = static_cast<int>(std::abs(2. * grid_y0) / grid_dy);
261  const int neta = static_cast<int>(std::abs(2. * grid_eta0) / grid_deta);
262 
263  double ****cube = new double ***[2];
264  for (int i = 0; i < 2; i++) {
265  cube[i] = new double **[2];
266  for (int j = 0; j < 2; j++) {
267  cube[i][j] = new double *[2];
268  for (int k = 0; k < 2; k++) {
269  cube[i][j][k] = new double[2];
270  for (int l = 0; l < 2; l++) {
271  cube[i][j][k][l] = 0.0;
272  }
273  }
274  }
275  }
276 
277  for (int itime = 0; itime < ntime; itime++) {
278  // loop over time evolution
279  auto tau_local = grid_tau0 + (itime + 0.5) * grid_dt;
280  for (int l = 0; l < neta; l++) {
281  auto eta_local = grid_eta0 + (l + 0.5) * grid_deta;
282  // loops over the transverse plane
283  for (int i = 0; i < nx; i++) {
284  // loops over the transverse plane
285  auto x_local = grid_x0 + (i + 0.5) * grid_dx;
286  for (int j = 0; j < ny; j++) {
287  auto y_local = grid_y0 + (j + 0.5) * grid_dy;
288  bool intersect =
289  check_intersect_4D(tau_local, x_local, y_local, eta_local,
290  grid_dt, grid_dx, grid_dy, grid_deta, cube);
291  if (intersect) {
292  cornelius_ptr->find_surface_4d(cube);
293  for (int isurf = 0; isurf < cornelius_ptr->get_Nelements();
294  isurf++) {
295  auto tau_center = (cornelius_ptr->get_centroid_elem(isurf, 0) +
296  tau_local - grid_dt / 2.);
297  auto x_center = (cornelius_ptr->get_centroid_elem(isurf, 1) +
298  x_local - grid_dx / 2.);
299  auto y_center = (cornelius_ptr->get_centroid_elem(isurf, 2) +
300  y_local - grid_dy / 2.);
301  auto eta_center = (cornelius_ptr->get_centroid_elem(isurf, 3) +
302  eta_local - grid_deta / 2.);
303 
304  auto da_tau = (cornelius_ptr->get_normal_elem(isurf, 0));
305  auto da_x = (cornelius_ptr->get_normal_elem(isurf, 1));
306  auto da_y = (cornelius_ptr->get_normal_elem(isurf, 2));
307  auto da_eta = (cornelius_ptr->get_normal_elem(isurf, 3));
308 
309  auto fluid_cell =
310  bulk_info.get(tau_center, x_center, y_center, eta_center);
311  auto surface_cell = PrepareASurfaceCell(
312  tau_center, x_center, y_center, eta_center, da_tau, da_x,
313  da_y, da_eta, fluid_cell);
314  surface_cell_list.push_back(surface_cell);
315  }
316  }
317  }
318  }
319  }
320  }
321 
322  for (int i = 0; i < 2; i++) {
323  for (int j = 0; j < 2; j++) {
324  for (int k = 0; k < 2; k++) {
325  delete[] cube[i][j][k];
326  }
327  delete[] cube[i][j];
328  }
329  delete[] cube[i];
330  }
331  delete[] cube;
332 }
333 
337  Jetscape::real da3, const FluidCellInfo fluid_cell) {
338 
339  SurfaceCellInfo temp_cell;
340  temp_cell.tau = tau;
341  temp_cell.x = x;
342  temp_cell.y = y;
343  temp_cell.eta = eta;
344  temp_cell.d3sigma_mu[0] = da0;
345  temp_cell.d3sigma_mu[1] = da1;
346  temp_cell.d3sigma_mu[2] = da2;
347  temp_cell.d3sigma_mu[3] = da3;
348 
349  temp_cell.energy_density = fluid_cell.energy_density;
350  temp_cell.entropy_density = fluid_cell.entropy_density;
351  temp_cell.temperature = fluid_cell.temperature;
352  temp_cell.pressure = fluid_cell.pressure;
353  temp_cell.qgp_fraction = fluid_cell.qgp_fraction;
354  temp_cell.mu_B = fluid_cell.mu_B;
355  temp_cell.mu_C = fluid_cell.mu_C;
356  temp_cell.mu_S = fluid_cell.mu_S;
357 
358  temp_cell.vx = fluid_cell.vx;
359  temp_cell.vy = fluid_cell.vy;
360  temp_cell.vz = fluid_cell.vz;
361 
362  for (int i = 0; i < 4; i++) {
363  for (int j = 0; j < 4; j++) {
364  temp_cell.pi[i][j] = fluid_cell.pi[i][j];
365  }
366  }
367  temp_cell.bulk_Pi = fluid_cell.bulk_Pi;
368 
369  return (temp_cell);
370 }
371 
372 } // namespace Jetscape