1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/* Copyright 2019 Luca Fedeli
*
* This file is part of WarpX.
*
* License: BSD-3-Clause-LBNL
*/
#include "Laser/LaserProfiles.H"
#include "Utils/Parser/ParserUtils.H"
#include "Utils/TextMsg.H"
#include "Utils/WarpX_Complex.H"
#include <AMReX.H>
#include <AMReX_Extension.H>
#include <AMReX_GpuLaunch.H>
#include <AMReX_GpuQualifiers.H>
#include <AMReX_Math.H>
#include <AMReX_ParmParse.H>
#include <AMReX_REAL.H>
#include <memory>
#include <set>
#include <string>
using namespace amrex;
void
WarpXLaserProfiles::FieldFunctionLaserProfile::init (
const amrex::ParmParse& ppl,
const amrex::ParmParse& ppc,
CommonLaserParameters /*params*/)
{
// Parse the properties of the parse_field_function profile
ppl.get("field_function(X,Y,t)", m_params.field_function);
m_parser.define(m_params.field_function);
m_parser.registerVariables({"X","Y","t"});
std::set<std::string> symbols = m_parser.symbols();
symbols.erase("X");
symbols.erase("Y");
symbols.erase("t"); // after removing variables, we are left with constants
for (auto it = symbols.begin(); it != symbols.end(); ) {
Real v;
if (utils::parser::queryWithParser(ppc, it->c_str(), v)) {
m_parser.setConstant(*it, v);
it = symbols.erase(it);
} else {
++it;
}
}
std::stringstream ss;
for (auto const& s : symbols) ss << " " << s;
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(symbols.empty(),
"Laser Profile: Unknown symbols " + ss.str());
}
void
WarpXLaserProfiles::FieldFunctionLaserProfile::fill_amplitude (
const int np, Real const * AMREX_RESTRICT const Xp, Real const * AMREX_RESTRICT const Yp,
Real t, Real * AMREX_RESTRICT const amplitude) const
{
auto parser = m_parser.compile<3>();
amrex::ParallelFor(np, [=] AMREX_GPU_DEVICE (int i) noexcept
{
amplitude[i] = parser(Xp[i], Yp[i], t);
});
}
|