Fixed bug in programm.
This commit is contained in:
@@ -53,7 +53,7 @@ const size_t H5TB_Population_Interface::sizes[7] = {
|
|||||||
void H5TB_Population_Interface::create() {
|
void H5TB_Population_Interface::create() {
|
||||||
herr_t state = H5TBmake_table(table_name.c_str(), *loc_id, table_name.c_str(), 7, 0,
|
herr_t state = H5TBmake_table(table_name.c_str(), *loc_id, table_name.c_str(), 7, 0,
|
||||||
size, fieldNames, offset, fieldTypes,
|
size, fieldNames, offset, fieldTypes,
|
||||||
chunkSize, nullptr, 0, nullptr);
|
chunkSize, NULL, 0, NULL);
|
||||||
if (state < 0) {
|
if (state < 0) {
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss<<"H5TB_Population_Interface::create: Error creating.\n";
|
ss<<"H5TB_Population_Interface::create: Error creating.\n";
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ const size_t H5TB_Population_Meta_Interface::sizes[12] = {
|
|||||||
void H5TB_Population_Meta_Interface::create() {
|
void H5TB_Population_Meta_Interface::create() {
|
||||||
herr_t state = H5TBmake_table(table_name.c_str(), *loc_id, table_name.c_str(), 12, 0,
|
herr_t state = H5TBmake_table(table_name.c_str(), *loc_id, table_name.c_str(), 12, 0,
|
||||||
size, fieldNames, offset, fieldTypes,
|
size, fieldNames, offset, fieldTypes,
|
||||||
chunkSize, nullptr, 0, nullptr);
|
chunkSize, NULL, 0, NULL);
|
||||||
if (state < 0) {
|
if (state < 0) {
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss<<"H5TB_Population_Meta_Interface::create: Error creating.\n";
|
ss<<"H5TB_Population_Meta_Interface::create: Error creating.\n";
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "simulation.hpp"
|
#include "simulation.hpp"
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -20,6 +21,13 @@ int main(int argc, char *argv[]) {
|
|||||||
if (rank==0) {
|
if (rank==0) {
|
||||||
cout<<"Number CPUs: "<<size<<"\n"<<endl;
|
cout<<"Number CPUs: "<<size<<"\n"<<endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
std::cout << "Process " << getpid() << " is " << rank
|
||||||
|
<< " of " << size << " processes" << std::endl;
|
||||||
|
if (rank == 0) sleep(600);
|
||||||
|
*/
|
||||||
|
|
||||||
Simulation Sim;
|
Simulation Sim;
|
||||||
|
|
||||||
int start_time = MPI_Wtime();
|
int start_time = MPI_Wtime();
|
||||||
@@ -30,4 +38,3 @@ int main(int argc, char *argv[]) {
|
|||||||
MPI_Finalize();
|
MPI_Finalize();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ include $(HOMEBASE)/src/makeinclude/include.mak
|
|||||||
|
|
||||||
OBJS := particle_looper.o \
|
OBJS := particle_looper.o \
|
||||||
tcs_container.o dcs_theta_container.o dcs_ionization_container.o \
|
tcs_container.o dcs_theta_container.o dcs_ionization_container.o \
|
||||||
population_container.o veo \
|
population_container.o velocity_container.o \
|
||||||
thermalPop_container.o energeticPop_container.o \
|
thermalPop_container.o energeticPop_container.o \
|
||||||
particle.o injector.o timer.o katrin_fields.o \
|
particle.o injector.o timer.o katrin_fields.o \
|
||||||
h5_file.o logger_builder.o population_load_saver.o \
|
h5_file.o logger_builder.o population_load_saver.o \
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ std::vector<species> get_all_species_vector();
|
|||||||
std::string get_species_string(const species &spec);
|
std::string get_species_string(const species &spec);
|
||||||
species get_species_from_string(const std::string &species_string);
|
species get_species_from_string(const std::string &species_string);
|
||||||
double get_species_mass(const species &spec);
|
double get_species_mass(const species &spec);
|
||||||
|
int get_number_with_container ();
|
||||||
std::ostream& operator<<(std::ostream& os, const species& spec);
|
std::ostream& operator<<(std::ostream& os, const species& spec);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ string Population_Load_Saver::get_save_path() {
|
|||||||
|
|
||||||
void Population_Load_Saver::write_overhead(ofstream *save_stream) {
|
void Population_Load_Saver::write_overhead(ofstream *save_stream) {
|
||||||
*save_stream<<"# File is automatically created. File contains Populations Density. To be loaded as start offset.\n";
|
*save_stream<<"# File is automatically created. File contains Populations Density. To be loaded as start offset.\n";
|
||||||
*save_stream<<calc_number()<<"\t # Number of Populations \n";
|
int num_species = calc_number_pops();
|
||||||
|
*save_stream<<num_species<<"\t # Number of Populations \n";
|
||||||
|
|
||||||
*save_stream<<timer->get_time_s()<<"\t # Offset Time in seconds \n";
|
*save_stream<<timer->get_time_s()<<"\t # Offset Time in seconds \n";
|
||||||
|
|
||||||
@@ -88,18 +89,17 @@ void Population_Load_Saver::write_species(ofstream *save_stream, species this_sp
|
|||||||
*save_stream<<"end_of_species \n";
|
*save_stream<<"end_of_species \n";
|
||||||
}
|
}
|
||||||
|
|
||||||
int Population_Load_Saver::calc_number() {
|
int Population_Load_Saver::calc_number_pops() {
|
||||||
int num = 0;
|
int num_species = 0;
|
||||||
vector<species> all_species = get_all_species_vector();
|
vector<species> all_species = get_all_species_vector();
|
||||||
for (vector<species>::iterator itr = all_species.begin(); itr!= all_species.end(); itr++) {
|
for (vector<species>::iterator itr = all_species.begin(); itr!= all_species.end(); itr++) {
|
||||||
if (populations->find(*itr)->access_container() != nullptr) {
|
if (populations->find(*itr)->access_container() != nullptr) {
|
||||||
num += 1 ;
|
num_species += 1 ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return num;
|
return num_species;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Population_Load_Saver::load() {
|
void Population_Load_Saver::load() {
|
||||||
// Maybe change whole system to h5, therefore allowing sloppy style
|
// Maybe change whole system to h5, therefore allowing sloppy style
|
||||||
string load_path = get_enviroment_variable("pop_load_path");
|
string load_path = get_enviroment_variable("pop_load_path");
|
||||||
@@ -115,7 +115,7 @@ void Population_Load_Saver::load() {
|
|||||||
}
|
}
|
||||||
goto_nextline(&load_stream); //ignore first line
|
goto_nextline(&load_stream); //ignore first line
|
||||||
int number_populations = get_num_populations_line(&load_stream);
|
int number_populations = get_num_populations_line(&load_stream);
|
||||||
if (number_populations != calc_number()) {
|
if (number_populations != calc_number_pops()) {
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss<<"Population_Load_Saver::load: Number Population missmatch.\n";
|
ss<<"Population_Load_Saver::load: Number Population missmatch.\n";
|
||||||
throw MyException(ss.str());
|
throw MyException(ss.str());
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ private:
|
|||||||
std::string get_save_path();
|
std::string get_save_path();
|
||||||
void write_overhead(std::ofstream *save_stream);
|
void write_overhead(std::ofstream *save_stream);
|
||||||
void write_species(std::ofstream *save_stream, species this_species);
|
void write_species(std::ofstream *save_stream, species this_species);
|
||||||
int calc_number();
|
int calc_number_pops();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void load();
|
void load();
|
||||||
|
|||||||
@@ -29,19 +29,28 @@ Simulation::~Simulation() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Simulation::init_pop_arrays() {
|
void Simulation::init_pop_arrays() {
|
||||||
|
Population_Manager *populations = looper.get_populations();
|
||||||
|
|
||||||
|
int number_pop_species = 0;
|
||||||
vector<species> all_species = get_all_species_vector();
|
vector<species> all_species = get_all_species_vector();
|
||||||
number_pop_species = all_species.size();
|
for (vector<species>::iterator itr = all_species.begin(); itr!= all_species.end(); itr++) {
|
||||||
|
if (populations->find(*itr)->access_container() != nullptr) {
|
||||||
|
number_pop_species += 1 ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pop_species = new species[number_pop_species];
|
pop_species = new species[number_pop_species];
|
||||||
pop_array_lengths = new int[number_pop_species];
|
pop_array_lengths = new int[number_pop_species];
|
||||||
global_cum_time_s = new double *[number_pop_species];
|
global_cum_time_s = new double *[number_pop_species];
|
||||||
global_offset = new double *[number_pop_species];
|
global_offset = new double *[number_pop_species];
|
||||||
|
|
||||||
Population_Manager *populations = looper.get_populations();
|
|
||||||
Population_Base *population;
|
Population_Base *population;
|
||||||
for (int i = 0; i<number_pop_species; i++) {
|
|
||||||
pop_species[i] = all_species[i];
|
int i = 0;
|
||||||
population = populations->find(pop_species[i]);
|
for (vector<species>::iterator itr = all_species.begin(); itr!= all_species.end(); itr++) {
|
||||||
|
if (populations->find(*itr)->access_container() != nullptr) {
|
||||||
|
pop_species[i] = *itr;
|
||||||
|
population = populations->find(*itr);
|
||||||
|
|
||||||
pop_array_lengths[i] = population->access_container()->data_size;
|
pop_array_lengths[i] = population->access_container()->data_size;
|
||||||
global_cum_time_s[i] = new double[pop_array_lengths[i]];
|
global_cum_time_s[i] = new double[pop_array_lengths[i]];
|
||||||
@@ -50,6 +59,8 @@ void Simulation::init_pop_arrays() {
|
|||||||
global_cum_time_s[i][j] = 0;
|
global_cum_time_s[i][j] = 0;
|
||||||
global_offset[i][j] = 0;
|
global_offset[i][j] = 0;
|
||||||
}
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user