Skip to content
Snippets Groups Projects
Select Git revision
  • master default protected
  • feature/add-fft-interface
  • feature/expose-rnumber-from-simulations
  • feature/particle_state_generation_with_variable_box_size
  • feature/forcing-unit-test
  • feature/dealias-check2
  • bugfix/check_field_exists
  • feature/dealias-check
  • v3.x
  • feature/particles-vectorization
  • 6.2.4
  • 6.2.3
  • 6.2.2
  • 6.2.1
  • 6.2.0
  • 6.1.0
  • 6.0.0
  • 5.8.1
  • 5.8.0
  • 5.7.2
  • 5.7.1
  • 5.7.0
  • 5.6.0
  • 5.5.1
  • 5.5.0
  • 5.4.7
  • 5.4.6
  • 5.4.5
  • 5.4.4
  • 5.4.3
30 results

native_binary_to_hdf5.cpp

Blame
  • user avatar
    Chichi Lalescu authored
    8d88006b
    History
    native_binary_to_hdf5.cpp 1.97 KiB
    #include <string>
    #include <cmath>
    #include "native_binary_to_hdf5.hpp"
    #include "scope_timer.hpp"
    
    
    template <typename rnumber>
    int native_binary_to_hdf5<rnumber>::initialize(void)
    {
        this->read_parameters();
        this->vec_field = new field<rnumber, FFTW, THREE>(
                nx, ny, nz,
                this->comm,
                DEFAULT_FFTW_FLAG);
        this->vec_field->real_space_representation = false;
        this->bin_IO = new field_binary_IO<rnumber, COMPLEX, THREE>(
                this->vec_field->clayout->sizes,
                this->vec_field->clayout->subsizes,
                this->vec_field->clayout->starts,
                this->vec_field->clayout->comm);
        return EXIT_SUCCESS;
    }
    
    template <typename rnumber>
    int native_binary_to_hdf5<rnumber>::work_on_current_iteration(void)
    {
        char itername[16];
        sprintf(itername, "i%.5x", this->iteration);
        std::string native_binary_fname = (
                this->simname +
                std::string("_cvorticity_") +
                std::string(itername));
        this->bin_IO->read(
                native_binary_fname,
                this->vec_field->get_cdata());
        this->vec_field->io(
                (native_binary_fname +
                 std::string(".h5")),
                "vorticity",
                this->iteration,
                false);
        return EXIT_SUCCESS;
    }
    
    template <typename rnumber>
    int native_binary_to_hdf5<rnumber>::finalize(void)
    {
        delete this->bin_IO;
        delete this->vec_field;
        return EXIT_SUCCESS;
    }
    
    template <typename rnumber>
    int native_binary_to_hdf5<rnumber>::read_parameters(void)
    {
        this->postprocess::read_parameters();
        hid_t parameter_file = H5Fopen(
                (this->simname + std::string(".h5")).c_str(),
                H5F_ACC_RDONLY,
                H5P_DEFAULT);
        this->iteration_list = hdf5_tools::read_vector<int>(
                parameter_file,
                "/native_binary_to_hdf5/iteration_list");
        H5Fclose(parameter_file);
        return EXIT_SUCCESS;
    }
    
    template class native_binary_to_hdf5<float>;
    template class native_binary_to_hdf5<double>;