Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
clvisc.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file clvisc.h
1 /*******************************************************************************
2  * Copyright (c) 2018-2019 LongGang Pang, lgpang@qq.com
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and/or associated documentation files (the
6  * "Materials"), to deal in the Materials without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sublicense, and/or sell copies of the Materials, and to
9  * permit persons to whom the Materials are furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included
13  * in all copies or substantial portions of the Materials.
14  *
15  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21  * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
22  ******************************************************************************/
23 
24 
25 #ifndef __CL_VISC__
26 #define __CL_VISC__
27 
28 #define __CL_ENABLE_EXCEPTIONS
29 // System includes
30 //#include <CL/cl.hpp>
31 #include "clideal.h"
32 #include "bulkinfo.h"
33 
34 namespace clvisc {
35 
38 class CLVisc
39 {
40  private:
42  // CLVisc uses many data and member functions in ideal_
45 
46  // store start time to avoid one initilize with multiple evolve()
47  double tau0_;
48 
49  // current time during the evolution
50 
51  double tau_;
52  // size_ = cfg_.nx * cfg_.ny * cfg_.nz
53  size_t size_;
55 
56  // notice h_share_pi_ has 10 components
57  // pi00, 01, 02, 03, 11, 12, 13, 22, 23, 33
58  std::vector<cl_real> h_shear_pi_;
59  // notice h_bulk_pi_ has 1 component
60  std::vector<cl_real> h_bulk_pi_;
61  // notice h_net_charge_ has 4 components
62  // net_baryon, net_electric, net_strangeness and one slot for future
63  std::vector<cl_real4> h_net_charge_;
64 
68 
69  // source term for IS equations
76 
77  // gpu buffer to check the goodness of each cell
79 
80  // kernel functions in kernel_IS.cl
88 
89  // kernel functions in kernel_visc.cl
95 
97 
99 
100  // d_udiff = u_{visc}^{n} - u_{visc}^{n-1}
101  void update_udiff_();
102 
104  void half_step_visc_(int step);
105  // update half step using Runge-Kutta method, step = {1, 2}
106  void half_step_(int step);
107 
108  public:
109 
110  CLVisc(const Config & cfg, std::string device_type, int device_id);
111 
113 
114  inline const Config & get_config() {return cfg_;}
115 
116  // read initial energy density from external vector
117  template <typename ValueType>
118  void read_ini(const std::vector<ValueType> & ed);
119 
120  // read initial ed, vx, vy, vz vector
121  template <typename ValueType>
122  void read_ini(const std::vector<ValueType> & ed,
123  const std::vector<ValueType> & vx,
124  const std::vector<ValueType> & vy,
125  const std::vector<ValueType> & vz);
126 
127  // read initial ed, vx, vy, vz vector and shear viscosity
128  template <typename ValueType>
129  void read_ini(const std::vector<ValueType> & ed,
130  const std::vector<ValueType> & vx,
131  const std::vector<ValueType> & vy,
132  const std::vector<ValueType> & vz,
133  const std::vector<ValueType> & pi00,
134  const std::vector<ValueType> & pi01,
135  const std::vector<ValueType> & pi02,
136  const std::vector<ValueType> & pi03,
137  const std::vector<ValueType> & pi11,
138  const std::vector<ValueType> & pi12,
139  const std::vector<ValueType> & pi13,
140  const std::vector<ValueType> & pi22,
141  const std::vector<ValueType> & pi23,
142  const std::vector<ValueType> & pi33);
143 
144  // read initial ed, vx, vy, vz vector and shear viscosity,
145  // bulk viscosity and charge current
146  template <typename ValueType>
147  void read_ini(const std::vector<ValueType> & ed,
148  const std::vector<ValueType> & vx,
149  const std::vector<ValueType> & vy,
150  const std::vector<ValueType> & vz,
151  const std::vector<ValueType> & pi00,
152  const std::vector<ValueType> & pi01,
153  const std::vector<ValueType> & pi02,
154  const std::vector<ValueType> & pi03,
155  const std::vector<ValueType> & pi11,
156  const std::vector<ValueType> & pi12,
157  const std::vector<ValueType> & pi13,
158  const std::vector<ValueType> & pi22,
159  const std::vector<ValueType> & pi23,
160  const std::vector<ValueType> & pi33,
161  const std::vector<ValueType> & bulk_pi,
162  const std::vector<ValueType> & net_charge_baryon_,
163  const std::vector<ValueType> & net_charge_electric,
164  const std::vector<ValueType> & net_charge_strange);
165 
166 
167  // run clvisc evolution for one time step
168  void one_step();
169 
170  // run clvisc evolution for all time steps
171  // stop when max_T < freeze_out_temperature
172  void evolve();
173 
174 
175  ~CLVisc();
176 
177 };
178 
179 } // end namespace clvisc
180 
181 #endif
182 
183