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 
10 #include <AMReX_Gpu.H>
11 #include <AMReX_ParmParse.H>
12 #include <AMReX_Parser.H>
13 #include <AMReX_REAL.H>
14 #include <AMReX_Vector.H>
15 
16 #include <functional>
17 #include <limits>
18 #include <map>
19 #include <memory>
20 #include <string>
21 #include <utility>
22 
23 
24 namespace WarpXLaserProfiles {
25 
31 {
32  amrex::Real wavelength;
33  amrex::Real e_max;
34  amrex::Vector<amrex::Real> p_X;// ! Polarization
36 };
37 
38 
50 {
51 public:
64  virtual void
65  init (
66  const amrex::ParmParse& ppl,
67  const amrex::ParmParse& ppc,
68  CommonLaserParameters params) = 0;
69 
77  virtual void
78  update (
79  amrex::Real t) = 0;
80 
91  virtual void
92  fill_amplitude (
93  const int np,
94  amrex::Real const * AMREX_RESTRICT const Xp,
95  amrex::Real const * AMREX_RESTRICT const Yp,
96  amrex::Real t,
97  amrex::Real * AMREX_RESTRICT const amplitude) const = 0;
98 
99  virtual ~ILaserProfile(){}
100 };
101 
106 {
107 
108 public:
109  void
110  init (
111  const amrex::ParmParse& ppl,
112  const amrex::ParmParse& ppc,
113  CommonLaserParameters params) override final;
114 
115  //No update needed
116  void
117  update (amrex::Real /*t */) override final {}
118 
119  void
120  fill_amplitude (
121  const int np,
122  amrex::Real const * AMREX_RESTRICT const Xp,
123  amrex::Real const * AMREX_RESTRICT const Yp,
124  amrex::Real t,
125  amrex::Real * AMREX_RESTRICT const amplitude) const override final;
126 
127 private:
128  struct {
129  amrex::Real waist = std::numeric_limits<amrex::Real>::quiet_NaN();
130  amrex::Real duration = std::numeric_limits<amrex::Real>::quiet_NaN();
131  amrex::Real t_peak = std::numeric_limits<amrex::Real>::quiet_NaN();
132  amrex::Real focal_distance = std::numeric_limits<amrex::Real>::quiet_NaN();
133  amrex::Real zeta = 0;
134  amrex::Real beta = 0;
135  amrex::Real phi2 = 0;
136  amrex::Real phi0 = 0;
137 
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 };
212 
220 {
221 
222 public:
223  void
224  init (
225  const amrex::ParmParse& ppl,
226  const amrex::ParmParse& ppc,
227  CommonLaserParameters params) override final;
228 
233  void
234  update (amrex::Real t) override final;
235 
249  void
250  fill_amplitude (
251  const int np,
252  amrex::Real const * AMREX_RESTRICT const Xp,
253  amrex::Real const * AMREX_RESTRICT const Yp,
254  amrex::Real t,
255  amrex::Real * AMREX_RESTRICT const amplitude) const override final;
256 
268  void internal_fill_amplitude_uniform(
269  const int idx_t_left,
270  const int np,
271  amrex::Real const * AMREX_RESTRICT const Xp,
272  amrex::Real const * AMREX_RESTRICT const Yp,
273  amrex::Real t,
274  amrex::Real * AMREX_RESTRICT const amplitude) const;
275 
287  void internal_fill_amplitude_nonuniform(
288  const int idx_t_left,
289  const int np,
290  amrex::Real const * AMREX_RESTRICT const Xp,
291  amrex::Real const * AMREX_RESTRICT const Yp,
292  amrex::Real t,
293  amrex::Real * AMREX_RESTRICT const amplitude) const;
294 
295 private:
311  void parse_txye_file(std::string txye_file_name);
312 
318  std::pair<int,int> find_left_right_time_indices(amrex::Real t) const;
319 
327  void read_data_t_chuck(int t_begin, int t_end);
328 
333  struct{
335  std::string txye_file_name;
337  bool is_grid_uniform = false;
341  int nt, nx, ny;
366  amrex::Real t_delay = amrex::Real(0.0);
367 
368  } m_params;
369 
371 };
372 
377 const
378 std::map<
379 std::string,
380 std::function<std::unique_ptr<ILaserProfile>()>
381 >
383 {
384  {"gaussian",
385  [] () {return std::make_unique<GaussianLaserProfile>();} },
386  {"harris",
387  [] () {return std::make_unique<HarrisLaserProfile>();} },
388  {"parse_field_function",
389  [] () {return std::make_unique<FieldFunctionLaserProfile>();} },
390  {"from_txye_file",
391  [] () {return std::make_unique<FromTXYEFileLaserProfile>();} }
392 };
393 
394 } //WarpXLaserProfiles
395 
396 #endif //WARPX_LaserProfiles_H_
amrex::Gpu::DeviceVector< amrex::Real > d_x_coords
Definition: LaserProfiles.H:350
amrex::Vector< amrex::Real > nvec
Definition: LaserProfiles.H:35
Definition: LaserProfiles.H:30
Definition: LaserProfiles.H:183
int last_time_index
Definition: LaserProfiles.H:361
amrex::Gpu::DeviceVector< amrex::Real > d_y_coords
Definition: LaserProfiles.H:355
void update(amrex::Real) override final
Definition: LaserProfiles.H:195
amrex::Gpu::DeviceVector< amrex::Real > E_data
Definition: LaserProfiles.H:363
amrex::Vector< amrex::Real > h_x_coords
Definition: LaserProfiles.H:349
int ny
Definition: LaserProfiles.H:341
CommonLaserParameters m_common_params
Definition: LaserProfiles.H:177
amrex::Vector< amrex::Real > h_y_coords
Definition: LaserProfiles.H:354
int first_time_index
Definition: LaserProfiles.H:359
Definition: LaserProfiles.H:24
int time_chunk_size
Definition: LaserProfiles.H:357
Definition: LaserProfiles.H:219
amrex::Vector< amrex::Real > t_coords
Definition: LaserProfiles.H:345
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:382
amrex::Real e_max
central wavelength
Definition: LaserProfiles.H:33
amrex::Vector< amrex::Real > p_X
maximum electric field at peak
Definition: LaserProfiles.H:34
amrex::Parser m_parser
Definition: LaserProfiles.H:210
std::string field_function
Definition: LaserProfiles.H:207
amrex::Real wavelength
Definition: LaserProfiles.H:32
void update(amrex::Real) override final
Definition: LaserProfiles.H:117
Definition: LaserProfiles.H:49
CommonLaserParameters m_common_params
Definition: LaserProfiles.H:370
CommonLaserParameters m_common_params
Definition: LaserProfiles.H:142
amrex::Vector< amrex::Real > stc_direction
Definition: LaserProfiles.H:138
Definition: LaserProfiles.H:148
#define AMREX_RESTRICT
std::string txye_file_name
Definition: LaserProfiles.H:335
virtual ~ILaserProfile()
Definition: LaserProfiles.H:99
Definition: LaserProfiles.H:105
amrex::Real theta_stc
Direction of the spatio-temporal couplings.
Definition: LaserProfiles.H:139