SimiLie
Loading...
Searching...
No Matches
cosimplex.hpp
1// SPDX-FileCopyrightText: 2024 Baptiste Legouix
2// SPDX-License-Identifier: MIT
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(SimplexType simplex, ElementType value) noexcept
39 : m_simplex(simplex)
40 , m_value(value)
41 {
42 }
43
44 KOKKOS_DEFAULTED_FUNCTION ~Cosimplex() = default;
45
46 KOKKOS_DEFAULTED_FUNCTION Cosimplex& operator=(Cosimplex const& other) = default;
47
48 KOKKOS_DEFAULTED_FUNCTION Cosimplex& operator=(Cosimplex&& other) = default;
49
50 static KOKKOS_FUNCTION constexpr std::size_t dimension() noexcept
51 {
52 return SimplexType::dimension();
53 }
54
55 KOKKOS_FUNCTION SimplexType simplex() noexcept
56 {
57 return m_simplex;
58 }
59
60 KOKKOS_FUNCTION SimplexType const simplex() const noexcept
61 {
62 return m_simplex;
63 }
64
65 KOKKOS_FUNCTION discrete_element_type discrete_element() noexcept
66 {
67 return m_simplex.discrete_element();
68 }
69
70 KOKKOS_FUNCTION discrete_element_type discrete_element() const noexcept
71 {
72 return m_simplex.discrete_element();
73 }
74
75 KOKKOS_FUNCTION discrete_vector_type discrete_vector() noexcept
76 {
77 return m_simplex.discrete_vector();
78 }
79
80 KOKKOS_FUNCTION discrete_vector_type discrete_vector() const noexcept
81 {
82 return m_simplex.discrete_vector();
83 }
84
85 KOKKOS_FUNCTION bool negative() noexcept
86 {
87 return m_simplex.negative();
88 }
89
90 KOKKOS_FUNCTION bool negative() const noexcept
91 {
92 return m_simplex.negative();
93 }
94
95 KOKKOS_FUNCTION element_type value() noexcept
96 {
97 return m_value;
98 }
99
100 KOKKOS_FUNCTION element_type const value() const noexcept
101 {
102 return m_value;
103 }
104};
105
106template <misc::Specialization<Cosimplex> CosimplexType>
107std::ostream& operator<<(std::ostream& out, CosimplexType const& cosimplex)
108{
109 out << " " << cosimplex.simplex() << ": " << cosimplex.value() << "\n";
110 return out;
111}
112
113} // namespace exterior
114
115} // namespace sil
Cosimplex class.
Definition cosimplex.hpp:20
KOKKOS_FUNCTION element_type value() noexcept
Definition cosimplex.hpp:95
SimplexType::discrete_vector_type discrete_vector_type
Definition cosimplex.hpp:25
static KOKKOS_FUNCTION constexpr std::size_t dimension() noexcept
Definition cosimplex.hpp:50
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:75
KOKKOS_FUNCTION discrete_element_type discrete_element() const noexcept
Definition cosimplex.hpp:70
KOKKOS_FUNCTION SimplexType simplex() noexcept
Definition cosimplex.hpp:55
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:80
KOKKOS_FUNCTION SimplexType const simplex() const noexcept
Definition cosimplex.hpp:60
KOKKOS_FUNCTION bool negative() noexcept
Definition cosimplex.hpp:85
SimplexType::discrete_element_type discrete_element_type
Definition cosimplex.hpp:24
KOKKOS_FUNCTION constexpr Cosimplex(SimplexType simplex, ElementType value) noexcept
Definition cosimplex.hpp:38
KOKKOS_FUNCTION bool negative() const noexcept
Definition cosimplex.hpp:90
KOKKOS_FUNCTION discrete_element_type discrete_element() noexcept
Definition cosimplex.hpp:65
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:14