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
21#include <functional>
22
23namespace shamrock::solvergraph {
24
44 template<class Tin, class Tout>
45 class NodeMapEdge : public INode {
46
47 std::function<void(const Tin &, Tout &)> map_edge;
48
49 public:
55 NodeMapEdge(std::function<void(const Tin &, Tout &)> map_edge)
56 : map_edge(std::move(map_edge)) {}
57
68 inline void set_edges(std::shared_ptr<Tin> in_edge, std::shared_ptr<Tout> out_edge) {
69 __internal_set_ro_edges({in_edge});
70 __internal_set_rw_edges({out_edge});
71 }
72
83
89 inline virtual std::string _impl_get_label() const { return "MapEdge"; };
90
96 inline virtual std::string _impl_get_tex() const {
97
98 auto in_edge = get_ro_edge_base(0).get_tex_symbol();
99 auto out_edge = get_rw_edge_base(0).get_tex_symbol();
100
101 std::string tex = R"tex(
102 Map edge ${in_edge}$ to ${out_edge}$
103 )tex";
104
105 shambase::replace_all(tex, "{in_edge}", in_edge);
106 shambase::replace_all(tex, "{out_edge}", out_edge);
107
108 return tex;
109 }
110 };
111
112} // namespace shamrock::solvergraph
T & get_rw_edge(int slot)
Get a read write edge and cast it to the type T.
Definition INode.hpp:87
void __internal_set_rw_edges(std::vector< std::shared_ptr< IEdge > > new_rw_edges)
Set the read write edges.
Definition INode.hpp:220
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:137
void __internal_set_ro_edges(std::vector< std::shared_ptr< IEdge > > new_ro_edges)
Set the read only edges.
Definition INode.hpp:210
const T & get_ro_edge(int slot)
Get a read only edge and cast it to the type T.
Definition INode.hpp:81
const IEdge & get_ro_edge_base(int slot)
Get a reference to a read only edge.
Definition INode.hpp:128
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:110
This file contains the definition for the stacktrace related functionality.
#define __shamrock_stack_entry()
Macro to create a stack entry.