Fixed bug in programm.

This commit is contained in:
Christian
2019-08-05 19:15:38 +02:00
parent 66df79925a
commit cc24fd0a99
8 changed files with 44 additions and 26 deletions
@@ -53,7 +53,7 @@ const size_t H5TB_Population_Interface::sizes[7] = {
void H5TB_Population_Interface::create() {
herr_t state = H5TBmake_table(table_name.c_str(), *loc_id, table_name.c_str(), 7, 0,
size, fieldNames, offset, fieldTypes,
chunkSize, nullptr, 0, nullptr);
chunkSize, NULL, 0, NULL);
if (state < 0) {
stringstream ss;
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() {
herr_t state = H5TBmake_table(table_name.c_str(), *loc_id, table_name.c_str(), 12, 0,
size, fieldNames, offset, fieldTypes,
chunkSize, nullptr, 0, nullptr);
chunkSize, NULL, 0, NULL);
if (state < 0) {
stringstream ss;
ss<<"H5TB_Population_Meta_Interface::create: Error creating.\n";
+9 -2
View File
@@ -7,7 +7,8 @@
//
#include "simulation.hpp"
#include <sys/types.h>
#include <unistd.h>
using namespace std;
@@ -20,6 +21,13 @@ int main(int argc, char *argv[]) {
if (rank==0) {
cout<<"Number CPUs: "<<size<<"\n"<<endl;
}
/*
std::cout << "Process " << getpid() << " is " << rank
<< " of " << size << " processes" << std::endl;
if (rank == 0) sleep(600);
*/
Simulation Sim;
int start_time = MPI_Wtime();
@@ -30,4 +38,3 @@ int main(int argc, char *argv[]) {
MPI_Finalize();
return 0;
}
+1 -1
View File
@@ -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 veo \
population_container.o velocity_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 \
+1 -1
View File
@@ -25,7 +25,7 @@ std::vector<species> get_all_species_vector();
std::string get_species_string(const species &spec);
species get_species_from_string(const std::string &species_string);
double get_species_mass(const species &spec);
int get_number_with_container ();
std::ostream& operator<<(std::ostream& os, const species& spec);
+7 -7
View File
@@ -43,7 +43,8 @@ string Population_Load_Saver::get_save_path() {
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<<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";
@@ -88,18 +89,17 @@ void Population_Load_Saver::write_species(ofstream *save_stream, species this_sp
*save_stream<<"end_of_species \n";
}
int Population_Load_Saver::calc_number() {
int num = 0;
int Population_Load_Saver::calc_number_pops() {
int num_species = 0;
vector<species> all_species = get_all_species_vector();
for (vector<species>::iterator itr = all_species.begin(); itr!= all_species.end(); itr++) {
if (populations->find(*itr)->access_container() != nullptr) {
num += 1 ;
num_species += 1 ;
}
}
return num;
return num_species;
}
void Population_Load_Saver::load() {
// Maybe change whole system to h5, therefore allowing sloppy style
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
int number_populations = get_num_populations_line(&load_stream);
if (number_populations != calc_number()) {
if (number_populations != calc_number_pops()) {
stringstream ss;
ss<<"Population_Load_Saver::load: Number Population missmatch.\n";
throw MyException(ss.str());
+1 -1
View File
@@ -27,7 +27,7 @@ private:
std::string get_save_path();
void write_overhead(std::ofstream *save_stream);
void write_species(std::ofstream *save_stream, species this_species);
int calc_number();
int calc_number_pops();
public:
void load();
+23 -12
View File
@@ -29,26 +29,37 @@ Simulation::~Simulation() {
}
void Simulation::init_pop_arrays() {
Population_Manager *populations = looper.get_populations();
int number_pop_species = 0;
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_array_lengths = new int[number_pop_species];
global_cum_time_s = new double *[number_pop_species];
global_offset = new double *[number_pop_species];
Population_Manager *populations = looper.get_populations();
Population_Base *population;
for (int i = 0; i<number_pop_species; i++) {
pop_species[i] = all_species[i];
population = populations->find(pop_species[i]);
pop_array_lengths[i] = population->access_container()->data_size;
global_cum_time_s[i] = new double[pop_array_lengths[i]];
global_offset[i] = new double[pop_array_lengths[i]];
for (int j = 0; j<pop_array_lengths[i]; j++) {
global_cum_time_s[i][j] = 0;
global_offset[i][j] = 0;
int i = 0;
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;
global_cum_time_s[i] = new double[pop_array_lengths[i]];
global_offset[i] = new double[pop_array_lengths[i]];
for (int j = 0; j<pop_array_lengths[i]; j++) {
global_cum_time_s[i][j] = 0;
global_offset[i][j] = 0;
}
i++;
}
}
}