Documenting SimParams

This commit is contained in:
Max Lübke 2021-02-02 14:14:22 +01:00
parent 12f7820f91
commit 991f825dc6
2 changed files with 94 additions and 41 deletions

View File

@ -129,19 +129,6 @@ int SimParams::parseFromCmdl(char *argv[], RRuntime &R) {
void SimParams::initVectorParams(RRuntime &R, int col_count) {
if (simparams.dht_enabled) {
// cout << "\nCreating DHT\n";
// determine size of dht entries
// int dht_data_size = grid.getCols() * sizeof(double);
// int dht_key_size =
// grid.getCols() * sizeof(double) + (params.dt_differ *
// sizeof(double));
// // // determine bucket count for preset memory usage
// // // bucket size is key + value + 1 byte for status
// int dht_buckets_per_process =
// params.dht_size_per_process / (1 + dht_data_size + dht_key_size);
// MDL : following code moved here from worker.cpp
/*Load significance vector from R setup file (or set default)*/
bool signif_vector_exists = R.parseEval("exists('signif_vector')");
if (signif_vector_exists) {
@ -159,12 +146,6 @@ void SimParams::initVectorParams(RRuntime &R, int col_count) {
}
if (simparams.world_rank == 0) {
// // print only on master, values are equal on all workes
// cout << "CPP: dht_data_size: " << dht_data_size << "\n";
// cout << "CPP: dht_key_size: " << dht_key_size << "\n";
// cout << "CPP: dht_buckets_per_process: " << dht_buckets_per_process
// << endl;
// MDL: new output on signif_vector and prop_type
if (signif_vector_exists) {
cout << "CPP: using problem-specific rounding digits: " << endl;
@ -184,28 +165,6 @@ void SimParams::initVectorParams(RRuntime &R, int col_count) {
}
}
// void SimParams::parseR(RRuntime &R) {
// // if local_rank == 0 then master else worker
// R["local_rank"] = simparams.world_rank;
// // assign a char* (string) to 'filesim'
// R["filesim"] = wrap(simparams.filesim);
// // assign a char* (string) to 'fileout'
// R["fileout"] = wrap(simparams.out_dir);
// // pass the boolean "store_result" to the R process
// R["store_result"] = simparams.store_result;
// // worker count
// R["n_procs"] = simparams.world_size - 1;
// // work package size
// R["work_package_size"] = simparams.wp_size;
// // dht enabled?
// R["dht_enabled"] = simparams.dht_enabled;
// // log before rounding?
// R["dht_log"] = simparams.dht_log;
// // eval the init string, ignoring any returns
// R.parseEvalQ("source(filesim)");
// }
void SimParams::setDtDiffer(bool dt_differ) { simparams.dt_differ = dt_differ; }
t_simparams SimParams::getNumParams() { return this->simparams; }

View File

@ -87,17 +87,88 @@ class SimParams {
*/
int parseFromCmdl(char *argv[], RRuntime &R);
/**
* @brief Init std::vector values
*
* This will initialize dht_signif_vector and dht_prop_type_vector internally
* depending on whether vectors are defined by R-Simulation file or not.
* 'init_chemistry' must be run beforehand.
*
* @param R R runtime
* @param col_count Count of variables per grid cell (typically the count of
* columns of each grid cell)
*/
void initVectorParams(RRuntime &R, int col_count);
/**
* @brief Set if dt differs
*
* Set a boolean variable if the timestep differs between iterations of
* simulation.
*
* @param dt_differ Boolean value, if dt differs
*/
void setDtDiffer(bool dt_differ);
/**
* @brief Get the numerical params struct
*
* Returns a struct which contains all numerical or boolean simulation
* parameters.
*
* @return t_simparams Parameter struct
*/
t_simparams getNumParams();
/**
* @brief Get the DHT_Signif_Vector
*
* Returns a vector indicating which significant values are used for each
* variable of a grid cell.
*
* @return std::vector<int> Vector of integers containing information about
* significant digits
*/
std::vector<int> getDHTSignifVector();
/**
* @brief Get the DHT_Prop_Type_Vector
*
* Returns a vector indicating of which type a variable of a grid cell is.
*
* @return std::vector<std::string> Vector if strings defining a type of a
* variable
*/
std::vector<std::string> getDHTPropTypeVector();
/**
* @brief Return name of DHT snapshot.
*
* Name of the DHT file which is used to initialize the DHT with a previously
* written snapshot.
*
* @return std::string Absolute paht to the DHT snapshot
*/
std::string getDHTFile();
/**
* @brief Get the filesim name
*
* Returns a string containing the absolute path to a R file defining the
* simulation.
*
* @return std::string Absolute path to R file
*/
std::string getFilesim();
/**
* @brief Get the output directory
*
* Returns the name of an absolute path where all output files should be
* stored.
*
* @return std::string Absolute path to output path
*/
std::string getOutDir();
private:
@ -135,11 +206,34 @@ class SimParams {
*/
t_simparams simparams;
/**
* @brief Defines significant digits for each variable of a grid cell
*
*/
std::vector<int> dht_signif_vector;
/**
* @brief Defines the type of a variable
*
*/
std::vector<std::string> dht_prop_type_vector;
/**
* @brief Absolute path to a DHT snapshot
*
*/
std::string dht_file;
/**
* @brief Absolute path to R file containing simulation definitions
*
*/
std::string filesim;
/**
* @brief Absolute path to output dir
*
*/
std::string out_dir;
};
} // namespace poet