Skip to content

Commit 48babf5

Browse files
authored
Implement pure-SoA HDF5 particle IO (#5204)
This closes #5152. Although it's a bit worse than that issue indicated, HDF5 particle IO wasn't implemented for pure SoA at all. This PR does so. The proposed changes: - [x] fix a bug or incorrect behavior in AMReX - [ ] add new capabilities to AMReX - [ ] changes answers in the test suite to more than roundoff level - [ ] are likely to significantly affect the results of downstream AMReX users - [ ] include documentation in the code and/or rst files, if appropriate
1 parent 2922573 commit 48babf5

File tree

10 files changed

+877
-122
lines changed

10 files changed

+877
-122
lines changed

Src/Extern/HDF5/AMReX_ParticleHDF5.H

Lines changed: 165 additions & 119 deletions
Large diffs are not rendered by default.

Src/Extern/HDF5/AMReX_WriteBinaryParticleDataHDF5.H

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ void WriteHDF5ParticleDataSync (PC const& pc,
138138
const int NProcs = ParallelDescriptor::NProcs();
139139
const int IOProcNumber = ParallelDescriptor::IOProcessorNumber();
140140

141-
AMREX_ALWAYS_ASSERT(real_comp_names.size() == pc.NumRealComps() + NStructReal);
141+
{
142+
int nrc = PC::ParticleType::is_soa_particle ?
143+
pc.NumRealComps() + NStructReal - AMREX_SPACEDIM : pc.NumRealComps() + NStructReal;
144+
AMREX_ALWAYS_ASSERT(static_cast<int>(real_comp_names.size()) == nrc);
145+
}
142146
AMREX_ALWAYS_ASSERT( int_comp_names.size() == pc.NumIntComps() + NStructInt);
143147

144148
#ifdef AMREX_USE_HDF5_ASYNC
@@ -273,7 +277,7 @@ void WriteHDF5ParticleDataSync (PC const& pc,
273277
CreateWriteHDF5AttrString(fid, "version_name", versionName.c_str());
274278

275279
int num_output_real = 0;
276-
for (int i = 0; i < pc.NumRealComps() + NStructReal; ++i) {
280+
for (int i = 0; i < static_cast<int>(write_real_comp.size()); ++i) {
277281
if (write_real_comp[i]) { ++num_output_real; }
278282
}
279283

@@ -298,7 +302,7 @@ void WriteHDF5ParticleDataSync (PC const& pc,
298302
// Real component names
299303
int real_comp_count = AMREX_SPACEDIM; // position values
300304

301-
for (int i = 0; i < NStructReal + pc.NumRealComps(); ++i ) {
305+
for (int i = 0; i < static_cast<int>(write_real_comp.size()); ++i ) {
302306
if (write_real_comp[i]) {
303307
/* HdrFile << real_comp_names[i] << '\n'; */
304308
snprintf(comp_name, sizeof comp_name, "real_component_%d", real_comp_count);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This test requires particle support
2+
if (NOT AMReX_PARTICLES)
3+
return()
4+
endif ()
5+
6+
foreach(D IN LISTS AMReX_SPACEDIM)
7+
set(_sources main.cpp)
8+
9+
setup_test(${D} _sources _input_files)
10+
11+
unset(_sources)
12+
endforeach()
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
AMREX_HOME = ../../../
2+
3+
DEBUG = FALSE
4+
5+
DIM = 3
6+
7+
COMP = gnu
8+
9+
PRECISION = DOUBLE
10+
11+
USE_MPI = TRUE
12+
MPI_THREAD_MULTIPLE = FALSE
13+
14+
USE_OMP = FALSE
15+
16+
TINY_PROFILE = TRUE
17+
18+
USE_PARTICLES = TRUE
19+
20+
USE_HDF5 = FALSE
21+
# Set HDF5_HOME to the root of your HDF5 installation, e.g.:
22+
# HDF5_HOME = /path/to/hdf5
23+
24+
###################################################
25+
26+
EBASE = main
27+
28+
include $(AMREX_HOME)/Tools/GNUMake/Make.defs
29+
30+
include ./Make.package
31+
include $(AMREX_HOME)/Src/Base/Make.package
32+
include $(AMREX_HOME)/Src/Particle/Make.package
33+
34+
include $(AMREX_HOME)/Tools/GNUMake/Make.rules
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CEXE_sources += main.cpp

0 commit comments

Comments
 (0)