Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
NodeMapEdge.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
17
19#include "shambase/string.hpp"
22#include <functional>
23
24namespace shamrock::solvergraph {
25
45 template<class Tin, class Tout>
46 class NodeMapEdge : public INode {
47
48 std::function<void(const Tin &, Tout &)> map_edge;
49
50 public:
56 NodeMapEdge(std::function<void(const Tin &, Tout &)> map_edge)
57 : map_edge(std::move(map_edge)) {}
58
69 inline void set_edges(std::shared_ptr<Tin> in_edge, std::shared_ptr<Tout> out_edge) {
70 __internal_set_ro_edges({in_edge});
71 __internal_set_rw_edges({out_edge});
72 }
73
84
90 inline virtual std::string _impl_get_label() const { return "MapEdge"; };
91
97 inline virtual std::string _impl_get_tex() const {
98
99 auto in_edge = get_ro_edge_base(0).get_tex_symbol();
100 auto out_edge = get_rw_edge_base(0).get_tex_symbol();
101
102 std::string tex = R"tex(
103 Map edge ${in_edge}$ to ${out_edge}$
104 )tex";
105
106 shambase::replace_all(tex, "{in_edge}", in_edge);
107 shambase::replace_all(tex, "{out_edge}", out_edge);
108
109 return tex;
110 }
111 };
112
113} // namespace shamrock::solvergraph
T & get_rw_edge(int slot)
Get a read write edge and cast it to the type T.
Definition INode.hpp:97
void __internal_set_rw_edges(std::vector< std::shared_ptr< IEdge > > new_rw_edges)
Set the read write edges.
Definition INode.hpp:249
IEdge & get_rw_edge_base(int slot)
Get a reference to a read write edge and cast it to the type IEdge.
Definition INode.hpp:147
void __internal_set_ro_edges(std::vector< std::shared_ptr< IEdge > > new_ro_edges)
Set the read only edges.
Definition INode.hpp:238
const T & get_ro_edge(int slot)
Get a read only edge and cast it to the type T.
Definition INode.hpp:91
const IEdge & get_ro_edge_base(int slot)
Get a reference to a read only edge.
Definition INode.hpp:138
virtual std::string _impl_get_tex() const
Get the TeX representation of the node.
void _impl_evaluate_internal()
Evaluate the node.
NodeMapEdge(std::function< void(const Tin &, Tout &)> map_edge)
Construct a new NodeMapEdge object.
virtual std::string _impl_get_label() const
Get the label of the node.
void set_edges(std::shared_ptr< Tin > in_edge, std::shared_ptr< Tout > out_edge)
Set the edges of the node.
void replace_all(std::string &inout, std::string_view what, std::string_view with)
replace all occurence of a search string with another
Definition string.hpp:106
This file contains the definition for the stacktrace related functionality.
#define __shamrock_stack_entry()
Macro to create a stack entry.