SimiLie
Loading...
Searching...
No Matches
cosimplex.hpp
1// SPDX-FileCopyrightText: 2024 Baptiste Legouix
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4#pragma once
5
6#include <ddc/ddc.hpp>
7
8#include <similie/misc/are_all_same.hpp>
9#include <similie/misc/specialization.hpp>
10
11#include "chain.hpp"
12
13namespace sil {
14
15namespace exterior {
16
18template <class SimplexType, class ElementType = double>
20{
21public:
22 using simplex_type = SimplexType;
23 using element_type = ElementType;
24 using discrete_element_type = SimplexType::discrete_element_type;
25 using discrete_vector_type = SimplexType::discrete_vector_type;
26
27private:
28 SimplexType m_simplex;
29 ElementType m_value;
30
31public:
32 KOKKOS_DEFAULTED_FUNCTION constexpr Cosimplex() = default;
33
34 KOKKOS_DEFAULTED_FUNCTION constexpr Cosimplex(Cosimplex const&) = default;
35
36 KOKKOS_DEFAULTED_FUNCTION constexpr Cosimplex(Cosimplex&&) = default;
37
38 KOKKOS_FUNCTION constexpr explicit Cosimplex(
39 SimplexType const& simplex,
40 ElementType value) noexcept
41 : m_simplex(simplex)
42 , m_value(value)
43 {
44 }
45
46 KOKKOS_DEFAULTED_FUNCTION ~Cosimplex() = default;
47
48 KOKKOS_DEFAULTED_FUNCTION Cosimplex& operator=(Cosimplex const& other) = default;
49
50 KOKKOS_DEFAULTED_FUNCTION Cosimplex& operator=(Cosimplex&& other) = default;
51
52 static constexpr std::size_t dimension() noexcept
53 {
54 return SimplexType::dimension();
55 }
56
57 KOKKOS_FUNCTION SimplexType simplex() noexcept
58 {
59 return m_simplex;
60 }
61
62 KOKKOS_FUNCTION SimplexType const simplex() const noexcept
63 {
64 return m_simplex;
65 }
66
67 KOKKOS_FUNCTION discrete_element_type discrete_element() noexcept
68 {
69 return m_simplex.discrete_element();
70 }
71
72 KOKKOS_FUNCTION discrete_element_type discrete_element() const noexcept
73 {
74 return m_simplex.discrete_element();
75 }
76
77 KOKKOS_FUNCTION discrete_vector_type discrete_vector() noexcept
78 {
79 return m_simplex.discrete_vector();
80 }
81
82 KOKKOS_FUNCTION discrete_vector_type discrete_vector() const noexcept
83 {
84 return m_simplex.discrete_vector();
85 }
86
87 KOKKOS_FUNCTION bool negative() noexcept
88 {
89 return m_simplex.negative();
90 }
91
92 KOKKOS_FUNCTION bool negative() const noexcept
93 {
94 return m_simplex.negative();
95 }
96
97 KOKKOS_FUNCTION element_type value() noexcept
98 {
99 return m_value;
100 }
101
102 KOKKOS_FUNCTION element_type const value() const noexcept
103 {
104 return m_value;
105 }
106
107 KOKKOS_FUNCTION Cosimplex const* operator->() const noexcept
108 {
109 return this;
110 }
111};
112
113template <misc::Specialization<Cosimplex> CosimplexType>
114std::ostream& operator<<(std::ostream& out, CosimplexType const& cosimplex)
115{
116 out << " " << cosimplex.simplex() << ": " << cosimplex.value() << "\n";
117 return out;
118}
119
120} // namespace exterior
121
122} // namespace sil
Cosimplex class.
Definition cosimplex.hpp:20
KOKKOS_FUNCTION element_type value() noexcept
Definition cosimplex.hpp:97
SimplexType::discrete_vector_type discrete_vector_type
Definition cosimplex.hpp:25
static constexpr std::size_t dimension() noexcept
Definition cosimplex.hpp:52
KOKKOS_DEFAULTED_FUNCTION constexpr Cosimplex(Cosimplex const &)=default
KOKKOS_FUNCTION element_type const value() const noexcept
KOKKOS_DEFAULTED_FUNCTION constexpr Cosimplex(Cosimplex &&)=default
KOKKOS_FUNCTION discrete_vector_type discrete_vector() noexcept
Definition cosimplex.hpp:77
KOKKOS_FUNCTION discrete_element_type discrete_element() const noexcept
Definition cosimplex.hpp:72
KOKKOS_FUNCTION SimplexType simplex() noexcept
Definition cosimplex.hpp:57
KOKKOS_DEFAULTED_FUNCTION Cosimplex & operator=(Cosimplex const &other)=default
KOKKOS_DEFAULTED_FUNCTION ~Cosimplex()=default
KOKKOS_DEFAULTED_FUNCTION constexpr Cosimplex()=default
KOKKOS_FUNCTION discrete_vector_type discrete_vector() const noexcept
Definition cosimplex.hpp:82
KOKKOS_FUNCTION SimplexType const simplex() const noexcept
Definition cosimplex.hpp:62
KOKKOS_FUNCTION bool negative() noexcept
Definition cosimplex.hpp:87
SimplexType::discrete_element_type discrete_element_type
Definition cosimplex.hpp:24
KOKKOS_FUNCTION bool negative() const noexcept
Definition cosimplex.hpp:92
KOKKOS_FUNCTION discrete_element_type discrete_element() noexcept
Definition cosimplex.hpp:67
KOKKOS_FUNCTION Cosimplex const * operator->() const noexcept
KOKKOS_FUNCTION constexpr Cosimplex(SimplexType const &simplex, ElementType value) noexcept
Definition cosimplex.hpp:38
KOKKOS_DEFAULTED_FUNCTION Cosimplex & operator=(Cosimplex &&other)=default
std::ostream & operator<<(std::ostream &out, ChainType const &chain)
Definition chain.hpp:304
The top-level namespace of SimiLie.
Definition csr.hpp:15