DamBreak++ Wave Simulator 0.3
DamBreak++ Simulation Framework
Loading...
Searching...
No Matches
dbpp_NodalTpl.hpp
Go to the documentation of this file.
1#pragma once
2
3// C++ includes
4#include <optional>
5#include <iostream>
6// SfxBase19 include
7#include "include/Sfx_UniversalConstants.h"
8
9namespace dbpp
10{
18 template <typename... Ts>
19 std::ostream& operator<< ( std::ostream& os, const std::tuple<Ts...>& theTuple)
20 {
21 std::apply(
22 [&os](const Ts &...tupleArgs)
23 {
24 os << '[';
25 std::size_t n{ 0 };
26 ((os << tupleArgs << (++n != sizeof...(Ts) ? ", " : "")), ...);
27 os << ']';
28 },
29 theTuple);
30 return os;
31 }
32
45 template <typename... Params>
46 struct NodalTpl
47 {
48 bool m_tiedNode{ false };
49 bool m_ghostNode{ false };
50 std::tuple<Params...> m_tpl;
54 using index_type = std::tuple_element_t<0, decltype(m_tpl)>;
58 using value_type = std::tuple_element_t<1, decltype(m_tpl)>;
62 NodalTpl() = default;
68 NodalTpl(Params... Prms, bool tied = false) : m_tiedNode{ tied }, m_tpl(Prms...) {}
73 auto size() const { return std::tuple_size_v<decltype(m_tpl)>; }
78 auto nodeXcoord() const
79 {
80 if( isGNode())
81 return std::get<1>(m_tpl);
82 else
83 {
84 return -1; // temporary fix
85 }
86 //return std::make_tuple(std::get<1>(m_tpl), std::get<2>(m_tpl), std::get<3>(m_tpl));
87 }
88
92 auto Values() const {
93 return std::make_tuple(std::get<1>(m_tpl), std::get<2>(m_tpl), std::get<3>(m_tpl));
94 }
95
99 auto nodeNo() const noexcept { return std::get<0>(m_tpl); }
104 std::optional<index_type> tieNodeIdx() const
105 {
106 if( isTiedNode())
107 {
108 return std::get<0>(m_tpl);
109 }
110 else
111 {
112 return std::nullopt;
113 }
114 }
115
119 auto isGhostNode() const noexcept
120 {
121 assert(std::get<0>(m_tpl) < Sfx::EMCNEILNbSections::value);
122 return m_ghostNode;;
123 }
124
127 void setAsGhostNode() { m_ghostNode = true; }
131 bool isGNode() const { return (std::tuple_size_v<decltype(m_tpl)>) == 2; }
136 bool isTiedNode() const
137 {
138 assert(std::get<0>(m_tpl) < Sfx::EMCNEILNbSections::value); // default prototype
139 return m_tiedNode;
140 }
141
145 auto operator<=> ( const NodalTpl& aOther) const = default;
146 };
147} // End of namespace
Definition DamBreakProb.h:15
std::ostream & operator<<(std::ostream &os, const std::tuple< Ts... > &theTuple)
print tuple element (apply on a tuple)
Definition dbpp_NodalTpl.hpp:19
bool isGNode() const
tuple implement '<=>' spaceship operator
Definition dbpp_NodalTpl.hpp:131
bool isTiedNode() const
Definition dbpp_NodalTpl.hpp:136
auto size() const
Number of element.
Definition dbpp_NodalTpl.hpp:73
bool m_tiedNode
Definition dbpp_NodalTpl.hpp:48
auto Values() const
Nodal values.
Definition dbpp_NodalTpl.hpp:92
void setAsGhostNode()
Node part of global domain (not computational domain)
Definition dbpp_NodalTpl.hpp:127
std::tuple_element_t< 0, decltype(m_tpl)> index_type
first tuple element type
Definition dbpp_NodalTpl.hpp:54
std::tuple< Params... > m_tpl
Definition dbpp_NodalTpl.hpp:50
std::tuple_element_t< 1, decltype(m_tpl)> value_type
Alias (second tuple element type)
Definition dbpp_NodalTpl.hpp:58
auto isGhostNode() const noexcept
Definition dbpp_NodalTpl.hpp:119
NodalTpl(Params... Prms, bool tied=false)
Ctor from values.
Definition dbpp_NodalTpl.hpp:68
bool m_ghostNode
Definition dbpp_NodalTpl.hpp:49
std::optional< index_type > tieNodeIdx() const
boundary condition
Definition dbpp_NodalTpl.hpp:104
auto nodeNo() const noexcept
Global node index.
Definition dbpp_NodalTpl.hpp:99
NodalTpl()=default
default ctor
auto operator<=>(const NodalTpl &aOther) const =default
logical operator ==,!=, <,<=,>,>= data member tuple implement '<=>' spaceship operator
auto nodeXcoord() const
coordinate
Definition dbpp_NodalTpl.hpp:78