15 #include <TBufferJSON.h>
33 std::unordered_map<ParamGroupUid, std::unique_ptr<ParamGroup>>
45 groups_[el.first] = el.second->NewCopy();
62 other.groups_.clear();
68 this->
groups_[el.first] = el.second->NewCopy();
74 json j_copy = j_document;
75 j_copy.erase(
"groups_");
78 j_new[
"bdm::Param"] = j_copy;
81 auto j_groups = j_document[
"groups_"];
82 for (json::iterator it = j_groups.begin(); it != j_groups.end(); ++it) {
83 j_new[(*it)[
"second"][
"_typename"].get<std::string>()] = (*it)[
"second"];
90 json j_return = j_flattened[
"bdm::Param"];
91 j_return[
"groups_"] = {};
92 auto& j_groups = j_return[
"groups_"];
94 auto j_original_groups = j_original[
"groups_"];
95 for (json::iterator it = j_original_groups.begin();
96 it != j_original_groups.end(); ++it) {
98 j_param_group[
"$pair"] = (*it)[
"$pair"];
99 j_param_group[
"first"] = (*it)[
"first"];
100 j_param_group[
"second"] =
101 j_flattened[(*it)[
"second"][
"_typename"].get<std::string>()];
102 j_groups.push_back(j_param_group);
110 std::string current_json_str(
111 TBufferJSON::ToJSON(
this, TBufferJSON::kMapAsObject).Data());
114 json j_document = json::parse(current_json_str);
116 return j_flattened.dump(4);
117 }
catch (std::exception& e) {
119 Concat(
"Couldn't parse `Param` parameters.\n", e.what(),
"\n",
121 return std::string();
128 std::string json_str(
129 TBufferJSON::ToJSON(
this, TBufferJSON::kMapAsObject).Data());
130 json j_param = json::parse(json_str);
133 auto j_patch = json::parse(patch);
135 j_flattened.merge_patch(j_patch);
136 }
catch (std::exception& e) {
138 Concat(
"Couldn't merge the given json parameters.\n", e.what(),
143 Param* restored =
nullptr;
144 TBufferJSON::FromJSON(restored, j_unflattened.dump().c_str());
151 const std::string config_key =
"simulation.thread_safety_mechanism";
152 if (config->contains_qualified(config_key)) {
153 auto value = config->get_qualified_as<std::string>(config_key);
157 auto str_value = *value;
158 if (str_value ==
"none") {
160 }
else if (str_value ==
"user-specified") {
162 Param::ThreadSafetyMechanism::kUserSpecified;
163 }
else if (str_value ==
"automatic") {
172 const std::string config_key =
"performance.mapped_data_array_mode";
173 if (config->contains_qualified(config_key)) {
174 auto value = config->get_qualified_as<std::string>(config_key);
178 auto str_value = *value;
179 if (str_value ==
"zero-copy") {
181 }
else if (str_value ==
"cache") {
183 }
else if (str_value ==
"copy") {
189 "Parameter mapped_data_array_mode was set to an invalid value (",
198 const std::string config_key =
"simulation.bound_space";
199 if (config->contains_qualified(config_key)) {
200 auto value = config->get_qualified_as<std::string>(config_key);
204 auto str_value = *value;
205 if (str_value ==
"open") {
207 }
else if (str_value ==
"closed") {
209 }
else if (str_value ==
"torus") {
213 Concat(
"Parameter bound_space was set to an invalid value (",
223 el.second->AssignFromConfig(config);
237 "simulation.max_displacement");
241 "simulation.diffusion_boundary_condition");
244 "simulation.calculate_gradients");
252 "visualization.pv_insitu_pipeline");
254 "visualization.pv_insitu_pipelinearguments");
259 "visualization.export_generate_pvsm");
261 "visualization.compress_pv_files");
264 auto visualize_agentstarr = config->get_table_array(
"visualize_agent");
265 if (visualize_agentstarr) {
266 for (
const auto& table : *visualize_agentstarr) {
270 if (table->contains(
"name")) {
271 auto name = table->get_as<std::string>(
"name");
274 "Missing name for attribute visualize_agent");
278 if (table->contains(
"additional_data_members")) {
280 table->get_array_of<std::string>(
"additional_data_members");
282 std::set<std::string> data_members;
283 for (
const auto& val : *dm_option) {
284 data_members.insert(val);
288 std::set<std::string> data_members;
296 auto visualize_diffusiontarr = config->get_table_array(
"visualize_diffusion");
297 if (visualize_diffusiontarr) {
298 for (
const auto& table : *visualize_diffusiontarr) {
299 if (table->contains(
"name")) {
300 auto name = table->get_as<std::string>(
"name");
303 "Missing name for attribute visualize_diffusion");
310 if (table->contains(
"concentration")) {
311 auto concentration = table->get_as<
bool>(
"concentration");
316 if (table->contains(
"gradient")) {
317 auto gradient = table->get_as<
bool>(
"gradient");
329 if (config->get_table(
"simulation")) {
331 config->get_table(
"simulation")
332 ->get_array_of<std::string>(
"unschedule_default_operations");
333 for (
const auto& op : *disabled_ops) {
340 "performance.scheduling_batch_size");
342 "performance.detect_static_agents");
346 "performance.mem_mgr_aligned_pages_shift");
348 "performance.mem_mgr_growth_rate");
350 "performance.mem_mgr_max_mem_per_thread_factor");
352 "performance.minimize_memory_while_rebalancing");
359 "development.show_simulation_step");