Node.h 1.93 KB
Newer Older
1 2 3 4 5
#ifndef OERSTED_NODE_H
#define OERSTED_NODE_H

// TODO: Const

6 7
#include <cstddef>

8 9
#include "Mesh.hpp"

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
template<size_t N>
class SmallVector {
private:
    double Value[N];
};

template<size_t M, size_t N>
class SmallMatrix {
};

template<size_t M, bool Symmetric>
class SquareMatrix : public SmallMatrix<M, M> {
};

template<>
class SmallVector<2> {
public:
    SmallVector() : Value{} {};

29 30
    SmallVector(Point const& p) : Value{p.X, p.Y} {};

31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
    SmallVector(double x, double y) : Value{x, y} {};

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

    double x() const { return Value[0]; };

    void x(double val) { Value[0] = val; };

    double y() const { return Value[1]; };

    void y(double val) { Value[1] = val; };

private:
    double Value[2];
};

using XY = SmallVector<2>;

template<>
class SmallVector<3> {
public:
    SmallVector() : Value{} {};

    SmallVector(double x, double y, double z) : Value{x, y, z} {};

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

    double x() const { return Value[0]; }

    double y() const { return Value[1]; }

    double z() const { return Value[2]; }

private:
    double Value[3];
};

using XYZ = SmallVector<3>;

template<>
class SquareMatrix<2, true> {
public:
    SquareMatrix() : Value{} {};

    SquareMatrix(double xx, double xy, double yy) : Value{xx, xy, yy} {};

    double xx() const { return Value[0]; };

    double xy() const { return Value[1]; };

    double yx() const { return Value[1]; };

    double yy() const { return Value[2]; };

private:
    double Value[3];
};

template<>
class SquareMatrix<2, false> {
public:
    SquareMatrix() : Value{} {};

    SquareMatrix(double xx, double xy, double yx, double yy) : Value{xx, xy, yx, yy} {};

    double xx() const { return Value[0]; };

    double xy() const { return Value[1]; };

    double yx() const { return Value[2]; };

    double yy() const { return Value[3]; };

private:
    double Value[4];
};

#endif //OERSTED_NODE_H