This repository was archived by the owner on Feb 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.cpp
More file actions
59 lines (52 loc) · 1.35 KB
/
settings.cpp
File metadata and controls
59 lines (52 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <fstream>
#include "json.hpp"
#include "settings.h"
void to_json(nlohmann::json &j, const Settings &s)
{
j = nlohmann::json{{"L", s.L},
{"steps", s.steps},
{"plotgap", s.plotgap},
{"F", s.F},
{"k", s.k},
{"dt", s.dt},
{"Du", s.Du},
{"Dv", s.Dv},
{"noise", s.noise},
{"output", s.output},
{"adios_config", s.adios_config}};
}
void from_json(const nlohmann::json &j, Settings &s)
{
j.at("L").get_to(s.L);
j.at("steps").get_to(s.steps);
j.at("plotgap").get_to(s.plotgap);
j.at("F").get_to(s.F);
j.at("k").get_to(s.k);
j.at("dt").get_to(s.dt);
j.at("Du").get_to(s.Du);
j.at("Dv").get_to(s.Dv);
j.at("noise").get_to(s.noise);
j.at("output").get_to(s.output);
j.at("adios_config").get_to(s.adios_config);
}
Settings::Settings()
{
L = 128;
steps = 20000;
plotgap = 200;
F = 0.04;
k = 0.06075;
dt = 0.2;
Du = 0.05;
Dv = 0.1;
noise = 0.0;
output = "foo.bp";
adios_config = "adios2_config.xml";
}
Settings Settings::from_json(const std::string &fname)
{
std::ifstream ifs(fname);
nlohmann::json j;
ifs >> j;
return j.get<Settings>();
}