From fd848331f2fd6af8c56a0027cc5f088286e347c4 Mon Sep 17 00:00:00 2001 From: Tools Date: Wed, 11 Sep 2019 10:06:14 -0700 Subject: Source & Tools: No EOL Whitespaces End-of-line (EOL) whitespaces are verbose and increase diffs and merge conflicts over time. Cleaned them up for the `Source/`, `Examples/` and `Tools/` directory with the following bash one-liner: ```bash find . -type f -not -path './.git*' \ -exec sed -i 's/[[:blank:]]*$//' {} \; ``` Committed as generic user so git does not credit the many lines to me: ```bash GIT_AUTHOR_NAME="Tools" GIT_AUTHOR_EMAIL="warpx@lbl.gov" \ git commit ``` --- .../FieldSolver/SpectralSolver/SpectralAlgorithms/PMLPsatdAlgorithm.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PMLPsatdAlgorithm.H') diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PMLPsatdAlgorithm.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PMLPsatdAlgorithm.H index a2511b6b7..50eb5c9b1 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PMLPsatdAlgorithm.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PMLPsatdAlgorithm.H @@ -17,7 +17,7 @@ class PMLPsatdAlgorithm : public SpectralBaseAlgorithm void InitializeSpectralCoefficients( const SpectralKSpace& spectral_kspace, - const amrex::DistributionMapping& dm, + const amrex::DistributionMapping& dm, const amrex::Real dt); // Redefine functions from base class -- cgit v1.2.3 From d6f8ce933459c52552772ae8bba683ec2e8cb3ad Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Wed, 11 Sep 2019 16:06:07 -0700 Subject: Source: tabs2spaces Manually fix tabs to four spaces and alignments for consistent prepresentation of source code over all machines. --- Source/BoundaryConditions/PML.H | 4 +- Source/BoundaryConditions/WarpXEvolvePML.cpp | 28 +- Source/Diagnostics/BoostedFrameDiagnostic.H | 2 +- Source/Diagnostics/BoostedFrameDiagnostic.cpp | 4 +- Source/Diagnostics/ElectrostaticIO.cpp | 6 +- Source/Diagnostics/ParticleIO.cpp | 8 +- Source/Diagnostics/WarpXIO.cpp | 399 ++++++++++----------- Source/Evolve/WarpXEvolveEM.cpp | 6 +- Source/Evolve/WarpXEvolveES.cpp | 38 +- .../PicsarHybridSpectralSolver.cpp | 34 +- .../SpectralAlgorithms/PMLPsatdAlgorithm.H | 6 +- Source/FieldSolver/WarpXPushFieldsEM.cpp | 77 ++-- Source/FortranInterface/WarpX_f.H | 16 +- Source/Initialization/PlasmaInjector.cpp | 2 +- Source/Initialization/WarpXInitData.cpp | 38 +- Source/Laser/LaserParticleContainer.cpp | 258 ++++++------- Source/Parallelization/WarpXComm.cpp | 6 +- Source/Parallelization/WarpXRegrid.cpp | 2 +- Source/Particles/MultiParticleContainer.H | 14 +- Source/Particles/MultiParticleContainer.cpp | 4 +- Source/Particles/PhysicalParticleContainer.H | 8 +- Source/Particles/PhysicalParticleContainer.cpp | 22 +- Source/Particles/WarpXParticleContainer.H | 16 +- Source/Particles/WarpXParticleContainer.cpp | 46 +-- Source/Python/WarpXWrappers.cpp | 30 +- Source/WarpX.H | 6 +- Source/WarpX.cpp | 245 +++++++------ Source/main.cpp | 14 +- 28 files changed, 672 insertions(+), 667 deletions(-) (limited to 'Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PMLPsatdAlgorithm.H') diff --git a/Source/BoundaryConditions/PML.H b/Source/BoundaryConditions/PML.H index 9e04322f5..2db7befd6 100644 --- a/Source/BoundaryConditions/PML.H +++ b/Source/BoundaryConditions/PML.H @@ -141,9 +141,9 @@ public: const std::array& j_cp); void ExchangeB (PatchType patch_type, - const std::array& Bp, int do_pml_in_domain); + const std::array& Bp, int do_pml_in_domain); void ExchangeE (PatchType patch_type, - const std::array& Ep, int do_pml_in_domain); + const std::array& Ep, int do_pml_in_domain); void CopyJtoPMLs (PatchType patch_type, const std::array& jp); diff --git a/Source/BoundaryConditions/WarpXEvolvePML.cpp b/Source/BoundaryConditions/WarpXEvolvePML.cpp index f5c231ddf..67b179f9c 100644 --- a/Source/BoundaryConditions/WarpXEvolvePML.cpp +++ b/Source/BoundaryConditions/WarpXEvolvePML.cpp @@ -58,24 +58,24 @@ WarpX::DampPML (int lev, PatchType patch_type) const Box& tby = mfi.tilebox(By_nodal_flag); const Box& tbz = mfi.tilebox(Bz_nodal_flag); WRPX_DAMP_PML(tex.loVect(), tex.hiVect(), - tey.loVect(), tey.hiVect(), - tez.loVect(), tez.hiVect(), - tbx.loVect(), tbx.hiVect(), - tby.loVect(), tby.hiVect(), - tbz.loVect(), tbz.hiVect(), - BL_TO_FORTRAN_3D((*pml_E[0])[mfi]), - BL_TO_FORTRAN_3D((*pml_E[1])[mfi]), - BL_TO_FORTRAN_3D((*pml_E[2])[mfi]), - BL_TO_FORTRAN_3D((*pml_B[0])[mfi]), - BL_TO_FORTRAN_3D((*pml_B[1])[mfi]), - BL_TO_FORTRAN_3D((*pml_B[2])[mfi]), - WRPX_PML_TO_FORTRAN(sigba[mfi])); + tey.loVect(), tey.hiVect(), + tez.loVect(), tez.hiVect(), + tbx.loVect(), tbx.hiVect(), + tby.loVect(), tby.hiVect(), + tbz.loVect(), tbz.hiVect(), + BL_TO_FORTRAN_3D((*pml_E[0])[mfi]), + BL_TO_FORTRAN_3D((*pml_E[1])[mfi]), + BL_TO_FORTRAN_3D((*pml_E[2])[mfi]), + BL_TO_FORTRAN_3D((*pml_B[0])[mfi]), + BL_TO_FORTRAN_3D((*pml_B[1])[mfi]), + BL_TO_FORTRAN_3D((*pml_B[2])[mfi]), + WRPX_PML_TO_FORTRAN(sigba[mfi])); if (pml_F) { const Box& tnd = mfi.nodaltilebox(); WRPX_DAMP_PML_F(tnd.loVect(), tnd.hiVect(), - BL_TO_FORTRAN_3D((*pml_F)[mfi]), - WRPX_PML_TO_FORTRAN(sigba[mfi])); + BL_TO_FORTRAN_3D((*pml_F)[mfi]), + WRPX_PML_TO_FORTRAN(sigba[mfi])); } } } diff --git a/Source/Diagnostics/BoostedFrameDiagnostic.H b/Source/Diagnostics/BoostedFrameDiagnostic.H index 6c8eb15db..4263af8d0 100644 --- a/Source/Diagnostics/BoostedFrameDiagnostic.H +++ b/Source/Diagnostics/BoostedFrameDiagnostic.H @@ -139,7 +139,7 @@ private: // maps field index in data_buffer_[i] -> cell_centered_data for // snapshots i. By default, all fields in cell_centered_data are dumped. // Needs to be amrex::Vector because used in a ParallelFor kernel. - amrex::Gpu::ManagedDeviceVector map_actual_fields_to_dump; + amrex::Gpu::ManagedDeviceVector map_actual_fields_to_dump; // Name of fields to dump. By default, all fields in cell_centered_data. // Needed for file headers only. std::vector mesh_field_names = {"Ex", "Ey", "Ez", diff --git a/Source/Diagnostics/BoostedFrameDiagnostic.cpp b/Source/Diagnostics/BoostedFrameDiagnostic.cpp index f1d437509..abd9e99fe 100644 --- a/Source/Diagnostics/BoostedFrameDiagnostic.cpp +++ b/Source/Diagnostics/BoostedFrameDiagnostic.cpp @@ -567,7 +567,9 @@ BoostedFrameDiagnostic(Real zmin_lab, Real zmax_lab, Real v_window_lab, user_fields_to_dump); // If user specifies fields to dump, overwrite ncomp_to_dump, // map_actual_fields_to_dump and mesh_field_names. - for (int i = 0; i < 10; ++i) map_actual_fields_to_dump.push_back(i); + for (int i = 0; i < 10; ++i) + map_actual_fields_to_dump.push_back(i); + if (do_user_fields){ ncomp_to_dump = user_fields_to_dump.size(); map_actual_fields_to_dump.resize(ncomp_to_dump); diff --git a/Source/Diagnostics/ElectrostaticIO.cpp b/Source/Diagnostics/ElectrostaticIO.cpp index 75be2a24c..a023da0b7 100644 --- a/Source/Diagnostics/ElectrostaticIO.cpp +++ b/Source/Diagnostics/ElectrostaticIO.cpp @@ -29,10 +29,10 @@ WritePlotFileES (const amrex::Vector >& rho, const int nlevels = finestLevel()+1; { - Vector varnames; - Vector > mf(finest_level+1); + Vector varnames; + Vector > mf(finest_level+1); - for (int lev = 0; lev <= finest_level; ++lev) { + for (int lev = 0; lev <= finest_level; ++lev) { int ncomp = 5; const int ngrow = 0; mf[lev].reset(new MultiFab(grids[lev], dmap[lev], ncomp, ngrow)); diff --git a/Source/Diagnostics/ParticleIO.cpp b/Source/Diagnostics/ParticleIO.cpp index 741d3f50d..5cf3f3047 100644 --- a/Source/Diagnostics/ParticleIO.cpp +++ b/Source/Diagnostics/ParticleIO.cpp @@ -69,7 +69,7 @@ void MultiParticleContainer::Checkpoint (const std::string& dir) const { for (unsigned i = 0, n = species_names.size(); i < n; ++i) { - allcontainers[i]->Checkpoint(dir, species_names[i]); + allcontainers[i]->Checkpoint(dir, species_names[i]); } } @@ -129,7 +129,7 @@ void MultiParticleContainer::Restart (const std::string& dir) { for (unsigned i = 0, n = species_names.size(); i < n; ++i) { - allcontainers[i]->Restart(dir, species_names[i]); + allcontainers[i]->Restart(dir, species_names[i]); } } @@ -137,7 +137,7 @@ void MultiParticleContainer::ReadHeader (std::istream& is) { for (auto& pc : allcontainers) { - pc->ReadHeader(is); + pc->ReadHeader(is); } } @@ -145,7 +145,7 @@ void MultiParticleContainer::WriteHeader (std::ostream& os) const { for (const auto& pc : allcontainers) { - pc->WriteHeader(os); + pc->WriteHeader(os); } } diff --git a/Source/Diagnostics/WarpXIO.cpp b/Source/Diagnostics/WarpXIO.cpp index 6aa1f7a5b..2ac3a5eb8 100644 --- a/Source/Diagnostics/WarpXIO.cpp +++ b/Source/Diagnostics/WarpXIO.cpp @@ -35,72 +35,71 @@ WarpX::GotoNextLine (std::istream& is) void WarpX::WriteWarpXHeader(const std::string& name) const { - if (ParallelDescriptor::IOProcessor()) + if (ParallelDescriptor::IOProcessor()) { - VisMF::IO_Buffer io_buffer(VisMF::IO_Buffer_Size); - std::ofstream HeaderFile; - HeaderFile.rdbuf()->pubsetbuf(io_buffer.dataPtr(), io_buffer.size()); - std::string HeaderFileName(name + "/WarpXHeader"); + VisMF::IO_Buffer io_buffer(VisMF::IO_Buffer_Size); + std::ofstream HeaderFile; + HeaderFile.rdbuf()->pubsetbuf(io_buffer.dataPtr(), io_buffer.size()); + std::string HeaderFileName(name + "/WarpXHeader"); HeaderFile.open(HeaderFileName.c_str(), std::ofstream::out | std::ofstream::trunc | std::ofstream::binary); - if( ! HeaderFile.good()) { - amrex::FileOpenFailed(HeaderFileName); - } + if( ! HeaderFile.good()) + amrex::FileOpenFailed(HeaderFileName); - HeaderFile.precision(17); + HeaderFile.precision(17); - HeaderFile << "Checkpoint version: 1\n"; + HeaderFile << "Checkpoint version: 1\n"; - const int nlevels = finestLevel()+1; - HeaderFile << nlevels << "\n"; + const int nlevels = finestLevel()+1; + HeaderFile << nlevels << "\n"; - for (int i = 0; i < istep.size(); ++i) { - HeaderFile << istep[i] << " "; - } - HeaderFile << "\n"; + for (int i = 0; i < istep.size(); ++i) { + HeaderFile << istep[i] << " "; + } + HeaderFile << "\n"; - for (int i = 0; i < nsubsteps.size(); ++i) { - HeaderFile << nsubsteps[i] << " "; - } - HeaderFile << "\n"; + for (int i = 0; i < nsubsteps.size(); ++i) { + HeaderFile << nsubsteps[i] << " "; + } + HeaderFile << "\n"; - for (int i = 0; i < t_new.size(); ++i) { - HeaderFile << t_new[i] << " "; - } - HeaderFile << "\n"; + for (int i = 0; i < t_new.size(); ++i) { + HeaderFile << t_new[i] << " "; + } + HeaderFile << "\n"; - for (int i = 0; i < t_old.size(); ++i) { - HeaderFile << t_old[i] << " "; - } - HeaderFile << "\n"; + for (int i = 0; i < t_old.size(); ++i) { + HeaderFile << t_old[i] << " "; + } + HeaderFile << "\n"; - for (int i = 0; i < dt.size(); ++i) { - HeaderFile << dt[i] << " "; - } - HeaderFile << "\n"; + for (int i = 0; i < dt.size(); ++i) { + HeaderFile << dt[i] << " "; + } + HeaderFile << "\n"; - HeaderFile << moving_window_x << "\n"; + HeaderFile << moving_window_x << "\n"; HeaderFile << is_synchronized << "\n"; - // Geometry - for (int i = 0; i < AMREX_SPACEDIM; ++i) { + // Geometry + for (int i = 0; i < AMREX_SPACEDIM; ++i) { HeaderFile << Geom(0).ProbLo(i) << ' '; - } + } HeaderFile << '\n'; for (int i = 0; i < AMREX_SPACEDIM; ++i) { HeaderFile << Geom(0).ProbHi(i) << ' '; - } + } HeaderFile << '\n'; - // BoxArray - for (int lev = 0; lev < nlevels; ++lev) { - boxArray(lev).writeOn(HeaderFile); - HeaderFile << '\n'; - } + // BoxArray + for (int lev = 0; lev < nlevels; ++lev) { + boxArray(lev).writeOn(HeaderFile); + HeaderFile << '\n'; + } - mypc->WriteHeader(HeaderFile); + mypc->WriteHeader(HeaderFile); } } @@ -125,18 +124,18 @@ WarpX::WriteCheckPointFile() const for (int lev = 0; lev < nlevels; ++lev) { - VisMF::Write(*Efield_fp[lev][0], - amrex::MultiFabFileFullPrefix(lev, checkpointname, level_prefix, "Ex_fp")); - VisMF::Write(*Efield_fp[lev][1], - amrex::MultiFabFileFullPrefix(lev, checkpointname, level_prefix, "Ey_fp")); - VisMF::Write(*Efield_fp[lev][2], - amrex::MultiFabFileFullPrefix(lev, checkpointname, level_prefix, "Ez_fp")); - VisMF::Write(*Bfield_fp[lev][0], - amrex::MultiFabFileFullPrefix(lev, checkpointname, level_prefix, "Bx_fp")); - VisMF::Write(*Bfield_fp[lev][1], - amrex::MultiFabFileFullPrefix(lev, checkpointname, level_prefix, "By_fp")); - VisMF::Write(*Bfield_fp[lev][2], - amrex::MultiFabFileFullPrefix(lev, checkpointname, level_prefix, "Bz_fp")); + VisMF::Write(*Efield_fp[lev][0], + amrex::MultiFabFileFullPrefix(lev, checkpointname, level_prefix, "Ex_fp")); + VisMF::Write(*Efield_fp[lev][1], + amrex::MultiFabFileFullPrefix(lev, checkpointname, level_prefix, "Ey_fp")); + VisMF::Write(*Efield_fp[lev][2], + amrex::MultiFabFileFullPrefix(lev, checkpointname, level_prefix, "Ez_fp")); + VisMF::Write(*Bfield_fp[lev][0], + amrex::MultiFabFileFullPrefix(lev, checkpointname, level_prefix, "Bx_fp")); + VisMF::Write(*Bfield_fp[lev][1], + amrex::MultiFabFileFullPrefix(lev, checkpointname, level_prefix, "By_fp")); + VisMF::Write(*Bfield_fp[lev][2], + amrex::MultiFabFileFullPrefix(lev, checkpointname, level_prefix, "Bz_fp")); if (is_synchronized) { // Need to save j if synchronized because after restart we need j to evolve E by dt/2. VisMF::Write(*current_fp[lev][0], @@ -196,108 +195,108 @@ WarpX::InitFromCheckpoint () // Header { - std::string File(restart_chkfile + "/WarpXHeader"); - - VisMF::IO_Buffer io_buffer(VisMF::GetIOBufferSize()); - - Vector fileCharPtr; - ParallelDescriptor::ReadAndBcastFile(File, fileCharPtr); - std::string fileCharPtrString(fileCharPtr.dataPtr()); - std::istringstream is(fileCharPtrString, std::istringstream::in); - - std::string line, word; - - std::getline(is, line); - - int nlevs; - is >> nlevs; - GotoNextLine(is); - finest_level = nlevs-1; - - std::getline(is, line); - { - std::istringstream lis(line); - int i = 0; - while (lis >> word) { - istep[i++] = std::stoi(word); - } - } - - std::getline(is, line); - { - std::istringstream lis(line); - int i = 0; - while (lis >> word) { - nsubsteps[i++] = std::stoi(word); - } - } - - std::getline(is, line); - { - std::istringstream lis(line); - int i = 0; - while (lis >> word) { - t_new[i++] = std::stod(word); - } - } - - std::getline(is, line); - { - std::istringstream lis(line); - int i = 0; - while (lis >> word) { - t_old[i++] = std::stod(word); - } - } - - std::getline(is, line); - { - std::istringstream lis(line); - int i = 0; - while (lis >> word) { - dt[i++] = std::stod(word); - } - } - - is >> moving_window_x; - GotoNextLine(is); + std::string File(restart_chkfile + "/WarpXHeader"); + + VisMF::IO_Buffer io_buffer(VisMF::GetIOBufferSize()); + + Vector fileCharPtr; + ParallelDescriptor::ReadAndBcastFile(File, fileCharPtr); + std::string fileCharPtrString(fileCharPtr.dataPtr()); + std::istringstream is(fileCharPtrString, std::istringstream::in); + + std::string line, word; + + std::getline(is, line); + + int nlevs; + is >> nlevs; + GotoNextLine(is); + finest_level = nlevs-1; + + std::getline(is, line); + { + std::istringstream lis(line); + int i = 0; + while (lis >> word) { + istep[i++] = std::stoi(word); + } + } + + std::getline(is, line); + { + std::istringstream lis(line); + int i = 0; + while (lis >> word) { + nsubsteps[i++] = std::stoi(word); + } + } + + std::getline(is, line); + { + std::istringstream lis(line); + int i = 0; + while (lis >> word) { + t_new[i++] = std::stod(word); + } + } + + std::getline(is, line); + { + std::istringstream lis(line); + int i = 0; + while (lis >> word) { + t_old[i++] = std::stod(word); + } + } + + std::getline(is, line); + { + std::istringstream lis(line); + int i = 0; + while (lis >> word) { + dt[i++] = std::stod(word); + } + } + + is >> moving_window_x; + GotoNextLine(is); is >> is_synchronized; - GotoNextLine(is); - - Real prob_lo[AMREX_SPACEDIM]; - std::getline(is, line); - { - std::istringstream lis(line); - int i = 0; - while (lis >> word) { - prob_lo[i++] = std::stod(word); - } - } - - Real prob_hi[AMREX_SPACEDIM]; - std::getline(is, line); - { - std::istringstream lis(line); - int i = 0; - while (lis >> word) { - prob_hi[i++] = std::stod(word); - } - } + GotoNextLine(is); + + Real prob_lo[AMREX_SPACEDIM]; + std::getline(is, line); + { + std::istringstream lis(line); + int i = 0; + while (lis >> word) { + prob_lo[i++] = std::stod(word); + } + } + + Real prob_hi[AMREX_SPACEDIM]; + std::getline(is, line); + { + std::istringstream lis(line); + int i = 0; + while (lis >> word) { + prob_hi[i++] = std::stod(word); + } + } ResetProbDomain(RealBox(prob_lo,prob_hi)); - for (int lev = 0; lev < nlevs; ++lev) { - BoxArray ba; - ba.readFrom(is); - GotoNextLine(is); - DistributionMapping dm { ba, ParallelDescriptor::NProcs() }; + for (int lev = 0; lev < nlevs; ++lev) { + BoxArray ba; + ba.readFrom(is); + GotoNextLine(is); + DistributionMapping dm { ba, ParallelDescriptor::NProcs() }; SetBoxArray(lev, ba); SetDistributionMap(lev, dm); - AllocLevelData(lev, ba, dm); - } + AllocLevelData(lev, ba, dm); + } - mypc->ReadHeader(is); + mypc->ReadHeader(is); } const int nlevs = finestLevel()+1; @@ -633,43 +632,43 @@ WarpX::WriteJobInfo (const std::string& dir) const { if (ParallelDescriptor::IOProcessor()) { - // job_info file with details about the run - std::ofstream jobInfoFile; - std::string FullPathJobInfoFile = dir; + // job_info file with details about the run + std::ofstream jobInfoFile; + std::string FullPathJobInfoFile = dir; std::string PrettyLine = std::string(78, '=') + "\n"; // std::string OtherLine = std::string(78, '-') + "\n"; // std::string SkipSpace = std::string(8, ' ') + "\n"; - FullPathJobInfoFile += "/warpx_job_info"; - jobInfoFile.open(FullPathJobInfoFile.c_str(), std::ios::out); + FullPathJobInfoFile += "/warpx_job_info"; + jobInfoFile.open(FullPathJobInfoFile.c_str(), std::ios::out); - // job information - jobInfoFile << PrettyLine; - jobInfoFile << " WarpX Job Information\n"; - jobInfoFile << PrettyLine; + // job information + jobInfoFile << PrettyLine; + jobInfoFile << " WarpX Job Information\n"; + jobInfoFile << PrettyLine; - jobInfoFile << "number of MPI processes: " << ParallelDescriptor::NProcs() << "\n"; + jobInfoFile << "number of MPI processes: " << ParallelDescriptor::NProcs() << "\n"; #ifdef _OPENMP - jobInfoFile << "number of threads: " << omp_get_max_threads() << "\n"; + jobInfoFile << "number of threads: " << omp_get_max_threads() << "\n"; #endif - jobInfoFile << "\n\n"; + jobInfoFile << "\n\n"; // build information - jobInfoFile << PrettyLine; - jobInfoFile << " Build Information\n"; - jobInfoFile << PrettyLine; + jobInfoFile << PrettyLine; + jobInfoFile << " Build Information\n"; + jobInfoFile << PrettyLine; - jobInfoFile << "build date: " << buildInfoGetBuildDate() << "\n"; - jobInfoFile << "build machine: " << buildInfoGetBuildMachine() << "\n"; - jobInfoFile << "build dir: " << buildInfoGetBuildDir() << "\n"; - jobInfoFile << "AMReX dir: " << buildInfoGetAMReXDir() << "\n"; + jobInfoFile << "build date: " << buildInfoGetBuildDate() << "\n"; + jobInfoFile << "build machine: " << buildInfoGetBuildMachine() << "\n"; + jobInfoFile << "build dir: " << buildInfoGetBuildDir() << "\n"; + jobInfoFile << "AMReX dir: " << buildInfoGetAMReXDir() << "\n"; - jobInfoFile << "\n"; + jobInfoFile << "\n"; - jobInfoFile << "COMP: " << buildInfoGetComp() << "\n"; - jobInfoFile << "COMP version: " << buildInfoGetCompVersion() << "\n"; + jobInfoFile << "COMP: " << buildInfoGetComp() << "\n"; + jobInfoFile << "COMP version: " << buildInfoGetCompVersion() << "\n"; jobInfoFile << "\n"; @@ -686,64 +685,64 @@ WarpX::WriteJobInfo (const std::string& dir) const jobInfoFile << "Link flags: " << buildInfoGetLinkFlags() << "\n"; jobInfoFile << "Libraries: " << buildInfoGetLibraries() << "\n"; - jobInfoFile << "\n"; + jobInfoFile << "\n"; - const char* githash1 = buildInfoGetGitHash(1); - const char* githash2 = buildInfoGetGitHash(2); - const char* githash3 = buildInfoGetGitHash(3); - if (strlen(githash1) > 0) { - jobInfoFile << "WarpX git describe: " << githash1 << "\n"; - } - if (strlen(githash2) > 0) { - jobInfoFile << "AMReX git describe: " << githash2 << "\n"; - } - if (strlen(githash3) > 0) { - jobInfoFile << "PICSAR git describe: " << githash3 << "\n"; - } + const char* githash1 = buildInfoGetGitHash(1); + const char* githash2 = buildInfoGetGitHash(2); + const char* githash3 = buildInfoGetGitHash(3); + if (strlen(githash1) > 0) { + jobInfoFile << "WarpX git describe: " << githash1 << "\n"; + } + if (strlen(githash2) > 0) { + jobInfoFile << "AMReX git describe: " << githash2 << "\n"; + } + if (strlen(githash3) > 0) { + jobInfoFile << "PICSAR git describe: " << githash3 << "\n"; + } - jobInfoFile << "\n\n"; + jobInfoFile << "\n\n"; - // grid information + // grid information jobInfoFile << PrettyLine; jobInfoFile << " Grid Information\n"; jobInfoFile << PrettyLine; for (int i = 0; i <= finest_level; i++) - { + { jobInfoFile << " level: " << i << "\n"; jobInfoFile << " number of boxes = " << grids[i].size() << "\n"; jobInfoFile << " maximum zones = "; for (int n = 0; n < AMREX_SPACEDIM; n++) - { + { jobInfoFile << geom[i].Domain().length(n) << " "; - } + } jobInfoFile << "\n\n"; - } + } jobInfoFile << " Boundary conditions\n"; jobInfoFile << " -x: " << "interior" << "\n"; jobInfoFile << " +x: " << "interior" << "\n"; if (AMREX_SPACEDIM >= 2) { - jobInfoFile << " -y: " << "interior" << "\n"; - jobInfoFile << " +y: " << "interior" << "\n"; + jobInfoFile << " -y: " << "interior" << "\n"; + jobInfoFile << " +y: " << "interior" << "\n"; } if (AMREX_SPACEDIM == 3) { - jobInfoFile << " -z: " << "interior" << "\n"; - jobInfoFile << " +z: " << "interior" << "\n"; + jobInfoFile << " -z: " << "interior" << "\n"; + jobInfoFile << " +z: " << "interior" << "\n"; } jobInfoFile << "\n\n"; - // runtime parameters - jobInfoFile << PrettyLine; - jobInfoFile << " Inputs File Parameters\n"; - jobInfoFile << PrettyLine; + // runtime parameters + jobInfoFile << PrettyLine; + jobInfoFile << " Inputs File Parameters\n"; + jobInfoFile << PrettyLine; - ParmParse::dumpTable(jobInfoFile, true); + ParmParse::dumpTable(jobInfoFile, true); - jobInfoFile.close(); + jobInfoFile.close(); } } diff --git a/Source/Evolve/WarpXEvolveEM.cpp b/Source/Evolve/WarpXEvolveEM.cpp index a4ed803ee..95e086bbf 100644 --- a/Source/Evolve/WarpXEvolveEM.cpp +++ b/Source/Evolve/WarpXEvolveEM.cpp @@ -183,7 +183,7 @@ WarpX::EvolveEM (int numsteps) } // slice gen // - if (to_make_plot || do_insitu || to_make_slice_plot) + if (to_make_plot || do_insitu || to_make_slice_plot) { FillBoundaryE(); FillBoundaryB(); @@ -199,7 +199,7 @@ WarpX::EvolveEM (int numsteps) last_insitu_step = step+1; if (to_make_plot) - WritePlotFile(); + WritePlotFile(); if (to_make_slice_plot) { @@ -211,7 +211,7 @@ WarpX::EvolveEM (int numsteps) if (do_insitu) UpdateInSitu(); - } + } if (check_int > 0 && (step+1) % check_int == 0) { last_check_file_step = step+1; diff --git a/Source/Evolve/WarpXEvolveES.cpp b/Source/Evolve/WarpXEvolveES.cpp index e1e4a3929..effd6ec96 100644 --- a/Source/Evolve/WarpXEvolveES.cpp +++ b/Source/Evolve/WarpXEvolveES.cpp @@ -61,7 +61,7 @@ WarpX::EvolveES (int numsteps) { for (int step = istep[0]; step < numsteps_max && cur_time < stop_time; ++step) { - // Start loop on time steps + // Start loop on time steps amrex::Print() << "\nSTEP " << step+1 << " starts ...\n"; #ifdef WARPX_USE_PY if (warpx_py_beforestep) warpx_py_beforestep(); @@ -124,36 +124,36 @@ WarpX::EvolveES (int numsteps) { amrex::Print()<< "STEP " << step+1 << " ends." << " TIME = " << cur_time << " DT = " << dt[0] << "\n"; - // sync up time - for (int i = 0; i <= finest_level; ++i) { - t_new[i] = cur_time; - } + // sync up time + for (int i = 0; i <= finest_level; ++i) { + t_new[i] = cur_time; + } - if (to_make_plot) { + if (to_make_plot) { // replace with ES field Gather mypc->DepositCharge(rhoNodal); computePhi(rhoNodal, phiNodal); phiNodal[0]->FillBoundary(Geom(0).periodicity()); computeE(eFieldNodal, phiNodal); mypc->FieldGatherES(eFieldNodal, gather_masks); - last_plot_file_step = step+1; - WritePlotFileES(rhoNodal, phiNodal, eFieldNodal); - } + last_plot_file_step = step+1; + WritePlotFileES(rhoNodal, phiNodal, eFieldNodal); + } - if (check_int > 0 && (step+1) % check_int == 0) { - last_check_file_step = step+1; - WriteCheckPointFile(); - } + if (check_int > 0 && (step+1) % check_int == 0) { + last_check_file_step = step+1; + WriteCheckPointFile(); + } - if (cur_time >= stop_time - 1.e-3*dt[0]) { - max_time_reached = true; - break; - } + if (cur_time >= stop_time - 1.e-3*dt[0]) { + max_time_reached = true; + break; + } #ifdef WARPX_USE_PY if (warpx_py_afterstep) warpx_py_afterstep(); #endif - // End loop on time steps + // End loop on time steps } if (plot_int > 0 && istep[0] > last_plot_file_step && (max_time_reached || istep[0] >= max_step)) { @@ -161,7 +161,7 @@ WarpX::EvolveES (int numsteps) { } if (check_int > 0 && istep[0] > last_check_file_step && (max_time_reached || istep[0] >= max_step)) { - WriteCheckPointFile(); + WriteCheckPointFile(); } } diff --git a/Source/FieldSolver/PicsarHybridSpectralSolver/PicsarHybridSpectralSolver.cpp b/Source/FieldSolver/PicsarHybridSpectralSolver/PicsarHybridSpectralSolver.cpp index 26c93086a..6b7a34271 100644 --- a/Source/FieldSolver/PicsarHybridSpectralSolver/PicsarHybridSpectralSolver.cpp +++ b/Source/FieldSolver/PicsarHybridSpectralSolver/PicsarHybridSpectralSolver.cpp @@ -336,7 +336,7 @@ WarpX::InitFFTDataPlan (int lev) // No FFT patch on this MPI rank (may happen with FFTW) // Still need to call the MPI-FFT initialization routines { - nullfftdata.reset(new FFTData()); + nullfftdata.reset(new FFTData()); warpx_fft_dataplan_init(&nox_fft, &noy_fft, &noz_fft, nullfftdata->data, &FFTData::N, dx_fp.data(), &dt[lev], &fftw_plan_measure, @@ -392,8 +392,8 @@ WarpX::PushPSATD_hybridFFT (int lev, amrex::Real /* dt */) if (Efield_fp_fft[lev][0]->local_size() == 1) //Only one FFT patch on this MPI { - for (MFIter mfi(*Efield_fp_fft[lev][0]); mfi.isValid(); ++mfi) - { + for (MFIter mfi(*Efield_fp_fft[lev][0]); mfi.isValid(); ++mfi) + { warpx_fft_push_eb(WARPX_TO_FORTRAN_ANYD((*Efield_fp_fft[lev][0])[mfi]), WARPX_TO_FORTRAN_ANYD((*Efield_fp_fft[lev][1])[mfi]), WARPX_TO_FORTRAN_ANYD((*Efield_fp_fft[lev][2])[mfi]), @@ -405,29 +405,29 @@ WarpX::PushPSATD_hybridFFT (int lev, amrex::Real /* dt */) WARPX_TO_FORTRAN_ANYD((*current_fp_fft[lev][2])[mfi]), WARPX_TO_FORTRAN_N_ANYD((*rho_fp_fft[lev])[mfi],0), WARPX_TO_FORTRAN_N_ANYD((*rho_fp_fft[lev])[mfi],1)); - } + } } else if (Efield_fp_fft[lev][0]->local_size() == 0) // No FFT patch on this MPI rank // Still need to call the MPI-FFT routine. { - FArrayBox fab(Box(IntVect::TheZeroVector(), IntVect::TheUnitVector())); - warpx_fft_push_eb(WARPX_TO_FORTRAN_ANYD(fab), - WARPX_TO_FORTRAN_ANYD(fab), - WARPX_TO_FORTRAN_ANYD(fab), - WARPX_TO_FORTRAN_ANYD(fab), - WARPX_TO_FORTRAN_ANYD(fab), - WARPX_TO_FORTRAN_ANYD(fab), - WARPX_TO_FORTRAN_ANYD(fab), - WARPX_TO_FORTRAN_ANYD(fab), - WARPX_TO_FORTRAN_ANYD(fab), - WARPX_TO_FORTRAN_ANYD(fab), - WARPX_TO_FORTRAN_ANYD(fab)); + FArrayBox fab(Box(IntVect::TheZeroVector(), IntVect::TheUnitVector())); + warpx_fft_push_eb(WARPX_TO_FORTRAN_ANYD(fab), + WARPX_TO_FORTRAN_ANYD(fab), + WARPX_TO_FORTRAN_ANYD(fab), + WARPX_TO_FORTRAN_ANYD(fab), + WARPX_TO_FORTRAN_ANYD(fab), + WARPX_TO_FORTRAN_ANYD(fab), + WARPX_TO_FORTRAN_ANYD(fab), + WARPX_TO_FORTRAN_ANYD(fab), + WARPX_TO_FORTRAN_ANYD(fab), + WARPX_TO_FORTRAN_ANYD(fab), + WARPX_TO_FORTRAN_ANYD(fab)); } else // Multiple FFT patches on this MPI rank { - amrex::Abort("WarpX::PushPSATD: TODO"); + amrex::Abort("WarpX::PushPSATD: TODO"); } BL_PROFILE_VAR_STOP(blp_push_eb); diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PMLPsatdAlgorithm.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PMLPsatdAlgorithm.H index 50eb5c9b1..80ceb2e93 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PMLPsatdAlgorithm.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PMLPsatdAlgorithm.H @@ -16,9 +16,9 @@ class PMLPsatdAlgorithm : public SpectralBaseAlgorithm const amrex::Real dt); void InitializeSpectralCoefficients( - const SpectralKSpace& spectral_kspace, - const amrex::DistributionMapping& dm, - const amrex::Real dt); + const SpectralKSpace& spectral_kspace, + const amrex::DistributionMapping& dm, + const amrex::Real dt); // Redefine functions from base class virtual void pushSpectralFields(SpectralFieldData& f) const override final; diff --git a/Source/FieldSolver/WarpXPushFieldsEM.cpp b/Source/FieldSolver/WarpXPushFieldsEM.cpp index b3d8e9d76..91641e9da 100644 --- a/Source/FieldSolver/WarpXPushFieldsEM.cpp +++ b/Source/FieldSolver/WarpXPushFieldsEM.cpp @@ -249,17 +249,18 @@ WarpX::EvolveB (int lev, PatchType patch_type, amrex::Real a_dt) const Box& tbz = mfi.tilebox(Bz_nodal_flag); WRPX_PUSH_PML_BVEC( - tbx.loVect(), tbx.hiVect(), - tby.loVect(), tby.hiVect(), - tbz.loVect(), tbz.hiVect(), - BL_TO_FORTRAN_3D((*pml_E[0])[mfi]), - BL_TO_FORTRAN_3D((*pml_E[1])[mfi]), - BL_TO_FORTRAN_3D((*pml_E[2])[mfi]), - BL_TO_FORTRAN_3D((*pml_B[0])[mfi]), - BL_TO_FORTRAN_3D((*pml_B[1])[mfi]), - BL_TO_FORTRAN_3D((*pml_B[2])[mfi]), - &dtsdx, &dtsdy, &dtsdz, - &WarpX::maxwell_fdtd_solver_id); + tbx.loVect(), tbx.hiVect(), + tby.loVect(), tby.hiVect(), + tbz.loVect(), tbz.hiVect(), + BL_TO_FORTRAN_3D((*pml_E[0])[mfi]), + BL_TO_FORTRAN_3D((*pml_E[1])[mfi]), + BL_TO_FORTRAN_3D((*pml_E[2])[mfi]), + BL_TO_FORTRAN_3D((*pml_B[0])[mfi]), + BL_TO_FORTRAN_3D((*pml_B[1])[mfi]), + BL_TO_FORTRAN_3D((*pml_B[2])[mfi]), + &dtsdx, &dtsdy, &dtsdz, + &WarpX::maxwell_fdtd_solver_id + ); } } } @@ -471,16 +472,17 @@ WarpX::EvolveE (int lev, PatchType patch_type, amrex::Real a_dt) auto const& pml_Ezfab = pml_E[2]->array(mfi); WRPX_PUSH_PML_EVEC( - tex.loVect(), tex.hiVect(), - tey.loVect(), tey.hiVect(), - tez.loVect(), tez.hiVect(), - BL_TO_FORTRAN_3D((*pml_E[0])[mfi]), - BL_TO_FORTRAN_3D((*pml_E[1])[mfi]), - BL_TO_FORTRAN_3D((*pml_E[2])[mfi]), - BL_TO_FORTRAN_3D((*pml_B[0])[mfi]), - BL_TO_FORTRAN_3D((*pml_B[1])[mfi]), - BL_TO_FORTRAN_3D((*pml_B[2])[mfi]), - &dtsdx_c2, &dtsdy_c2, &dtsdz_c2); + tex.loVect(), tex.hiVect(), + tey.loVect(), tey.hiVect(), + tez.loVect(), tez.hiVect(), + BL_TO_FORTRAN_3D((*pml_E[0])[mfi]), + BL_TO_FORTRAN_3D((*pml_E[1])[mfi]), + BL_TO_FORTRAN_3D((*pml_E[2])[mfi]), + BL_TO_FORTRAN_3D((*pml_B[0])[mfi]), + BL_TO_FORTRAN_3D((*pml_B[1])[mfi]), + BL_TO_FORTRAN_3D((*pml_B[2])[mfi]), + &dtsdx_c2, &dtsdy_c2, &dtsdz_c2 + ); if (pml_has_particles) { // Update the E field in the PML, using the current @@ -523,15 +525,16 @@ WarpX::EvolveE (int lev, PatchType patch_type, amrex::Real a_dt) if (pml_F) { WRPX_PUSH_PML_EVEC_F( - tex.loVect(), tex.hiVect(), - tey.loVect(), tey.hiVect(), - tez.loVect(), tez.hiVect(), - BL_TO_FORTRAN_3D((*pml_E[0])[mfi]), - BL_TO_FORTRAN_3D((*pml_E[1])[mfi]), - BL_TO_FORTRAN_3D((*pml_E[2])[mfi]), - BL_TO_FORTRAN_3D((*pml_F )[mfi]), - &dtsdx_c2, &dtsdy_c2, &dtsdz_c2, - &WarpX::maxwell_fdtd_solver_id); + tex.loVect(), tex.hiVect(), + tey.loVect(), tey.hiVect(), + tez.loVect(), tez.hiVect(), + BL_TO_FORTRAN_3D((*pml_E[0])[mfi]), + BL_TO_FORTRAN_3D((*pml_E[1])[mfi]), + BL_TO_FORTRAN_3D((*pml_E[2])[mfi]), + BL_TO_FORTRAN_3D((*pml_F )[mfi]), + &dtsdx_c2, &dtsdy_c2, &dtsdz_c2, + &WarpX::maxwell_fdtd_solver_id + ); } } } @@ -606,12 +609,14 @@ WarpX::EvolveF (int lev, PatchType patch_type, Real a_dt, DtType a_dt_type) for ( MFIter mfi(*pml_F, TilingIfNotGPU()); mfi.isValid(); ++mfi ) { const Box& bx = mfi.tilebox(); - WRPX_PUSH_PML_F(bx.loVect(), bx.hiVect(), - BL_TO_FORTRAN_ANYD((*pml_F )[mfi]), - BL_TO_FORTRAN_ANYD((*pml_E[0])[mfi]), - BL_TO_FORTRAN_ANYD((*pml_E[1])[mfi]), - BL_TO_FORTRAN_ANYD((*pml_E[2])[mfi]), - &dtsdx[0], &dtsdx[1], &dtsdx[2]); + WRPX_PUSH_PML_F( + bx.loVect(), bx.hiVect(), + BL_TO_FORTRAN_ANYD((*pml_F )[mfi]), + BL_TO_FORTRAN_ANYD((*pml_E[0])[mfi]), + BL_TO_FORTRAN_ANYD((*pml_E[1])[mfi]), + BL_TO_FORTRAN_ANYD((*pml_E[2])[mfi]), + &dtsdx[0], &dtsdx[1], &dtsdx[2] + ); } } } diff --git a/Source/FortranInterface/WarpX_f.H b/Source/FortranInterface/WarpX_f.H index 825d9effd..4f96d6d08 100644 --- a/Source/FortranInterface/WarpX_f.H +++ b/Source/FortranInterface/WarpX_f.H @@ -70,11 +70,11 @@ extern "C" #endif void warpx_compute_E (const int* lo, const int* hi, - const BL_FORT_FAB_ARG_3D(phi), - BL_FORT_FAB_ARG_3D(Ex), - BL_FORT_FAB_ARG_3D(Ey), - BL_FORT_FAB_ARG_3D(Ez), - const amrex::Real* dx); + const BL_FORT_FAB_ARG_3D(phi), + BL_FORT_FAB_ARG_3D(Ex), + BL_FORT_FAB_ARG_3D(Ey), + BL_FORT_FAB_ARG_3D(Ez), + const amrex::Real* dx); /// /// These functions are used in electrostatic mode. @@ -169,9 +169,9 @@ extern "C" BL_FORT_FAB_ARG_3D(by), BL_FORT_FAB_ARG_3D(bz), const amrex::Real* dtsdx, - const amrex::Real* dtsdy, - const amrex::Real* dtsdz, - const int* maxwell_fdtd_solver_id); + const amrex::Real* dtsdy, + const amrex::Real* dtsdz, + const int* maxwell_fdtd_solver_id); void WRPX_PUSH_PML_EVEC(const int* xlo, const int* xhi, diff --git a/Source/Initialization/PlasmaInjector.cpp b/Source/Initialization/PlasmaInjector.cpp index 4dc16cb63..af04c6b31 100644 --- a/Source/Initialization/PlasmaInjector.cpp +++ b/Source/Initialization/PlasmaInjector.cpp @@ -46,7 +46,7 @@ namespace { } else if (name == "m_p"){ return PhysConst::m_p; } else if (name == "inf"){ - return std::numeric_limits::infinity(); + return std::numeric_limits::infinity(); } else if (pp.query("mass", result)) { return result; } else { diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp index 843773505..9c0cf2fd3 100644 --- a/Source/Initialization/WarpXInitData.cpp +++ b/Source/Initialization/WarpXInitData.cpp @@ -25,11 +25,11 @@ WarpX::InitData () } else { - InitFromCheckpoint(); + InitFromCheckpoint(); if (is_synchronized) { ComputeDt(); } - PostRestart(); + PostRestart(); } ComputePMLFactors(); @@ -87,12 +87,12 @@ WarpX::InitDiagnostics () { const Real* current_hi = geom[0].ProbHi(); Real dt_boost = dt[0]; - // Find the positions of the lab-frame box that corresponds to the boosted-frame box at t=0 - Real zmin_lab = current_lo[moving_window_dir]/( (1.+beta_boost)*gamma_boost ); - Real zmax_lab = current_hi[moving_window_dir]/( (1.+beta_boost)*gamma_boost ); + // Find the positions of the lab-frame box that corresponds to the boosted-frame box at t=0 + Real zmin_lab = current_lo[moving_window_dir]/( (1.+beta_boost)*gamma_boost ); + Real zmax_lab = current_hi[moving_window_dir]/( (1.+beta_boost)*gamma_boost ); myBFD.reset(new BoostedFrameDiagnostic(zmin_lab, - zmax_lab, + zmax_lab, moving_window_v, dt_snapshots_lab, num_snapshots_lab, gamma_boost, t_new[0], dt_boost, @@ -251,9 +251,9 @@ WarpX::InitOpenbc () BoxList bl{IndexType::TheNodeType()}; for (int i = 0; i < nprocs; ++i) { - bl.push_back(Box(IntVect(alllohi[6*i ],alllohi[6*i+1],alllohi[6*i+2]), - IntVect(alllohi[6*i+3],alllohi[6*i+4],alllohi[6*i+5]), - IndexType::TheNodeType())); + bl.push_back(Box(IntVect(alllohi[6*i ],alllohi[6*i+1],alllohi[6*i+2]), + IntVect(alllohi[6*i+3],alllohi[6*i+4],alllohi[6*i+5]), + IndexType::TheNodeType())); } BoxArray ba{bl}; @@ -286,13 +286,13 @@ WarpX::InitOpenbc () #endif for (MFIter mfi(phi); mfi.isValid(); ++mfi) { - const Box& bx = mfi.validbox(); - warpx_compute_E(bx.loVect(), bx.hiVect(), - BL_TO_FORTRAN_3D(phi[mfi]), - BL_TO_FORTRAN_3D((*Efield[lev][0])[mfi]), - BL_TO_FORTRAN_3D((*Efield[lev][1])[mfi]), - BL_TO_FORTRAN_3D((*Efield[lev][2])[mfi]), - dx); + const Box& bx = mfi.validbox(); + warpx_compute_E(bx.loVect(), bx.hiVect(), + BL_TO_FORTRAN_3D(phi[mfi]), + BL_TO_FORTRAN_3D((*Efield[lev][0])[mfi]), + BL_TO_FORTRAN_3D((*Efield[lev][1])[mfi]), + BL_TO_FORTRAN_3D((*Efield[lev][2])[mfi]), + dx); } } #endif @@ -301,9 +301,9 @@ void WarpX::InitLevelData (int lev, Real time) { for (int i = 0; i < 3; ++i) { - current_fp[lev][i]->setVal(0.0); - Efield_fp[lev][i]->setVal(0.0); - Bfield_fp[lev][i]->setVal(0.0); + current_fp[lev][i]->setVal(0.0); + Efield_fp[lev][i]->setVal(0.0); + Bfield_fp[lev][i]->setVal(0.0); } if (lev > 0) { diff --git a/Source/Laser/LaserParticleContainer.cpp b/Source/Laser/LaserParticleContainer.cpp index d0ff51313..ec602a593 100644 --- a/Source/Laser/LaserParticleContainer.cpp +++ b/Source/Laser/LaserParticleContainer.cpp @@ -30,125 +30,125 @@ LaserParticleContainer::LaserParticleContainer (AmrCore* amr_core, int ispecies, ParmParse pp(laser_name); - // Parse the type of laser profile and set the corresponding flag `profile` - std::string laser_type_s; - pp.get("profile", laser_type_s); - std::transform(laser_type_s.begin(), laser_type_s.end(), laser_type_s.begin(), ::tolower); - if (laser_type_s == "gaussian") { - profile = laser_t::Gaussian; + // Parse the type of laser profile and set the corresponding flag `profile` + std::string laser_type_s; + pp.get("profile", laser_type_s); + std::transform(laser_type_s.begin(), laser_type_s.end(), laser_type_s.begin(), ::tolower); + if (laser_type_s == "gaussian") { + profile = laser_t::Gaussian; } else if(laser_type_s == "harris") { profile = laser_t::Harris; } else if(laser_type_s == "parse_field_function") { profile = laser_t::parse_field_function; - } else { - amrex::Abort("Unknown laser type"); - } - - // Parse the properties of the antenna - pp.getarr("position", position); - pp.getarr("direction", nvec); - pp.getarr("polarization", p_X); - pp.query("pusher_algo", pusher_algo); - pp.get("wavelength", wavelength); - pp.get("e_max", e_max); - pp.query("do_continuous_injection", do_continuous_injection); - - if ( profile == laser_t::Gaussian ) { - // Parse the properties of the Gaussian profile - pp.get("profile_waist", profile_waist); - pp.get("profile_duration", profile_duration); - pp.get("profile_t_peak", profile_t_peak); - pp.get("profile_focal_distance", profile_focal_distance); - stc_direction = p_X; - pp.queryarr("stc_direction", stc_direction); - pp.query("zeta", zeta); - pp.query("beta", beta); - pp.query("phi2", phi2); - } - - if ( profile == laser_t::Harris ) { - // Parse the properties of the Harris profile - pp.get("profile_waist", profile_waist); - pp.get("profile_duration", profile_duration); - pp.get("profile_focal_distance", profile_focal_distance); - } + } else { + amrex::Abort("Unknown laser type"); + } - if ( profile == laser_t::parse_field_function ) { - // Parse the properties of the parse_field_function profile - pp.get("field_function(X,Y,t)", field_function); - parser.define(field_function); - parser.registerVariables({"X","Y","t"}); - - ParmParse ppc("my_constants"); - std::set symbols = 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)) { - parser.setConstant(*it, v); - it = symbols.erase(it); - } else { - ++it; - } + // Parse the properties of the antenna + pp.getarr("position", position); + pp.getarr("direction", nvec); + pp.getarr("polarization", p_X); + pp.query("pusher_algo", pusher_algo); + pp.get("wavelength", wavelength); + pp.get("e_max", e_max); + pp.query("do_continuous_injection", do_continuous_injection); + + if ( profile == laser_t::Gaussian ) { + // Parse the properties of the Gaussian profile + pp.get("profile_waist", profile_waist); + pp.get("profile_duration", profile_duration); + pp.get("profile_t_peak", profile_t_peak); + pp.get("profile_focal_distance", profile_focal_distance); + stc_direction = p_X; + pp.queryarr("stc_direction", stc_direction); + pp.query("zeta", zeta); + pp.query("beta", beta); + pp.query("phi2", phi2); } - for (auto const& s : symbols) { // make sure there no unknown symbols - amrex::Abort("Laser Profile: Unknown symbol "+s); + + if ( profile == laser_t::Harris ) { + // Parse the properties of the Harris profile + pp.get("profile_waist", profile_waist); + pp.get("profile_duration", profile_duration); + pp.get("profile_focal_distance", profile_focal_distance); } - } - // Plane normal - Real s = 1.0/std::sqrt(nvec[0]*nvec[0] + nvec[1]*nvec[1] + nvec[2]*nvec[2]); - nvec = { nvec[0]*s, nvec[1]*s, nvec[2]*s }; - - if (WarpX::gamma_boost > 1.) { - // Check that the laser direction is equal to the boost direction - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( nvec[0]*WarpX::boost_direction[0] - + nvec[1]*WarpX::boost_direction[1] - + nvec[2]*WarpX::boost_direction[2] - 1. < 1.e-12, - "The Lorentz boost should be in the same direction as the laser propagation"); - // Get the position of the plane, along the boost direction, in the lab frame - // and convert the position of the antenna to the boosted frame - Z0_lab = nvec[0]*position[0] + nvec[1]*position[1] + nvec[2]*position[2]; - Real Z0_boost = Z0_lab/WarpX::gamma_boost; - position[0] += (Z0_boost-Z0_lab)*nvec[0]; - position[1] += (Z0_boost-Z0_lab)*nvec[1]; - position[2] += (Z0_boost-Z0_lab)*nvec[2]; - } + if ( profile == laser_t::parse_field_function ) { + // Parse the properties of the parse_field_function profile + pp.get("field_function(X,Y,t)", field_function); + parser.define(field_function); + parser.registerVariables({"X","Y","t"}); + + ParmParse ppc("my_constants"); + std::set symbols = 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)) { + 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); + } + } + + // Plane normal + Real s = 1.0/std::sqrt(nvec[0]*nvec[0] + nvec[1]*nvec[1] + nvec[2]*nvec[2]); + nvec = { nvec[0]*s, nvec[1]*s, nvec[2]*s }; + + if (WarpX::gamma_boost > 1.) { + // Check that the laser direction is equal to the boost direction + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( nvec[0]*WarpX::boost_direction[0] + + nvec[1]*WarpX::boost_direction[1] + + nvec[2]*WarpX::boost_direction[2] - 1. < 1.e-12, + "The Lorentz boost should be in the same direction as the laser propagation"); + // Get the position of the plane, along the boost direction, in the lab frame + // and convert the position of the antenna to the boosted frame + Z0_lab = nvec[0]*position[0] + nvec[1]*position[1] + nvec[2]*position[2]; + Real Z0_boost = Z0_lab/WarpX::gamma_boost; + position[0] += (Z0_boost-Z0_lab)*nvec[0]; + position[1] += (Z0_boost-Z0_lab)*nvec[1]; + position[2] += (Z0_boost-Z0_lab)*nvec[2]; + } - // The first polarization vector - s = 1.0/std::sqrt(p_X[0]*p_X[0] + p_X[1]*p_X[1] + p_X[2]*p_X[2]); - p_X = { p_X[0]*s, p_X[1]*s, p_X[2]*s }; + // The first polarization vector + s = 1.0/std::sqrt(p_X[0]*p_X[0] + p_X[1]*p_X[1] + p_X[2]*p_X[2]); + p_X = { p_X[0]*s, p_X[1]*s, p_X[2]*s }; - Real dp = std::inner_product(nvec.begin(), nvec.end(), p_X.begin(), 0.0); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(std::abs(dp) < 1.0e-14, - "Laser plane vector is not perpendicular to the main polarization vector"); + Real dp = std::inner_product(nvec.begin(), nvec.end(), p_X.begin(), 0.0); + AMREX_ALWAYS_ASSERT_WITH_MESSAGE(std::abs(dp) < 1.0e-14, + "Laser plane vector is not perpendicular to the main polarization vector"); - p_Y = CrossProduct(nvec, p_X); // The second polarization vector + p_Y = CrossProduct(nvec, p_X); // The second polarization vector - s = 1.0/std::sqrt(stc_direction[0]*stc_direction[0] + stc_direction[1]*stc_direction[1] + stc_direction[2]*stc_direction[2]); - stc_direction = { stc_direction[0]*s, stc_direction[1]*s, stc_direction[2]*s }; - dp = std::inner_product(nvec.begin(), nvec.end(), stc_direction.begin(), 0.0); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(std::abs(dp) < 1.0e-14, - "stc_direction is not perpendicular to the laser plane vector"); + s = 1.0/std::sqrt(stc_direction[0]*stc_direction[0] + stc_direction[1]*stc_direction[1] + stc_direction[2]*stc_direction[2]); + stc_direction = { stc_direction[0]*s, stc_direction[1]*s, stc_direction[2]*s }; + dp = std::inner_product(nvec.begin(), nvec.end(), stc_direction.begin(), 0.0); + AMREX_ALWAYS_ASSERT_WITH_MESSAGE(std::abs(dp) < 1.0e-14, + "stc_direction is not perpendicular to the laser plane vector"); - // Get angle between p_X and stc_direction - // in 2d, stcs are in the simulation plane + // Get angle between p_X and stc_direction + // in 2d, stcs are in the simulation plane #if AMREX_SPACEDIM == 3 - theta_stc = acos(stc_direction[0]*p_X[0] + + theta_stc = acos(stc_direction[0]*p_X[0] + stc_direction[1]*p_X[1] + stc_direction[2]*p_X[2]); #else - theta_stc = 0.; + theta_stc = 0.; #endif #if AMREX_SPACEDIM == 3 - u_X = p_X; - u_Y = p_Y; + u_X = p_X; + u_Y = p_Y; #else - u_X = CrossProduct({0., 1., 0.}, nvec); - u_Y = {0., 1., 0.}; + u_X = CrossProduct({0., 1., 0.}, nvec); + u_Y = {0., 1., 0.}; #endif laser_injection_box= Geom(0).ProbDomain(); @@ -327,19 +327,19 @@ LaserParticleContainer::InitData (int lev) IntVect(plane_hi[0],plane_hi[1],0)}; BoxArray plane_ba {plane_box}; { - IntVect chunk(plane_box.size()); - const int min_size = 8; - while (plane_ba.size() < nprocs && chunk[0] > min_size && chunk[1] > min_size) - { - for (int j = 1; j >= 0 ; j--) - { - chunk[j] /= 2; - - if (plane_ba.size() < nprocs) { - plane_ba.maxSize(chunk); - } - } - } + IntVect chunk(plane_box.size()); + const int min_size = 8; + while (plane_ba.size() < nprocs && chunk[0] > min_size && chunk[1] > min_size) + { + for (int j = 1; j >= 0 ; j--) + { + chunk[j] /= 2; + + if (plane_ba.size() < nprocs) { + plane_ba.maxSize(chunk); + } + } + } } #else BoxArray plane_ba { Box {IntVect(plane_lo[0],0), IntVect(plane_hi[0],0)} }; @@ -351,29 +351,29 @@ LaserParticleContainer::InitData (int lev) const Vector& procmap = plane_dm.ProcessorMap(); for (int i = 0, n = plane_ba.size(); i < n; ++i) { - if (procmap[i] == myproc) - { - const Box& bx = plane_ba[i]; - for (IntVect cell = bx.smallEnd(); cell <= bx.bigEnd(); bx.next(cell)) - { - const Vector& pos = Transform(cell[0], cell[1]); + if (procmap[i] == myproc) + { + const Box& bx = plane_ba[i]; + for (IntVect cell = bx.smallEnd(); cell <= bx.bigEnd(); bx.next(cell)) + { + const Vector& pos = Transform(cell[0], cell[1]); #if (AMREX_SPACEDIM == 3) - const Real* x = pos.dataPtr(); + const Real* x = pos.dataPtr(); #else - const Real x[2] = {pos[0], pos[2]}; + const Real x[2] = {pos[0], pos[2]}; #endif - if (laser_injection_box.contains(x)) - { - for (int k = 0; k<2; ++k) { - particle_x.push_back(pos[0]); - particle_y.push_back(pos[1]); - particle_z.push_back(pos[2]); + if (laser_injection_box.contains(x)) + { + for (int k = 0; k<2; ++k) { + particle_x.push_back(pos[0]); + particle_y.push_back(pos[1]); + particle_z.push_back(pos[2]); + } + particle_w.push_back( weight); + particle_w.push_back(-weight); } - particle_w.push_back( weight); - particle_w.push_back(-weight); } - } - } + } } const int np = particle_z.size(); RealVector particle_ux(np, 0.0); diff --git a/Source/Parallelization/WarpXComm.cpp b/Source/Parallelization/WarpXComm.cpp index 93fc12799..ea939cef3 100644 --- a/Source/Parallelization/WarpXComm.cpp +++ b/Source/Parallelization/WarpXComm.cpp @@ -252,12 +252,12 @@ WarpX::FillBoundaryE (int lev, PatchType patch_type) { if (do_pml && pml[lev]->ok()) { - pml[lev]->ExchangeE(patch_type, + pml[lev]->ExchangeE(patch_type, { Efield_fp[lev][0].get(), Efield_fp[lev][1].get(), Efield_fp[lev][2].get() }, do_pml_in_domain); - pml[lev]->FillBoundaryE(patch_type); + pml[lev]->FillBoundaryE(patch_type); } const auto& period = Geom(lev).periodicity(); @@ -296,7 +296,7 @@ WarpX::FillBoundaryB (int lev, PatchType patch_type) { if (do_pml && pml[lev]->ok()) { - pml[lev]->ExchangeB(patch_type, + pml[lev]->ExchangeB(patch_type, { Bfield_fp[lev][0].get(), Bfield_fp[lev][1].get(), Bfield_fp[lev][2].get() }, diff --git a/Source/Parallelization/WarpXRegrid.cpp b/Source/Parallelization/WarpXRegrid.cpp index c737591c7..5441755f5 100644 --- a/Source/Parallelization/WarpXRegrid.cpp +++ b/Source/Parallelization/WarpXRegrid.cpp @@ -18,7 +18,7 @@ WarpX::LoadBalance () const Real nprocs = ParallelDescriptor::NProcs(); const int nmax = static_cast(std::ceil(nboxes/nprocs*load_balance_knapsack_factor)); const DistributionMapping newdm = (load_balance_with_sfc) - ? DistributionMapping::makeSFC(*costs[lev], false) + ? DistributionMapping::makeSFC(*costs[lev], false) : DistributionMapping::makeKnapSack(*costs[lev], nmax); RemakeLevel(lev, t_new[lev], boxArray(lev), newdm); } diff --git a/Source/Particles/MultiParticleContainer.H b/Source/Particles/MultiParticleContainer.H index ac261b177..2b18e174d 100644 --- a/Source/Particles/MultiParticleContainer.H +++ b/Source/Particles/MultiParticleContainer.H @@ -31,7 +31,7 @@ public: ~MultiParticleContainer() {} WarpXParticleContainer& GetParticleContainer (int ispecies) { - return *allcontainers[ispecies]; + return *allcontainers[ispecies]; } std::array meanParticleVelocity(int ispecies) { @@ -95,13 +95,13 @@ public: /// This is the electromagnetic version. /// void Evolve (int lev, - const amrex::MultiFab& Ex, const amrex::MultiFab& Ey, const amrex::MultiFab& Ez, - const amrex::MultiFab& Bx, const amrex::MultiFab& By, const amrex::MultiFab& Bz, - amrex::MultiFab& jx, amrex::MultiFab& jy, amrex::MultiFab& jz, - amrex::MultiFab* cjx, amrex::MultiFab* cjy, amrex::MultiFab* cjz, + const amrex::MultiFab& Ex, const amrex::MultiFab& Ey, const amrex::MultiFab& Ez, + const amrex::MultiFab& Bx, const amrex::MultiFab& By, const amrex::MultiFab& Bz, + amrex::MultiFab& jx, amrex::MultiFab& jy, amrex::MultiFab& jz, + amrex::MultiFab* cjx, amrex::MultiFab* cjy, amrex::MultiFab* cjz, amrex::MultiFab* rho, amrex::MultiFab* crho, - const amrex::MultiFab* cEx, const amrex::MultiFab* cEy, const amrex::MultiFab* cEz, - const amrex::MultiFab* cBx, const amrex::MultiFab* cBy, const amrex::MultiFab* cBz, + const amrex::MultiFab* cEx, const amrex::MultiFab* cEy, const amrex::MultiFab* cEz, + const amrex::MultiFab* cBx, const amrex::MultiFab* cBy, const amrex::MultiFab* cBz, amrex::Real t, amrex::Real dt); /// diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 612583e2f..d5ad7a366 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -239,8 +239,8 @@ MultiParticleContainer::Evolve (int lev, if (rho) rho->setVal(0.0); if (crho) crho->setVal(0.0); for (auto& pc : allcontainers) { - pc->Evolve(lev, Ex, Ey, Ez, Bx, By, Bz, jx, jy, jz, cjx, cjy, cjz, - rho, crho, cEx, cEy, cEz, cBx, cBy, cBz, t, dt); + pc->Evolve(lev, Ex, Ey, Ez, Bx, By, Bz, jx, jy, jz, cjx, cjy, cjz, + rho, crho, cEx, cEy, cEz, cBx, cBy, cBz, t, dt); } } diff --git a/Source/Particles/PhysicalParticleContainer.H b/Source/Particles/PhysicalParticleContainer.H index 7946b4650..529bffab1 100644 --- a/Source/Particles/PhysicalParticleContainer.H +++ b/Source/Particles/PhysicalParticleContainer.H @@ -62,13 +62,13 @@ public: int depos_lev); virtual void Evolve (int lev, - const amrex::MultiFab& Ex, + const amrex::MultiFab& Ex, const amrex::MultiFab& Ey, const amrex::MultiFab& Ez, - const amrex::MultiFab& Bx, + const amrex::MultiFab& Bx, const amrex::MultiFab& By, const amrex::MultiFab& Bz, - amrex::MultiFab& jx, + amrex::MultiFab& jx, amrex::MultiFab& jy, amrex::MultiFab& jz, amrex::MultiFab* cjx, @@ -86,7 +86,7 @@ public: amrex::Real dt) override; virtual void PushPX(WarpXParIter& pti, - amrex::Cuda::ManagedDeviceVector& xp, + amrex::Cuda::ManagedDeviceVector& xp, amrex::Cuda::ManagedDeviceVector& yp, amrex::Cuda::ManagedDeviceVector& zp, amrex::Cuda::ManagedDeviceVector& giv, diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 99c6973f9..0b82df7b5 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -455,8 +455,8 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox) std::size_t shared_mem_bytes = plasma_injector->sharedMemoryNeeded(); int lrrfac = rrfac; - bool loc_do_field_ionization = do_field_ionization; - int loc_ionization_initial_level = ionization_initial_level; + bool loc_do_field_ionization = do_field_ionization; + int loc_ionization_initial_level = ionization_initial_level; // Loop over all new particles and inject them (creates too many // particles, in particular does not consider xmin, xmax etc.). @@ -1501,13 +1501,13 @@ PhysicalParticleContainer::SplitParticles(int lev) } } } - // Add local arrays psplit_x etc. to the temporary - // particle container pctmp_split. Split particles - // are tagged with p.id()=NoSplitParticleID so that - // they are not re-split when entering a higher level - // AddNParticles calls Redistribute, so that particles - // in pctmp_split are in the proper grids and tiles - pctmp_split.AddNParticles(lev, + // Add local arrays psplit_x etc. to the temporary + // particle container pctmp_split. Split particles + // are tagged with p.id()=NoSplitParticleID so that + // they are not re-split when entering a higher level + // AddNParticles calls Redistribute, so that particles + // in pctmp_split are in the proper grids and tiles + pctmp_split.AddNParticles(lev, np_split_to_add, psplit_x.dataPtr(), psplit_y.dataPtr(), @@ -1518,9 +1518,9 @@ PhysicalParticleContainer::SplitParticles(int lev) 1, psplit_w.dataPtr(), 1, NoSplitParticleID); - // Copy particles from tmp to current particle container + // Copy particles from tmp to current particle container addParticles(pctmp_split,1); - // Clear tmp container + // Clear tmp container pctmp_split.clearParticles(); } diff --git a/Source/Particles/WarpXParticleContainer.H b/Source/Particles/WarpXParticleContainer.H index 06540871b..4411436fa 100644 --- a/Source/Particles/WarpXParticleContainer.H +++ b/Source/Particles/WarpXParticleContainer.H @@ -11,12 +11,12 @@ enum struct ConvertDirection{WarpX_to_SI, SI_to_WarpX}; struct PIdx { enum { // Particle Attributes stored in amrex::ParticleContainer's struct of array - w = 0, // weight - ux, uy, uz, Ex, Ey, Ez, Bx, By, Bz, + w = 0, // weight + ux, uy, uz, Ex, Ey, Ez, Bx, By, Bz, #ifdef WARPX_DIM_RZ theta, // RZ needs all three position components #endif - nattribs + nattribs }; }; @@ -131,9 +131,9 @@ public: #endif // WARPX_DO_ELECTROSTATIC virtual void Evolve (int lev, - const amrex::MultiFab& Ex, const amrex::MultiFab& Ey, const amrex::MultiFab& Ez, - const amrex::MultiFab& Bx, const amrex::MultiFab& By, const amrex::MultiFab& Bz, - amrex::MultiFab& jx, amrex::MultiFab& jy, amrex::MultiFab& jz, + const amrex::MultiFab& Ex, const amrex::MultiFab& Ey, const amrex::MultiFab& Ez, + const amrex::MultiFab& Bx, const amrex::MultiFab& By, const amrex::MultiFab& Bz, + amrex::MultiFab& jx, amrex::MultiFab& jy, amrex::MultiFab& jz, amrex::MultiFab* cjx, amrex::MultiFab* cjy, amrex::MultiFab* cjz, amrex::MultiFab* rho, amrex::MultiFab* crho, const amrex::MultiFab* cEx, const amrex::MultiFab* cEy, const amrex::MultiFab* cEz, @@ -231,8 +231,8 @@ public: void AddNParticles (int lev, int n, const amrex::Real* x, const amrex::Real* y, const amrex::Real* z, - const amrex::Real* vx, const amrex::Real* vy, const amrex::Real* vz, - int nattr, const amrex::Real* attr, int uniqueparticles, int id=-1); + const amrex::Real* vx, const amrex::Real* vy, const amrex::Real* vz, + int nattr, const amrex::Real* attr, int uniqueparticles, int id=-1); void AddOneParticle (int lev, int grid, int tile, amrex::Real x, amrex::Real y, amrex::Real z, diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp index 83de9fb0e..6de7a6011 100644 --- a/Source/Particles/WarpXParticleContainer.cpp +++ b/Source/Particles/WarpXParticleContainer.cpp @@ -108,7 +108,7 @@ WarpXParticleContainer::ReadParameters () static bool initialized = false; if (!initialized) { - ParmParse pp("particles"); + ParmParse pp("particles"); #ifdef AMREX_USE_GPU do_tiling = false; // By default, tiling is off on GPU @@ -118,7 +118,7 @@ WarpXParticleContainer::ReadParameters () pp.query("do_tiling", do_tiling); pp.query("do_not_push", do_not_push); - initialized = true; + initialized = true; } } @@ -168,28 +168,28 @@ WarpXParticleContainer::AddOneParticle (ParticleTileType& particle_tile, void WarpXParticleContainer::AddNParticles (int lev, int n, const Real* x, const Real* y, const Real* z, - const Real* vx, const Real* vy, const Real* vz, - int nattr, const Real* attr, int uniqueparticles, int id) + const Real* vx, const Real* vy, const Real* vz, + int nattr, const Real* attr, int uniqueparticles, int id) { BL_ASSERT(nattr == 1); const Real* weight = attr; int ibegin, iend; if (uniqueparticles) { - ibegin = 0; - iend = n; + ibegin = 0; + iend = n; } else { - int myproc = ParallelDescriptor::MyProc(); - int nprocs = ParallelDescriptor::NProcs(); - int navg = n/nprocs; - int nleft = n - navg * nprocs; - if (myproc < nleft) { - ibegin = myproc*(navg+1); - iend = ibegin + navg+1; - } else { - ibegin = myproc*navg + nleft; - iend = ibegin + navg; - } + int myproc = ParallelDescriptor::MyProc(); + int nprocs = ParallelDescriptor::NProcs(); + int navg = n/nprocs; + int nleft = n - navg * nprocs; + if (myproc < nleft) { + ibegin = myproc*(navg+1); + iend = ibegin + navg+1; + } else { + ibegin = myproc*navg + nleft; + iend = ibegin + navg; + } } // Add to grid 0 and tile 0 @@ -206,12 +206,12 @@ WarpXParticleContainer::AddNParticles (int lev, for (int i = ibegin; i < iend; ++i) { ParticleType p; - if (id==-1) - { - p.id() = ParticleType::NextID(); - } else { - p.id() = id; - } + if (id==-1) + { + p.id() = ParticleType::NextID(); + } else { + p.id() = id; + } p.cpu() = ParallelDescriptor::MyProc(); #if (AMREX_SPACEDIM == 3) p.pos(0) = x[i]; diff --git a/Source/Python/WarpXWrappers.cpp b/Source/Python/WarpXWrappers.cpp index b59f80495..c6d7dfdb8 100644 --- a/Source/Python/WarpXWrappers.cpp +++ b/Source/Python/WarpXWrappers.cpp @@ -55,18 +55,18 @@ extern "C" int warpx_nSpecies() { - auto & mypc = WarpX::GetInstance().GetPartContainer(); + auto & mypc = WarpX::GetInstance().GetPartContainer(); return mypc.nSpecies(); } bool warpx_use_fdtd_nci_corr() { - return WarpX::use_fdtd_nci_corr; + return WarpX::use_fdtd_nci_corr; } int warpx_l_lower_order_in_v() { - return WarpX::l_lower_order_in_v; + return WarpX::l_lower_order_in_v; } int warpx_nComps() @@ -81,32 +81,32 @@ extern "C" void amrex_init (int argc, char* argv[]) { - amrex::Initialize(argc,argv); + amrex::Initialize(argc,argv); } #ifdef BL_USE_MPI void amrex_init_with_inited_mpi (int argc, char* argv[], MPI_Comm mpicomm) { - amrex::Initialize(argc,argv,true,mpicomm); + amrex::Initialize(argc,argv,true,mpicomm); } #endif void amrex_finalize (int finalize_mpi) { - amrex::Finalize(); + amrex::Finalize(); } void warpx_init () { - WarpX& warpx = WarpX::GetInstance(); - warpx.InitData(); + WarpX& warpx = WarpX::GetInstance(); + warpx.InitData(); if (warpx_py_afterinit) warpx_py_afterinit(); if (warpx_py_particleloader) warpx_py_particleloader(); } void warpx_finalize () { - WarpX::ResetInstance(); + WarpX::ResetInstance(); } void warpx_set_callback_py_afterinit (WARPX_CALLBACK_PY_FUNC_0 callback) @@ -160,8 +160,8 @@ extern "C" void warpx_evolve (int numsteps) { - WarpX& warpx = WarpX::GetInstance(); - warpx.Evolve(numsteps); + WarpX& warpx = WarpX::GetInstance(); + warpx.Evolve(numsteps); } void warpx_addNParticles(int speciesnumber, int lenx, @@ -169,10 +169,10 @@ extern "C" double* vx, double* vy, double* vz, int nattr, double* attr, int uniqueparticles) { - auto & mypc = WarpX::GetInstance().GetPartContainer(); - auto & myspc = mypc.GetParticleContainer(speciesnumber); + auto & mypc = WarpX::GetInstance().GetPartContainer(); + auto & myspc = mypc.GetParticleContainer(speciesnumber); const int lev = 0; - myspc.AddNParticles(lev, lenx, x, y, z, vx, vy, vz, nattr, attr, uniqueparticles); + myspc.AddNParticles(lev, lenx, x, y, z, vx, vy, vz, nattr, attr, uniqueparticles); } void warpx_ConvertLabParamsToBoost() @@ -444,7 +444,7 @@ extern "C" } void mypc_Redistribute () { - auto & mypc = WarpX::GetInstance().GetPartContainer(); + auto & mypc = WarpX::GetInstance().GetPartContainer(); mypc.Redistribute(); } diff --git a/Source/WarpX.H b/Source/WarpX.H index 7131355d2..0cfd9c623 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -300,20 +300,20 @@ protected: //! DistributionMapping. Only used during initialization. Called //! by AmrCoreInitFromScratch. virtual void MakeNewLevelFromScratch (int lev, amrex::Real time, const amrex::BoxArray& ba, - const amrex::DistributionMapping& dm) final; + const amrex::DistributionMapping& dm) final; //! Make a new level using provided BoxArray and //! DistributionMapping and fill with interpolated coarse level //! data. Called by AmrCore::regrid. virtual void MakeNewLevelFromCoarse (int lev, amrex::Real time, const amrex::BoxArray& ba, - const amrex::DistributionMapping& dm) final + const amrex::DistributionMapping& dm) final { amrex::Abort("MakeNewLevelFromCoarse: To be implemented"); } //! Remake an existing level using provided BoxArray and //! DistributionMapping and fill with existing fine and coarse //! data. Called by AmrCore::regrid. virtual void RemakeLevel (int lev, amrex::Real time, const amrex::BoxArray& ba, - const amrex::DistributionMapping& dm) final; + const amrex::DistributionMapping& dm) final; //! Delete level data. Called by AmrCore::regrid. virtual void ClearLevel (int lev) final; diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index e57d833c8..d2ccc71ef 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -112,7 +112,7 @@ WarpX& WarpX::GetInstance () { if (!m_instance) { - m_instance = new WarpX(); + m_instance = new WarpX(); } return *m_instance; } @@ -142,7 +142,7 @@ WarpX::WarpX () #if 0 // no subcycling yet for (int lev = 1; lev <= maxLevel(); ++lev) { - nsubsteps[lev] = MaxRefRatio(lev-1); + nsubsteps[lev] = MaxRefRatio(lev-1); } #endif @@ -251,142 +251,142 @@ void WarpX::ReadParameters () { { - ParmParse pp; // Traditionally, max_step and stop_time do not have prefix. - pp.query("max_step", max_step); - pp.query("stop_time", stop_time); + ParmParse pp; // Traditionally, max_step and stop_time do not have prefix. + pp.query("max_step", max_step); + pp.query("stop_time", stop_time); } { - ParmParse pp("amr"); // Traditionally, these have prefix, amr. + ParmParse pp("amr"); // Traditionally, these have prefix, amr. - pp.query("check_file", check_file); - pp.query("check_int", check_int); + pp.query("check_file", check_file); + pp.query("check_int", check_int); - pp.query("plot_file", plot_file); - pp.query("plot_int", plot_int); + pp.query("plot_file", plot_file); + pp.query("plot_int", plot_int); - pp.query("restart", restart_chkfile); + pp.query("restart", restart_chkfile); } { - ParmParse pp("warpx"); + ParmParse pp("warpx"); - pp.query("cfl", cfl); - pp.query("verbose", verbose); - pp.query("regrid_int", regrid_int); + pp.query("cfl", cfl); + pp.query("verbose", verbose); + pp.query("regrid_int", regrid_int); pp.query("do_subcycling", do_subcycling); pp.query("override_sync_int", override_sync_int); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(do_subcycling != 1 || max_level <= 1, - "Subcycling method 1 only works for 2 levels."); + AMREX_ALWAYS_ASSERT_WITH_MESSAGE(do_subcycling != 1 || max_level <= 1, + "Subcycling method 1 only works for 2 levels."); - ReadBoostedFrameParameters(gamma_boost, beta_boost, boost_direction); + ReadBoostedFrameParameters(gamma_boost, beta_boost, boost_direction); - // pp.query returns 1 if argument zmax_plasma_to_compute_max_step is - // specified by the user, 0 otherwise. - do_compute_max_step_from_zmax = - pp.query("zmax_plasma_to_compute_max_step", - zmax_plasma_to_compute_max_step); + // pp.query returns 1 if argument zmax_plasma_to_compute_max_step is + // specified by the user, 0 otherwise. + do_compute_max_step_from_zmax = + pp.query("zmax_plasma_to_compute_max_step", + zmax_plasma_to_compute_max_step); - pp.queryarr("B_external", B_external); + pp.queryarr("B_external", B_external); - pp.query("do_moving_window", do_moving_window); - if (do_moving_window) - { - std::string s; - pp.get("moving_window_dir", s); - if (s == "x" || s == "X") { - moving_window_dir = 0; - } + pp.query("do_moving_window", do_moving_window); + if (do_moving_window) + { + std::string s; + pp.get("moving_window_dir", s); + if (s == "x" || s == "X") { + moving_window_dir = 0; + } #if (AMREX_SPACEDIM == 3) - else if (s == "y" || s == "Y") { - moving_window_dir = 1; - } + else if (s == "y" || s == "Y") { + moving_window_dir = 1; + } #endif - else if (s == "z" || s == "Z") { - moving_window_dir = AMREX_SPACEDIM-1; - } - else { - const std::string msg = "Unknown moving_window_dir: "+s; - amrex::Abort(msg.c_str()); - } - - moving_window_x = geom[0].ProbLo(moving_window_dir); - - pp.get("moving_window_v", moving_window_v); - moving_window_v *= PhysConst::c; - } - - pp.query("do_boosted_frame_diagnostic", do_boosted_frame_diagnostic); - if (do_boosted_frame_diagnostic) { - - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(gamma_boost > 1.0, - "gamma_boost must be > 1 to use the boosted frame diagnostic."); - - pp.query("lab_data_directory", lab_data_directory); - - std::string s; - pp.get("boost_direction", s); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( (s == "z" || s == "Z"), - "The boosted frame diagnostic currently only works if the boost is in the z direction."); - - pp.get("num_snapshots_lab", num_snapshots_lab); - - // Read either dz_snapshots_lab or dt_snapshots_lab - bool snapshot_interval_is_specified = 0; - Real dz_snapshots_lab = 0; - snapshot_interval_is_specified += pp.query("dt_snapshots_lab", dt_snapshots_lab); - if ( pp.query("dz_snapshots_lab", dz_snapshots_lab) ){ - dt_snapshots_lab = dz_snapshots_lab/PhysConst::c; - snapshot_interval_is_specified = 1; + else if (s == "z" || s == "Z") { + moving_window_dir = AMREX_SPACEDIM-1; + } + else { + const std::string msg = "Unknown moving_window_dir: "+s; + amrex::Abort(msg.c_str()); + } + + moving_window_x = geom[0].ProbLo(moving_window_dir); + + pp.get("moving_window_v", moving_window_v); + moving_window_v *= PhysConst::c; } - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( - snapshot_interval_is_specified, - "When using back-transformed diagnostics, user should specify either dz_snapshots_lab or dt_snapshots_lab."); - pp.get("gamma_boost", gamma_boost); + pp.query("do_boosted_frame_diagnostic", do_boosted_frame_diagnostic); + if (do_boosted_frame_diagnostic) { - pp.query("do_boosted_frame_fields", do_boosted_frame_fields); + AMREX_ALWAYS_ASSERT_WITH_MESSAGE(gamma_boost > 1.0, + "gamma_boost must be > 1 to use the boosted frame diagnostic."); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(do_moving_window, - "The moving window should be on if using the boosted frame diagnostic."); + pp.query("lab_data_directory", lab_data_directory); - pp.get("moving_window_dir", s); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( (s == "z" || s == "Z"), - "The boosted frame diagnostic currently only works if the moving window is in the z direction."); - } + std::string s; + pp.get("boost_direction", s); + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( (s == "z" || s == "Z"), + "The boosted frame diagnostic currently only works if the boost is in the z direction."); - pp.query("do_electrostatic", do_electrostatic); - pp.query("n_buffer", n_buffer); - pp.query("const_dt", const_dt); - - // Read filter and fill IntVect filter_npass_each_dir with - // proper size for AMREX_SPACEDIM - pp.query("use_filter", use_filter); - Vector parse_filter_npass_each_dir(AMREX_SPACEDIM,1); - pp.queryarr("filter_npass_each_dir", parse_filter_npass_each_dir); - filter_npass_each_dir[0] = parse_filter_npass_each_dir[0]; - filter_npass_each_dir[1] = parse_filter_npass_each_dir[1]; + pp.get("num_snapshots_lab", num_snapshots_lab); + + // Read either dz_snapshots_lab or dt_snapshots_lab + bool snapshot_interval_is_specified = 0; + Real dz_snapshots_lab = 0; + snapshot_interval_is_specified += pp.query("dt_snapshots_lab", dt_snapshots_lab); + if ( pp.query("dz_snapshots_lab", dz_snapshots_lab) ){ + dt_snapshots_lab = dz_snapshots_lab/PhysConst::c; + snapshot_interval_is_specified = 1; + } + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( + snapshot_interval_is_specified, + "When using back-transformed diagnostics, user should specify either dz_snapshots_lab or dt_snapshots_lab."); + + pp.get("gamma_boost", gamma_boost); + + pp.query("do_boosted_frame_fields", do_boosted_frame_fields); + + AMREX_ALWAYS_ASSERT_WITH_MESSAGE(do_moving_window, + "The moving window should be on if using the boosted frame diagnostic."); + + pp.get("moving_window_dir", s); + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( (s == "z" || s == "Z"), + "The boosted frame diagnostic currently only works if the moving window is in the z direction."); + } + + pp.query("do_electrostatic", do_electrostatic); + pp.query("n_buffer", n_buffer); + pp.query("const_dt", const_dt); + + // Read filter and fill IntVect filter_npass_each_dir with + // proper size for AMREX_SPACEDIM + pp.query("use_filter", use_filter); + Vector parse_filter_npass_each_dir(AMREX_SPACEDIM,1); + pp.queryarr("filter_npass_each_dir", parse_filter_npass_each_dir); + filter_npass_each_dir[0] = parse_filter_npass_each_dir[0]; + filter_npass_each_dir[1] = parse_filter_npass_each_dir[1]; #if (AMREX_SPACEDIM == 3) - filter_npass_each_dir[2] = parse_filter_npass_each_dir[2]; + filter_npass_each_dir[2] = parse_filter_npass_each_dir[2]; #endif - pp.query("num_mirrors", num_mirrors); - if (num_mirrors>0){ - mirror_z.resize(num_mirrors); - pp.getarr("mirror_z", mirror_z, 0, num_mirrors); - mirror_z_width.resize(num_mirrors); - pp.getarr("mirror_z_width", mirror_z_width, 0, num_mirrors); - mirror_z_npoints.resize(num_mirrors); - pp.getarr("mirror_z_npoints", mirror_z_npoints, 0, num_mirrors); - } + pp.query("num_mirrors", num_mirrors); + if (num_mirrors>0){ + mirror_z.resize(num_mirrors); + pp.getarr("mirror_z", mirror_z, 0, num_mirrors); + mirror_z_width.resize(num_mirrors); + pp.getarr("mirror_z_width", mirror_z_width, 0, num_mirrors); + mirror_z_npoints.resize(num_mirrors); + pp.getarr("mirror_z_npoints", mirror_z_npoints, 0, num_mirrors); + } - pp.query("serialize_ics", serialize_ics); - pp.query("refine_plasma", refine_plasma); + pp.query("serialize_ics", serialize_ics); + pp.query("refine_plasma", refine_plasma); pp.query("do_dive_cleaning", do_dive_cleaning); pp.query("n_field_gather_buffer", n_field_gather_buffer); pp.query("n_current_deposition_buffer", n_current_deposition_buffer); - pp.query("sort_int", sort_int); + pp.query("sort_int", sort_int); pp.query("do_pml", do_pml); pp.query("pml_ncell", pml_ncell); @@ -411,7 +411,7 @@ WarpX::ReadParameters () #endif if ( (do_pml_j_damping==1)&&(do_pml_in_domain==0) ){ - amrex::Abort("J-damping can only be done when PML are inside simulation domain (do_pml_in_domain=1)"); + amrex::Abort("J-damping can only be done when PML are inside simulation domain (do_pml_in_domain=1)"); } pp.query("dump_openpmd", dump_openpmd); @@ -517,16 +517,15 @@ WarpX::ReadParameters () // Only needs to be set with WARPX_DIM_RZ, otherwise defaults to 1. pp.query("n_rz_azimuthal_modes", n_rz_azimuthal_modes); - } { - ParmParse pp("interpolation"); - pp.query("nox", nox); - pp.query("noy", noy); - pp.query("noz", noz); + ParmParse pp("interpolation"); + pp.query("nox", nox); + pp.query("noy", noy); + pp.query("noz", noz); AMREX_ALWAYS_ASSERT_WITH_MESSAGE( nox == noy and nox == noz , - "warpx.nox, noy and noz must be equal"); + "warpx.nox, noy and noz must be equal"); AMREX_ALWAYS_ASSERT_WITH_MESSAGE( nox >= 1, "warpx.nox must >= 1"); } @@ -617,21 +616,21 @@ void WarpX::ClearLevel (int lev) { for (int i = 0; i < 3; ++i) { - Efield_aux[lev][i].reset(); - Bfield_aux[lev][i].reset(); + Efield_aux[lev][i].reset(); + Bfield_aux[lev][i].reset(); - current_fp[lev][i].reset(); - Efield_fp [lev][i].reset(); - Bfield_fp [lev][i].reset(); + current_fp[lev][i].reset(); + Efield_fp [lev][i].reset(); + Bfield_fp [lev][i].reset(); current_store[lev][i].reset(); - current_cp[lev][i].reset(); - Efield_cp [lev][i].reset(); - Bfield_cp [lev][i].reset(); + current_cp[lev][i].reset(); + Efield_cp [lev][i].reset(); + Bfield_cp [lev][i].reset(); - Efield_cax[lev][i].reset(); - Bfield_cax[lev][i].reset(); + Efield_cax[lev][i].reset(); + Bfield_cax[lev][i].reset(); current_buf[lev][i].reset(); } diff --git a/Source/main.cpp b/Source/main.cpp index 6aca49cd3..551be9c30 100644 --- a/Source/main.cpp +++ b/Source/main.cpp @@ -29,20 +29,20 @@ int main(int argc, char* argv[]) const Real strt_total = amrex::second(); { - WarpX warpx; + WarpX warpx; - warpx.InitData(); + warpx.InitData(); - warpx.Evolve(); + warpx.Evolve(); - Real end_total = amrex::second() - strt_total; + Real end_total = amrex::second() - strt_total; - ParallelDescriptor::ReduceRealMax(end_total ,ParallelDescriptor::IOProcessorNumber()); - if (warpx.Verbose()) { + ParallelDescriptor::ReduceRealMax(end_total, ParallelDescriptor::IOProcessorNumber()); + if (warpx.Verbose()) { amrex::Print() << "Total Time : " << end_total << '\n'; amrex::Print() << "WarpX Version: " << WarpX::Version() << '\n'; amrex::Print() << "PICSAR Version: " << WarpX::PicsarVersion() << '\n'; - } + } } BL_PROFILE_VAR_STOP(pmain); -- cgit v1.2.3