WarpX
LaserProfiles.H
Go to the documentation of this file.
1 /* Copyright 2019-2020 Luca Fedeli, Maxence Thevenet
2  * Ilian Kara-Mostefa
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 #include <AMReX_Box.H>
16 #include <AMReX_FArrayBox.H>
17 
18 #include <functional>
19 #include <limits>
20 #include <map>
21 #include <memory>
22 #include <string>
23 #include <utility>
24 
25 #include "Utils/WarpX_Complex.H"
26 
27 namespace WarpXLaserProfiles {
28 
34 {
35  amrex::Real wavelength;
36  amrex::Real e_max;
37  amrex::Vector<amrex::Real> p_X;// ! Polarization
39 };
40 
41 
53 {
54 public:
66  virtual void
67  init (
68  const amrex::ParmParse& ppl,
69  CommonLaserParameters params) = 0;
70 
78  virtual void
80  amrex::Real t) = 0;
81 
92  virtual void
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  CommonLaserParameters params) override final;
114 
115  //No update needed
116  void
117  update (amrex::Real /*t */) override final {}
118 
119  void
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;
141 
143 };
144 
149 {
150 
151 public:
152  void
153  init (
154  const amrex::ParmParse& ppl,
155  CommonLaserParameters params) override final;
156 
157  //No update needed
158  void
159  update (amrex::Real /*t */) override final {}
160 
161  void
163  const int np,
164  amrex::Real const * AMREX_RESTRICT const Xp,
165  amrex::Real const * AMREX_RESTRICT const Yp,
166  amrex::Real t,
167  amrex::Real * AMREX_RESTRICT const amplitude) const override final;
168 
169 private:
170  struct{
171  std::string field_function;
173 
175 };
176 
184 {
185 
186 public:
187  void
188  init (
189  const amrex::ParmParse& ppl,
190  CommonLaserParameters params) override final;
191 
196  void
197  update (amrex::Real t) override final;
198 
212  void
214  const int np,
215  amrex::Real const * AMREX_RESTRICT const Xp,
216  amrex::Real const * AMREX_RESTRICT const Yp,
217  amrex::Real t,
218  amrex::Real * AMREX_RESTRICT const amplitude) const override final;
219 
232  const int idx_t_left,
233  const int np,
234  amrex::Real const * AMREX_RESTRICT const Xp,
235  amrex::Real const * AMREX_RESTRICT const Yp,
236  amrex::Real t,
237  amrex::Real * AMREX_RESTRICT const amplitude) const;
238 
251  const int idx_t_left,
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;
257 
258 
259 
272  const int idx_t_left,
273  const int np,
274  amrex::Real const * AMREX_RESTRICT const Xp,
275  amrex::Real const * AMREX_RESTRICT const Yp,
276  amrex::Real t,
277  amrex::Real * AMREX_RESTRICT const amplitude) const;
278 
279 private:
283  void parse_lasy_file(std::string lasy_file_name);
284 
298  void parse_binary_file(std::string binary_file_name);
299 
305  std::pair<int,int> find_left_right_time_indices(amrex::Real t) const;
306 
314  void read_data_t_chunk(int t_begin, int t_end);
315 
323  void read_binary_data_t_chunk(int t_begin, int t_end);
324 
329  struct{
330 
332  std::string fileGeom;
334  std::string binary_file_name;
336  std::string lasy_file_name;
342  int nt, nx, ny;
344  int nr;
348  amrex::Real t_min;
350  amrex::Real t_max;
352  amrex::Real x_min;
354  amrex::Real x_max;
356  amrex::Real y_min;
358  amrex::Real y_max;
359  amrex::Real r_min;
360  amrex::Real r_max;
373  amrex::Real t_delay = amrex::Real(0.0);
374 
376 
378 };
379 
384 const
385 std::map<
386 std::string,
387 std::function<std::unique_ptr<ILaserProfile>()>
388 >
390 {
391  {"gaussian",
392  [] () {return std::make_unique<GaussianLaserProfile>();} },
393  {"parse_field_function",
394  [] () {return std::make_unique<FieldFunctionLaserProfile>();} },
395  {"from_file",
396  [] () {return std::make_unique<FromFileLaserProfile>();} }
397 };
398 
399 } //WarpXLaserProfiles
400 
401 #endif //WARPX_LaserProfiles_H_
#define AMREX_RESTRICT
Definition: LaserProfiles.H:149
struct WarpXLaserProfiles::FieldFunctionLaserProfile::@5 m_params
amrex::Parser m_parser
Definition: LaserProfiles.H:174
void init(const amrex::ParmParse &ppl, CommonLaserParameters params) override final
Definition: LaserProfileFieldFunction.cpp:28
std::string field_function
Definition: LaserProfiles.H:171
void update(amrex::Real) override final
Definition: LaserProfiles.H:159
void fill_amplitude(const int np, amrex::Real const *AMREX_RESTRICT const Xp, amrex::Real const *AMREX_RESTRICT const Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT const amplitude) const override final
Definition: LaserProfileFieldFunction.cpp:39
Definition: LaserProfiles.H:184
std::string binary_file_name
Definition: LaserProfiles.H:334
int last_time_index
Definition: LaserProfiles.H:366
amrex::Real y_max
Definition: LaserProfiles.H:358
int first_time_index
Definition: LaserProfiles.H:364
amrex::Real t_max
Definition: LaserProfiles.H:350
void internal_fill_amplitude_uniform_cylindrical(const int idx_t_left, const int np, amrex::Real const *AMREX_RESTRICT const Xp, amrex::Real const *AMREX_RESTRICT const Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT const amplitude) const
Function to fill the amplitude in case of a uniform grid and for the lasy format in RZ geometry....
Definition: LaserProfileFromFile.cpp:496
void fill_amplitude(const int np, amrex::Real const *AMREX_RESTRICT const Xp, amrex::Real const *AMREX_RESTRICT const Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT const amplitude) const override final
compute field amplitude at particles' position for a laser beam loaded from an E(x,...
Definition: LaserProfileFromFile.cpp:133
void internal_fill_amplitude_uniform_cartesian(const int idx_t_left, const int np, amrex::Real const *AMREX_RESTRICT const Xp, amrex::Real const *AMREX_RESTRICT const Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT const amplitude) const
Function to fill the amplitude in case of a uniform grid and for the lasy format in 3D Cartesian....
Definition: LaserProfileFromFile.cpp:411
int time_chunk_size
Definition: LaserProfiles.H:362
void init(const amrex::ParmParse &ppl, CommonLaserParameters params) override final
Definition: LaserProfileFromFile.cpp:53
amrex::Real r_max
Definition: LaserProfiles.H:360
void parse_binary_file(std::string binary_file_name)
parse a field file in the binary 'binary' format (whose details are given below).
Definition: LaserProfileFromFile.cpp:221
int nt
Definition: LaserProfiles.H:342
void read_data_t_chunk(int t_begin, int t_end)
Load field data within the temporal range [t_begin, t_end].
Definition: LaserProfileFromFile.cpp:294
bool file_in_lasy_format
Definition: LaserProfiles.H:338
std::string lasy_file_name
Definition: LaserProfiles.H:336
void update(amrex::Real t) override final
Reads new field data chunk from file if needed.
Definition: LaserProfileFromFile.cpp:114
int nr
Definition: LaserProfiles.H:344
amrex::Real y_min
Definition: LaserProfiles.H:356
CommonLaserParameters m_common_params
Definition: LaserProfiles.H:377
amrex::Real t_delay
Definition: LaserProfiles.H:373
amrex::Gpu::DeviceVector< Complex > E_lasy_data
Definition: LaserProfiles.H:368
void parse_lasy_file(std::string lasy_file_name)
parse a field file in the HDF5 'lasy' format
Definition: LaserProfileFromFile.cpp:164
amrex::Real r_min
Definition: LaserProfiles.H:359
void read_binary_data_t_chunk(int t_begin, int t_end)
Load field data within the temporal range [t_begin, t_end].
Definition: LaserProfileFromFile.cpp:355
void internal_fill_amplitude_uniform_binary(const int idx_t_left, const int np, amrex::Real const *AMREX_RESTRICT const Xp, amrex::Real const *AMREX_RESTRICT const Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT const amplitude) const
Function to fill the amplitude in case of a uniform grid and for the binary format....
Definition: LaserProfileFromFile.cpp:595
int nx
Definition: LaserProfiles.H:342
std::pair< int, int > find_left_right_time_indices(amrex::Real t) const
Finds left and right time indices corresponding to time t.
Definition: LaserProfileFromFile.cpp:284
amrex::Real x_max
Definition: LaserProfiles.H:354
amrex::Gpu::DeviceVector< amrex::Real > E_binary_data
Definition: LaserProfiles.H:370
std::string fileGeom
Definition: LaserProfiles.H:332
struct WarpXLaserProfiles::FromFileLaserProfile::@6 m_params
m_params contains all the internal parameters used by this laser profile
int n_rz_azimuthal_components
Definition: LaserProfiles.H:346
int ny
Definition: LaserProfiles.H:342
amrex::Real x_min
Definition: LaserProfiles.H:352
amrex::Real t_min
Definition: LaserProfiles.H:348
Definition: LaserProfiles.H:107
amrex::Real phi2
Definition: LaserProfiles.H:135
void fill_amplitude(const int np, amrex::Real const *AMREX_RESTRICT const Xp, amrex::Real const *AMREX_RESTRICT const Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT const amplitude) const override final
Definition: LaserProfileGaussian.cpp:99
amrex::Real zeta
Definition: LaserProfiles.H:133
amrex::Real theta_stc
Direction of the spatio-temporal couplings.
Definition: LaserProfiles.H:139
amrex::Real phi0
Definition: LaserProfiles.H:136
amrex::Real focal_distance
Definition: LaserProfiles.H:132
struct WarpXLaserProfiles::GaussianLaserProfile::@4 m_params
amrex::Real t_peak
Definition: LaserProfiles.H:131
amrex::Real duration
Definition: LaserProfiles.H:130
void init(const amrex::ParmParse &ppl, CommonLaserParameters params) override final
Definition: LaserProfileGaussian.cpp:33
CommonLaserParameters m_common_params
Definition: LaserProfiles.H:142
amrex::Real waist
Definition: LaserProfiles.H:129
amrex::Vector< amrex::Real > stc_direction
Definition: LaserProfiles.H:138
void update(amrex::Real) override final
Definition: LaserProfiles.H:117
amrex::Real beta
Definition: LaserProfiles.H:134
Definition: LaserProfiles.H:53
virtual void update(amrex::Real t)=0
virtual void fill_amplitude(const int np, amrex::Real const *AMREX_RESTRICT const Xp, amrex::Real const *AMREX_RESTRICT const Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT const amplitude) const =0
virtual void init(const amrex::ParmParse &ppl, CommonLaserParameters params)=0
virtual ~ILaserProfile()
Definition: LaserProfiles.H:100
Definition: LaserProfiles.H:27
const std::map< std::string, std::function< std::unique_ptr< ILaserProfile >)>> laser_profiles_dictionary
Definition: LaserProfiles.H:389
Definition: LaserProfiles.H:34
amrex::Real e_max
central wavelength
Definition: LaserProfiles.H:36
amrex::Real wavelength
Definition: LaserProfiles.H:35
amrex::Vector< amrex::Real > p_X
maximum electric field at peak
Definition: LaserProfiles.H:37
amrex::Vector< amrex::Real > nvec
Definition: LaserProfiles.H:38