Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
ISPHSetupNode.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
21#include <string>
22#include <vector>
23
25
32 std::string name;
33 u32 type;
34 std::vector<ISPHSetupNode_Dot> inputs;
35
48 u32 add_node(u32 &counter, std::string &out) {
49
50 std::vector<u32> inputs_id{};
51 for (auto &in : inputs) {
52 inputs_id.push_back(in.add_node(counter, out));
53 }
54
55 u32 counter_val = counter;
56 counter++;
57
58 out += "node_" + std::to_string(counter_val) + " [label=\"" + name + "\"];\n";
59
60 for (auto i : inputs_id) {
61 out += "node_" + std::to_string(i) + " -> node_" + std::to_string(counter_val)
62 + ";\n";
63 }
64
65 return counter_val;
66 }
67 };
68
75 public:
81 virtual bool is_done() = 0;
82
91
96 virtual std::string get_name() = 0;
97
108
112 virtual ~ISPHSetupNode() = default;
113
122 std::string get_dot() {
123 std::string out;
124
125 out += "digraph G {\n";
126 out += "rankdir=LR;\n";
127
128 u32 counter = 0;
129 u32 final_node = get_dot_subgraph().add_node(counter, out);
130
131 out += "node_" + std::to_string(counter + 1) + " [label=\"Simulation\"];\n";
132 out += "node_" + std::to_string(final_node) + " -> node_" + std::to_string(counter + 1)
133 + ";\n";
134
135 out += "}\n";
136 return out;
137 }
138 };
139
141 using SetupNodePtr = std::shared_ptr<ISPHSetupNode>;
142
143} // namespace shammodels::sph::modules
std::uint32_t u32
32 bit unsigned integer
This class is an interface that all SPH setup nodes must implement. It describe an operation associat...
virtual shamrock::patch::PatchDataLayer next_n(u32 nmax)=0
This function generate patchdata with at most nmax per MPI ranks This function is always assumed as c...
std::string get_dot()
Generate a dot graph for the setup tree.
virtual ISPHSetupNode_Dot get_dot_subgraph()=0
Get a dot subgraph describing the node and its childrens (recursively)
virtual bool is_done()=0
This function return true if the setup is done.
virtual ~ISPHSetupNode()=default
Virtual destructor for the ISPHSetupNode class.
virtual std::string get_name()=0
Get the name of the node.
PatchDataLayer container class, the layout is described in patchdata_layout.
namespace for the sph model modules
std::shared_ptr< ISPHSetupNode > SetupNodePtr
Alias for a shared pointer to an ISPHSetupNode.
This struct is used to generate a dot graph of the setup tree.
u32 add_node(u32 &counter, std::string &out)
This function generate a dot graph for the setup tree.