예제 #1
0
void reset_parameters() {
    cfg = conf_f32;
    pattern = NULL;
    dir = FWD_B;
    mb = 0;
    alg = DIRECT;
    attr = attr_t();
    skip_impl = "";
    allow_unimpl = false;
}
예제 #2
0
void save_particle_space(const Tspace_& space, H5::Group* root)
{
    typedef ParticleSpaceHDF5Traits traits_type;
    typedef typename traits_type::h5_species_struct h5_species_struct;
    typedef typename traits_type::h5_particle_struct h5_particle_struct;

    typedef std::vector<std::pair<ParticleID, Particle> >
        particle_container_type;
    const particle_container_type& particles(space.list_particles());
    const unsigned int num_particles(particles.size());

    std::vector<Species> species;
    typedef utils::get_mapper_mf<Species::serial_type, unsigned int>::type
        species_id_map_type;
    species_id_map_type species_id_map;

    boost::scoped_array<h5_particle_struct>
        h5_particle_table(new h5_particle_struct[num_particles]);
    for (unsigned int i(0); i < num_particles; ++i)
    {
        species_id_map_type::const_iterator
            it(species_id_map.find(particles[i].second.species_serial()));
        if (it == species_id_map.end())
        {
            species.push_back(particles[i].second.species());
            it = species_id_map.insert(
                std::make_pair(particles[i].second.species_serial(),
                               species.size())).first;
        }

        h5_particle_table[i].lot = particles[i].first.lot();
        h5_particle_table[i].serial = particles[i].first.serial();
        h5_particle_table[i].sid = (*it).second;
        h5_particle_table[i].posx = particles[i].second.position()[0];
        h5_particle_table[i].posy = particles[i].second.position()[1];
        h5_particle_table[i].posz = particles[i].second.position()[2];
        h5_particle_table[i].radius = particles[i].second.radius();
        h5_particle_table[i].D = particles[i].second.D();
    }

    boost::scoped_array<h5_species_struct>
        h5_species_table(new h5_species_struct[species.size()]);
    for (unsigned int i(0); i < species.size(); ++i)
    {
        h5_species_table[i].id = i + 1;
        std::strcpy(h5_species_table[i].serial,
                    species[i].serial().c_str());
    }

    const int RANK = 1;
    hsize_t dim1[] = {num_particles};
    H5::DataSpace dataspace1(RANK, dim1);
    boost::scoped_ptr<H5::DataSet> dataset1(new H5::DataSet(
        root->createDataSet(
            "particles", traits_type::get_particle_comp_type(), dataspace1)));

    hsize_t dim2[] = {species.size()};
    H5::DataSpace dataspace2(RANK, dim2);
    boost::scoped_ptr<H5::DataSet> dataset2(new H5::DataSet(
        root->createDataSet(
            "species", traits_type::get_species_comp_type(), dataspace2)));

    dataset1->write(h5_particle_table.get(), dataset1->getDataType());
    dataset2->write(h5_species_table.get(), dataset2->getDataType());

    const uint32_t space_type = static_cast<uint32_t>(Space::PARTICLE);
    H5::Attribute attr_space_type(
        root->createAttribute(
            "type", H5::PredType::STD_I32LE, H5::DataSpace(H5S_SCALAR)));
    attr_space_type.write(H5::PredType::STD_I32LE, &space_type);

    const double t = space.t();
    H5::Attribute attr_t(
        root->createAttribute(
            "t", H5::PredType::IEEE_F64LE, H5::DataSpace(H5S_SCALAR)));
    attr_t.write(H5::PredType::IEEE_F64LE, &t);

    const Real3 edge_lengths = space.edge_lengths();
    const hsize_t dims[] = {3};
    const H5::ArrayType lengths_type(H5::PredType::NATIVE_DOUBLE, 1, dims);
    H5::Attribute attr_lengths(
        root->createAttribute(
            "edge_lengths", lengths_type, H5::DataSpace(H5S_SCALAR)));
    double lengths[] = {edge_lengths[0], edge_lengths[1], edge_lengths[2]};
    attr_lengths.write(lengths_type, lengths);
}