Files
katrin-plasma/src/mc_electron/h5tb_particle_interface.cpp
T
Christian 6f288bb0c1 Reworked Katrin Geometrics.
Added creation of T3+ clusters.
Added diss. recombination fo T3+ + e-
2019-07-12 15:15:23 +02:00

76 lines
2.3 KiB
C++

//
// h5tb_particle_interface.cpp
// mc_electron
//
// Created by Christian Reiling on 19.05.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#include <sstream>
#include "h5tb_particle_interface.hpp"
using namespace std;
logParticle samplelogParticle = {0,0,0,0,0,0,0,0};
const size_t H5TB_Particle_Interface::size = sizeof(logParticle);
const char *H5TB_Particle_Interface::fieldNames[8] = { "Id","ParentId", "x_m", "y_m", "z_m", "vx_ms", "vy_ms", "vz_ms" };
const size_t H5TB_Particle_Interface::offset[8] = {
HOFFSET(logParticle, Id),
HOFFSET(logParticle, parentId),
HOFFSET(logParticle, x_m),
HOFFSET(logParticle, y_m),
HOFFSET(logParticle, z_m),
HOFFSET(logParticle, vx_ms),
HOFFSET(logParticle, vy_ms),
HOFFSET(logParticle, vz_ms)};
const hid_t H5TB_Particle_Interface::fieldTypes[8] = {
H5T_NATIVE_INT,
H5T_NATIVE_INT,
H5T_NATIVE_DOUBLE,
H5T_NATIVE_DOUBLE,
H5T_NATIVE_DOUBLE,
H5T_NATIVE_DOUBLE,
H5T_NATIVE_DOUBLE,
H5T_NATIVE_DOUBLE};
const hsize_t H5TB_Particle_Interface::chunkSize = 4096;
const size_t H5TB_Particle_Interface::sizes[8] = {
sizeof( samplelogParticle.Id),
sizeof( samplelogParticle.parentId),
sizeof( samplelogParticle.x_m),
sizeof( samplelogParticle.y_m),
sizeof( samplelogParticle.z_m),
sizeof( samplelogParticle.vx_ms),
sizeof( samplelogParticle.vy_ms),
sizeof( samplelogParticle.vz_ms)};
void H5TB_Particle_Interface::create() {
herr_t state = H5TBmake_table(table_name.c_str(), *loc_id, table_name.c_str(), 8, 0,
size, fieldNames, offset, fieldTypes,
chunkSize, NULL, 0, NULL);
if (state < 0) {
stringstream ss;
ss<<"H5TB_Particle_Interface::create: Error creating.\n";
throw MyException(ss.str());
}
}
void H5TB_Particle_Interface::write(const Particle &logPart) {
logParticle logParticle_buffer = transform(logPart);
// Maybe add real buffer here....
H5TBappend_records(*loc_id, table_name.c_str() , 1, size, offset, sizes, &logParticle_buffer );
}
loggerParticle H5TB_Particle_Interface::transform(const Particle &logPart) {
logParticle res;
res.Id = logPart.get_Id();
res.parentId = logPart.get_PId();
res.x_m = logPart.get_x_m()[0];
res.y_m = logPart.get_x_m()[1];
res.z_m = logPart.get_x_m()[2];
res.vx_ms = logPart.get_v_ms()[0];
res.vy_ms = logPart.get_v_ms()[1];
res.vz_ms = logPart.get_v_ms()[2];
return res;
}