-
Notifications
You must be signed in to change notification settings - Fork 50
Core IO
Sam Reeve edited this page Sep 12, 2024
·
5 revisions
Particle data can be output from multiple optional libraries in Cabana.
Cabana::Experimental::HDF5ParticleOutput::writeTimeStep()
Cabana::Experimental::HDF5ParticleOutput::readTimeStep()
// Define data including particle coordinates
using DeviceType = Kokkos::Device<Kokkos::Serial, Kokkos::HostSpace>;
using DataTypes = Cabana::MemberTypes<double[3], // coords
double[3], // vec
float[3][3], // matrix
int>; // id.
Cabana::AoSoA<DataTypes, TEST_MEMSPACE> aosoa( "particles", num_particle );
auto positions = slice<0>( aosoa, "coordinates" );
auto vec = Cabana::slice<1>( aosoa, "vec" );
auto matrix = Cabana::slice<2>( aosoa, "matrix" );
auto ids = Cabana::slice<3>( aosoa, "ids" );
Cabana::Experimental::HDF5ParticleOutput::HDF5Config h5_config;
Cabana::Experimental::HDF5ParticleOutput::writeTimeStep(
h5_config, "particles", MPI_COMM_WORLD, step, time, coords.size(),
positions, ids, vec, matrix );
Cabana::Experimental::HDF5ParticleOutput::readTimeStep(
h5_config, "particles", MPI_COMM_WORLD, step, coords.size(),
ids.label(), time_read, ids_read );
Many programs can be used to directly read in the HDF5 or Silo output from Cabana, including Paraview and Visit. Many online tutorials show how to manipulate the input particle data.
For details on how to visualize or postprocess this data with Python, see h5py postprocessing
Cabana::Experimental::SiloParticleOutput::writeTimeStep()
// Define data including particle coordinates
using DeviceType = Kokkos::Device<Kokkos::Serial, Kokkos::HostSpace>;
using DataTypes = Cabana::MemberTypes<double[3], // coords
double[3], // vec
float[3][3], // matrix
int>; // id.
Cabana::AoSoA<DataTypes, TEST_MEMSPACE> aosoa( "particles", num_particle );
auto positions = slice<0>( aosoa, "coordinates" );
auto vec = Cabana::slice<1>( aosoa, "vec" );
auto matrix = Cabana::slice<2>( aosoa, "matrix" );
auto ids = Cabana::slice<3>( aosoa, "ids" );
Cabana::Experimental::SiloParticleOutput::writeTimeStep(
"particles", MPI_COMM_WORLD, num_group, time_step_index, time,
positions, ids, matrix, vec );
This is part of the Programming Guide series
Cabana - A Co-Designed Library for Exascale Particle Simulations