diff options
Diffstat (limited to 'Source/Utils')
-rw-r--r-- | Source/Utils/WarpXMovingWindow.cpp | 13 | ||||
-rw-r--r-- | Source/Utils/WarpXTagging.cpp | 6 | ||||
-rw-r--r-- | Source/Utils/WarpXUtil.H | 12 | ||||
-rw-r--r-- | Source/Utils/WarpXUtil.cpp | 16 |
4 files changed, 36 insertions, 11 deletions
diff --git a/Source/Utils/WarpXMovingWindow.cpp b/Source/Utils/WarpXMovingWindow.cpp index f84701a02..c577da7f3 100644 --- a/Source/Utils/WarpXMovingWindow.cpp +++ b/Source/Utils/WarpXMovingWindow.cpp @@ -99,8 +99,8 @@ WarpX::MoveWindow (bool move_j) for (int dim = 0; dim < 3; ++dim) { // Fine grid - shiftMF(*Bfield_fp[lev][dim], geom[lev], num_shift, dir); - shiftMF(*Efield_fp[lev][dim], geom[lev], num_shift, dir); + shiftMF(*Bfield_fp[lev][dim], geom[lev], num_shift, dir, B_external_grid[dim]); + shiftMF(*Efield_fp[lev][dim], geom[lev], num_shift, dir, E_external_grid[dim]); if (move_j) { shiftMF(*current_fp[lev][dim], geom[lev], num_shift, dir); } @@ -113,8 +113,8 @@ WarpX::MoveWindow (bool move_j) if (lev > 0) { // Coarse grid - shiftMF(*Bfield_cp[lev][dim], geom[lev-1], num_shift_crse, dir); - shiftMF(*Efield_cp[lev][dim], geom[lev-1], num_shift_crse, dir); + shiftMF(*Bfield_cp[lev][dim], geom[lev-1], num_shift_crse, dir, B_external_grid[dim]); + shiftMF(*Efield_cp[lev][dim], geom[lev-1], num_shift_crse, dir, E_external_grid[dim]); shiftMF(*Bfield_aux[lev][dim], geom[lev], num_shift, dir); shiftMF(*Efield_aux[lev][dim], geom[lev], num_shift, dir); if (move_j) { @@ -203,7 +203,8 @@ WarpX::MoveWindow (bool move_j) } void -WarpX::shiftMF (MultiFab& mf, const Geometry& geom, int num_shift, int dir) +WarpX::shiftMF (MultiFab& mf, const Geometry& geom, int num_shift, int dir, + amrex::Real external_field) { BL_PROFILE("WarpX::shiftMF()"); const BoxArray& ba = mf.boxArray(); @@ -257,7 +258,7 @@ WarpX::shiftMF (MultiFab& mf, const Geometry& geom, int num_shift, int dir) if (outbox.ok()) { AMREX_PARALLEL_FOR_4D ( outbox, nc, i, j, k, n, { - srcfab(i,j,k,n) = 0.0; + srcfab(i,j,k,n) = external_field; }); } diff --git a/Source/Utils/WarpXTagging.cpp b/Source/Utils/WarpXTagging.cpp index 8ea3211a3..91bb802e8 100644 --- a/Source/Utils/WarpXTagging.cpp +++ b/Source/Utils/WarpXTagging.cpp @@ -22,9 +22,9 @@ WarpX::ErrorEst (int lev, TagBoxArray& tags, Real time, int /*ngrow*/) for (BoxIterator bi(bx); bi.ok(); ++bi) { const IntVect& cell = bi(); - RealVect pos {AMREX_D_DECL((cell[0]+0.5)*dx[0]+problo[0], - (cell[1]+0.5)*dx[1]+problo[1], - (cell[2]+0.5)*dx[2]+problo[2])}; + RealVect pos {AMREX_D_DECL((cell[0]+0.5_rt)*dx[0]+problo[0], + (cell[1]+0.5_rt)*dx[1]+problo[1], + (cell[2]+0.5_rt)*dx[2]+problo[2])}; if (pos > fine_tag_lo && pos < fine_tag_hi) { fab(cell) = TagBox::SET; } diff --git a/Source/Utils/WarpXUtil.H b/Source/Utils/WarpXUtil.H index fd6e72dc6..ab28c5446 100644 --- a/Source/Utils/WarpXUtil.H +++ b/Source/Utils/WarpXUtil.H @@ -2,6 +2,8 @@ #include <AMReX_Vector.H> #include <AMReX_MultiFab.H> +#include <string> + void ReadBoostedFrameParameters(amrex::Real& gamma_boost, amrex::Real& beta_boost, amrex::Vector<int>& boost_direction); @@ -9,3 +11,13 @@ void ConvertLabParamsToBoost(); void NullifyMF(amrex::MultiFab& mf, int lev, amrex::Real zmin, amrex::Real zmax); + +namespace WarpXUtilIO{ + /** + * A helper function to write binary data on disk. + * @param[in] filename where to write + * @param[in] data Vector containing binary data to write on disk + * return true if it succeeds, false otherwise + */ + bool WriteBinaryDataOnFile(std::string filename, const amrex::Vector<char>& data); +} diff --git a/Source/Utils/WarpXUtil.cpp b/Source/Utils/WarpXUtil.cpp index 4b11eb69d..8764a09c6 100644 --- a/Source/Utils/WarpXUtil.cpp +++ b/Source/Utils/WarpXUtil.cpp @@ -1,10 +1,11 @@ -#include <cmath> - #include <WarpXUtil.H> #include <WarpXConst.H> #include <AMReX_ParmParse.H> #include <WarpX.H> +#include <cmath> +#include <fstream> + using namespace amrex; void ReadBoostedFrameParameters(Real& gamma_boost, Real& beta_boost, @@ -152,3 +153,14 @@ void NullifyMF(amrex::MultiFab& mf, int lev, amrex::Real zmin, amrex::Real zmax) } } } + +namespace WarpXUtilIO{ + bool WriteBinaryDataOnFile(std::string filename, const amrex::Vector<char>& data) + { + std::ofstream of{filename, std::ios::binary}; + of.write(data.data(), data.size()); + of.close(); + return of.good(); + } +} + |