From fb91fe1e41d37dbc2ac3225e7feb048e3b773d81 Mon Sep 17 00:00:00 2001 From: Andrew Myers Date: Mon, 6 Aug 2018 17:08:40 -0700 Subject: forgot to add in these new files. --- Source/WarpXUtil.cpp | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Source/WarpXUtil.cpp (limited to 'Source/WarpXUtil.cpp') diff --git a/Source/WarpXUtil.cpp b/Source/WarpXUtil.cpp new file mode 100644 index 000000000..d84bdb70d --- /dev/null +++ b/Source/WarpXUtil.cpp @@ -0,0 +1,73 @@ +#include + +#include + +using namespace amrex; + +void ReadBoostedFrameParameters(Real& gamma_boost, Real& beta_boost, + Vector& boost_direction) +{ + ParmParse pp("warpx"); + pp.query("gamma_boost", gamma_boost); + beta_boost = std::sqrt(1.-1./pow(gamma_boost,2)); + if( gamma_boost > 1. ) { + std::string s; + pp.get("boost_direction", s); + if (s == "x" || s == "X") { + boost_direction[0] = 1; + } +#if (AMREX_SPACEDIM == 3) + else if (s == "y" || s == "Y") { + boost_direction[1] = 1; + } +#endif + else if (s == "z" || s == "Z") { + boost_direction[2] = 1; + } + else { + const std::string msg = "Unknown boost_dir: "+s; + Abort(msg.c_str()); + } + + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( s == "z" || s == "Z" , + "The boost must be in the z direction."); + } +} + +void ConvertLabParamsToBoost() +{ + + Real gamma_boost, beta_boost; + Vector boost_direction {0,0,0}; + + ReadBoostedFrameParameters(gamma_boost, beta_boost, boost_direction); + + if (gamma_boost <= 1.) return; + + Vector prob_lo(AMREX_SPACEDIM); + Vector prob_hi(AMREX_SPACEDIM); + + ParmParse pp("geometry"); + pp.getarr("prob_lo",prob_lo,0,AMREX_SPACEDIM); + BL_ASSERT(prob_lo.size() == AMREX_SPACEDIM); + pp.getarr("prob_hi",prob_hi,0,AMREX_SPACEDIM); + BL_ASSERT(prob_hi.size() == AMREX_SPACEDIM); + +#if (AMREX_SPACEDIM == 3) + Vector dim_map {0, 1, 2}; +#else + Vector dim_map {0, 2}; +#endif + + for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) + { + if (boost_direction[dim_map[idim]]) { + prob_lo[idim] += prob_lo[idim] * gamma_boost * (1.0 + beta_boost*beta_boost); + prob_hi[idim] += prob_hi[idim] * gamma_boost * (1.0 + beta_boost*beta_boost); + break; + } + } + + pp.addarr("prob_lo", prob_lo); + pp.addarr("prob_hi", prob_hi); +} -- cgit v1.2.3 From 0a3180379e4b7c5b78c20d4b7c94ff4934cf8a93 Mon Sep 17 00:00:00 2001 From: Maxence Thevenet Date: Thu, 9 Aug 2018 18:07:13 -0700 Subject: changes in utils --- Source/WarpXUtil.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'Source/WarpXUtil.cpp') diff --git a/Source/WarpXUtil.cpp b/Source/WarpXUtil.cpp index d84bdb70d..b719d7f64 100644 --- a/Source/WarpXUtil.cpp +++ b/Source/WarpXUtil.cpp @@ -1,5 +1,7 @@ -#include +#include +#include +#include #include using namespace amrex; @@ -62,9 +64,12 @@ void ConvertLabParamsToBoost() for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) { if (boost_direction[dim_map[idim]]) { - prob_lo[idim] += prob_lo[idim] * gamma_boost * (1.0 + beta_boost*beta_boost); - prob_hi[idim] += prob_hi[idim] * gamma_boost * (1.0 + beta_boost*beta_boost); - break; + amrex::Real convert_factor; + // Assume that the window travels with speed +c + convert_factor = 1./( gamma_boost * ( 1 - beta_boost ) ); + prob_lo[idim] *= convert_factor; + prob_hi[idim] *= convert_factor; + break; } } -- cgit v1.2.3 From 7db19f64211297aac0bba32f12839265e7463e53 Mon Sep 17 00:00:00 2001 From: Maxence Thevenet Date: Thu, 9 Aug 2018 18:24:51 -0700 Subject: indentation --- Source/WarpXUtil.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'Source/WarpXUtil.cpp') diff --git a/Source/WarpXUtil.cpp b/Source/WarpXUtil.cpp index b719d7f64..4edd41838 100644 --- a/Source/WarpXUtil.cpp +++ b/Source/WarpXUtil.cpp @@ -64,15 +64,14 @@ void ConvertLabParamsToBoost() for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) { if (boost_direction[dim_map[idim]]) { - amrex::Real convert_factor; - // Assume that the window travels with speed +c - convert_factor = 1./( gamma_boost * ( 1 - beta_boost ) ); - prob_lo[idim] *= convert_factor; - prob_hi[idim] *= convert_factor; - break; + amrex::Real convert_factor; + // Assume that the window travels with speed +c + convert_factor = 1./( gamma_boost * ( 1 - beta_boost ) ); + prob_lo[idim] *= convert_factor; + prob_hi[idim] *= convert_factor; + break; } - } - + } pp.addarr("prob_lo", prob_lo); pp.addarr("prob_hi", prob_hi); } -- cgit v1.2.3