WarpX
LaserProfiles.H
Go to the documentation of this file.
1 /* Copyright 2019-2020 Luca Fedeli, Maxence Thevenet
2  *
3  * This file is part of WarpX.
4  *
5  * License: BSD-3-Clause-LBNL
6  */
7 #ifndef WARPX_LaserProfiles_H_
8 #define WARPX_LaserProfiles_H_
9 
11 
12 #include <AMReX_REAL.H>
13 #include <AMReX_ParmParse.H>
14 #include <AMReX_Vector.H>
15 #include <AMReX_Gpu.H>
16 
17 #include <map>
18 #include <string>
19 #include <memory>
20 #include <functional>
21 #include <limits>
22 #include <utility>
23 
24 
25 namespace WarpXLaserProfiles {
26 
32 {
33  amrex::Real wavelength;
34  amrex::Real e_max;
35  amrex::Vector<amrex::Real> p_X;// ! Polarization
36  amrex::Vector<amrex::Real> nvec;
37 };
38 
39 
51 {
52 public:
65  virtual void
66  init (
67  const amrex::ParmParse& ppl,
68  const amrex::ParmParse& ppc,
69  CommonLaserParameters params) = 0;
70 
78  virtual void
79  update (
80  amrex::Real t) = 0;
81 
92  virtual void
93  fill_amplitude (
94  const int np,
95  amrex::Real const * AMREX_RESTRICT const Xp,
96  amrex::Real const * AMREX_RESTRICT const Yp,
97  amrex::Real t,
98  amrex::Real * AMREX_RESTRICT const amplitude) const = 0;
99 
100  virtual ~ILaserProfile(){}
101 };
102 
107 {
108 
109 public:
110  void
111  init (
112  const amrex::ParmParse& ppl,
113  const amrex::ParmParse& ppc,
114  CommonLaserParameters params) override final;
115 
116  //No update needed
117  void
118  update (amrex::Real /*t */) override final {}
119 
120  void
121  fill_amplitude (
122  const int np,
123  amrex::Real const * AMREX_RESTRICT const Xp,
124  amrex::Real const * AMREX_RESTRICT const Yp,
125  amrex::Real t,
126  amrex::Real * AMREX_RESTRICT const amplitude) const override final;
127 
128 private:
129  struct {
130  amrex::Real waist = std::numeric_limits<amrex::Real>::quiet_NaN();
131  amrex::Real duration = std::numeric_limits<amrex::Real>::quiet_NaN();
132  amrex::Real t_peak = std::numeric_limits<amrex::Real>::quiet_NaN();
133  amrex::Real focal_distance = std::numeric_limits<amrex::Real>::quiet_NaN();
134  amrex::Real zeta = 0;
135  amrex::Real beta = 0;
136  amrex::Real phi2 = 0;
137 
138  amrex::Vector<amrex::Real> stc_direction;
139  amrex::Real theta_stc;
140  } m_params;
141 
143 };
144 
149 {
150 
151 public:
152  void
153  init (
154  const amrex::ParmParse& ppl,
155  const amrex::ParmParse& ppc,
156  CommonLaserParameters params) override final;
157 
158  //No update needed
159  void
160  update (amrex::Real /*t */) override final {}
161 
162  void
163  fill_amplitude (
164  const int np,
165  amrex::Real const * AMREX_RESTRICT const Xp,
166  amrex::Real const * AMREX_RESTRICT const Yp,
167  amrex::Real t,
168  amrex::Real * AMREX_RESTRICT const amplitude) const override final;
169 
170 private:
171  struct {
172  amrex::Real waist = std::numeric_limits<amrex::Real>::quiet_NaN();
173  amrex::Real duration = std::numeric_limits<amrex::Real>::quiet_NaN();
174  amrex::Real focal_distance = std::numeric_limits<amrex::Real>::quiet_NaN();
175  } m_params;
176 
178 };
179 
184 {
185 
186 public:
187  void
188  init (
189  const amrex::ParmParse& ppl,
190  const amrex::ParmParse& ppc,
191  CommonLaserParameters params) override final;
192 
193  //No update needed
194  void
195  update (amrex::Real /*t */) override final {}
196 
197  void
198  fill_amplitude (
199  const int np,
200  amrex::Real const * AMREX_RESTRICT const Xp,
201  amrex::Real const * AMREX_RESTRICT const Yp,
202  amrex::Real t,
203  amrex::Real * AMREX_RESTRICT const amplitude) const override final;
204 
205 private:
206  struct{
207  std::string field_function;
208  } m_params;
209 
211  std::unique_ptr<ParserWrapper<3> > m_gpu_parser;
212 };
213 
221 {
222 
223 public:
224  void
225  init (
226  const amrex::ParmParse& ppl,
227  const amrex::ParmParse& ppc,
228  CommonLaserParameters params) override final;
229 
234  void
235  update (amrex::Real t) override final;
236 
250  void
251  fill_amplitude (
252  const int np,
253  amrex::Real const * AMREX_RESTRICT const Xp,
254  amrex::Real const * AMREX_RESTRICT const Yp,
255  amrex::Real t,
256  amrex::Real * AMREX_RESTRICT const amplitude) const override final;
257 
269  void internal_fill_amplitude_uniform(
270  const int idx_t_left,
271  const int np,
272  amrex::Real const * AMREX_RESTRICT const Xp,
273  amrex::Real const * AMREX_RESTRICT const Yp,
274  amrex::Real t,
275  amrex::Real * AMREX_RESTRICT const amplitude) const;
276 
288  void internal_fill_amplitude_nonuniform(
289  const int idx_t_left,
290  const int np,
291  amrex::Real const * AMREX_RESTRICT const Xp,
292  amrex::Real const * AMREX_RESTRICT const Yp,
293  amrex::Real t,
294  amrex::Real * AMREX_RESTRICT const amplitude) const;
295 
296 private:
312  void parse_txye_file(std::string txye_file_name);
313 
319  std::pair<int,int> find_left_right_time_indices(amrex::Real t) const;
320 
328  void read_data_t_chuck(int t_begin, int t_end);
329 
334  struct{
336  std::string txye_file_name;
338  bool is_grid_uniform = false;
342  int nt, nx, ny;
346  amrex::Vector<amrex::Real> t_coords;
350  amrex::Vector<amrex::Real> h_x_coords;
351  amrex::Gpu::DeviceVector<amrex::Real> d_x_coords;
355  amrex::Vector<amrex::Real> h_y_coords;
356  amrex::Gpu::DeviceVector<amrex::Real> d_y_coords;
364  amrex::Gpu::DeviceVector<amrex::Real> E_data;
365  } m_params;
366 
368 };
369 
374 const
375 std::map<
376 std::string,
377 std::function<std::unique_ptr<ILaserProfile>()>
378 >
380 {
381  {"gaussian",
382  [] () {return std::make_unique<GaussianLaserProfile>();} },
383  {"harris",
384  [] () {return std::make_unique<HarrisLaserProfile>();} },
385  {"parse_field_function",
386  [] () {return std::make_unique<FieldFunctionLaserProfile>();} },
387  {"from_txye_file",
388  [] () {return std::make_unique<FromTXYEFileLaserProfile>();} }
389 };
390 
391 } //WarpXLaserProfiles
392 
393 #endif //WARPX_LaserProfiles_H_
amrex::Gpu::DeviceVector< amrex::Real > d_x_coords
Definition: LaserProfiles.H:351
WarpXParser m_parser
Definition: LaserProfiles.H:210
amrex::Vector< amrex::Real > nvec
Definition: LaserProfiles.H:36
Definition: LaserProfiles.H:31
Definition: LaserProfiles.H:183
int last_time_index
Definition: LaserProfiles.H:362
amrex::Gpu::DeviceVector< amrex::Real > d_y_coords
Definition: LaserProfiles.H:356
void update(amrex::Real) override final
Definition: LaserProfiles.H:195
amrex::Gpu::DeviceVector< amrex::Real > E_data
Definition: LaserProfiles.H:364
amrex::Vector< amrex::Real > h_x_coords
Definition: LaserProfiles.H:350
std::unique_ptr< ParserWrapper< 3 > > m_gpu_parser
Definition: LaserProfiles.H:211
int ny
Definition: LaserProfiles.H:342
CommonLaserParameters m_common_params
Definition: LaserProfiles.H:177
amrex::Vector< amrex::Real > h_y_coords
Definition: LaserProfiles.H:355
int first_time_index
Definition: LaserProfiles.H:360
Definition: LaserProfiles.H:25
int time_chunk_size
Definition: LaserProfiles.H:358
Definition: LaserProfiles.H:220
amrex::Vector< amrex::Real > t_coords
Definition: LaserProfiles.H:346
void update(amrex::Real) override final
Definition: LaserProfiles.H:160
const std::map< std::string, std::function< std::unique_ptr< ILaserProfile >)>> laser_profiles_dictionary
Definition: LaserProfiles.H:379
amrex::Real e_max
central wavelength
Definition: LaserProfiles.H:34
amrex::Vector< amrex::Real > p_X
maximum electric field at peak
Definition: LaserProfiles.H:35
Definition: WarpXParser.H:26
std::string field_function
Definition: LaserProfiles.H:207
amrex::Real wavelength
Definition: LaserProfiles.H:33
void update(amrex::Real) override final
Definition: LaserProfiles.H:118
Definition: LaserProfiles.H:50
CommonLaserParameters m_common_params
Definition: LaserProfiles.H:367
CommonLaserParameters m_common_params
Definition: LaserProfiles.H:142
amrex::Vector< amrex::Real > stc_direction
Definition: LaserProfiles.H:138
Definition: LaserProfiles.H:148
std::string txye_file_name
Definition: LaserProfiles.H:336
virtual ~ILaserProfile()
Definition: LaserProfiles.H:100
Definition: LaserProfiles.H:106
amrex::Real theta_stc
Direction of the spatio-temporal couplings.
Definition: LaserProfiles.H:139