aboutsummaryrefslogtreecommitdiff
path: root/Source/Laser/LaserProfilesImpl/LaserProfileFieldFunction.cpp
diff options
context:
space:
mode:
authorGravatar MaxThevenet <mthevenet@lbl.gov> 2019-11-13 09:49:07 -0800
committerGravatar MaxThevenet <mthevenet@lbl.gov> 2019-11-13 09:49:07 -0800
commit368d294e811ee03577a466f6bdbe23124c3ccf84 (patch)
tree8a335f3060a6fd6cf94299a9cfaf8ef82910300c /Source/Laser/LaserProfilesImpl/LaserProfileFieldFunction.cpp
parent751b6e3867a2f41db88430476891fecb2e35b053 (diff)
parent1f594f0b5ecfa3169e90546f695a1c649af36aa1 (diff)
downloadWarpX-368d294e811ee03577a466f6bdbe23124c3ccf84.tar.gz
WarpX-368d294e811ee03577a466f6bdbe23124c3ccf84.tar.zst
WarpX-368d294e811ee03577a466f6bdbe23124c3ccf84.zip
Merge branch 'dev' into comm
Diffstat (limited to 'Source/Laser/LaserProfilesImpl/LaserProfileFieldFunction.cpp')
-rw-r--r--Source/Laser/LaserProfilesImpl/LaserProfileFieldFunction.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/Source/Laser/LaserProfilesImpl/LaserProfileFieldFunction.cpp b/Source/Laser/LaserProfilesImpl/LaserProfileFieldFunction.cpp
new file mode 100644
index 000000000..3c9d7379a
--- /dev/null
+++ b/Source/Laser/LaserProfilesImpl/LaserProfileFieldFunction.cpp
@@ -0,0 +1,45 @@
+#include <LaserProfiles.H>
+
+#include <WarpX_Complex.H>
+
+using namespace amrex;
+using namespace WarpXLaserProfiles;
+
+void
+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 (ppc.query(it->c_str(), v)) {
+ m_parser.setConstant(*it, v);
+ it = symbols.erase(it);
+ } else {
+ ++it;
+ }
+ }
+ for (auto const& s : symbols) { // make sure there no unknown symbols
+ amrex::Abort("Laser Profile: Unknown symbol "+s);
+ }
+}
+
+void
+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)
+{
+ for (int i = 0; i < np; ++i) {
+ amplitude[i] = m_parser.eval(Xp[i], Yp[i], t);
+ }
+}