From 271eb52eafffdefb8dfc3bb43ee521094fbd5a74 Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Fri, 10 May 2019 17:49:29 -0700 Subject: lab diags is a species argument. add comments --- Source/Particles/MultiParticleContainer.cpp | 36 +++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 440906348..bde8d244e 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -31,7 +31,21 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) pc_tmp.reset(new PhysicalParticleContainer(amr_core)); - if (WarpX::do_boosted_frame_diagnostic && WarpX::do_boosted_frame_particles) + // Compute the number of species for which mab frame data is dumped + // nspecies_lab_frame_diags, and map their ID to MultiParticleContainer + // particle IDs in map_species_lab_diags. + map_species_lab_diags.resize(nspecies); + nspecies_lab_frame_diags = 0; + for (int i=0; ido_boosted_frame_diags){ + map_species_lab_diags[nspecies_lab_frame_diags] = i; + nspecies_lab_frame_diags += 1; + do_boosted_frame_diags = 1; + } + } + + if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) { for (int i = 0; i < nspecies + nlasers; ++i) { @@ -376,13 +390,24 @@ MultiParticleContainer BL_PROFILE("MultiParticleContainer::GetLabFrameData"); + // Loop over particle species for (int i = 0; i < nspecies; ++i){ WarpXParticleContainer* pc = allcontainers[i].get(); WarpXParticleContainer::DiagnosticParticles diagnostic_particles; pc->GetParticleSlice(direction, z_old, z_new, t_boost, t_lab, dt, diagnostic_particles); - + // Here, diagnostic_particles[lev][index] is a WarpXParticleContainer::DiagnosticParticleData + // where "lev" is the AMR level and "index" is a [grid index][tile index] pair. + + // Loop over AMR levels for (int lev = 0; lev <= pc->finestLevel(); ++lev){ + // Loop over [grid index][tile index] pairs + // and Fills parts[species number i] with particle data from all grids and + // tiles in diagnostic_particles. parts contains particles from all + // AMR levels indistinctly. for (auto it = diagnostic_particles[lev].begin(); it != diagnostic_particles[lev].end(); ++it){ + // it->first is the [grid index][tile index] key + // it->second is the corresponding + // WarpXParticleContainer::DiagnosticParticleData value parts[i].GetRealData(DiagIdx::w).insert( parts[i].GetRealData(DiagIdx::w ).end(), it->second.GetRealData(DiagIdx::w ).begin(), it->second.GetRealData(DiagIdx::w ).end()); @@ -459,3 +484,10 @@ MultiParticleContainer::doContinuousInjection() const } return warpx_do_continuous_injection; } + +// Set number of species for which lab frame data is dumped +// and maps their ID to MultiParticleContainer IDs. +//void +//MultiParticleContainer::setSpeciesLabFrameDiags() const +//{ +//} -- cgit v1.2.3 From 5ebe5c35e5b6cac0428173291ece3e431954037f Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Sat, 11 May 2019 08:01:00 -0700 Subject: some debugging --- Source/Diagnostics/BoostedFrameDiagnostic.cpp | 44 ++++++++++++++++++++++----- Source/Particles/MultiParticleContainer.cpp | 13 ++++++-- Source/Particles/WarpXParticleContainer.H | 2 +- 3 files changed, 47 insertions(+), 12 deletions(-) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Source/Diagnostics/BoostedFrameDiagnostic.cpp b/Source/Diagnostics/BoostedFrameDiagnostic.cpp index 5d85fc8f8..ad33b68d8 100644 --- a/Source/Diagnostics/BoostedFrameDiagnostic.cpp +++ b/Source/Diagnostics/BoostedFrameDiagnostic.cpp @@ -497,6 +497,8 @@ BoostedFrameDiagnostic(Real zmin_lab, Real zmax_lab, Real v_window_lab, void BoostedFrameDiagnostic::Flush(const Geometry& geom) { BL_PROFILE("BoostedFrameDiagnostic::Flush"); + + std::cout<<"in Flush"\n; VisMF::Header::Version current_version = VisMF::GetHeaderVersion(); VisMF::SetHeaderVersion(amrex::VisMF::Header::NoFabHeader_v1); @@ -539,8 +541,10 @@ void BoostedFrameDiagnostic::Flush(const Geometry& geom) } if (WarpX::do_boosted_frame_particles) { - for (int j = 0; j < mypc.nSpecies(); ++j) { - std::string species_name = species_names[mypc.map_species_lab_diags[j]]; + // for (int j = 0; j < mypc.nSpecies(); ++j) { + for (int j = 0; j < mypc.nspecies_lab_frame_diags; ++j) { + int js = mypc.map_species_lab_diags[j]; + std::string species_name = species_names[js]; #ifdef WARPX_USE_HDF5 writeParticleDataHDF5(particles_buffer_[i][j], snapshots_[i].file_name, @@ -576,8 +580,12 @@ writeLabFrameData(const MultiFab* cell_centered_data, const Real zhi_boost = domain_z_boost.hi(boost_direction_); const std::vector species_names = mypc.GetSpeciesNames(); + + Print()<<"in BoostedFrameDiagnostic::writeLabFrameData 1\n"; for (int i = 0; i < N_snapshots_; ++i) { + std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 2\n"; + const Real old_z_boost = snapshots_[i].current_z_boost; snapshots_[i].updateCurrentZPositions(t_boost, inv_gamma_boost_, @@ -589,6 +597,7 @@ writeLabFrameData(const MultiFab* cell_centered_data, (snapshots_[i].current_z_lab > snapshots_[i].zmax_lab) ) continue; int i_lab = (snapshots_[i].current_z_lab - snapshots_[i].zmin_lab) / dz_lab_; + std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 3\n"; if (buff_counter_[i] == 0) { if (WarpX::do_boosted_frame_fields) { @@ -603,6 +612,7 @@ writeLabFrameData(const MultiFab* cell_centered_data, } if (WarpX::do_boosted_frame_particles) particles_buffer_[i].resize(mypc.nspecies_lab_frame_diags); } + std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 4\n"; if (WarpX::do_boosted_frame_fields) { const int ncomp = cell_centered_data->nComp(); @@ -642,11 +652,15 @@ writeLabFrameData(const MultiFab* cell_centered_data, &ncomp, &i_boost, &i_lab); } } - + std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 5\n"; if (WarpX::do_boosted_frame_particles) { + std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 6\n"; + mypc.GetLabFrameData(snapshots_[i].file_name, i_lab, boost_direction_, old_z_boost, snapshots_[i].current_z_boost, t_boost, snapshots_[i].t_lab, dt, particles_buffer_[i]); + std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 7\n"; + } @@ -667,7 +681,11 @@ writeLabFrameData(const MultiFab* cell_centered_data, } if (WarpX::do_boosted_frame_particles) { + std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 8\n"; + for (int j = 0; j < mypc.nspecies_lab_frame_diags; ++j) { + std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 9\n"; + const std::string species_name = species_names[mypc.map_species_lab_diags[j]]; #ifdef WARPX_USE_HDF5 writeParticleDataHDF5(particles_buffer_[i][j], @@ -675,9 +693,14 @@ writeLabFrameData(const MultiFab* cell_centered_data, species_name); #else std::stringstream part_ss; + std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 10\n"; + part_ss << snapshots_[i].file_name + "/" + species_name + "/"; + std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 11\n"; + writeParticleData(particles_buffer_[i][j], part_ss.str(), i_lab); #endif + std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 12\n"; } particles_buffer_[i].clear(); } @@ -860,9 +883,12 @@ LabSnapShot(Real t_lab_in, Real t_boost, Real zmin_lab_in, if (WarpX::do_boosted_frame_particles){ auto & mypc = WarpX::GetInstance().GetPartContainer(); const std::vector species_names = mypc.GetSpeciesNames(); - for (int j = 0; j < mypc.nSpecies(); ++j) + // for (int j = 0; j < mypc.nSpecies(); ++j) + for (int j = 0; j < mypc.nspecies_lab_frame_diags; ++j) { - std::string species_name = species_names[mypc.map_species_lab_diags[j]]; + int js = mypc.map_species_lab_diags[j]; + std::cout<<"js "<(particle_field_names.size()); ++k) { @@ -886,11 +912,13 @@ LabSnapShot(Real t_lab_in, Real t_boost, Real zmin_lab_in, auto & mypc = WarpX::GetInstance().GetPartContainer(); const std::vector species_names = mypc.GetSpeciesNames(); - int nspecies = mypc.nSpecies(); +// int nspecies = mypc.nSpecies(); const std::string particles_prefix = "particle"; - for(int i = 0; i < nspecies; ++i) { - std::string species_name = species_names[mypc.map_species_lab_diags[i]]; +// for(int i = 0; i < nspecies; ++i) { + for(int i = 0; i < mypc.nspecies_lab_frame_diags; ++i) { + int is = mypc.map_species_lab_diags[i]; + std::string species_name = species_names[is]; const std::string fullpath = file_name + "/" + species_name; if (!UtilCreateDirectory(fullpath, 0755)) CreateDirectoryFailed(fullpath); diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index bde8d244e..4726cb4cf 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -40,8 +40,8 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) auto& pc = allcontainers[i]; if (pc->do_boosted_frame_diags){ map_species_lab_diags[nspecies_lab_frame_diags] = i; - nspecies_lab_frame_diags += 1; do_boosted_frame_diags = 1; + nspecies_lab_frame_diags += 1; } } @@ -389,12 +389,16 @@ MultiParticleContainer { BL_PROFILE("MultiParticleContainer::GetLabFrameData"); + std::cout<<"GetLabFrameData 1\n"; // Loop over particle species - for (int i = 0; i < nspecies; ++i){ - WarpXParticleContainer* pc = allcontainers[i].get(); + for (int i = 0; i < nspecies_lab_frame_diags; ++i){ + int isp = map_species_lab_diags[i]; +std::cout<<"GetLabFrameData 2\n"; + WarpXParticleContainer* pc = allcontainers[isp].get(); WarpXParticleContainer::DiagnosticParticles diagnostic_particles; pc->GetParticleSlice(direction, z_old, z_new, t_boost, t_lab, dt, diagnostic_particles); +std::cout<<"GetLabFrameData 3\n"; // Here, diagnostic_particles[lev][index] is a WarpXParticleContainer::DiagnosticParticleData // where "lev" is the AMR level and "index" is a [grid index][tile index] pair. @@ -404,13 +408,16 @@ MultiParticleContainer // and Fills parts[species number i] with particle data from all grids and // tiles in diagnostic_particles. parts contains particles from all // AMR levels indistinctly. +std::cout<<"GetLabFrameData 4\n"; for (auto it = diagnostic_particles[lev].begin(); it != diagnostic_particles[lev].end(); ++it){ // it->first is the [grid index][tile index] key // it->second is the corresponding // WarpXParticleContainer::DiagnosticParticleData value +std::cout<<"GetLabFrameData 5\n"; parts[i].GetRealData(DiagIdx::w).insert( parts[i].GetRealData(DiagIdx::w ).end(), it->second.GetRealData(DiagIdx::w ).begin(), it->second.GetRealData(DiagIdx::w ).end()); +std::cout<<"GetLabFrameData 6\n"; parts[i].GetRealData(DiagIdx::x).insert( parts[i].GetRealData(DiagIdx::x ).end(), it->second.GetRealData(DiagIdx::x ).begin(), diff --git a/Source/Particles/WarpXParticleContainer.H b/Source/Particles/WarpXParticleContainer.H index 600061e8d..d1e25f3ad 100644 --- a/Source/Particles/WarpXParticleContainer.H +++ b/Source/Particles/WarpXParticleContainer.H @@ -271,7 +271,7 @@ protected: // support all features allowed by direct injection. int do_continuous_injection = 0; - int do_boosted_frame_diags = 0; + int do_boosted_frame_diags = 1; amrex::Vector local_rho; amrex::Vector local_jx; -- cgit v1.2.3 From 71cdf5ca0bfe5a239382cdfb56df1d2d9e68c65f Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Sun, 12 May 2019 06:54:06 -0700 Subject: debugging --- Source/Diagnostics/BoostedFrameDiagnostic.cpp | 17 ++++++++++++----- Source/Evolve/WarpXEvolveEM.cpp | 4 ++++ Source/Particles/MultiParticleContainer.cpp | 1 + Source/Particles/PhysicalParticleContainer.cpp | 2 ++ 4 files changed, 19 insertions(+), 5 deletions(-) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Source/Diagnostics/BoostedFrameDiagnostic.cpp b/Source/Diagnostics/BoostedFrameDiagnostic.cpp index ad33b68d8..934610b9e 100644 --- a/Source/Diagnostics/BoostedFrameDiagnostic.cpp +++ b/Source/Diagnostics/BoostedFrameDiagnostic.cpp @@ -498,7 +498,7 @@ void BoostedFrameDiagnostic::Flush(const Geometry& geom) { BL_PROFILE("BoostedFrameDiagnostic::Flush"); - std::cout<<"in Flush"\n; + std::cout<<"in Flush\n"; VisMF::Header::Version current_version = VisMF::GetHeaderVersion(); VisMF::SetHeaderVersion(amrex::VisMF::Header::NoFabHeader_v1); @@ -546,6 +546,7 @@ void BoostedFrameDiagnostic::Flush(const Geometry& geom) int js = mypc.map_species_lab_diags[j]; std::string species_name = species_names[js]; #ifdef WARPX_USE_HDF5 + std::cout<<"particles_buffer_ j "< zhi_boost) or (snapshots_[i].current_z_lab < snapshots_[i].zmin_lab) or (snapshots_[i].current_z_lab > snapshots_[i].zmax_lab) ) continue; + std::cout<<"toto 3\n"; int i_lab = (snapshots_[i].current_z_lab - snapshots_[i].zmin_lab) / dz_lab_; std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 3\n"; @@ -656,9 +661,9 @@ writeLabFrameData(const MultiFab* cell_centered_data, if (WarpX::do_boosted_frame_particles) { std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 6\n"; - mypc.GetLabFrameData(snapshots_[i].file_name, i_lab, boost_direction_, - old_z_boost, snapshots_[i].current_z_boost, - t_boost, snapshots_[i].t_lab, dt, particles_buffer_[i]); + //mypc.GetLabFrameData(snapshots_[i].file_name, i_lab, boost_direction_, + // old_z_boost, snapshots_[i].current_z_boost, + // t_boost, snapshots_[i].t_lab, dt, particles_buffer_[i]); std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 7\n"; } @@ -688,6 +693,7 @@ writeLabFrameData(const MultiFab* cell_centered_data, const std::string species_name = species_names[mypc.map_species_lab_diags[j]]; #ifdef WARPX_USE_HDF5 + std::cout<<"particles_buffer_ j "<writeLabFrameData"<writeLabFrameData(cell_centered_data.get(), *mypc, geom[0], cur_time, dt[0]); + std::cout<<"after myBFD->writeLabFrameData"<Flush"<Flush(geom[0]); + std::cout<<"after myBFD->Flush"<GetParticleSlice(direction, z_old, z_new, t_boost, t_lab, dt, diagnostic_particles); std::cout<<"GetLabFrameData 3\n"; diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index d99cc9c66..c4d4abfd6 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -1863,6 +1863,8 @@ void PhysicalParticleContainer::GetParticleSlice(const int direction, const Real // Note the the slice should always move in the negative boost direction. AMREX_ALWAYS_ASSERT(z_new < z_old); + AMREX_ALWAYS_ASSERT(do_boosted_frame_diags == 1); + const int nlevs = std::max(0, finestLevel()+1); // we figure out a box for coarse-grained rejection. If the RealBox corresponding to a -- cgit v1.2.3 From c952dbe2e3d9a2c7bab2774e8036e0e9ff72e0ed Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Sun, 12 May 2019 07:58:38 -0700 Subject: only selected species BFD-dumped, but all old attribs initialized --- Source/Diagnostics/BoostedFrameDiagnostic.cpp | 30 ++++---------------------- Source/Particles/MultiParticleContainer.cpp | 19 ++++++++++------ Source/Particles/PhysicalParticleContainer.cpp | 9 +++++--- Source/Particles/WarpXParticleContainer.cpp | 9 +++++--- Source/WarpX.cpp | 2 +- 5 files changed, 29 insertions(+), 40 deletions(-) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Source/Diagnostics/BoostedFrameDiagnostic.cpp b/Source/Diagnostics/BoostedFrameDiagnostic.cpp index 934610b9e..7a44bc66a 100644 --- a/Source/Diagnostics/BoostedFrameDiagnostic.cpp +++ b/Source/Diagnostics/BoostedFrameDiagnostic.cpp @@ -582,27 +582,19 @@ writeLabFrameData(const MultiFab* cell_centered_data, const std::vector species_names = mypc.GetSpeciesNames(); - Print()<<"in BoostedFrameDiagnostic::writeLabFrameData 1\n"; - for (int i = 0; i < N_snapshots_; ++i) { - std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 2\n"; - std::cout<<"i "< zhi_boost) or (snapshots_[i].current_z_lab < snapshots_[i].zmin_lab) or (snapshots_[i].current_z_lab > snapshots_[i].zmax_lab) ) continue; - std::cout<<"toto 3\n"; int i_lab = (snapshots_[i].current_z_lab - snapshots_[i].zmin_lab) / dz_lab_; - std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 3\n"; if (buff_counter_[i] == 0) { if (WarpX::do_boosted_frame_fields) { @@ -617,7 +609,6 @@ writeLabFrameData(const MultiFab* cell_centered_data, } if (WarpX::do_boosted_frame_particles) particles_buffer_[i].resize(mypc.nspecies_lab_frame_diags); } - std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 4\n"; if (WarpX::do_boosted_frame_fields) { const int ncomp = cell_centered_data->nComp(); @@ -657,14 +648,11 @@ writeLabFrameData(const MultiFab* cell_centered_data, &ncomp, &i_boost, &i_lab); } } - std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 5\n"; if (WarpX::do_boosted_frame_particles) { - std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 6\n"; - //mypc.GetLabFrameData(snapshots_[i].file_name, i_lab, boost_direction_, - // old_z_boost, snapshots_[i].current_z_boost, - // t_boost, snapshots_[i].t_lab, dt, particles_buffer_[i]); - std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 7\n"; + mypc.GetLabFrameData(snapshots_[i].file_name, i_lab, boost_direction_, + old_z_boost, snapshots_[i].current_z_boost, + t_boost, snapshots_[i].t_lab, dt, particles_buffer_[i]); } @@ -686,28 +674,21 @@ writeLabFrameData(const MultiFab* cell_centered_data, } if (WarpX::do_boosted_frame_particles) { - std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 8\n"; for (int j = 0; j < mypc.nspecies_lab_frame_diags; ++j) { - std::cout<<"in BoostedFrameDiagnostic::writeLabFrameData 9\n"; const std::string species_name = species_names[mypc.map_species_lab_diags[j]]; #ifdef WARPX_USE_HDF5 - std::cout<<"particles_buffer_ j "<(particle_field_names.size()); ++k) @@ -919,10 +899,8 @@ LabSnapShot(Real t_lab_in, Real t_boost, Real zmin_lab_in, auto & mypc = WarpX::GetInstance().GetPartContainer(); const std::vector species_names = mypc.GetSpeciesNames(); -// int nspecies = mypc.nSpecies(); const std::string particles_prefix = "particle"; -// for(int i = 0; i < nspecies; ++i) { for(int i = 0; i < mypc.nspecies_lab_frame_diags; ++i) { int is = mypc.map_species_lab_diags[i]; std::string species_name = species_names[is]; diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 841c41835..337005dc3 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -55,7 +55,19 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) allcontainers[i]->AddRealComp("uxold"); allcontainers[i]->AddRealComp("uyold"); allcontainers[i]->AddRealComp("uzold"); + } + /* + for (int i = 0; i < nspecies_lab_frame_diags; ++i) + { + int is = map_species_lab_diags[i]; + allcontainers[is]->AddRealComp("xold"); + allcontainers[is]->AddRealComp("yold"); + allcontainers[is]->AddRealComp("zold"); + allcontainers[is]->AddRealComp("uxold"); + allcontainers[is]->AddRealComp("uyold"); + allcontainers[is]->AddRealComp("uzold"); } + */ pc_tmp->AddRealComp("xold"); pc_tmp->AddRealComp("yold"); pc_tmp->AddRealComp("zold"); @@ -389,17 +401,13 @@ MultiParticleContainer { BL_PROFILE("MultiParticleContainer::GetLabFrameData"); - std::cout<<"GetLabFrameData 1\n"; // Loop over particle species for (int i = 0; i < nspecies_lab_frame_diags; ++i){ int isp = map_species_lab_diags[i]; -std::cout<<"GetLabFrameData 2\n"; WarpXParticleContainer* pc = allcontainers[isp].get(); - std::cout<<"getparticleslice "<< isp<GetParticleSlice(direction, z_old, z_new, t_boost, t_lab, dt, diagnostic_particles); -std::cout<<"GetLabFrameData 3\n"; // Here, diagnostic_particles[lev][index] is a WarpXParticleContainer::DiagnosticParticleData // where "lev" is the AMR level and "index" is a [grid index][tile index] pair. @@ -409,16 +417,13 @@ std::cout<<"GetLabFrameData 3\n"; // and Fills parts[species number i] with particle data from all grids and // tiles in diagnostic_particles. parts contains particles from all // AMR levels indistinctly. -std::cout<<"GetLabFrameData 4\n"; for (auto it = diagnostic_particles[lev].begin(); it != diagnostic_particles[lev].end(); ++it){ // it->first is the [grid index][tile index] key // it->second is the corresponding // WarpXParticleContainer::DiagnosticParticleData value -std::cout<<"GetLabFrameData 5\n"; parts[i].GetRealData(DiagIdx::w).insert( parts[i].GetRealData(DiagIdx::w ).end(), it->second.GetRealData(DiagIdx::w ).begin(), it->second.GetRealData(DiagIdx::w ).end()); -std::cout<<"GetLabFrameData 6\n"; parts[i].GetRealData(DiagIdx::x).insert( parts[i].GetRealData(DiagIdx::x ).end(), it->second.GetRealData(DiagIdx::x ).begin(), diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index c4d4abfd6..a3f555bd0 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -219,7 +219,8 @@ PhysicalParticleContainer::AddGaussianBeam(Real x_m, Real y_m, Real z_m, attribs[PIdx::uz] = u[2]; attribs[PIdx::w ] = weight; - if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) + // if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) + if (WarpX::do_boosted_frame_diagnostic) { auto& particle_tile = DefineAndReturnParticleTile(0, 0, 0); particle_tile.push_back_real(particle_comps["xold"], x); @@ -503,7 +504,8 @@ PhysicalParticleContainer::AddPlasmaCPU (int lev, RealBox part_realbox) attribs[PIdx::uy] = u[1]; attribs[PIdx::uz] = u[2]; - if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) + // if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) + if (WarpX::do_boosted_frame_diagnostic) { auto& particle_tile = DefineAndReturnParticleTile(lev, grid_id, tile_id); particle_tile.push_back_real(particle_comps["xold"], x); @@ -745,7 +747,8 @@ PhysicalParticleContainer::AddPlasmaGPU (int lev, RealBox part_realbox) attribs[PIdx::uz] = u[2]; // note - this will be slow on the GPU, need to revisit - if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) + // if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) + if (WarpX::do_boosted_frame_diagnostic) { auto& particle_tile = DefineAndReturnParticleTile(lev, grid_id, tile_id); particle_tile.push_back_real(particle_comps["xold"], x); diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp index 0cf5c10b4..9bee0031a 100644 --- a/Source/Particles/WarpXParticleContainer.cpp +++ b/Source/Particles/WarpXParticleContainer.cpp @@ -78,7 +78,8 @@ WarpXParticleContainer::WarpXParticleContainer (AmrCore* amr_core, int ispecies) particle_comps["theta"] = PIdx::theta; #endif - if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) + // if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) + if (WarpX::do_boosted_frame_diagnostic) { particle_comps["xold"] = PIdx::nattribs; particle_comps["yold"] = PIdx::nattribs+1; @@ -231,7 +232,8 @@ WarpXParticleContainer::AddNParticles (int lev, p.pos(1) = z[i]; #endif - if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) + // if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) + if (WarpX::do_boosted_frame_diagnostic) { auto& particle_tile = DefineAndReturnParticleTile(0, 0, 0); particle_tile.push_back_real(particle_comps["xold"], x[i]); @@ -249,7 +251,8 @@ WarpXParticleContainer::AddNParticles (int lev, particle_tile.push_back_real(PIdx::uy, vy + ibegin, vy + iend); particle_tile.push_back_real(PIdx::uz, vz + ibegin, vz + iend); - if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) + // if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) + if (WarpX::do_boosted_frame_diagnostic) { auto& particle_tile = DefineAndReturnParticleTile(0, 0, 0); particle_tile.push_back_real(particle_comps["uxold"], vx + ibegin, vx + iend); diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index c863e9a4c..7c026e105 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -329,7 +329,7 @@ WarpX::ReadParameters () pp.get("gamma_boost", gamma_boost); pp.query("do_boosted_frame_fields", do_boosted_frame_fields); - pp.query("do_boosted_frame_particles", do_boosted_frame_particles); + // pp.query("do_boosted_frame_particles", do_boosted_frame_particles); AMREX_ALWAYS_ASSERT_WITH_MESSAGE(do_moving_window, -- cgit v1.2.3 From 9a26a71845fde091c7840772bef1b23dbc46d6ac Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Sun, 12 May 2019 10:17:28 -0700 Subject: old attribs not allocated if species not BFD --- Source/Diagnostics/BoostedFrameDiagnostic.cpp | 22 ++++++++++------------ Source/Evolve/WarpXEvolveEM.cpp | 2 -- Source/Laser/LaserParticleContainer.cpp | 5 +++-- Source/Particles/MultiParticleContainer.H | 11 ++++++++--- Source/Particles/MultiParticleContainer.cpp | 7 +++++-- Source/Particles/PhysicalParticleContainer.cpp | 12 +++++------- Source/Particles/WarpXParticleContainer.H | 1 - Source/Particles/WarpXParticleContainer.cpp | 19 +++++++++++++------ Source/WarpX.cpp | 2 +- 9 files changed, 45 insertions(+), 36 deletions(-) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Source/Diagnostics/BoostedFrameDiagnostic.cpp b/Source/Diagnostics/BoostedFrameDiagnostic.cpp index 7a44bc66a..413730f91 100644 --- a/Source/Diagnostics/BoostedFrameDiagnostic.cpp +++ b/Source/Diagnostics/BoostedFrameDiagnostic.cpp @@ -497,8 +497,6 @@ BoostedFrameDiagnostic(Real zmin_lab, Real zmax_lab, Real v_window_lab, void BoostedFrameDiagnostic::Flush(const Geometry& geom) { BL_PROFILE("BoostedFrameDiagnostic::Flush"); - - std::cout<<"in Flush\n"; VisMF::Header::Version current_version = VisMF::GetHeaderVersion(); VisMF::SetHeaderVersion(amrex::VisMF::Header::NoFabHeader_v1); @@ -542,11 +540,10 @@ void BoostedFrameDiagnostic::Flush(const Geometry& geom) if (WarpX::do_boosted_frame_particles) { // for (int j = 0; j < mypc.nSpecies(); ++j) { - for (int j = 0; j < mypc.nspecies_lab_frame_diags; ++j) { - int js = mypc.map_species_lab_diags[j]; + for (int j = 0; j < mypc.nSpeciesLabFrameDiags(); ++j) { + int js = mypc.mapSpeciesLabDiags(j); std::string species_name = species_names[js]; #ifdef WARPX_USE_HDF5 - std::cout<<"particles_buffer_ j "<(particle_field_names.size()); ++k) { std::string field_path = species_name + "/" + particle_field_names[k]; @@ -872,9 +870,9 @@ LabSnapShot(Real t_lab_in, Real t_boost, Real zmin_lab_in, auto & mypc = WarpX::GetInstance().GetPartContainer(); const std::vector species_names = mypc.GetSpeciesNames(); // for (int j = 0; j < mypc.nSpecies(); ++j) - for (int j = 0; j < mypc.nspecies_lab_frame_diags; ++j) + for (int j = 0; j < mypc.nSpeciesLabFrameDiags(); ++j) { - int js = mypc.map_species_lab_diags[j]; + int js = mypc.mapSpeciesLabDiags(j); std::string species_name = species_names[js]; output_create_species_group(file_name, species_name); for (int k = 0; k < static_cast(particle_field_names.size()); ++k) @@ -901,8 +899,8 @@ LabSnapShot(Real t_lab_in, Real t_boost, Real zmin_lab_in, const std::vector species_names = mypc.GetSpeciesNames(); const std::string particles_prefix = "particle"; - for(int i = 0; i < mypc.nspecies_lab_frame_diags; ++i) { - int is = mypc.map_species_lab_diags[i]; + for(int i = 0; i < mypc.nSpeciesLabFrameDiags(); ++i) { + int is = mypc.mapSpeciesLabDiags(i); std::string species_name = species_names[is]; const std::string fullpath = file_name + "/" + species_name; if (!UtilCreateDirectory(fullpath, 0755)) diff --git a/Source/Evolve/WarpXEvolveEM.cpp b/Source/Evolve/WarpXEvolveEM.cpp index 5f6760f22..d88f178df 100644 --- a/Source/Evolve/WarpXEvolveEM.cpp +++ b/Source/Evolve/WarpXEvolveEM.cpp @@ -173,9 +173,7 @@ WarpX::EvolveEM (int numsteps) if (WarpX::do_boosted_frame_fields) { cell_centered_data = GetCellCenteredData(); } - std::cout<<"before myBFD->writeLabFrameData"<writeLabFrameData(cell_centered_data.get(), *mypc, geom[0], cur_time, dt[0]); - std::cout<<"after myBFD->writeLabFrameData"<::max(); - - ParmParse pp(laser_name); + do_boosted_frame_diags = 0; + + ParmParse pp(laser_name); // Parse the type of laser profile and set the corresponding flag `profile` std::string laser_type_s; diff --git a/Source/Particles/MultiParticleContainer.H b/Source/Particles/MultiParticleContainer.H index 5a79443d0..217f727b0 100644 --- a/Source/Particles/MultiParticleContainer.H +++ b/Source/Particles/MultiParticleContainer.H @@ -157,6 +157,10 @@ public: int nSpecies() const {return nspecies;} + int nSpeciesLabFrameDiags() const {return nspecies_lab_frame_diags;} + int mapSpeciesLabDiags(int i) const {return map_species_lab_diags[i];} + int doBoostedFrameDiags() const {return do_boosted_frame_diags;} + int nSpeciesDepositOnMainGrid () const { int r = 0; for (int i : deposit_on_main_grid) { @@ -186,9 +190,6 @@ public: // Number of coefficients for the stencil of the NCI corrector. // The stencil is applied in the z direction only. static constexpr int nstencilz_fdtd_nci_corr=5; - int nspecies_lab_frame_diags = 0; - std::vector map_species_lab_diags; - int do_boosted_frame_diags = 0; amrex::Vector > fdtd_nci_stencilz_ex; amrex::Vector > fdtd_nci_stencilz_by; @@ -219,6 +220,10 @@ private: void ReadParameters (); + int nspecies_lab_frame_diags = 0; + std::vector map_species_lab_diags; + int do_boosted_frame_diags = 0; + // runtime parameters int nlasers = 0; int nspecies = 1; // physical particles only. nspecies+nlasers == allcontainers.size(). diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 337005dc3..508f3f606 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -47,6 +47,8 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) { + //maxoldattribs + /* for (int i = 0; i < nspecies + nlasers; ++i) { allcontainers[i]->AddRealComp("xold"); @@ -56,7 +58,7 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) allcontainers[i]->AddRealComp("uyold"); allcontainers[i]->AddRealComp("uzold"); } - /* + */ for (int i = 0; i < nspecies_lab_frame_diags; ++i) { int is = map_species_lab_diags[i]; @@ -67,13 +69,14 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) allcontainers[is]->AddRealComp("uyold"); allcontainers[is]->AddRealComp("uzold"); } - */ + /* pc_tmp->AddRealComp("xold"); pc_tmp->AddRealComp("yold"); pc_tmp->AddRealComp("zold"); pc_tmp->AddRealComp("uxold"); pc_tmp->AddRealComp("uyold"); pc_tmp->AddRealComp("uzold"); + */ } } diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index a3f555bd0..dd167ba41 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -219,8 +219,7 @@ PhysicalParticleContainer::AddGaussianBeam(Real x_m, Real y_m, Real z_m, attribs[PIdx::uz] = u[2]; attribs[PIdx::w ] = weight; - // if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) - if (WarpX::do_boosted_frame_diagnostic) + if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) { auto& particle_tile = DefineAndReturnParticleTile(0, 0, 0); particle_tile.push_back_real(particle_comps["xold"], x); @@ -504,8 +503,7 @@ PhysicalParticleContainer::AddPlasmaCPU (int lev, RealBox part_realbox) attribs[PIdx::uy] = u[1]; attribs[PIdx::uz] = u[2]; - // if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) - if (WarpX::do_boosted_frame_diagnostic) + if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) { auto& particle_tile = DefineAndReturnParticleTile(lev, grid_id, tile_id); particle_tile.push_back_real(particle_comps["xold"], x); @@ -747,8 +745,7 @@ PhysicalParticleContainer::AddPlasmaGPU (int lev, RealBox part_realbox) attribs[PIdx::uz] = u[2]; // note - this will be slow on the GPU, need to revisit - // if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) - if (WarpX::do_boosted_frame_diagnostic) + if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) { auto& particle_tile = DefineAndReturnParticleTile(lev, grid_id, tile_id); particle_tile.push_back_real(particle_comps["xold"], x); @@ -838,8 +835,9 @@ FieldGatherES (const amrex::Vector, const auto& particles = pti.GetArrayOfStructs(); int nstride = particles.dataShape().first; const long np = pti.numParticles(); - + std::cout<<"start 1 GetAttribs\n"; auto& attribs = pti.GetAttribs(); + std::cout<<"end 2 GetAttribs\n"; auto& Exp = attribs[PIdx::Ex]; auto& Eyp = attribs[PIdx::Ey]; #if AMREX_SPACEDIM == 3 diff --git a/Source/Particles/WarpXParticleContainer.H b/Source/Particles/WarpXParticleContainer.H index d1e25f3ad..6968f2a61 100644 --- a/Source/Particles/WarpXParticleContainer.H +++ b/Source/Particles/WarpXParticleContainer.H @@ -59,7 +59,6 @@ public: const amrex::Cuda::ManagedDeviceVector& y, const amrex::Cuda::ManagedDeviceVector& z); #endif - const std::array& GetAttribs () const { return GetStructOfArrays().GetRealData(); } diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp index 9bee0031a..66f0dfb5c 100644 --- a/Source/Particles/WarpXParticleContainer.cpp +++ b/Source/Particles/WarpXParticleContainer.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include using namespace amrex; @@ -22,7 +24,9 @@ WarpXParIter::GetPosition (Cuda::ManagedDeviceVector& x, Cuda::ManagedDevi { amrex::ParIter<0,0,PIdx::nattribs>::GetPosition(x, z); #ifdef WARPX_RZ + std::cout<<"start 2 GetAttribs()\n"; const auto& attribs = GetAttribs(); + std::cout<<"stop 2 GetAttribs()\n"; const auto& theta = attribs[PIdx::theta]; y.resize(x.size()); for (unsigned int i=0 ; i < x.size() ; i++) { @@ -39,7 +43,9 @@ void WarpXParIter::SetPosition (const Cuda::ManagedDeviceVector& x, const Cuda::ManagedDeviceVector& y, const Cuda::ManagedDeviceVector& z) { #ifdef WARPX_RZ + std::cout<<"start 3 GetAttribs()\n"; auto& attribs = GetAttribs(); + std::cout<<"stop 3 GetAttribs()\n"; auto& theta = attribs[PIdx::theta]; Cuda::DeviceVector r(x.size()); for (unsigned int i=0 ; i < x.size() ; i++) { @@ -78,8 +84,7 @@ WarpXParticleContainer::WarpXParticleContainer (AmrCore* amr_core, int ispecies) particle_comps["theta"] = PIdx::theta; #endif - // if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) - if (WarpX::do_boosted_frame_diagnostic) + if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) { particle_comps["xold"] = PIdx::nattribs; particle_comps["yold"] = PIdx::nattribs+1; @@ -232,8 +237,7 @@ WarpXParticleContainer::AddNParticles (int lev, p.pos(1) = z[i]; #endif - // if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) - if (WarpX::do_boosted_frame_diagnostic) + if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) { auto& particle_tile = DefineAndReturnParticleTile(0, 0, 0); particle_tile.push_back_real(particle_comps["xold"], x[i]); @@ -251,8 +255,7 @@ WarpXParticleContainer::AddNParticles (int lev, particle_tile.push_back_real(PIdx::uy, vy + ibegin, vy + iend); particle_tile.push_back_real(PIdx::uz, vz + ibegin, vz + iend); - // if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) - if (WarpX::do_boosted_frame_diagnostic) + if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) { auto& particle_tile = DefineAndReturnParticleTile(0, 0, 0); particle_tile.push_back_real(particle_comps["uxold"], vx + ibegin, vx + iend); @@ -998,7 +1001,9 @@ WarpXParticleContainer::PushXES (Real dt) int nstride = particles.dataShape().first; const long np = pti.numParticles(); + std::cout<<"start 4 GetAttribs()\n"; auto& attribs = pti.GetAttribs(); + std::cout<<"stop 4 GetAttribs()\n"; auto& uxp = attribs[PIdx::ux]; auto& uyp = attribs[PIdx::uy]; auto& uzp = attribs[PIdx::uz]; @@ -1047,7 +1052,9 @@ WarpXParticleContainer::PushX (int lev, Real dt) // - positions are stored as an array of struct, in `ParticleType` ParticleType * AMREX_RESTRICT pstructs = &(pti.GetArrayOfStructs()[0]); // - momenta are stored as a struct of array, in `attribs` + std::cout<<"start 5 GetAttribs()\n"; auto& attribs = pti.GetAttribs(); + std::cout<<"stop 5 GetAttribs()\n"; Real* AMREX_RESTRICT ux = attribs[PIdx::ux].dataPtr(); Real* AMREX_RESTRICT uy = attribs[PIdx::uy].dataPtr(); Real* AMREX_RESTRICT uz = attribs[PIdx::uz].dataPtr(); diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 7c026e105..e4c54cc05 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -160,7 +160,7 @@ WarpX::WarpX () current_injection_position = geom[0].ProbLo(moving_window_dir); } } - do_boosted_frame_particles = mypc->do_boosted_frame_diags; + do_boosted_frame_particles = mypc->doBoostedFrameDiags(); Efield_aux.resize(nlevs_max); Bfield_aux.resize(nlevs_max); -- cgit v1.2.3 From 449c1254dfd126b7b2b6291b05177cb22ed38f5c Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Sun, 12 May 2019 10:35:02 -0700 Subject: cleaning (remove print statements etc.) --- Source/Diagnostics/BoostedFrameDiagnostic.cpp | 5 +---- Source/Evolve/WarpXEvolveEM.cpp | 2 -- Source/Particles/MultiParticleContainer.H | 2 -- Source/Particles/MultiParticleContainer.cpp | 21 --------------------- Source/Particles/PhysicalParticleContainer.cpp | 2 -- Source/Particles/WarpXParticleContainer.cpp | 10 ---------- Source/WarpX.cpp | 7 +------ 7 files changed, 2 insertions(+), 47 deletions(-) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Source/Diagnostics/BoostedFrameDiagnostic.cpp b/Source/Diagnostics/BoostedFrameDiagnostic.cpp index 413730f91..49038b9e2 100644 --- a/Source/Diagnostics/BoostedFrameDiagnostic.cpp +++ b/Source/Diagnostics/BoostedFrameDiagnostic.cpp @@ -539,7 +539,6 @@ void BoostedFrameDiagnostic::Flush(const Geometry& geom) } if (WarpX::do_boosted_frame_particles) { - // for (int j = 0; j < mypc.nSpecies(); ++j) { for (int j = 0; j < mypc.nSpeciesLabFrameDiags(); ++j) { int js = mypc.mapSpeciesLabDiags(j); std::string species_name = species_names[js]; @@ -645,8 +644,8 @@ writeLabFrameData(const MultiFab* cell_centered_data, &ncomp, &i_boost, &i_lab); } } - if (WarpX::do_boosted_frame_particles) { + if (WarpX::do_boosted_frame_particles) { mypc.GetLabFrameData(snapshots_[i].file_name, i_lab, boost_direction_, old_z_boost, snapshots_[i].current_z_boost, t_boost, snapshots_[i].t_lab, dt, particles_buffer_[i]); @@ -732,7 +731,6 @@ writeParticleDataHDF5(const WarpXParticleContainer::DiagnosticParticleData& pdat ParallelDescriptor::ReduceLongMax(old_np); // Write data here - Print()<<"particle_field_names.size()"<(particle_field_names.size()); ++k) { std::string field_path = species_name + "/" + particle_field_names[k]; @@ -869,7 +867,6 @@ LabSnapShot(Real t_lab_in, Real t_boost, Real zmin_lab_in, if (WarpX::do_boosted_frame_particles){ auto & mypc = WarpX::GetInstance().GetPartContainer(); const std::vector species_names = mypc.GetSpeciesNames(); - // for (int j = 0; j < mypc.nSpecies(); ++j) for (int j = 0; j < mypc.nSpeciesLabFrameDiags(); ++j) { int js = mypc.mapSpeciesLabDiags(j); diff --git a/Source/Evolve/WarpXEvolveEM.cpp b/Source/Evolve/WarpXEvolveEM.cpp index d88f178df..dab58f95b 100644 --- a/Source/Evolve/WarpXEvolveEM.cpp +++ b/Source/Evolve/WarpXEvolveEM.cpp @@ -247,9 +247,7 @@ WarpX::EvolveEM (int numsteps) } if (do_boosted_frame_diagnostic) { - std::cout<<"before myBFD->Flush"<Flush(geom[0]); - std::cout<<"after myBFD->Flush"<AddRealComp("xold"); - allcontainers[i]->AddRealComp("yold"); - allcontainers[i]->AddRealComp("zold"); - allcontainers[i]->AddRealComp("uxold"); - allcontainers[i]->AddRealComp("uyold"); - allcontainers[i]->AddRealComp("uzold"); - } - */ for (int i = 0; i < nspecies_lab_frame_diags; ++i) { int is = map_species_lab_diags[i]; @@ -69,14 +57,12 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) allcontainers[is]->AddRealComp("uyold"); allcontainers[is]->AddRealComp("uzold"); } - /* pc_tmp->AddRealComp("xold"); pc_tmp->AddRealComp("yold"); pc_tmp->AddRealComp("zold"); pc_tmp->AddRealComp("uxold"); pc_tmp->AddRealComp("uyold"); pc_tmp->AddRealComp("uzold"); - */ } } @@ -500,10 +486,3 @@ MultiParticleContainer::doContinuousInjection() const } return warpx_do_continuous_injection; } - -// Set number of species for which lab frame data is dumped -// and maps their ID to MultiParticleContainer IDs. -//void -//MultiParticleContainer::setSpeciesLabFrameDiags() const -//{ -//} diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index dd167ba41..37c136a3d 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -835,9 +835,7 @@ FieldGatherES (const amrex::Vector, const auto& particles = pti.GetArrayOfStructs(); int nstride = particles.dataShape().first; const long np = pti.numParticles(); - std::cout<<"start 1 GetAttribs\n"; auto& attribs = pti.GetAttribs(); - std::cout<<"end 2 GetAttribs\n"; auto& Exp = attribs[PIdx::Ex]; auto& Eyp = attribs[PIdx::Ey]; #if AMREX_SPACEDIM == 3 diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp index 66f0dfb5c..0cf5c10b4 100644 --- a/Source/Particles/WarpXParticleContainer.cpp +++ b/Source/Particles/WarpXParticleContainer.cpp @@ -6,8 +6,6 @@ #include #include #include -#include -#include using namespace amrex; @@ -24,9 +22,7 @@ WarpXParIter::GetPosition (Cuda::ManagedDeviceVector& x, Cuda::ManagedDevi { amrex::ParIter<0,0,PIdx::nattribs>::GetPosition(x, z); #ifdef WARPX_RZ - std::cout<<"start 2 GetAttribs()\n"; const auto& attribs = GetAttribs(); - std::cout<<"stop 2 GetAttribs()\n"; const auto& theta = attribs[PIdx::theta]; y.resize(x.size()); for (unsigned int i=0 ; i < x.size() ; i++) { @@ -43,9 +39,7 @@ void WarpXParIter::SetPosition (const Cuda::ManagedDeviceVector& x, const Cuda::ManagedDeviceVector& y, const Cuda::ManagedDeviceVector& z) { #ifdef WARPX_RZ - std::cout<<"start 3 GetAttribs()\n"; auto& attribs = GetAttribs(); - std::cout<<"stop 3 GetAttribs()\n"; auto& theta = attribs[PIdx::theta]; Cuda::DeviceVector r(x.size()); for (unsigned int i=0 ; i < x.size() ; i++) { @@ -1001,9 +995,7 @@ WarpXParticleContainer::PushXES (Real dt) int nstride = particles.dataShape().first; const long np = pti.numParticles(); - std::cout<<"start 4 GetAttribs()\n"; auto& attribs = pti.GetAttribs(); - std::cout<<"stop 4 GetAttribs()\n"; auto& uxp = attribs[PIdx::ux]; auto& uyp = attribs[PIdx::uy]; auto& uzp = attribs[PIdx::uz]; @@ -1052,9 +1044,7 @@ WarpXParticleContainer::PushX (int lev, Real dt) // - positions are stored as an array of struct, in `ParticleType` ParticleType * AMREX_RESTRICT pstructs = &(pti.GetArrayOfStructs()[0]); // - momenta are stored as a struct of array, in `attribs` - std::cout<<"start 5 GetAttribs()\n"; auto& attribs = pti.GetAttribs(); - std::cout<<"stop 5 GetAttribs()\n"; Real* AMREX_RESTRICT ux = attribs[PIdx::ux].dataPtr(); Real* AMREX_RESTRICT uy = attribs[PIdx::uy].dataPtr(); Real* AMREX_RESTRICT uz = attribs[PIdx::uz].dataPtr(); diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index e4c54cc05..6b1edaccd 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -56,12 +56,9 @@ int WarpX::num_mirrors = 0; int WarpX::sort_int = -1; +bool WarpX::do_boosted_frame_diagnostic = false; int WarpX::num_snapshots_lab = std::numeric_limits::lowest(); Real WarpX::dt_snapshots_lab = std::numeric_limits::lowest(); -// bool WarpX::do_boosted_frame_diagnostic = false; -// bool WarpX::do_boosted_frame_fields = true; -// bool WarpX::do_boosted_frame_particles = true; -bool WarpX::do_boosted_frame_diagnostic = false; bool WarpX::do_boosted_frame_fields = true; bool WarpX::do_boosted_frame_particles = true; @@ -329,8 +326,6 @@ WarpX::ReadParameters () pp.get("gamma_boost", gamma_boost); pp.query("do_boosted_frame_fields", do_boosted_frame_fields); - // pp.query("do_boosted_frame_particles", do_boosted_frame_particles); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(do_moving_window, "The moving window should be on if using the boosted frame diagnostic."); -- cgit v1.2.3 From c69763f866d06bc6d065421fed5d40176eecaffe Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Mon, 13 May 2019 08:20:11 -0700 Subject: more consistent names: BFD everywhere --- Source/Diagnostics/BoostedFrameDiagnostic.cpp | 18 +++++++++--------- Source/Particles/MultiParticleContainer.H | 8 ++++---- Source/Particles/MultiParticleContainer.cpp | 18 +++++++++--------- 3 files changed, 22 insertions(+), 22 deletions(-) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Source/Diagnostics/BoostedFrameDiagnostic.cpp b/Source/Diagnostics/BoostedFrameDiagnostic.cpp index 49038b9e2..affe28cb5 100644 --- a/Source/Diagnostics/BoostedFrameDiagnostic.cpp +++ b/Source/Diagnostics/BoostedFrameDiagnostic.cpp @@ -539,8 +539,8 @@ void BoostedFrameDiagnostic::Flush(const Geometry& geom) } if (WarpX::do_boosted_frame_particles) { - for (int j = 0; j < mypc.nSpeciesLabFrameDiags(); ++j) { - int js = mypc.mapSpeciesLabDiags(j); + for (int j = 0; j < mypc.nSpeciesBoostedFrameDiags(); ++j) { + int js = mypc.mapSpeciesBoostedFrameDiags(j); std::string species_name = species_names[js]; #ifdef WARPX_USE_HDF5 writeParticleDataHDF5(particles_buffer_[i][j], @@ -603,7 +603,7 @@ writeLabFrameData(const MultiFab* cell_centered_data, DistributionMapping buff_dm(buff_ba); data_buffer_[i].reset( new MultiFab(buff_ba, buff_dm, ncomp, 0) ); } - if (WarpX::do_boosted_frame_particles) particles_buffer_[i].resize(mypc.nSpeciesLabFrameDiags()); + if (WarpX::do_boosted_frame_particles) particles_buffer_[i].resize(mypc.nSpeciesBoostedFrameDiags()); } if (WarpX::do_boosted_frame_fields) { @@ -671,9 +671,9 @@ writeLabFrameData(const MultiFab* cell_centered_data, if (WarpX::do_boosted_frame_particles) { - for (int j = 0; j < mypc.nSpeciesLabFrameDiags(); ++j) { + for (int j = 0; j < mypc.nSpeciesBoostedFrameDiags(); ++j) { - const std::string species_name = species_names[mypc.mapSpeciesLabDiags(j)]; + const std::string species_name = species_names[mypc.mapSpeciesBoostedFrameDiags(j)]; #ifdef WARPX_USE_HDF5 writeParticleDataHDF5(particles_buffer_[i][j], snapshots_[i].file_name, @@ -867,9 +867,9 @@ LabSnapShot(Real t_lab_in, Real t_boost, Real zmin_lab_in, if (WarpX::do_boosted_frame_particles){ auto & mypc = WarpX::GetInstance().GetPartContainer(); const std::vector species_names = mypc.GetSpeciesNames(); - for (int j = 0; j < mypc.nSpeciesLabFrameDiags(); ++j) + for (int j = 0; j < mypc.nSpeciesBoostedFrameDiags(); ++j) { - int js = mypc.mapSpeciesLabDiags(j); + int js = mypc.mapSpeciesBoostedFrameDiags(j); std::string species_name = species_names[js]; output_create_species_group(file_name, species_name); for (int k = 0; k < static_cast(particle_field_names.size()); ++k) @@ -896,8 +896,8 @@ LabSnapShot(Real t_lab_in, Real t_boost, Real zmin_lab_in, const std::vector species_names = mypc.GetSpeciesNames(); const std::string particles_prefix = "particle"; - for(int i = 0; i < mypc.nSpeciesLabFrameDiags(); ++i) { - int is = mypc.mapSpeciesLabDiags(i); + for(int i = 0; i < mypc.nSpeciesBoostedFrameDiags(); ++i) { + int is = mypc.mapSpeciesBoostedFrameDiags(i); std::string species_name = species_names[is]; const std::string fullpath = file_name + "/" + species_name; if (!UtilCreateDirectory(fullpath, 0755)) diff --git a/Source/Particles/MultiParticleContainer.H b/Source/Particles/MultiParticleContainer.H index e88879127..6b511b9cb 100644 --- a/Source/Particles/MultiParticleContainer.H +++ b/Source/Particles/MultiParticleContainer.H @@ -155,8 +155,8 @@ public: int nSpecies() const {return nspecies;} - int nSpeciesLabFrameDiags() const {return nspecies_lab_frame_diags;} - int mapSpeciesLabDiags(int i) const {return map_species_lab_diags[i];} + int nSpeciesBoostedFrameDiags() const {return nspecies_boosted_frame_diags;} + int mapSpeciesBoostedFrameDiags(int i) const {return map_species_boosted_frame_diags[i];} int doBoostedFrameDiags() const {return do_boosted_frame_diags;} int nSpeciesDepositOnMainGrid () const { @@ -218,8 +218,8 @@ private: void ReadParameters (); - int nspecies_lab_frame_diags = 0; - std::vector map_species_lab_diags; + int nspecies_boosted_frame_diags = 0; + std::vector map_species_boosted_frame_diags; int do_boosted_frame_diags = 0; // runtime parameters diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index ea87e2d5b..6d618c096 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -31,25 +31,25 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) pc_tmp.reset(new PhysicalParticleContainer(amr_core)); - // Compute the number of species for which mab frame data is dumped + // Compute the number of species for which lab-frame data is dumped // nspecies_lab_frame_diags, and map their ID to MultiParticleContainer // particle IDs in map_species_lab_diags. - map_species_lab_diags.resize(nspecies); - nspecies_lab_frame_diags = 0; + map_species_boosted_frame_diags.resize(nspecies); + nspecies_boosted_frame_diags = 0; for (int i=0; ido_boosted_frame_diags){ - map_species_lab_diags[nspecies_lab_frame_diags] = i; + map_species_boosted_frame_diags[nspecies_boosted_frame_diags] = i; do_boosted_frame_diags = 1; - nspecies_lab_frame_diags += 1; + nspecies_boosted_frame_diags += 1; } } if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) { - for (int i = 0; i < nspecies_lab_frame_diags; ++i) + for (int i = 0; i < nspecies_boosted_frame_diags; ++i) { - int is = map_species_lab_diags[i]; + int is = map_species_boosted_frame_diags[i]; allcontainers[is]->AddRealComp("xold"); allcontainers[is]->AddRealComp("yold"); allcontainers[is]->AddRealComp("zold"); @@ -392,8 +392,8 @@ MultiParticleContainer BL_PROFILE("MultiParticleContainer::GetLabFrameData"); // Loop over particle species - for (int i = 0; i < nspecies_lab_frame_diags; ++i){ - int isp = map_species_lab_diags[i]; + for (int i = 0; i < nspecies_boosted_frame_diags; ++i){ + int isp = map_species_boosted_frame_diags[i]; WarpXParticleContainer* pc = allcontainers[isp].get(); WarpXParticleContainer::DiagnosticParticles diagnostic_particles; pc->GetParticleSlice(direction, z_old, z_new, t_boost, t_lab, dt, diagnostic_particles); -- cgit v1.2.3