@@ -192,24 +192,26 @@ FullDiagnostics::Flush ( int i_buffer, bool /* force_flush */ )
192
192
// is supported for BackTransformed Diagnostics, in BTDiagnostics class.
193
193
auto & warpx = WarpX::GetInstance ();
194
194
195
- m_flush_format->WriteToFile (
196
- m_varnames, m_mf_output.at (i_buffer), m_geom_output.at (i_buffer), warpx.getistep (),
197
- warpx.gett_new (0 ),
198
- m_output_species.at (i_buffer), nlev_output, m_file_prefix,
199
- m_file_min_digits, m_plot_raw_fields, m_plot_raw_fields_guards);
195
+ if (m_diag_type == DiagTypes::TimeAveraged) {
196
+ if (m_time_average_type == TimeAverageType::Static || m_time_average_type == TimeAverageType::Dynamic) {
197
+ // Loop over the output levels and divide by the number of steps in the averaging period
198
+ for (int lev = 0 ; lev < nlev_output; ++lev) {
199
+ m_sum_mf_output.at (i_buffer).at (lev).mult (1 ./m_average_period_steps);
200
+ }
200
201
201
- if (m_time_average_type == TimeAverageType::Static || m_time_average_type == TimeAverageType::Dynamic) {
202
- // Loop over the output levels and divide by the number of steps in the averaging period
203
- for ( int lev = 0 ; lev < nlev_output; ++lev) {
204
- m_sum_mf_output .at (i_buffer). at (lev). mult ( 1 ./m_average_period_steps);
205
- }
202
+ m_flush_format-> WriteToFile (
203
+ m_varnames, m_sum_mf_output. at (i_buffer), m_geom_output. at (i_buffer), warpx. getistep (),
204
+ warpx. gett_new ( 0 ),
205
+ m_output_species .at (i_buffer), nlev_output, m_file_prefix,
206
+ m_file_min_digits, m_plot_raw_fields, m_plot_raw_fields_guards);
206
207
207
- m_flush_format->WriteToFile (
208
- m_varnames, m_sum_mf_output.at (i_buffer), m_geom_output.at (i_buffer), warpx.getistep (),
208
+ }
209
+ } else {
210
+ m_flush_format->WriteToFile (
211
+ m_varnames, m_mf_output.at (i_buffer), m_geom_output.at (i_buffer), warpx.getistep (),
209
212
warpx.gett_new (0 ),
210
213
m_output_species.at (i_buffer), nlev_output, m_file_prefix,
211
214
m_file_min_digits, m_plot_raw_fields, m_plot_raw_fields_guards);
212
-
213
215
}
214
216
215
217
FlushRaw ();
@@ -233,30 +235,33 @@ FullDiagnostics::DoDump (int step, int /*i_buffer*/, bool force_flush)
233
235
bool
234
236
FullDiagnostics::DoComputeAndPack (int step, bool force_flush)
235
237
{
236
- if (m_time_average_type == TimeAverageType::Dynamic) {
237
- m_average_start_step = m_intervals.nextContains (step) - m_average_period_steps;
238
- // check that the periods do not overlap and that the start step is not negative
239
- if (m_average_start_step > 0 ) {
240
- if (m_average_start_step < m_intervals.previousContains (step)) {
241
- WARPX_ABORT_WITH_MESSAGE (
242
- " Averaging periods may not overlap within a single diagnostic. "
243
- " Please create a second diagnostic for overlapping time averaging periods "
244
- " and account for the increased memory consumption."
245
- );
246
- } else {
247
- WARPX_ABORT_WITH_MESSAGE (" The step to begin time averaging may not be a negative number." );
248
- }
249
- }
250
- }
251
238
252
239
// Start averaging at output step (from diag.intervals) - period + 1
253
240
bool in_averaging_period = false ;
254
- if (step > m_intervals.nextContains (step) - m_average_start_step && step <= m_intervals.nextContains (step)) {
255
- in_averaging_period = true ;
241
+ if (m_diag_type == DiagTypes::TimeAveraged) {
242
+ if (m_time_average_type == TimeAverageType::Dynamic) {
243
+ m_average_start_step = m_intervals.nextContains (step) - m_average_period_steps;
244
+ // check that the periods do not overlap and that the start step is not negative
245
+ if (m_average_start_step > 0 ) {
246
+ if (m_average_start_step < m_intervals.previousContains (step)) {
247
+ WARPX_ABORT_WITH_MESSAGE (
248
+ " Averaging periods may not overlap within a single diagnostic. "
249
+ " Please create a second diagnostic for overlapping time averaging periods "
250
+ " and account for the increased memory consumption."
251
+ );
252
+ } else {
253
+ WARPX_ABORT_WITH_MESSAGE (" The step to begin time averaging may not be a negative number." );
254
+ }
255
+ }
256
+ }
256
257
257
- if (m_time_average_type == TimeAverageType::Static) {
258
- // Update time averaging period to current step
259
- m_average_period_steps = step - m_average_start_step;
258
+ if (step > m_intervals.nextContains (step) - m_average_start_step && step <= m_intervals.nextContains (step)) {
259
+ in_averaging_period = true ;
260
+
261
+ if (m_time_average_type == TimeAverageType::Static) {
262
+ // Update time averaging period to current step
263
+ m_average_period_steps = step - m_average_start_step;
264
+ }
260
265
}
261
266
}
262
267
@@ -719,10 +724,14 @@ FullDiagnostics::InitializeBufferData (int i_buffer, int lev, bool restart ) {
719
724
const int ngrow = (m_format == " sensei" || m_format == " ascent" ) ? 1 : 0 ;
720
725
int const ncomp = static_cast <int >(m_varnames.size ());
721
726
m_mf_output[i_buffer][lev] = amrex::MultiFab (ba, dmap, ncomp, ngrow);
722
- // Allocate MultiFab for cell-centered field output accumulation. The data will be averaged before flushing.
723
- m_sum_mf_output[i_buffer][lev] = amrex::MultiFab (ba, dmap, ncomp, ngrow);
724
- // Initialize to zero because we add data.
725
- m_sum_mf_output[i_buffer][lev].setVal (0 .);
727
+
728
+ if (m_diag_type == DiagTypes::TimeAveraged) {
729
+ // Allocate MultiFab for cell-centered field output accumulation. The data will be averaged before flushing.
730
+ m_sum_mf_output[i_buffer][lev] = amrex::MultiFab (ba, dmap, ncomp, ngrow);
731
+ // Initialize to zero because we add data.
732
+ m_sum_mf_output[i_buffer][lev].setVal (0 .);
733
+ }
734
+
726
735
if (lev == 0 ) {
727
736
// The extent of the domain covered by the diag multifab, m_mf_output
728
737
// default non-periodic geometry for diags
0 commit comments