Skip to content

Core IO

Sam Reeve edited this page Sep 12, 2024 · 5 revisions

Overview

Particle data can be output from multiple optional libraries in Cabana.

HDF5

Implementation

Cabana_HDF5ParticleOutput.hpp

Interface

    Cabana::Experimental::HDF5ParticleOutput::writeTimeStep()
    Cabana::Experimental::HDF5ParticleOutput::readTimeStep()

Examples

Usage

    // 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 );

Visualization

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.

Python postprocessing

For details on how to visualize or postprocess this data with Python, see h5py postprocessing

SILO

Implementation

Cabana_SiloParticleOutput.hpp

Interface

Cabana::Experimental::SiloParticleOutput::writeTimeStep()

Examples

Usage

    // 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

Clone this wiki locally