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

field_output_test.cpp

Blame
  • user avatar
    Chichi Lalescu authored
    3291590d
    History
    field_output_test.cpp 1.43 KiB
    #include <string>
    #include <cmath>
    #include <random>
    #include "field_output_test.hpp"
    #include "scope_timer.hpp"
    
    
    template <typename rnumber>
    int field_output_test<rnumber>::initialize(void)
    {
        this->read_parameters();
        return EXIT_SUCCESS;
    }
    
    template <typename rnumber>
    int field_output_test<rnumber>::finalize(void)
    {
        return EXIT_SUCCESS;
    }
    
    template <typename rnumber>
    int field_output_test<rnumber>::read_parameters()
    {
        this->test::read_parameters();
        return EXIT_SUCCESS;
    }
    
    template <typename rnumber>
    int field_output_test<rnumber>::do_work(void)
    {
        // allocate
        field<rnumber, FFTW, ONE> *scal_field = new field<rnumber, FFTW, ONE>(
                this->nx, this->ny, this->nz,
                this->comm,
                DEFAULT_FFTW_FLAG);
        std::default_random_engine rgen;
        std::normal_distribution<rnumber> rdist;
        rgen.seed(1);
    
        // fill up scal_field
        scal_field->real_space_representation = true;
        scal_field->RLOOP(
                [&](ptrdiff_t rindex,
                    ptrdiff_t xindex,
                    ptrdiff_t yindex,
                    ptrdiff_t zindex){
                scal_field->rval(rindex) = rdist(rgen);
                });
    
        scal_field->io(
                this->simname + std::string("_fields.h5"),
                "scal_field",
                0,
                false);
    
        // deallocate
        delete scal_field;
        return EXIT_SUCCESS;
    }
    
    template class field_output_test<float>;
    template class field_output_test<double>;