12 #include "../utils/runtime_error.h" 13 #include "../utils/split.h" 26 bool timestep_matches =
false;
34 while (std::getline(ifs, line))
36 if (line.find(
"ITEM: TIMESTEP") == 0)
38 std::getline(ifs, line);
42 timestep_matches =
true;
46 line.find(
"ITEM: NUMBER OF ATOMS") == 0 && !timestep_matches)
48 std::getline(ifs, line);
49 n_atoms = std::stoi(line);
51 else if (line.find(
"ITEM: BOX BOUNDS") == 0 && timestep_matches)
55 for (
int i = 0; i != 3; ++i)
57 auto key =
"pbc_" +
Str(
"xyz").substr(i, 1);
59 data[key] = strs[3+i] ==
"pp";
62 for (
const Str &dim : {
"x",
"y",
"z"})
64 std::getline(ifs, line);
67 data[
"lo_"+dim] = std::stod(strs[0]);
68 data[
"hi_"+dim] = std::stod(strs[1]);
73 else if (line.find(
"ITEM: ATOMS") == 0)
75 for (
int i = 0; i != n_atoms; ++i)
77 std::getline(ifs, line);
std::function< bool(const Json &)> JsonToBoolFunc
An alias for a function accepts a Json object and returns a bool.
Vec< Str > split(const Str &str, char delim=' ')
Mimicking Python's split.
std::string Str
Str is an alias for string.
virtual void compute_impl(Json &data, JsonToVoidFunc check_required_keys, JsonToBoolFunc check_optional_keys) override
This method overrides Updater::compute_impl.
nlohmann::json Json
Json is an alias for nlohmann::json.
This file has a definition of StaDumpBox class, which is a subclass of Starter class.
void runtime_error(const Str &msg)
Raise (for Python) and throw (for C++) a runtime error.
Namespace for utility functions.
std::function< void(const Json &)> JsonToVoidFunc
An alias for a function accepts a Json object.