Boundary.h 2.49 KB
Newer Older
JasonPries's avatar
JasonPries committed
1 2 3
#ifndef OERSTED_BOUNDARY_H
#define OERSTED_BOUNDARY_H

4 5 6
#include <vector>
#include <cstddef>

7 8
#include <Sketch.hpp>

JasonPries's avatar
JasonPries committed
9 10 11 12 13
template<size_t Dimension>
class Boundary {
};

template<>
14
class Boundary<2> { // TODO: Rename DiscreteBoundary
JasonPries's avatar
JasonPries committed
15
public:
16 17
    Boundary() {};

18 19 20
    Boundary(std::vector<size_t> &&nodes) : CurvePtr{nullptr}, Nodes{nodes} {};

    Boundary(std::shared_ptr<Curve const> cptr, std::vector<size_t> &&nodes) : CurvePtr{cptr}, Nodes{nodes} {};
JasonPries's avatar
JasonPries committed
21

JasonPries's avatar
JasonPries committed
22 23
    size_t size() const { return Nodes.size(); };

24
    auto &nodes() { return Nodes; };
JasonPries's avatar
JasonPries committed
25

26
    auto const &nodes() const { return Nodes; };
JasonPries's avatar
JasonPries committed
27

28
    auto &node(size_t i) { return Nodes[i]; };
JasonPries's avatar
JasonPries committed
29

30
    auto const &node(size_t i) const { return Nodes[i]; };
JasonPries's avatar
JasonPries committed
31

32 33
    auto curve() const { return CurvePtr; };

JasonPries's avatar
JasonPries committed
34
protected:
35
    std::shared_ptr<Curve const> CurvePtr;
JasonPries's avatar
JasonPries committed
36 37 38
    std::vector<size_t> Nodes;
};

JasonPries's avatar
JasonPries committed
39
/*
JasonPries's avatar
JasonPries committed
40
template <size_t Dimension>
JasonPries's avatar
JasonPries committed
41
class BoundaryPair {};
JasonPries's avatar
JasonPries committed
42

JasonPries's avatar
JasonPries committed
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
template <>
class BoundaryPair<2> {
public:
    BoundaryPair(std::shared_ptr<Boundary<2>> first, std::shared_ptr<Boundary<2>> second) : First{first}, Second{second} {};

    std::shared_ptr<Boundary<2>> const &first() { return First; };

    std::shared_ptr<Boundary<2>> const &second() { return Second; };

protected:
    std::shared_ptr<Boundary<2>> First;
    std::shared_ptr<Boundary<2>> Second;
};
*/

class VariableMap {
public:
60
    VariableMap(size_t first, size_t second, double value) : First{std::min(first,second)}, Second{std::max(first,second)}, Value{value} {};
JasonPries's avatar
JasonPries committed
61 62 63 64 65

    size_t first() const { return First; };

    size_t second() const { return Second; };

66 67 68
    double_t value() const { return Value; };

    void value(double_t value) { Value = value; };
JasonPries's avatar
JasonPries committed
69

70 71 72 73 74 75 76 77
    inline bool operator==(VariableMap const &rhs) {
        return (First == rhs.First && Second == rhs.Second && Value == rhs.Value);
    }

    inline bool operator<(VariableMap const &rhs) {
        return (First < rhs.First) || (First == rhs.First && Second < rhs.Second);
    }

JasonPries's avatar
JasonPries committed
78 79 80
protected:
    size_t First;
    size_t Second;
81
    double_t Value;
JasonPries's avatar
JasonPries committed
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
};

class BoundaryMap {
public:
    BoundaryMap(std::vector<VariableMap> map) : Map{map} {};

    size_t size() const { return Map.size(); };

    VariableMap const &map(size_t i) const { return Map[i]; };

    std::vector<VariableMap> const &map() const { return Map; };

    size_t first(size_t i) const { return Map[i].first(); };

    size_t second(size_t i) const { return Map[i].second(); };

    double value(size_t i) const { return Map[i].value(); };

protected:
    std::vector<VariableMap> Map;
JasonPries's avatar
JasonPries committed
102 103
};

JasonPries's avatar
JasonPries committed
104
#endif //OERSTED_BOUNDARY_H