icedb
version 0.5.1
Snow particle scattering database API
|
#include <icedb/defs.h>
#include <boost/program_options.hpp>
#include <atomic>
#include <chrono>
#include <deque>
#include <future>
#include <iostream>
#include <memory>
#include <mutex>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <icedb/shape.hpp>
#include <icedb/Database.hpp>
#include <icedb/fs_backend.hpp>
#include "../../lib/private/hdf5_supplemental.hpp"
#include "shape.hpp"
#include "shapeIOtext.hpp"
Go to the source code of this file.
Functions | |
void | readtask () |
This is the primary function in each thread devoted to reading shapes. Usually, about three of these threads are active. More... | |
bool | construct_thread_pool (int numThreads) |
Convenience function to build a pool of threads for parsing shapes and writing to the hdf5 file. More... | |
int | main (int argc, char **argv) |
The main body of the program. More... | |
Variables | |
std::vector< std::unique_ptr< std::thread > > | pool |
3d_structures program - An example program to read and write shape files More... | |
std::atomic< int > | countCurrentReading |
std::mutex | mStack |
std::mutex | mOutStack |
std::deque< std::pair< sfs::path, std::string > > | myreadstack |
std::deque< std::tuple< icedb::Examples::Shapes::ShapeDataBasic, sfs::path, std::string > > | mywritestack |
const std::map< std::string, std::set< sfs::path > > | file_formats |
float | resolution_um = 0 |
The resolution of each shape lattice, in micrometers. More... | |
bool | nccompat = true |
Are we forcing NetCDF-4 compatability. More... | |
icedb::Groups::Group::Group_ptr | basegrp |
Shapes get written to this location in the output database. More... | |
bool construct_thread_pool | ( | int | numThreads | ) |
Convenience function to build a pool of threads for parsing shapes and writing to the hdf5 file.
Definition at line 132 of file shapes-main.cpp.
References readtask().
Referenced by main().
int main | ( | int | argc, |
char ** | argv | ||
) |
The main body of the program.
The main program:
Definition at line 149 of file shapes-main.cpp.
References basegrp, icedb::fs::impl::collectDatasetFiles(), construct_thread_pool(), countCurrentReading, mOutStack, nccompat, resolution_um, and icedb::fs::hdf5::useZLIB().
void readtask | ( | ) |
This is the primary function in each thread devoted to reading shapes. Usually, about three of these threads are active.
This is a simple loop.
Definition at line 90 of file shapes-main.cpp.
References countCurrentReading, mOutStack, mStack, nccompat, icedb::Examples::Shapes::ShapeRequiredData::particle_id, icedb::Examples::Shapes::readTextFile(), icedb::Examples::Shapes::ShapeDataBasic::required, and resolution_um.
Referenced by construct_thread_pool().
icedb::Groups::Group::Group_ptr basegrp |
Shapes get written to this location in the output database.
Definition at line 79 of file shapes-main.cpp.
Referenced by main(), and icedb::Databases::Database_impl::makeDatabaseFileStandard().
std::atomic<int> countCurrentReading |
Definition at line 56 of file shapes-main.cpp.
Referenced by main(), and readtask().
const std::map<std::string, std::set<sfs::path> > file_formats |
Definition at line 70 of file shapes-main.cpp.
std::mutex mOutStack |
Definition at line 60 of file shapes-main.cpp.
Referenced by main(), and readtask().
std::mutex mStack |
Definition at line 60 of file shapes-main.cpp.
Referenced by readtask().
std::deque<std::pair<sfs::path, std::string> > myreadstack |
Definition at line 65 of file shapes-main.cpp.
std::deque<std::tuple<icedb::Examples::Shapes::ShapeDataBasic, sfs::path, std::string> > mywritestack |
Definition at line 67 of file shapes-main.cpp.
bool nccompat = true |
Are we forcing NetCDF-4 compatability.
Definition at line 77 of file shapes-main.cpp.
Referenced by main(), and readtask().
std::vector<std::unique_ptr<std::thread> > pool |
3d_structures program - An example program to read and write shape files
This program reads shape files (in ADDA or DDSCAT formats) and writes an HDF5/netCDF file as an output. The program demonstrates how to create shapes using the library's C++ interface.
This example is multi-threaded. This makes it somewhat complicated. Read operations on ASCII text are slow, as are filesystem calls. This program can read in files at near disk speed. Sadly, HDF5 can only write objects using one thread at a time, and its internal compression filters are also single-threaded.
Here's how the program works:
Definition at line 54 of file shapes-main.cpp.
float resolution_um = 0 |
The resolution of each shape lattice, in micrometers.
Definition at line 76 of file shapes-main.cpp.
Referenced by main(), and readtask().