Reworked logging model:
Added T+, T3+. Changes in logging hierarchie: Every species individually logs positions.
This commit is contained in:
@@ -15,15 +15,15 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
H5_File::H5_File(std::string name_extension) {
|
H5_File::H5_File(std::string output_path) {
|
||||||
create(name_extension);
|
create(output_path);
|
||||||
h5part = H5_Particles(&h5_file);
|
|
||||||
h5pop = H5_Populations(&h5_file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void H5_File::create(std::string output_path) {
|
void H5_File::create(std::string output_path) {
|
||||||
//const string constH5Name = get_file_name();
|
//const string constH5Name = get_file_name();
|
||||||
h5_file = H5Fcreate(output_path.c_str(), H5F_ACC_EXCL, H5P_DEFAULT, H5P_DEFAULT);
|
h5f = H5Fcreate(output_path.c_str(), H5F_ACC_EXCL, H5P_DEFAULT, H5P_DEFAULT);
|
||||||
|
h5g_particles = H5Gcreate(h5f, h5g_particles_path.c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
||||||
|
h5g_populations = H5Gcreate(h5f, h5g_populations_path.c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -9,19 +9,24 @@
|
|||||||
#ifndef h5_file_hpp
|
#ifndef h5_file_hpp
|
||||||
#define h5_file_hpp
|
#define h5_file_hpp
|
||||||
|
|
||||||
#include "h5_particles.h"
|
#include "hdf5.h"
|
||||||
#include "h5_populations.h"
|
#include "hdf5_hl.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class H5_File {
|
class H5_File {
|
||||||
hid_t h5_file;
|
hid_t h5f;
|
||||||
H5_Particles h5part;
|
hid_t h5g_particles;
|
||||||
H5_Populations h5pop;
|
hid_t h5g_populations;
|
||||||
|
|
||||||
|
std::string h5g_particles_path = "/Particles";
|
||||||
|
std::string h5g_populations_path = "/Populations";
|
||||||
|
|
||||||
public:
|
public:
|
||||||
H5_File() {};
|
H5_File() {};
|
||||||
H5_File(std::string output_path);
|
H5_File(std::string output_path);
|
||||||
H5_Particles *get_h5part() {return &h5part;}
|
hid_t *get_h5f() {return &h5f}
|
||||||
H5_Populations *get_h5pop() {return &h5pop;}
|
std::string get_h5g_particles_path() {return h5g_particles_path;}
|
||||||
|
std::string get_h5g_populations_path() {return h5g_populations_path;}
|
||||||
private:
|
private:
|
||||||
void create(std::string output_path);
|
void create(std::string output_path);
|
||||||
//std::string get_file_name();
|
//std::string get_file_name();
|
||||||
|
|||||||
@@ -1,120 +0,0 @@
|
|||||||
//
|
|
||||||
// h5_particles.h
|
|
||||||
// mc_electron
|
|
||||||
//
|
|
||||||
// Created by Christian Reiling on 18.05.19.
|
|
||||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef h5_particles_h
|
|
||||||
#define h5_particles_h
|
|
||||||
|
|
||||||
#include "read_system.h"
|
|
||||||
#include <string>
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
#include "hdf5.h"
|
|
||||||
#include "hdf5_hl.h"
|
|
||||||
|
|
||||||
#include "katrin_geo.h"
|
|
||||||
|
|
||||||
class H5_Particles {
|
|
||||||
int numberZBins;
|
|
||||||
bool logging;
|
|
||||||
double *zValues;
|
|
||||||
|
|
||||||
|
|
||||||
hid_t *h5_file;
|
|
||||||
hid_t *h5g_particles;
|
|
||||||
hid_t *h5g_z;
|
|
||||||
|
|
||||||
public:
|
|
||||||
H5_Particles() {};
|
|
||||||
H5_Particles(hid_t *h5_file);
|
|
||||||
|
|
||||||
int get_numberZBins() {return numberZBins;}
|
|
||||||
bool get_logging() {return logging;}
|
|
||||||
double *get_zValues() {return zValues;}
|
|
||||||
hid_t *get_h5g_z() {return h5g_z;}
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
void set_logging();
|
|
||||||
void set_zValues();
|
|
||||||
void print_logInfo();
|
|
||||||
|
|
||||||
void create_h5gs();
|
|
||||||
};
|
|
||||||
|
|
||||||
inline H5_Particles::H5_Particles(hid_t *h5_file) {
|
|
||||||
this->h5_file = h5_file;
|
|
||||||
numberZBins = load_parameter("numberZBins");
|
|
||||||
set_logging();
|
|
||||||
set_zValues();
|
|
||||||
//print_logInfo();
|
|
||||||
|
|
||||||
create_h5gs();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline void H5_Particles::set_logging() {
|
|
||||||
if (numberZBins == 0) {
|
|
||||||
logging = false;
|
|
||||||
} else if (numberZBins == -1 || numberZBins > 0){
|
|
||||||
logging = true;
|
|
||||||
} else {
|
|
||||||
std::stringstream ss;
|
|
||||||
ss<<"H5_Logger::Parameter numberZBins invalid value.\nnumberZBins:\t"<<numberZBins<<"\n";
|
|
||||||
throw MyException (ss.str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void H5_Particles::set_zValues() {
|
|
||||||
if (logging) {
|
|
||||||
zValues = new double[numberZBins];
|
|
||||||
double start_m = z_RW_m;
|
|
||||||
double length_m = z_WGTS_end_m - start_m;
|
|
||||||
double stepLength_m = length_m/(numberZBins-1);
|
|
||||||
|
|
||||||
double z_m;
|
|
||||||
for (int i = 0;i<numberZBins;i++) {
|
|
||||||
z_m = start_m + stepLength_m*i;
|
|
||||||
zValues[i] = z_m;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void H5_Particles::print_logInfo() {
|
|
||||||
std::stringstream ss;
|
|
||||||
if (!logging) {
|
|
||||||
ss<<"Logging disabled.\n";
|
|
||||||
} else if (numberZBins == -1) {
|
|
||||||
ss<<"Logging after every Interaction to one file.\n";
|
|
||||||
} else if (numberZBins == 1) {
|
|
||||||
ss<<"Only Logging Rearwall Output.\n";
|
|
||||||
} else {
|
|
||||||
ss<<"Logging at "<<numberZBins<<" z values.\n";
|
|
||||||
}
|
|
||||||
std::cout<<ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void H5_Particles::create_h5gs() {
|
|
||||||
h5g_particles = new hid_t;
|
|
||||||
*h5g_particles = H5Gcreate(*h5_file, "/Particles", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
|
||||||
|
|
||||||
if (numberZBins == -1) {
|
|
||||||
h5g_z = new hid_t[1];
|
|
||||||
h5g_z[0] = H5Gcreate(*h5_file, "/Particles/z=all", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
|
||||||
} else {
|
|
||||||
h5g_z = new hid_t [numberZBins];
|
|
||||||
for (int i = 0; i < numberZBins; i++)
|
|
||||||
{
|
|
||||||
std::stringstream ss;
|
|
||||||
ss << "/Particles/" << zValues[i];
|
|
||||||
h5g_z[i] = H5Gcreate(*h5_file, ss.str().c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* h5_particles_h */
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
//
|
|
||||||
// h5_populations.h
|
|
||||||
// mc_electron
|
|
||||||
//
|
|
||||||
// Created by Christian Reiling on 28.05.19.
|
|
||||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef h5_populations_h
|
|
||||||
#define h5_populations_h
|
|
||||||
|
|
||||||
#include "read_system.h"
|
|
||||||
#include <string>
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
#include "hdf5.h"
|
|
||||||
#include "hdf5_hl.h"
|
|
||||||
|
|
||||||
#include "katrin_geo.h"
|
|
||||||
|
|
||||||
class H5_Populations {
|
|
||||||
hid_t *h5_file;
|
|
||||||
hid_t *h5g_populations;
|
|
||||||
|
|
||||||
public:
|
|
||||||
H5_Populations() {};
|
|
||||||
H5_Populations(hid_t *h5_file);
|
|
||||||
|
|
||||||
hid_t *get_h5g_pop() {return h5g_populations;}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
inline H5_Populations::H5_Populations(hid_t *h5_file) {
|
|
||||||
this->h5_file = h5_file;
|
|
||||||
h5g_populations = new hid_t;
|
|
||||||
*h5g_populations = H5Gcreate(*h5_file, "/Populations", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* h5_populations_h */
|
|
||||||
@@ -14,41 +14,53 @@
|
|||||||
|
|
||||||
#include "population_logger_base.h"
|
#include "population_logger_base.h"
|
||||||
|
|
||||||
|
const int Particle_Logger_Builder::logging = load_parameter("logging");
|
||||||
|
const int Particle_Logger_Builder::numberZBins = load_parameter("numberZBins");
|
||||||
|
|
||||||
Particle_Logger_Manager Particle_Logger_Builder::build(H5_File *h5f) {
|
Particle_Logger_Manager Particle_Logger_Builder::build(H5_File *h5f) {
|
||||||
Particle_Logger_Manager ParticleLogger;
|
Particle_Logger_Manager ParticleLogger;
|
||||||
H5_Particles *h5part = h5f->get_h5part();
|
|
||||||
double z_rw = z_RW_m;
|
|
||||||
ParticleLogger.add(build_eLogger(h5part));
|
|
||||||
ParticleLogger.add(new Off_Particle_Logger(tritium));
|
ParticleLogger.add(new Off_Particle_Logger(tritium));
|
||||||
ParticleLogger.add (new MultiZ_Particle_Logger(tritiumI, 1, &z_rw, h5part->get_h5g_z()));
|
|
||||||
ParticleLogger.add (new MultiZ_Particle_Logger(tritium2I, 1, &z_rw, h5part->get_h5g_z()));
|
|
||||||
ParticleLogger.add (new MultiZ_Particle_Logger(tritium3I, 1, &z_rw, h5part->get_h5g_z()));
|
|
||||||
|
|
||||||
/*
|
if (logging == 0) {
|
||||||
|
ParticleLogger.add(new Off_Particle_Logger(electron));
|
||||||
ParticleLogger.add(new Off_Particle_Logger(tritiumI));
|
ParticleLogger.add(new Off_Particle_Logger(tritiumI));
|
||||||
ParticleLogger.add(new Off_Particle_Logger(tritium2I));
|
ParticleLogger.add(new Off_Particle_Logger(tritium2I));
|
||||||
ParticleLogger.add(new Off_Particle_Logger(tritium3I));
|
ParticleLogger.add(new Off_Particle_Logger(tritium3I));
|
||||||
*/
|
} else if(numberZBins == -1){
|
||||||
|
ParticleLogger.add(new SF_Particle_Logger(electron, h5f));
|
||||||
|
ParticleLogger.add(new SF_Particle_Logger(tritiumI, h5f));
|
||||||
|
ParticleLogger.add(new SF_Particle_Logger(tritium2I, h5f));
|
||||||
|
ParticleLogger.add(new SF_Particle_Logger(tritium3I, h5f));
|
||||||
|
} else {
|
||||||
|
build_MultiZ(&ParticleLogger, h5f);
|
||||||
|
}
|
||||||
return ParticleLogger;
|
return ParticleLogger;
|
||||||
}
|
}
|
||||||
|
|
||||||
Particle_Logger_Base *Particle_Logger_Builder::build_eLogger(H5_Particles *h5part) {
|
void Population_Logger_Builder::build_MultiZ(Particle_Logger_Manager *ParticleLogger, H5_File *h5f) {
|
||||||
Particle_Logger_Base *res;
|
double *zValues = new double[numberZBins];
|
||||||
if (h5part->get_logging() == false) {
|
double start_m = z_RW_m;
|
||||||
res = new Off_Particle_Logger(electron);
|
double length_m = z_WGTS_end_m - start_m;
|
||||||
} else if(h5part->get_numberZBins() == -1){
|
double stepLength_m = length_m/(numberZBins-1);
|
||||||
res = new SF_Particle_Logger(electron, h5part->get_h5g_z());
|
|
||||||
} else {
|
double z_m;
|
||||||
res = new MultiZ_Particle_Logger(electron, h5part->get_numberZBins(), h5part->get_zValues(), h5part->get_h5g_z());
|
for (int i = 0;i<numberZBins;i++) {
|
||||||
|
z_m = start_m + stepLength_m*i;
|
||||||
|
zValues[i] = z_m;
|
||||||
}
|
}
|
||||||
return res;
|
ParticleLogger->add(new MultiZ_Particle_Logger(electron, h5f, numberZBins, zValues));
|
||||||
|
ParticleLogger->add(new MultiZ_Particle_Logger(tritiumI, h5f, numberZBins, zValues));
|
||||||
|
ParticleLogger->add(new MultiZ_Particle_Logger(tritium2I, h5f, numberZBins, zValues));
|
||||||
|
ParticleLogger->add(new MultiZ_Particle_Logger(tritium3I, h5f, numberZBins, zValues));
|
||||||
|
|
||||||
|
delete[] zValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Population_Logger_Manager Population_Logger_Builder::build(H5_File *h5f, Population_Manager *populations, Timer *timer) {
|
Population_Logger_Manager Population_Logger_Builder::build(H5_File *h5f, Population_Manager *populations, Timer *timer) {
|
||||||
Population_Logger_Manager Population_Loggers;
|
Population_Logger_Manager Population_Loggers;
|
||||||
hid_t *h5pop = h5f->get_h5pop()->get_h5g_pop();
|
Population_Loggers.add (new Population_Logger(populations->find(tritiumI), timer, h5f));
|
||||||
Population_Base *T2I_population = populations->find(tritium2I);
|
Population_Loggers.add (new Population_Logger(populations->find(tritium2I), timer, h5f));
|
||||||
Population_Loggers.add (new Population_Logger(T2I_population, timer, h5pop));
|
Population_Loggers.add (new Population_Logger(populations->find(tritium3I), timer, h5f));
|
||||||
return Population_Loggers;
|
return Population_Loggers;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,24 +19,22 @@
|
|||||||
|
|
||||||
typedef Manager_Base<Particle_Logger_Base> Particle_Logger_Manager;
|
typedef Manager_Base<Particle_Logger_Base> Particle_Logger_Manager;
|
||||||
|
|
||||||
class Particle_Logger_Builder {
|
|
||||||
|
|
||||||
|
class Particle_Logger_Builder {
|
||||||
|
static const int logging;
|
||||||
|
static const int numberZBins;
|
||||||
public:
|
public:
|
||||||
Particle_Logger_Builder() {};
|
Particle_Logger_Builder() {};
|
||||||
|
|
||||||
static Particle_Logger_Manager build(H5_File *h5f);
|
static Particle_Logger_Manager build(H5_File *h5f);
|
||||||
private:
|
static void build_MultiZ(Particle_Logger_Manager *ParticleLogger, H5_File *h5f);
|
||||||
static Particle_Logger_Base *build_eLogger(H5_Particles *h5part);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Population_Logger_Builder {
|
class Population_Logger_Builder {
|
||||||
public:
|
public:
|
||||||
Population_Logger_Builder() {};
|
Population_Logger_Builder() {};
|
||||||
|
|
||||||
static Population_Logger_Manager build(H5_File *h5f, Population_Manager *populations, Timer *timer);
|
static Population_Logger_Manager build(H5_File *h5f, Population_Manager *populations, Timer *timer);
|
||||||
//private:
|
|
||||||
//static Population_Logger_Manager *build_Logger(H5_Particles *h5part);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ int main(int argc, char *argv[]) {
|
|||||||
int size, rank;
|
int size, rank;
|
||||||
MPI_Comm_size(MPI_COMM_WORLD,&size);
|
MPI_Comm_size(MPI_COMM_WORLD,&size);
|
||||||
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
|
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
|
||||||
std::cout <<"CPU " <<rank <<" of " <<size <<endl;
|
if (rank==0) {
|
||||||
|
cout<<"Number CPUs: "<<size<<"\n"<<endl;
|
||||||
|
}
|
||||||
Simulation Sim;
|
Simulation Sim;
|
||||||
|
|
||||||
int start_time = MPI_Wtime();
|
int start_time = MPI_Wtime();
|
||||||
@@ -25,62 +27,7 @@ int main(int argc, char *argv[]) {
|
|||||||
if (rank == 0) {
|
if (rank == 0) {
|
||||||
cout<<"Total Time: "<<MPI_Wtime()-start_time<<" s\n";
|
cout<<"Total Time: "<<MPI_Wtime()-start_time<<" s\n";
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
clock_t start = clock();
|
|
||||||
|
|
||||||
|
|
||||||
cout<<"Duration: "<< ( clock() - start ) / (double) CLOCKS_PER_SEC <<"\n";
|
|
||||||
*/
|
|
||||||
MPI_Finalize();
|
MPI_Finalize();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
MPI_Init(&argc,&argv);
|
|
||||||
|
|
||||||
int size, rank;
|
|
||||||
MPI_Comm_size(MPI_COMM_WORLD,&size);
|
|
||||||
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
|
|
||||||
std::cout <<"CPU " <<rank <<" of " <<size <<endl;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MPI_Info info;
|
|
||||||
MPI_Info_create(&info);
|
|
||||||
|
|
||||||
hid_t plist_id = H5Pcreate(H5P_FILE_ACCESS);
|
|
||||||
H5Pset_fapl_mpio(plist_id, MPI_COMM_WORLD, info);
|
|
||||||
|
|
||||||
string filename="/Users/ChristianReiling/Desktop/MPI_test/outfiles/tableout.h5";
|
|
||||||
hid_t file;
|
|
||||||
file = H5Fcreate(filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, plist_id);
|
|
||||||
|
|
||||||
if(file <0) {
|
|
||||||
cerr << "Unable to create " << filename << "!" <<endl;
|
|
||||||
exit(941);
|
|
||||||
}
|
|
||||||
H5Pclose(plist_id);
|
|
||||||
|
|
||||||
H5TB_Particle_Interface table = H5TB_Particle_Interface("Samples", &file);
|
|
||||||
if (rank == 1) {
|
|
||||||
Particle electron = Particle_Builder::create_e(vec3(1,2,3), vec3 (4,5,6), 7, 8);
|
|
||||||
table.write(electron);
|
|
||||||
}
|
|
||||||
if (rank == 0) {
|
|
||||||
Particle electron = Particle_Builder::create_e(vec3(1,2,3), vec3 (4,5,6), 0, -1);
|
|
||||||
table.write(electron);
|
|
||||||
}
|
|
||||||
H5Fclose(file);
|
|
||||||
|
|
||||||
MPI_Finalize();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,43 +10,51 @@
|
|||||||
#define multiz_particle_logger_h
|
#define multiz_particle_logger_h
|
||||||
|
|
||||||
#include "particle_logger_base.h"
|
#include "particle_logger_base.h"
|
||||||
|
#include "h5_file.hpp"
|
||||||
|
|
||||||
|
|
||||||
class MultiZ_Particle_Logger : public Particle_Logger_Base {
|
class MultiZ_Particle_Logger : public Particle_Logger_Base {
|
||||||
|
hid_t h5g_species;
|
||||||
H5TB_Particle_Interface *h5tb;
|
H5TB_Particle_Interface *h5tb;
|
||||||
|
|
||||||
int numberZBins;
|
int numberZBins;
|
||||||
double *zLogValues;
|
double *zLogValues;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MultiZ_Particle_Logger(species this_species, const int &numberZBins, double *zLogValues, hid_t *h5g_z) : Particle_Logger_Base(this_species) {
|
MultiZ_Particle_Logger(species this_species, H5_File *h5_file, const int &numberZBins, double *zLogValues) : Particle_Logger_Base(this_species) {
|
||||||
this->numberZBins = numberZBins;
|
this->numberZBins = numberZBins;
|
||||||
this->zLogValues = new double[numberZBins];
|
this->zLogValues = new double[numberZBins];
|
||||||
for (int i = 0; i<numberZBins; i++) {
|
for (int i = 0; i<numberZBins; i++) {
|
||||||
this->zLogValues[i] = zLogValues[i];
|
this->zLogValues[i] = zLogValues[i];
|
||||||
}
|
}
|
||||||
create(h5g_z);
|
create(h5_file, this_species);
|
||||||
}
|
}
|
||||||
~MultiZ_Particle_Logger() {
|
~MultiZ_Particle_Logger() {
|
||||||
delete[] zLogValues;
|
delete[] zLogValues;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
void create(hid_t *h5g_z);
|
void create(H5_File *h5_file, species this_species);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void log(const Particle &logPart, const vec3 &oldLoc_m);
|
void log(const Particle &logPart, const vec3 &oldLoc_m);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline void MultiZ_Particle_Logger::create(hid_t *h5g_z) {
|
inline void MultiZ_Particle_Logger::create(H5_File *h5_file, species this_species) {
|
||||||
std::string speciesName = get_species_string(get_species());
|
std::stringstream ss;
|
||||||
|
ss<<h5_file->get_h5g_particles_path()<<"/"<<get_species_string(this_species);
|
||||||
|
h5g_species = H5Gcreate(*h5_file->get_h5f(), ss.str().c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
||||||
|
|
||||||
if (numberZBins < 1) {
|
if (numberZBins < 1) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss<<"MultiZ_Particle_Logger::create: numberZBins < 1.\n";
|
ss<<"MultiZ_Particle_Logger::create: numberZBins < 1.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
h5tb = new H5TB_Particle_Interface[numberZBins];
|
h5tb = new H5TB_Particle_Interface[numberZBins];
|
||||||
|
std::string table_name;
|
||||||
for (int i = 0; i < numberZBins; i++) {
|
for (int i = 0; i < numberZBins; i++) {
|
||||||
h5tb[i] = H5TB_Particle_Interface(speciesName, &h5g_z[i]);
|
table_name = std::to_string(zLogValues[i]);
|
||||||
|
h5tb[i] = H5TB_Particle_Interface(table_name.c_str(), &h5g_species);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,12 +21,15 @@ class Population_Logger {
|
|||||||
H5TB_Population_Interface h5tb;
|
H5TB_Population_Interface h5tb;
|
||||||
H5TB_Population_Meta_Interface h5tb_meta;
|
H5TB_Population_Meta_Interface h5tb_meta;
|
||||||
|
|
||||||
|
hid_t h5g_species;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Population_Logger(Population_Base *pop, Timer *timer, hid_t *h5g);
|
Population_Logger(Population_Base *pop, Timer *timer, H5_File *h5f);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void create_h5tb_meta(hid_t *h5g);
|
void create_h5g_species(H5_File *h5_file);
|
||||||
void create_h5tb(hid_t *h5g);
|
void create_h5tb_meta();
|
||||||
|
void create_h5tb();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void log();
|
void log();
|
||||||
@@ -34,26 +37,32 @@ private:
|
|||||||
pop_log_bin transform(pop_bin_content pop_bin);
|
pop_log_bin transform(pop_bin_content pop_bin);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline Population_Logger::Population_Logger(Population_Base *pop, Timer *timer, hid_t *h5g) {
|
inline Population_Logger::Population_Logger(Population_Base *pop, Timer *timer, H5_File *h5_file) {
|
||||||
this->pop = pop;
|
this->pop = pop;
|
||||||
this->timer = timer;
|
this->timer = timer;
|
||||||
create_h5tb_meta(h5g);
|
create_h5g_species(h5_file);
|
||||||
create_h5tb(h5g);
|
create_h5tb_meta();
|
||||||
|
create_h5tb();
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void Population_Logger::create_h5tb_meta(hid_t *h5g) {
|
inline void Population_Logger::create_h5g_species(H5_File *h5_file) {
|
||||||
|
std::string group_name = get_species_string(pop->get_species());
|
||||||
|
h5g_species = H5Gcreate(*h5_file->get_h5f(), group_name.c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Population_Logger::create_h5tb_meta() {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss<<get_species_string(pop->get_species())<<"_meta_data";
|
ss<<get_species_string(pop->get_species())<<"_meta_data";
|
||||||
h5tb_meta = H5TB_Population_Meta_Interface(ss.str(), h5g);
|
h5tb_meta = H5TB_Population_Meta_Interface(ss.str(), &h5g_species);
|
||||||
meta_vec bins_meta_info = pop->get_bins_meta_info();
|
meta_vec bins_meta_info = pop->get_bins_meta_info();
|
||||||
for (meta_vec::iterator itr = bins_meta_info.begin(); itr != bins_meta_info.end(); itr++) {
|
for (meta_vec::iterator itr = bins_meta_info.begin(); itr != bins_meta_info.end(); itr++) {
|
||||||
h5tb_meta.write(*itr);
|
h5tb_meta.write(*itr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Population_Logger::create_h5tb(hid_t *h5g) {
|
inline void Population_Logger::create_h5tb() {
|
||||||
std::string species_string = get_species_string(pop->get_species());
|
std::string species_string = get_species_string(pop->get_species());
|
||||||
h5tb = H5TB_Population_Interface(species_string, h5g);
|
h5tb = H5TB_Population_Interface(species_string, &h5g_species);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Population_Logger::log() {
|
inline void Population_Logger::log() {
|
||||||
|
|||||||
@@ -10,27 +10,31 @@
|
|||||||
#define sf_particle_logger_h
|
#define sf_particle_logger_h
|
||||||
|
|
||||||
#include "particle_logger_base.h"
|
#include "particle_logger_base.h"
|
||||||
|
#include "h5_file.hpp"
|
||||||
|
|
||||||
|
|
||||||
class SF_Particle_Logger : public Particle_Logger_Base {
|
class SF_Particle_Logger : public Particle_Logger_Base {
|
||||||
|
hid_t h5g_species;
|
||||||
H5TB_Particle_Interface h5tb;
|
H5TB_Particle_Interface h5tb;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SF_Particle_Logger(species this_species, hid_t *h5g_z) : Particle_Logger_Base(this_species) {
|
SF_Particle_Logger(species this_species, H5_File *h5_file) : Particle_Logger_Base(this_species) {
|
||||||
create(h5g_z);
|
create(h5_file, this_species);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void create(hid_t *h5g_z);
|
void create(H5_File *h5_file, species this_species);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void log(const Particle &logPart, const vec3 &oldLoc_m);
|
void log(const Particle &logPart, const vec3 &oldLoc_m);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline void SF_Particle_Logger::create(hid_t *h5g_z) {
|
inline void SF_Particle_Logger::create(H5_File *h5_file, species this_species) {
|
||||||
std::string speciesName = get_species_string(get_species());
|
std::stringstream ss;
|
||||||
h5tb = H5TB_Particle_Interface(speciesName, h5g_z);
|
ss<<h5_file->get_h5g_particles_path()<<"/"<<get_species_string(this_species);
|
||||||
|
h5g_species = H5Gcreate(*h5_file->get_h5f(), ss.str().c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
||||||
|
h5tb = H5TB_Particle_Interface("all", &h5g_species);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void SF_Particle_Logger::log(const Particle &logPart, const vec3 &oldLoc_m) {
|
inline void SF_Particle_Logger::log(const Particle &logPart, const vec3 &oldLoc_m) {
|
||||||
|
|||||||
Reference in New Issue
Block a user