30#include <nlohmann/json.hpp>
33namespace shammodels::gsph {
43 using Tscal = shambase::VecComponent<Tvec>;
44 static constexpr u32 dim = shambase::VectorProperties<Tvec>::dimension;
59 using Variant = std::variant<ChaWhitworth, InutsukaV2>;
63 void set(Variant v) { config = v; }
65 void set_cha_whitworth() { set(ChaWhitworth{}); }
69 inline bool is_cha_whitworth()
const {
return std::holds_alternative<ChaWhitworth>(config); }
71 inline bool is_inutsuka_v2()
const {
return std::holds_alternative<InutsukaV2>(config); }
73 inline void print_status()
const {
74 logger::raw_ln(
"--- Force formulation config");
76 if (std::get_if<ChaWhitworth>(&config)) {
77 logger::raw_ln(
" Type : ChaWhitworth (2003) - symmetric SPH form");
78 }
else if (std::get_if<InutsukaV2>(&config)) {
80 " Type : InutsukaV2 (2002) - effective volume/face, linear (1st order)");
85 logger::raw_ln(
"-------------");
89namespace shammodels::gsph {
94 using ChaWhitworth =
typename T::ChaWhitworth;
95 using InutsukaV2 =
typename T::InutsukaV2;
97 if (std::get_if<ChaWhitworth>(&p.config)) {
99 {
"force_formulation",
"cha_whitworth"},
101 }
else if (std::get_if<InutsukaV2>(&p.config)) {
103 {
"force_formulation",
"inutsuka_v2"},
113 using ChaWhitworth =
typename T::ChaWhitworth;
114 using InutsukaV2 =
typename T::InutsukaV2;
116 if (!j.contains(
"force_formulation")) {
118 "no field force_formulation is found in this json");
121 std::string force_formulation;
122 j.at(
"force_formulation").get_to(force_formulation);
124 if (force_formulation ==
"cha_whitworth") {
125 p.set(ChaWhitworth{});
126 }
else if (force_formulation ==
"inutsuka_v2") {
std::uint32_t u32
32 bit unsigned integer
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
void throw_unimplemented(SourceLocation loc=SourceLocation{})
Throw a std::runtime_error saying that the function is unimplemented.
Contains traits and utilities for backend related types.