Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
SinkPartStruct.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
19#include "nlohmann/json.hpp"
20#include "shambackends/vec.hpp"
21namespace shammodels::sph {
22
23 template<class Tvec>
24 struct SinkParticle {
25
26 public:
27 using Tscal = shambase::VecComponent<Tvec>;
29
30 Tvec pos;
31 Tvec velocity;
32 Tvec sph_acceleration;
33 Tvec ext_acceleration;
34 Tscal mass;
35 Tvec angular_momentum;
36 Tscal accretion_radius;
37 };
38
39 template<class Tvec>
40 inline void to_json(nlohmann::json &j, const SinkParticle<Tvec> &p) {
41 // Serialize EOSConfig to a json object
42
43 using json = nlohmann::json;
44
45 j = json{
46 {"pos", p.pos},
47 {"velocity", p.velocity},
48 {"sph_acceleration", p.sph_acceleration},
49 {"ext_acceleration", p.ext_acceleration},
50 {"mass", p.mass},
51 {"angular_momentum", p.angular_momentum},
52 {"accretion_radius", p.accretion_radius},
53 };
54 }
55
56 template<class Tvec>
57 inline void from_json(const nlohmann::json &j, SinkParticle<Tvec> &p) {
58
59 using json = nlohmann::json;
60
61 j.at("pos").get_to(p.pos);
62 j.at("velocity").get_to(p.velocity);
63 j.at("sph_acceleration").get_to(p.sph_acceleration);
64 j.at("ext_acceleration").get_to(p.ext_acceleration);
65 j.at("mass").get_to(p.mass);
66 j.at("angular_momentum").get_to(p.angular_momentum);
67 j.at("accretion_radius").get_to(p.accretion_radius);
68 }
69
70} // namespace shammodels::sph
std::uint32_t u32
32 bit unsigned integer
namespace for the sph model
void to_json(nlohmann::json &j, const EOSConfig< Tvec > &p)
Serialize EOSConfig to json.
Definition EOSConfig.cpp:43
void from_json(const nlohmann::json &j, EOSConfig< Tvec > &p)
Deserializes an EOSConfig<Tvec> from a JSON object.