WarpX
Loading...
Searching...
No Matches
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
28
40
41
53{
54public:
66 virtual void
68 const amrex::ParmParse& ppl,
69 CommonLaserParameters params) = 0;
70
78 virtual void
80 amrex::Real t) = 0;
81
92 virtual void
94 int np,
95 amrex::Real const * AMREX_RESTRICT Xp,
96 amrex::Real const * AMREX_RESTRICT Yp,
97 amrex::Real t,
98 amrex::Real* AMREX_RESTRICT amplitude) const = 0;
99
100 ILaserProfile () = default;
101 virtual ~ILaserProfile() = default;
102
103 ILaserProfile ( ILaserProfile const &) = default;
107};
108
113{
114
115public:
116 void
117 init (
118 const amrex::ParmParse& ppl,
119 CommonLaserParameters params) final;
120
121 //No update needed
122 void
123 update (amrex::Real /*t */) final {}
124
125 void
127 int np,
128 amrex::Real const * AMREX_RESTRICT Xp,
129 amrex::Real const * AMREX_RESTRICT Yp,
130 amrex::Real t,
131 amrex::Real * AMREX_RESTRICT amplitude) const final;
132
133private:
134 struct {
135 amrex::Real waist = std::numeric_limits<amrex::Real>::quiet_NaN();
136 amrex::Real duration = std::numeric_limits<amrex::Real>::quiet_NaN();
137 amrex::Real t_peak = std::numeric_limits<amrex::Real>::quiet_NaN();
138 amrex::Real focal_distance = std::numeric_limits<amrex::Real>::quiet_NaN();
139 amrex::Real zeta = 0;
140 amrex::Real beta = 0;
141 amrex::Real phi2 = 0;
142 amrex::Real phi0 = 0;
143
145 amrex::Real theta_stc;
147
149};
150
155{
156
157public:
158 void
159 init (
160 const amrex::ParmParse& ppl,
161 CommonLaserParameters params) final;
162
163 //No update needed
164 void
165 update (amrex::Real /*t */) final {}
166
167 void
169 int np,
170 amrex::Real const * AMREX_RESTRICT Xp,
171 amrex::Real const * AMREX_RESTRICT Yp,
172 amrex::Real t,
173 amrex::Real * AMREX_RESTRICT amplitude) const final;
174
175private:
176 struct{
177 std::string field_function;
179
181};
182
190{
191
192public:
193 void
194 init (
195 const amrex::ParmParse& ppl,
196 CommonLaserParameters params) final;
197
202 void
203 update (amrex::Real t) final;
204
218 void
220 int np,
221 amrex::Real const * AMREX_RESTRICT Xp,
222 amrex::Real const * AMREX_RESTRICT Yp,
223 amrex::Real t,
224 amrex::Real * AMREX_RESTRICT amplitude) const final;
225
238 int idx_t_left,
239 int np,
240 amrex::Real const * AMREX_RESTRICT Xp,
241 amrex::Real const * AMREX_RESTRICT Yp,
242 amrex::Real t,
243 amrex::Real * AMREX_RESTRICT amplitude) const;
244
257 int idx_t_left,
258 int np,
259 amrex::Real const * AMREX_RESTRICT Xp,
260 amrex::Real const * AMREX_RESTRICT Yp,
261 amrex::Real t,
262 amrex::Real * AMREX_RESTRICT amplitude) const;
263
264
265
278 int idx_t_left,
279 int np,
280 amrex::Real const * AMREX_RESTRICT Xp,
281 amrex::Real const * AMREX_RESTRICT Yp,
282 amrex::Real t,
283 amrex::Real * AMREX_RESTRICT amplitude) const;
284
285private:
289 void parse_lasy_file(const std::string& lasy_file_name);
290
304 void parse_binary_file(const std::string& binary_file_name);
305
311 [[nodiscard]] std::pair<int,int> find_left_right_time_indices(amrex::Real t) const;
312
320 void read_data_t_chunk(int t_begin, int t_end);
321
329 void read_binary_data_t_chunk(int t_begin, int t_end);
330
335 struct{
336
338 std::string binary_file_name;
340 std::string lasy_file_name;
348 int nt, nx, ny;
350 int nr;
354 amrex::Real t_min;
356 amrex::Real t_max;
358 amrex::Real x_min;
360 amrex::Real x_max;
362 amrex::Real y_min;
364 amrex::Real y_max;
365 amrex::Real r_min;
366 amrex::Real r_max;
379 amrex::Real t_delay = amrex::Real(0.0);
380
382
384};
385
390const
391std::map<
392std::string,
393std::function<std::unique_ptr<ILaserProfile>()>
394>
396{
397 {"gaussian",
398 [] () {return std::make_unique<GaussianLaserProfile>();} },
399 {"parse_field_function",
400 [] () {return std::make_unique<FieldFunctionLaserProfile>();} },
401 {"from_file",
402 [] () {return std::make_unique<FromFileLaserProfile>();} }
403};
404
405} //WarpXLaserProfiles
406
407#endif //WARPX_LaserProfiles_H_
#define AMREX_RESTRICT
Definition LaserProfiles.H:155
void fill_amplitude(int np, amrex::Real const *AMREX_RESTRICT Xp, amrex::Real const *AMREX_RESTRICT Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT amplitude) const final
Definition LaserProfileFieldFunction.cpp:39
void init(const amrex::ParmParse &ppl, CommonLaserParameters params) final
Definition LaserProfileFieldFunction.cpp:28
amrex::Parser m_parser
Definition LaserProfiles.H:180
std::string field_function
Definition LaserProfiles.H:177
struct WarpXLaserProfiles::FieldFunctionLaserProfile::@104372012120016244352230001075046217362177347265 m_params
void update(amrex::Real) final
Definition LaserProfiles.H:165
Definition LaserProfiles.H:190
std::string binary_file_name
Definition LaserProfiles.H:338
int last_time_index
Definition LaserProfiles.H:372
amrex::Real y_max
Definition LaserProfiles.H:364
void internal_fill_amplitude_uniform_binary(int idx_t_left, int np, amrex::Real const *AMREX_RESTRICT Xp, amrex::Real const *AMREX_RESTRICT Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT amplitude) const
Function to fill the amplitude in case of a uniform grid and for the binary format....
Definition LaserProfileFromFile.cpp:614
void fill_amplitude(int np, amrex::Real const *AMREX_RESTRICT Xp, amrex::Real const *AMREX_RESTRICT Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT amplitude) const final
compute field amplitude at particles' position for a laser beam loaded from an E(x,...
Definition LaserProfileFromFile.cpp:134
int first_time_index
Definition LaserProfiles.H:370
amrex::Real t_max
Definition LaserProfiles.H:356
int time_chunk_size
Definition LaserProfiles.H:368
amrex::Real r_max
Definition LaserProfiles.H:366
void init(const amrex::ParmParse &ppl, CommonLaserParameters params) final
Definition LaserProfileFromFile.cpp:53
int file_in_cartesian_geom
Definition LaserProfiles.H:344
int nt
Definition LaserProfiles.H:348
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:313
void internal_fill_amplitude_uniform_cylindrical(int idx_t_left, int np, amrex::Real const *AMREX_RESTRICT Xp, amrex::Real const *AMREX_RESTRICT Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT amplitude) const
Function to fill the amplitude in case of a uniform grid and for the lasy format in RZ geometry....
Definition LaserProfileFromFile.cpp:513
bool file_in_lasy_format
Definition LaserProfiles.H:342
std::string lasy_file_name
Definition LaserProfiles.H:340
void parse_lasy_file(const std::string &lasy_file_name)
parse a field file in the HDF5 'lasy' format
Definition LaserProfileFromFile.cpp:165
void internal_fill_amplitude_uniform_cartesian(int idx_t_left, int np, amrex::Real const *AMREX_RESTRICT Xp, amrex::Real const *AMREX_RESTRICT Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT amplitude) const
Function to fill the amplitude in case of a uniform grid and for the lasy format in 3D Cartesian....
Definition LaserProfileFromFile.cpp:428
int nr
Definition LaserProfiles.H:350
amrex::Real y_min
Definition LaserProfiles.H:362
CommonLaserParameters m_common_params
Definition LaserProfiles.H:383
void parse_binary_file(const std::string &binary_file_name)
parse a field file in the binary 'binary' format (whose details are given below).
Definition LaserProfileFromFile.cpp:240
struct WarpXLaserProfiles::FromFileLaserProfile::@224153172207061317357315344070135305351022234025 m_params
m_params contains all the internal parameters used by this laser profile
amrex::Real t_delay
Definition LaserProfiles.H:379
amrex::Gpu::DeviceVector< Complex > E_lasy_data
Definition LaserProfiles.H:374
amrex::Real r_min
Definition LaserProfiles.H:365
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:372
int nx
Definition LaserProfiles.H:348
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:303
amrex::Real x_max
Definition LaserProfiles.H:360
amrex::Gpu::DeviceVector< amrex::Real > E_binary_data
Definition LaserProfiles.H:376
int n_rz_azimuthal_components
Definition LaserProfiles.H:352
void update(amrex::Real t) final
Reads new field data chunk from file if needed.
Definition LaserProfileFromFile.cpp:114
int ny
Definition LaserProfiles.H:348
amrex::Real x_min
Definition LaserProfiles.H:358
amrex::Real t_min
Definition LaserProfiles.H:354
Definition LaserProfiles.H:113
amrex::Real phi2
Definition LaserProfiles.H:141
amrex::Real zeta
Definition LaserProfiles.H:139
amrex::Real theta_stc
Direction of the spatio-temporal couplings.
Definition LaserProfiles.H:145
amrex::Real phi0
Definition LaserProfiles.H:142
void fill_amplitude(int np, amrex::Real const *AMREX_RESTRICT Xp, amrex::Real const *AMREX_RESTRICT Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT amplitude) const final
Definition LaserProfileGaussian.cpp:100
amrex::Real focal_distance
Definition LaserProfiles.H:138
amrex::Real t_peak
Definition LaserProfiles.H:137
amrex::Real duration
Definition LaserProfiles.H:136
struct WarpXLaserProfiles::GaussianLaserProfile::@156326202164214342011334120011061353235350116063 m_params
CommonLaserParameters m_common_params
Definition LaserProfiles.H:148
void update(amrex::Real) final
Definition LaserProfiles.H:123
amrex::Real waist
Definition LaserProfiles.H:135
amrex::Vector< amrex::Real > stc_direction
Definition LaserProfiles.H:144
void init(const amrex::ParmParse &ppl, CommonLaserParameters params) final
Definition LaserProfileGaussian.cpp:33
amrex::Real beta
Definition LaserProfiles.H:140
ILaserProfile(ILaserProfile const &)=default
virtual void update(amrex::Real t)=0
virtual void init(const amrex::ParmParse &ppl, CommonLaserParameters params)=0
ILaserProfile & operator=(ILaserProfile const &)=default
virtual void fill_amplitude(int np, amrex::Real const *AMREX_RESTRICT Xp, amrex::Real const *AMREX_RESTRICT Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT amplitude) const =0
ILaserProfile(ILaserProfile &&)=default
Definition LaserProfiles.H:27
const std::map< std::string, std::function< std::unique_ptr< ILaserProfile >()> > laser_profiles_dictionary
Definition LaserProfiles.H:395
PODVector< T, ArenaAllocator< T > > DeviceVector
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