Merge branch 'reiling-development' of http://fsk-serval.puk.ac.za/gitea/katrin/katrin-plasma into reiling-development
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -32,7 +32,7 @@ const hid_t H5TB_Particle_Interface::fieldTypes[8] = {
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_DOUBLE};
|
||||
const hsize_t H5TB_Particle_Interface::chunkSize = 4096;
|
||||
const hsize_t H5TB_Particle_Interface::chunkSize = 145;
|
||||
const size_t H5TB_Particle_Interface::sizes[8] = {
|
||||
sizeof( samplelogParticle.Id),
|
||||
sizeof( samplelogParticle.parentId),
|
||||
@@ -56,9 +56,15 @@ void H5TB_Particle_Interface::create() {
|
||||
}
|
||||
|
||||
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 );
|
||||
buffer[buffer_count] = transform(logPart);
|
||||
buffer_count = buffer_count + 1;
|
||||
if (buffer_count == buffer_size) {
|
||||
H5TBappend_records(*loc_id, table_name.c_str() , buffer_size, size, offset, sizes, &buffer);
|
||||
buffer_count = 0;
|
||||
}
|
||||
}
|
||||
H5TB_Particle_Interface::~H5TB_Particle_Interface() {
|
||||
H5TBappend_records(*loc_id, table_name.c_str() , buffer_count, size, offset, sizes, &buffer);
|
||||
}
|
||||
|
||||
loggerParticle H5TB_Particle_Interface::transform(const Particle &logPart) {
|
||||
|
||||
@@ -34,11 +34,16 @@ class H5TB_Particle_Interface {
|
||||
static const hsize_t chunkSize;
|
||||
static const size_t sizes[8];
|
||||
|
||||
int buffer_size = 145;
|
||||
loggerParticle buffer[145];
|
||||
int buffer_count = 0;
|
||||
|
||||
std::string table_name;
|
||||
hid_t *loc_id;
|
||||
|
||||
public:
|
||||
H5TB_Particle_Interface() {};
|
||||
~H5TB_Particle_Interface();
|
||||
H5TB_Particle_Interface(const std::string &table_name, hid_t *loc_id) {
|
||||
this->table_name = table_name;
|
||||
this->loc_id = loc_id;
|
||||
|
||||
@@ -39,7 +39,7 @@ const hid_t H5TB_Population_Interface::fieldTypes[7] = {
|
||||
H5T_NATIVE_INT,
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_INT};
|
||||
const hsize_t H5TB_Population_Interface::chunkSize = 4096;
|
||||
const hsize_t H5TB_Population_Interface::chunkSize = 225;
|
||||
const size_t H5TB_Population_Interface::sizes[7] = {
|
||||
sizeof( sample_log_cell.phys_time_s),
|
||||
sizeof( sample_log_cell.z_bin),
|
||||
@@ -62,7 +62,14 @@ void H5TB_Population_Interface::create() {
|
||||
}
|
||||
|
||||
void H5TB_Population_Interface::write(const pop_bin &log_bin) {
|
||||
H5TBappend_records(*loc_id, table_name.c_str() , 1, size, offset, sizes, &log_bin);
|
||||
buffer[buffer_count] = log_bin;
|
||||
buffer_count = buffer_count + 1;
|
||||
if (buffer_count == buffer_size) {
|
||||
H5TBappend_records(*loc_id, table_name.c_str() , buffer_size, size, offset, sizes, &buffer);
|
||||
buffer_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
H5TB_Population_Interface::~H5TB_Population_Interface() {
|
||||
H5TBappend_records(*loc_id, table_name.c_str() , buffer_count, size, offset, sizes, &buffer);
|
||||
}
|
||||
|
||||
@@ -35,11 +35,16 @@ class H5TB_Population_Interface {
|
||||
static const hsize_t chunkSize;
|
||||
static const size_t sizes[7];
|
||||
|
||||
int buffer_size = 225;
|
||||
pop_bin buffer[225];
|
||||
int buffer_count = 0;
|
||||
|
||||
std::string table_name;
|
||||
hid_t *loc_id;
|
||||
|
||||
public:
|
||||
H5TB_Population_Interface() {};
|
||||
~H5TB_Population_Interface();
|
||||
H5TB_Population_Interface(const std::string &table_name, hid_t *loc_id) {
|
||||
this->table_name = table_name;
|
||||
this->loc_id = loc_id;
|
||||
|
||||
@@ -56,7 +56,7 @@ const hid_t H5TB_Population_Meta_Interface::fieldTypes[12] = {
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_DOUBLE};
|
||||
const hsize_t H5TB_Population_Meta_Interface::chunkSize = 4096;
|
||||
const hsize_t H5TB_Population_Meta_Interface::chunkSize = 100;
|
||||
const size_t H5TB_Population_Meta_Interface::sizes[12] = {
|
||||
sizeof( sample_bin.z_bin),
|
||||
sizeof( sample_bin.r_bin),
|
||||
@@ -84,5 +84,14 @@ void H5TB_Population_Meta_Interface::create() {
|
||||
}
|
||||
|
||||
void H5TB_Population_Meta_Interface::write(const pop_bin_meta_info &log_meta_bin) {
|
||||
H5TBappend_records(*loc_id, table_name.c_str() , 1, size, offset, sizes, &log_meta_bin);
|
||||
buffer[buffer_count] = log_meta_bin;
|
||||
buffer_count = buffer_count + 1;
|
||||
if (buffer_count == buffer_size) {
|
||||
H5TBappend_records(*loc_id, table_name.c_str() , buffer_size, size, offset, sizes, &buffer);
|
||||
buffer_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
H5TB_Population_Meta_Interface::~H5TB_Population_Meta_Interface() {
|
||||
H5TBappend_records(*loc_id, table_name.c_str() , buffer_count, size, offset, sizes, &buffer);
|
||||
}
|
||||
|
||||
@@ -42,11 +42,16 @@ class H5TB_Population_Meta_Interface {
|
||||
static const hsize_t chunkSize;
|
||||
static const size_t sizes[12];
|
||||
|
||||
int buffer_size = 100;
|
||||
pop_bin_meta_info buffer[100];
|
||||
int buffer_count = 0;
|
||||
|
||||
std::string table_name;
|
||||
hid_t *loc_id;
|
||||
|
||||
public:
|
||||
H5TB_Population_Meta_Interface() {};
|
||||
~H5TB_Population_Meta_Interface();
|
||||
H5TB_Population_Meta_Interface(const std::string &table_name, hid_t *loc_id) {
|
||||
this->table_name = table_name;
|
||||
this->loc_id = loc_id;
|
||||
|
||||
@@ -12,3 +12,4 @@
|
||||
|
||||
|
||||
const double Katrin_Fields::wgtsMagField_T = load_parameter("wgtsMagField_T");
|
||||
Vec3_Container Katrin_Fields::e_field(1000, 50, 20, get_data_path() + "e_field.dat");
|
||||
|
||||
@@ -11,10 +11,13 @@
|
||||
|
||||
#include "error_types.h"
|
||||
#include "katrin_geo.h"
|
||||
#include "read_system.h"
|
||||
#include "vec3_container.hpp"
|
||||
|
||||
|
||||
class Katrin_Fields {
|
||||
static const double wgtsMagField_T;
|
||||
static Vec3_Container e_field;
|
||||
|
||||
public:
|
||||
Katrin_Fields() {};
|
||||
@@ -27,13 +30,15 @@ public:
|
||||
}
|
||||
return vec3(0,0,wgtsMagField_T);
|
||||
}
|
||||
|
||||
static vec3 getElField_Vm(vec3 loc_m) {
|
||||
if (!in_Katrin(loc_m)) {
|
||||
std::stringstream ss;
|
||||
ss<<"Katrin_Fields::getElField_Vm: loc_m outside of Katrin.\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
return vec3(0,0,0);
|
||||
return e_field.get_data (loc_m);
|
||||
//return vec3(0,0,0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ include $(HOMEBASE)/src/makeinclude/include.mak
|
||||
|
||||
OBJS := particle_looper.o \
|
||||
tcs_container.o dcs_theta_container.o dcs_ionization_container.o \
|
||||
population_container.o velocity_container.o \
|
||||
population_container.o velocity_container.o vec3_container.o \
|
||||
thermalPop_container.o energeticPop_container.o \
|
||||
particle.o injector.o timer.o katrin_fields.o \
|
||||
h5_file.o logger_builder.o population_load_saver.o \
|
||||
|
||||
@@ -19,11 +19,7 @@ struct Bins {
|
||||
int r;
|
||||
int phi;
|
||||
inline bool operator==(Bins other) {
|
||||
if (z == other.z && r == other.r && phi == other.phi) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return z == other.z && r == other.r && phi == other.phi;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
//
|
||||
// vec3_container.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 02.09.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "vec3_container.hpp"
|
||||
|
||||
|
||||
#include "read_system.h"
|
||||
|
||||
Vec3_Container::Vec3_Container(int num_z_bins, int num_r_bins, int num_phi_bins, std::string load_path) {
|
||||
z_scale = Lin_Scale(z_WGTS_start_m, z_WGTS_end_m, num_z_bins);
|
||||
r_scale = Lin_Scale(0, r_WGTS_m, num_r_bins);
|
||||
phi_scale = Lin_Scale(0, 180, num_phi_bins);
|
||||
int num_tot_bins = num_z_bins * num_r_bins * num_phi_bins;
|
||||
data = new vec3[num_tot_bins];
|
||||
load_data(load_path);
|
||||
}
|
||||
|
||||
Vec3_Container::~Vec3_Container() {
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
void Vec3_Container::load_data(std::string load_path) {
|
||||
int num_tot_bins = z_scale.get_number_bins() * r_scale.get_number_bins() * phi_scale.get_number_bins();
|
||||
bool *check_array = new bool[num_tot_bins];
|
||||
for (int i = 0; i< num_tot_bins; i++) {
|
||||
check_array[i] = false;
|
||||
}
|
||||
|
||||
std::ifstream importStream(load_path);
|
||||
if (!importStream.good()) {
|
||||
std::stringstream ss;
|
||||
ss<<"Vec3_Container::load_data: Could not open file. \n loadFilePath= "<<load_path<<"\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
std::string csv_line;
|
||||
getline(importStream, csv_line); // ignore first line = header.
|
||||
while (getline(importStream, csv_line)) {
|
||||
remove_leading_whites(csv_line);
|
||||
replace_delimiter(csv_line);
|
||||
if ( check_ignore_line(csv_line) ) {
|
||||
continue;
|
||||
}
|
||||
read_line(csv_line, check_array);
|
||||
}
|
||||
importStream.close();
|
||||
|
||||
for (int i = 0; i< num_tot_bins; i++) {
|
||||
if (!check_array[i]) {
|
||||
std::stringstream ss;
|
||||
ss<<"Vec3_Container::load_data: Not all bins loaded.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
}
|
||||
delete[] check_array;
|
||||
}
|
||||
|
||||
void Vec3_Container::read_line(std::string csv_line, bool *check_array) {
|
||||
std::stringstream ss;
|
||||
ss.str(csv_line);
|
||||
int temp_bin;
|
||||
double temp_x, temp_y, temp_z;
|
||||
if ((ss>>temp_bin && ss>>temp_x) && (ss>>temp_y && ss>>temp_z)) {
|
||||
data[temp_bin] = vec3(temp_x, temp_y, temp_z);
|
||||
check_array[temp_bin] = true;
|
||||
} else {
|
||||
std::cout<<"Vec3_Container::load_data: Warning could not read line in inputFile. \nloadFilePath\t"<<csv_line<<"\n";
|
||||
}
|
||||
}
|
||||
|
||||
vec3 Vec3_Container::get_data (const vec3 &loc_m) {
|
||||
int bin = calc_data_bin(loc_m);
|
||||
return data[bin];
|
||||
}
|
||||
|
||||
int Vec3_Container::calc_data_bin(const vec3 &loc_m) {
|
||||
double z_m = calc_z_m(loc_m);
|
||||
double r_m = calc_r_m(loc_m);
|
||||
double phi = calc_phi(loc_m);
|
||||
int z_bin = z_scale.calc_index(z_m);
|
||||
int r_bin = r_scale.calc_index(r_m);
|
||||
int phi_bin = phi_scale.calc_index(phi);
|
||||
|
||||
return z_bin * r_scale.get_number_bins() * phi_scale.get_number_bins() + r_bin * phi_scale.get_number_bins() + phi_bin;
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// vec3_container.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 02.09.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef vec3_container_hpp
|
||||
#define vec3_container_hpp
|
||||
|
||||
#include "lin_scale.h"
|
||||
#include "kinematics.h"
|
||||
#include "constants.h"
|
||||
|
||||
class Vec3_Container {
|
||||
vec3 *data;
|
||||
Lin_Scale z_scale, r_scale, phi_scale;
|
||||
|
||||
public:
|
||||
Vec3_Container(int num_z_bins, int num_r_bins, int num_phi_bins, std::string load_path);
|
||||
|
||||
~Vec3_Container();
|
||||
Vec3_Container(const Vec3_Container& other);
|
||||
Vec3_Container& operator=(const Vec3_Container& other);
|
||||
private:
|
||||
void load_data(std::string load_path);
|
||||
void read_line(std::string csv_line, bool *check_array);
|
||||
public:
|
||||
vec3 get_data (const vec3 &loc_m);
|
||||
private:
|
||||
int calc_data_bin(const vec3 &loc_m);
|
||||
|
||||
};
|
||||
|
||||
#endif /* vec3_container_hpp */
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "constants.h"
|
||||
|
||||
// Bit sloppy since only works for velocity.dat which must have exact bins as specified in z_bins and r_bins here!!!
|
||||
// But velocities should be a constant of the simulation, therefore fine.
|
||||
|
||||
|
||||
class Velocity_Container {
|
||||
|
||||
Reference in New Issue
Block a user