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 
16 #include <functional>
17 #include <limits>
18 #include <map>
19 #include <memory>
20 #include <string>
21 #include <utility>
22 
23 #include "Utils/WarpX_Complex.H"
24 
25 namespace WarpXLaserProfiles {
26 
32 {
33  amrex::Real wavelength;
34  amrex::Real e_max;
35  amrex::Vector<amrex::Real> p_X;// ! Polarization
37 };
38 
39 
51 {
52 public:
64  virtual void
65  init (
66  const amrex::ParmParse& ppl,
67  CommonLaserParameters params) = 0;
68 
76  virtual void
78  amrex::Real t) = 0;
79 
90  virtual void
92  const int np,
93  amrex::Real const * AMREX_RESTRICT const Xp,
94  amrex::Real const * AMREX_RESTRICT const Yp,
95  amrex::Real t,
96  amrex::Real * AMREX_RESTRICT const amplitude) const = 0;
97 
98  virtual ~ILaserProfile(){}
99 };
100 
105 {
106 
107 public:
108  void
109  init (
110  const amrex::ParmParse& ppl,
111  CommonLaserParameters params) override final;
112 
113  //No update needed
114  void
115  update (amrex::Real /*t */) override final {}
116 
117  void
119  const int np,
120  amrex::Real const * AMREX_RESTRICT const Xp,
121  amrex::Real const * AMREX_RESTRICT const Yp,
122  amrex::Real t,
123  amrex::Real * AMREX_RESTRICT const amplitude) const override final;
124 
125 private:
126  struct {
127  amrex::Real waist = std::numeric_limits<amrex::Real>::quiet_NaN();
128  amrex::Real duration = std::numeric_limits<amrex::Real>::quiet_NaN();
129  amrex::Real t_peak = std::numeric_limits<amrex::Real>::quiet_NaN();
130  amrex::Real focal_distance = std::numeric_limits<amrex::Real>::quiet_NaN();
131  amrex::Real zeta = 0;
132  amrex::Real beta = 0;
133  amrex::Real phi2 = 0;
134  amrex::Real phi0 = 0;
135 
137  amrex::Real theta_stc;
139 
141 };
142 
147 {
148 
149 public:
150  void
151  init (
152  const amrex::ParmParse& ppl,
153  CommonLaserParameters params) override final;
154 
155  //No update needed
156  void
157  update (amrex::Real /*t */) override final {}
158 
159  void
161  const int np,
162  amrex::Real const * AMREX_RESTRICT const Xp,
163  amrex::Real const * AMREX_RESTRICT const Yp,
164  amrex::Real t,
165  amrex::Real * AMREX_RESTRICT const amplitude) const override final;
166 
167 private:
168  struct{
169  std::string field_function;
171 
173 };
174 
182 {
183 
184 public:
185  void
186  init (
187  const amrex::ParmParse& ppl,
188  CommonLaserParameters params) override final;
189 
194  void
195  update (amrex::Real t) override final;
196 
210  void
212  const int np,
213  amrex::Real const * AMREX_RESTRICT const Xp,
214  amrex::Real const * AMREX_RESTRICT const Yp,
215  amrex::Real t,
216  amrex::Real * AMREX_RESTRICT const amplitude) const override final;
217 
230  const int idx_t_left,
231  const int np,
232  amrex::Real const * AMREX_RESTRICT const Xp,
233  amrex::Real const * AMREX_RESTRICT const Yp,
234  amrex::Real t,
235  amrex::Real * AMREX_RESTRICT const amplitude) const;
236 
249  const int idx_t_left,
250  const int np,
251  amrex::Real const * AMREX_RESTRICT const Xp,
252  amrex::Real const * AMREX_RESTRICT const Yp,
253  amrex::Real t,
254  amrex::Real * AMREX_RESTRICT const amplitude) const;
255 
256 private:
260  void parse_lasy_file(std::string lasy_file_name);
261 
275  void parse_binary_file(std::string binary_file_name);
276 
282  std::pair<int,int> find_left_right_time_indices(amrex::Real t) const;
283 
291  void read_data_t_chunk(int t_begin, int t_end);
292 
300  void read_binary_data_t_chunk(int t_begin, int t_end);
301 
306  struct{
308  std::string binary_file_name;
310  std::string lasy_file_name;
316  int nt, nx, ny;
318  amrex::Real t_min;
320  amrex::Real t_max;
322  amrex::Real x_min;
324  amrex::Real x_max;
326  amrex::Real y_min;
328  amrex::Real y_max;
341  amrex::Real t_delay = amrex::Real(0.0);
342 
344 
346 };
347 
352 const
353 std::map<
354 std::string,
355 std::function<std::unique_ptr<ILaserProfile>()>
356 >
358 {
359  {"gaussian",
360  [] () {return std::make_unique<GaussianLaserProfile>();} },
361  {"parse_field_function",
362  [] () {return std::make_unique<FieldFunctionLaserProfile>();} },
363  {"from_file",
364  [] () {return std::make_unique<FromFileLaserProfile>();} }
365 };
366 
367 } //WarpXLaserProfiles
368 
369 #endif //WARPX_LaserProfiles_H_
#define AMREX_RESTRICT
Definition: LaserProfiles.H:147
struct WarpXLaserProfiles::FieldFunctionLaserProfile::@5 m_params
amrex::Parser m_parser
Definition: LaserProfiles.H:172
void init(const amrex::ParmParse &ppl, CommonLaserParameters params) override final
Definition: LaserProfileFieldFunction.cpp:28
std::string field_function
Definition: LaserProfiles.H:169
void update(amrex::Real) override final
Definition: LaserProfiles.H:157
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:182
std::string binary_file_name
Definition: LaserProfiles.H:308
int last_time_index
Definition: LaserProfiles.H:334
amrex::Real y_max
Definition: LaserProfiles.H:328
int first_time_index
Definition: LaserProfiles.H:332
amrex::Real t_max
Definition: LaserProfiles.H:320
void internal_fill_amplitude_uniform(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. This function canno...
Definition: LaserProfileFromFile.cpp:385
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:144
int time_chunk_size
Definition: LaserProfiles.H:330
void init(const amrex::ParmParse &ppl, CommonLaserParameters params) override final
Definition: LaserProfileFromFile.cpp:55
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:214
int nt
Definition: LaserProfiles.H:316
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:287
bool file_in_lasy_format
Definition: LaserProfiles.H:312
std::string lasy_file_name
Definition: LaserProfiles.H:310
void update(amrex::Real t) override final
Reads new field data chunk from file if needed.
Definition: LaserProfileFromFile.cpp:124
amrex::Real y_min
Definition: LaserProfiles.H:326
CommonLaserParameters m_common_params
Definition: LaserProfiles.H:345
amrex::Real t_delay
Definition: LaserProfiles.H:341
amrex::Gpu::DeviceVector< Complex > E_lasy_data
Definition: LaserProfiles.H:336
void parse_lasy_file(std::string lasy_file_name)
parse a field file in the HDF5 'lasy' format
Definition: LaserProfileFromFile.cpp:171
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:329
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:471
int nx
Definition: LaserProfiles.H:316
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:277
amrex::Real x_max
Definition: LaserProfiles.H:324
amrex::Gpu::DeviceVector< amrex::Real > E_binary_data
Definition: LaserProfiles.H:338
struct WarpXLaserProfiles::FromFileLaserProfile::@6 m_params
m_params contains all the internal parameters used by this laser profile
int ny
Definition: LaserProfiles.H:316
amrex::Real x_min
Definition: LaserProfiles.H:322
amrex::Real t_min
Definition: LaserProfiles.H:318
Definition: LaserProfiles.H:105
amrex::Real phi2
Definition: LaserProfiles.H:133
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:131
amrex::Real theta_stc
Direction of the spatio-temporal couplings.
Definition: LaserProfiles.H:137
amrex::Real phi0
Definition: LaserProfiles.H:134
amrex::Real focal_distance
Definition: LaserProfiles.H:130
struct WarpXLaserProfiles::GaussianLaserProfile::@4 m_params
amrex::Real t_peak
Definition: LaserProfiles.H:129
amrex::Real duration
Definition: LaserProfiles.H:128
void init(const amrex::ParmParse &ppl, CommonLaserParameters params) override final
Definition: LaserProfileGaussian.cpp:33
CommonLaserParameters m_common_params
Definition: LaserProfiles.H:140
amrex::Real waist
Definition: LaserProfiles.H:127
amrex::Vector< amrex::Real > stc_direction
Definition: LaserProfiles.H:136
void update(amrex::Real) override final
Definition: LaserProfiles.H:115
amrex::Real beta
Definition: LaserProfiles.H:132
Definition: LaserProfiles.H:51
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:98
Definition: LaserProfiles.H:25
const std::map< std::string, std::function< std::unique_ptr< ILaserProfile >)>> laser_profiles_dictionary
Definition: LaserProfiles.H:357
Definition: LaserProfiles.H:32
amrex::Real e_max
central wavelength
Definition: LaserProfiles.H:34
amrex::Real wavelength
Definition: LaserProfiles.H:33
amrex::Vector< amrex::Real > p_X
maximum electric field at peak
Definition: LaserProfiles.H:35
amrex::Vector< amrex::Real > nvec
Definition: LaserProfiles.H:36