Canoe
Comprehensive Atmosphere N' Ocean Engine
microphysical_schemes.cpp
Go to the documentation of this file.
1 // C/C++
2 #include <fstream>
3 #include <iostream>
4 #include <string>
5 
6 // athena
7 #include <athena/mesh/mesh.hpp>
8 #include <athena/parameter_input.hpp>
9 
10 // application
11 #include <application/exceptions.hpp>
12 
13 // microphysics
15 #include "microphysics.hpp"
16 
18  MeshBlock *pmb, ParameterInput *pin) {
19  std::string input_key = Microphysics::input_key;
20 
22 
23  if (pin->DoesParameterExist("chemistry", input_key)) {
24  std::string filename = pin->GetString("chemistry", input_key);
25  std::ifstream stream(filename);
26  if (stream.good() == false) {
27  throw NotFoundError("microphysics",
28  "Cannot open microphysics config file: " + filename);
29  }
30 
31  YAML::Node node = YAML::Load(stream);
32  if (!node["microphysics"]) {
33  throw NotFoundError("Microphysics", "microphysics");
34  }
35 
36  for (auto sys : node["microphysics"]) {
37  std::string name = sys.as<std::string>();
38  std::string scheme = node[name]["scheme"].as<std::string>();
39  if (scheme == "Kessler94") {
40  auto p = std::make_shared<Kessler94>(name, node[name]);
41  systems.push_back(p);
42  } else {
43  throw NotFoundError("Microphysics", scheme);
44  }
45  }
46  }
47 
48  return systems;
49 }
static AllMicrophysicalSchemes Create(MeshBlock *pmb, ParameterInput *pin)
static const std::string input_key
microphysics input key in the input file [microphysics_config]
std::vector< MicrophysicalSchemePtr > AllMicrophysicalSchemes