BioDynaMo  v1.03.61-fe34ced0
param.h
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 //
3 // Copyright (C) 2021 CERN & University of Surrey for the benefit of the
4 // BioDynaMo collaboration. All Rights Reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // See the LICENSE file distributed with this work for details.
10 // See the NOTICE file distributed with this work for additional information
11 // regarding copyright ownership.
12 //
13 // -----------------------------------------------------------------------------
14 
15 #ifndef CORE_PARAM_PARAM_H_
16 #define CORE_PARAM_PARAM_H_
17 
18 #include <cinttypes>
19 #include <map>
20 #include <memory>
21 #include <set>
22 #include <string>
23 #include <unordered_map>
24 #include <vector>
25 #include "core/analysis/style.h"
26 #include "core/param/param_group.h"
27 #include "core/real_t.h"
28 #include "core/util/root.h"
29 #include "core/util/type.h"
30 
31 namespace bdm {
32 
33 class Simulation;
34 
35 struct Param {
36  static void RegisterParamGroup(ParamGroup* param);
37 
38  Param();
39 
40  ~Param();
41 
42  Param(const Param& other);
43 
44  void Restore(Param&& other);
45 
50  std::string ToJsonString() const;
51 
56  void MergeJsonPatch(const std::string& patch);
57 
58  template <typename TParamGroup>
59  const TParamGroup* Get() const {
60  if (groups_.find(TParamGroup::kUid) != groups_.end()) {
61  return bdm_static_cast<const TParamGroup*>(groups_.at(TParamGroup::kUid));
62  } else {
63  Log::Error("TParamGroup::Get",
64  "Couldn't find the requested group parameter.");
65  return nullptr;
66  }
67  }
68 
69  template <typename TParamGroup>
70  TParamGroup* Get() {
71  if (groups_.find(TParamGroup::kUid) != groups_.end()) {
72  return bdm_static_cast<TParamGroup*>(groups_.at(TParamGroup::kUid));
73  } else {
74  Log::Error("TParamGroup::Get",
75  "Couldn't find the requested group parameter.");
76  return nullptr;
77  }
78  }
79 
80  // simulation values ---------------------------------------------------------
90  uint64_t random_seed = 4357;
91 
99  std::vector<std::string> unschedule_default_operations;
100 
103  enum NumericalODESolver { kEuler = 1, kRK4 = 2 };
104  NumericalODESolver numerical_ode_solver = NumericalODESolver::kEuler;
105 
113  std::string output_dir = "output";
114 
122  std::string environment = "uniform_grid";
123 
131  uint32_t nanoflann_depth = 10;
132 
140  uint32_t unibn_bucketsize = 16;
141 
150 
159  std::string backup_file = "";
160 
169  std::string restore_file = "";
170 
177  uint32_t backup_interval = 1800;
178 
186 
195 
198  kOpen = 0,
210  };
211 
219 
228 
237 
244  std::string diffusion_boundary_condition = "open";
245 
254 
255  std::string diffusion_method = "euler";
256 
263  bool calculate_gradients = true;
264 
272 
280  ThreadSafetyMechanism::kUserSpecified;
281 
282  // visualization values ------------------------------------------------------
283 
291  std::string visualization_engine = "paraview";
292 
302  bool insitu_visualization = false;
303 
310  bool export_visualization = false;
311 
318  bool root_visualization = false;
319 
326  std::string pv_insitu_pipeline =
327  Concat(std::getenv("BDMSYS"),
328  "/include/core/visualization/paraview/default_insitu_pipeline.py");
329 
341  std::string pv_insitu_pipelinearguments = "";
342 
352 
361 
383  std::map<std::string, std::set<std::string>>
385 
387  std::string name;
388  bool concentration = true;
389  bool gradient = false;
390  };
391 
414  std::vector<VisualizeDiffusion> visualize_diffusion;
415 
426 
427  // performance values --------------------------------------------------------
428 
435  uint64_t scheduling_batch_size = 1000;
436 
438 
455  ExecutionOrder execution_order = ExecutionOrder::kForEachAgentForEachOp;
456 
468  bool detect_static_agents = false;
469 
478  bool cache_neighbors = false;
479 
485  bool use_bdm_mem_mgr = true;
486 
498 
507 
521 
535 
544 
554  MappedDataArrayMode::kZeroCopy;
555 
556  // development values --------------------------------------------------------
566  bool statistics = false;
567 
575  bool debug_numa = false;
576 
584  uint64_t show_simulation_step = 0;
585 
596  bool use_progress_bar = false;
597 
598  // ---------------------------------------------------------------------------
599  // experimental group
600 
607  std::string compute_target = "cpu";
608 
615  bool opencl_debug = false;
616 
622  int preferred_gpu = 0;
623 
626  bool plot_memory_layout = false;
627 
629  void AssignFromConfig(const std::shared_ptr<cpptoml::table>&);
630 
631  private:
633  static std::unordered_map<ParamGroupUid, std::unique_ptr<ParamGroup>>
635  std::unordered_map<ParamGroupUid, ParamGroup*> groups_;
637 };
638 
639 } // namespace bdm
640 
641 #endif // CORE_PARAM_PARAM_H_
bdm::Param::VisualizeDiffusion
Definition: param.h:386
bdm::Param::visualization_engine
std::string visualization_engine
Definition: param.h:291
bdm::Param::use_progress_bar
bool use_progress_bar
Definition: param.h:596
bdm::Param::remove_output_dir_contents
bool remove_output_dir_contents
Definition: param.h:149
bdm::Param::kAutomatic
@ kAutomatic
Definition: param.h:271
style.h
bdm::Param::kNone
@ kNone
Definition: param.h:271
bdm::Param::kForEachOpForEachAgent
@ kForEachOpForEachAgent
Definition: param.h:437
bdm::Param::mapped_data_array_mode
Param::MappedDataArrayMode mapped_data_array_mode
Definition: param.h:553
bdm::Param::groups_
std::unordered_map< ParamGroupUid, ParamGroup * > groups_
Definition: param.h:635
bdm::Param::Param
Param()
Definition: param.cc:42
bdm::Param::detect_static_agents
bool detect_static_agents
Definition: param.h:468
bdm
Definition: agent.cc:39
bdm::Param::Get
TParamGroup * Get()
Definition: param.h:70
bdm::Param::kForEachAgentForEachOp
@ kForEachAgentForEachOp
Definition: param.h:437
bdm::Param::insitu_visualization
bool insitu_visualization
Definition: param.h:302
param_group.h
bdm::Param::debug_numa
bool debug_numa
Definition: param.h:575
bdm::Param::visualize_agents
std::map< std::string, std::set< std::string > > visualize_agents
JSON_object.
Definition: param.h:384
bdm::Param::ToJsonString
std::string ToJsonString() const
Definition: param.cc:108
bdm::Param::NumericalODESolver
NumericalODESolver
Definition: param.h:103
bdm::Param::mem_mgr_aligned_pages_shift
uint64_t mem_mgr_aligned_pages_shift
Definition: param.h:497
bdm::Param::use_bdm_mem_mgr
bool use_bdm_mem_mgr
Definition: param.h:485
bdm::real_t
double real_t
Definition: real_t.h:21
bdm::Param::unibn_bucketsize
uint32_t unibn_bucketsize
Definition: param.h:140
bdm::Param::cache_neighbors
bool cache_neighbors
Definition: param.h:478
bdm::Param::kCache
@ kCache
Definition: param.h:543
bdm::Param::DiffusionTest_CopyOldData_Test
friend class DiffusionTest_CopyOldData_Test
Definition: param.h:632
bdm::Param::BoundSpaceMode
BoundSpaceMode
Definition: param.h:196
bdm::Param::export_visualization
bool export_visualization
Definition: param.h:310
bdm::Param::kEuler
@ kEuler
Definition: param.h:103
bdm::Param::show_simulation_step
uint64_t show_simulation_step
Definition: param.h:584
bdm::Param::diffusion_boundary_condition
std::string diffusion_boundary_condition
Definition: param.h:244
bdm::Param::kTorus
@ kTorus
Definition: param.h:209
type.h
bdm::Param::backup_file
std::string backup_file
Definition: param.h:159
bdm::Param::RegisterParamGroup
static void RegisterParamGroup(ParamGroup *param)
Definition: param.cc:37
bdm::Param::VisualizeDiffusion::gradient
bool gradient
Definition: param.h:389
bdm::Param::mem_mgr_max_mem_per_thread_factor
uint64_t mem_mgr_max_mem_per_thread_factor
Definition: param.h:520
bdm::Param::numerical_ode_solver
NumericalODESolver numerical_ode_solver
Definition: param.h:104
bdm::Param::kRK4
@ kRK4
Definition: param.h:103
bdm::Param::Get
const TParamGroup * Get() const
Definition: param.h:59
bdm::Param::MappedDataArrayMode
MappedDataArrayMode
Definition: param.h:543
bdm::Param::kCopy
@ kCopy
Definition: param.h:543
bdm::Param::minimize_memory_while_rebalancing
bool minimize_memory_while_rebalancing
Definition: param.h:534
bdm::Param::compute_target
std::string compute_target
Definition: param.h:607
bdm::Param::BDM_CLASS_DEF_NV
BDM_CLASS_DEF_NV(Param, 1)
bdm::Param::mem_mgr_growth_rate
real_t mem_mgr_growth_rate
Definition: param.h:506
bdm::Param::backup_interval
uint32_t backup_interval
Definition: param.h:177
bdm::Param::opencl_debug
bool opencl_debug
Definition: param.h:615
bdm::Param::diffusion_method
std::string diffusion_method
Definition: param.h:255
bdm::Param::max_bound
real_t max_bound
Definition: param.h:236
bdm::Param::unschedule_default_operations
std::vector< std::string > unschedule_default_operations
Definition: param.h:99
bdm::Param::pv_insitu_pipelinearguments
std::string pv_insitu_pipelinearguments
Definition: param.h:341
bdm::Param::registered_groups_
static std::unordered_map< ParamGroupUid, std::unique_ptr< ParamGroup > > registered_groups_
Definition: param.h:634
bdm::Param::simulation_time_step
real_t simulation_time_step
Definition: param.h:185
bdm::Param::plot_memory_layout
bool plot_memory_layout
Definition: param.h:626
bdm::Param::scheduling_batch_size
uint64_t scheduling_batch_size
Definition: param.h:435
root.h
bdm::Param::kOpen
@ kOpen
The simulation space grows to encapsulate all agents.
Definition: param.h:198
bdm::Param::kClosed
@ kClosed
Definition: param.h:203
bdm::Param::VisualizeDiffusion::name
std::string name
Definition: param.h:387
bdm::Param::visualization_compress_pv_files
bool visualization_compress_pv_files
Definition: param.h:425
bdm::Param::min_bound
real_t min_bound
Definition: param.h:227
bdm::Param::ExecutionOrder
ExecutionOrder
Definition: param.h:437
bdm::ParamGroup
Interface for parameter groups.
Definition: param_group.h:45
bdm::Concat
std::string Concat(const Args &... parts)
Concatenates all arguments into a string. Equivalent to streaming all arguments into a stringstream a...
Definition: string.h:70
bdm::Param::execution_order
ExecutionOrder execution_order
Definition: param.h:455
bdm::Param::MergeJsonPatch
void MergeJsonPatch(const std::string &patch)
Definition: param.cc:126
bdm::Param::~Param
~Param()
Definition: param.cc:50
bdm::Log::Error
static void Error(const std::string &location, const Args &... parts)
Prints error message.
Definition: log.h:79
bdm::Param::simulation_max_displacement
real_t simulation_max_displacement
Definition: param.h:194
bdm::Param::AssignFromConfig
void AssignFromConfig(const std::shared_ptr< cpptoml::table > &)
Assign values from config file to variables.
Definition: param.cc:220
bdm::Param::random_seed
uint64_t random_seed
Definition: param.h:90
bdm::Param::environment
std::string environment
Definition: param.h:122
bdm::Param::ThreadSafetyMechanism
ThreadSafetyMechanism
Definition: param.h:271
bdm::Param::root_visualization
bool root_visualization
Definition: param.h:318
bdm::Param::bound_space
BoundSpaceMode bound_space
Definition: param.h:218
real_t.h
bdm::Param::visualization_interval
uint32_t visualization_interval
Definition: param.h:351
bdm::Param::output_dir
std::string output_dir
Definition: param.h:113
bdm::Param::calculate_gradients
bool calculate_gradients
Definition: param.h:263
bdm::Param::pv_insitu_pipeline
std::string pv_insitu_pipeline
Definition: param.h:326
bdm::Param::thread_safety_mechanism
ThreadSafetyMechanism thread_safety_mechanism
Definition: param.h:279
bdm::Param::VisualizeDiffusion::concentration
bool concentration
Definition: param.h:388
bdm::Param::preferred_gpu
int preferred_gpu
Definition: param.h:622
bdm::Param::restore_file
std::string restore_file
Definition: param.h:169
bdm::Param::visualize_diffusion
std::vector< VisualizeDiffusion > visualize_diffusion
Definition: param.h:414
bdm::Param
Definition: param.h:35
bdm::Param::kUserSpecified
@ kUserSpecified
Definition: param.h:271
bdm::Param::kZeroCopy
@ kZeroCopy
Definition: param.h:543
bdm::Param::visualization_export_generate_pvsm
bool visualization_export_generate_pvsm
Definition: param.h:360
bdm::Param::statistics
bool statistics
Definition: param.h:566
bdm::Param::Restore
void Restore(Param &&other)
Definition: param.cc:57
bdm::Param::nanoflann_depth
uint32_t nanoflann_depth
Definition: param.h:131