diff options
Diffstat (limited to 'Source/Diagnostics/BTDiagnostics.cpp')
-rw-r--r-- | Source/Diagnostics/BTDiagnostics.cpp | 50 |
1 files changed, 42 insertions, 8 deletions
diff --git a/Source/Diagnostics/BTDiagnostics.cpp b/Source/Diagnostics/BTDiagnostics.cpp index ff8d59427..3739bf21d 100644 --- a/Source/Diagnostics/BTDiagnostics.cpp +++ b/Source/Diagnostics/BTDiagnostics.cpp @@ -63,7 +63,11 @@ void BTDiagnostics::DerivedInitData () m_cell_centered_data.resize(nmax_lev); // allocate vector of cell-center functors for nlevels m_cell_center_functors.resize(nmax_lev); - // allocate vector to counter number of times the buffer has been refilled + // allocate vector to estimate maximum number of buffer multifabs needed to + // obtain the lab-frame snapshot. + m_max_buffer_multifabs.resize(m_num_buffers); + // allocate vector to count number of times the buffer multifab + // has been flushed and refilled m_buffer_flush_counter.resize(m_num_buffers); // allocate vector of geometry objects corresponding to each snapshot m_geom_snapshot.resize( m_num_buffers ); @@ -110,7 +114,11 @@ BTDiagnostics::ReadParameters () // Read list of back-transform diag parameters requested by the user // amrex::ParmParse pp(m_diag_name); - m_file_prefix = "diags/lab_frame_data/" + m_diag_name; + if (m_format == "openpmd") { + m_file_prefix = "diags/" + m_diag_name; + } else { + m_file_prefix = "diags/lab_frame_data/" + m_diag_name; + } pp.query("file_prefix", m_file_prefix); pp.query("do_back_transformed_fields", m_do_back_transformed_fields); pp.query("do_back_transformed_particles", m_do_back_transformed_particles); @@ -568,8 +576,26 @@ BTDiagnostics::DefineSnapshotGeometry (const int i_buffer, const int lev) const int k_lab = k_index_zlab (i_buffer, lev); // Box covering the extent of the user-defined diag in the back-transformed frame // for the ith snapshot - m_snapshot_box[i_buffer].setSmall( m_moving_window_dir, k_lab - m_snapshot_ncells_lab[i_buffer][m_moving_window_dir]); + // estimating the maximum number of buffer multifabs needed to obtain the + // full lab-frame snapshot + m_max_buffer_multifabs[i_buffer] = static_cast<int>( ceil ( + amrex::Real(m_snapshot_ncells_lab[i_buffer][m_moving_window_dir]) / + amrex::Real(m_buffer_size) ) ); + // number of cells in z is modified since each buffer multifab always + // contains a minimum m_buffer_size=256 cells + int num_z_cells_in_snapshot = m_max_buffer_multifabs[i_buffer] * m_buffer_size; + // Modify the domain indices according to the buffers that are flushed out + m_snapshot_box[i_buffer].setSmall( m_moving_window_dir, + k_lab - (num_z_cells_in_snapshot-1) ); m_snapshot_box[i_buffer].setBig( m_moving_window_dir, k_lab); + + // Modifying the physical coordinates of the lab-frame snapshot to be + // consistent with the above modified domain-indices in m_snapshot_box. + amrex::IntVect ref_ratio = amrex::IntVect(1); + amrex::Real new_lo = m_snapshot_domain_lab[i_buffer].hi(m_moving_window_dir) - + num_z_cells_in_snapshot * + dz_lab(warpx.getdt(lev), ref_ratio[m_moving_window_dir]); + m_snapshot_domain_lab[i_buffer].setLo(m_moving_window_dir, new_lo); if (lev == 0) { // The extent of the physical domain covered by the ith snapshot // Default non-periodic geometry for diags @@ -660,12 +686,20 @@ void BTDiagnostics::Flush (int i_buffer) { auto & warpx = WarpX::GetInstance(); - std::string tmp_file_name = amrex::Concatenate(m_file_prefix +"/snapshots_plotfile/snapshot",i_buffer,5); - tmp_file_name = tmp_file_name+"/buffer"; + std::string file_name = m_file_prefix; + if (m_format=="plotfile") { + file_name = amrex::Concatenate(m_file_prefix +"/snapshots_plotfile/snapshot",i_buffer,5); + file_name = file_name+"/buffer"; + } + bool isLastBTDFlush = ( ( m_max_buffer_multifabs[i_buffer] + - m_buffer_flush_counter[i_buffer]) == 1) ? true : false; + bool const isBTD = true; + double const labtime = m_t_lab[i_buffer]; m_flush_format->WriteToFile( m_varnames, m_mf_output[i_buffer], m_geom_output[i_buffer], warpx.getistep(), - warpx.gett_new(0), m_output_species, nlev_output, tmp_file_name, - m_plot_raw_fields, m_plot_raw_fields_guards, m_plot_raw_rho, m_plot_raw_F); + labtime, m_output_species, nlev_output, file_name, + m_plot_raw_fields, m_plot_raw_fields_guards, m_plot_raw_rho, m_plot_raw_F, + isBTD, i_buffer, m_geom_snapshot[i_buffer][0], isLastBTDFlush); if (m_format == "plotfile") { MergeBuffersForPlotfile(i_buffer); @@ -715,7 +749,6 @@ void BTDiagnostics::TMP_ClearSpeciesDataForBTD () { m_output_species.clear(); m_output_species_names.clear(); - } void BTDiagnostics::MergeBuffersForPlotfile (int i_snapshot) @@ -854,4 +887,5 @@ BTDiagnostics::InterleaveFabArrayHeader(std::string Buffer_FabHeader_path, } snapshot_FabHeader.WriteMultiFabHeader(); + } |