| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Copyright (C) 2025 Tiago V. L. Amorim (@tiagovla) | ||
| 2 | // | ||
| 3 | // This file is part of oiseau (https://github.com/tiagovla/oiseau) | ||
| 4 | // | ||
| 5 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 6 | |||
| 7 | #pragma once | ||
| 8 | |||
| 9 | #include <array> | ||
| 10 | #include <cstddef> | ||
| 11 | #include <string> | ||
| 12 | #include <string_view> | ||
| 13 | #include <utility> | ||
| 14 | #include <vector> | ||
| 15 | |||
| 16 | namespace oiseau::mesh { | ||
| 17 | |||
| 18 | class Cell; | ||
| 19 | using CellType = Cell const *; | ||
| 20 | |||
| 21 | enum class CellKind { | ||
| 22 | Undefined = 0, | ||
| 23 | Point, | ||
| 24 | Interval, | ||
| 25 | Triangle, | ||
| 26 | Quadrilateral, | ||
| 27 | Tetrahedron, | ||
| 28 | Hexahedron | ||
| 29 | }; | ||
| 30 | |||
| 31 | class Cell { | ||
| 32 | protected: | ||
| 33 | CellKind m_kind; | ||
| 34 | std::string m_name; | ||
| 35 | int m_dim; | ||
| 36 | std::vector<std::vector<std::vector<std::vector<int>>>> m_topology; | ||
| 37 | std::pair<std::vector<double>, std::array<std::size_t, 2>> m_geometry; | ||
| 38 | |||
| 39 | public: | ||
| 40 | 166 | virtual ~Cell() = default; | |
| 41 | virtual Cell *facet() = 0; | ||
| 42 | virtual Cell *edge() = 0; | ||
| 43 | std::string_view name() const; | ||
| 44 | int dimension() const; | ||
| 45 | int num_entities(int dim) const; | ||
| 46 | std::vector<std::vector<int>> get_entity_vertices(int dim) const; | ||
| 47 | std::vector<std::vector<int>> get_sub_entities(int dim0, int dim1) const; | ||
| 48 | const std::vector<std::vector<std::vector<std::vector<int>>>> &topology() const { | ||
| 49 | return m_topology; | ||
| 50 | } | ||
| 51 | int num_sub_entities(int dim) const; | ||
| 52 | ✗ | CellKind kind() const { return m_kind; } | |
| 53 | }; | ||
| 54 | |||
| 55 | class PointCell : public Cell { | ||
| 56 | public: | ||
| 57 | PointCell(); | ||
| 58 | ✗ | Cell *facet() override { return nullptr; } | |
| 59 | ✗ | Cell *edge() override { return nullptr; } | |
| 60 | }; | ||
| 61 | |||
| 62 | class IntervalCell : public Cell { | ||
| 63 | private: | ||
| 64 | PointCell m_facet; | ||
| 65 | |||
| 66 | public: | ||
| 67 | IntervalCell(); | ||
| 68 | ✗ | Cell *facet() override { return &m_facet; } | |
| 69 | ✗ | Cell *edge() override { return nullptr; } | |
| 70 | }; | ||
| 71 | |||
| 72 | class TriangleCell : public Cell { | ||
| 73 | private: | ||
| 74 | IntervalCell m_facet; | ||
| 75 | PointCell m_edge; | ||
| 76 | |||
| 77 | public: | ||
| 78 | TriangleCell(); | ||
| 79 | 1 | Cell *facet() override { return &m_facet; } | |
| 80 | 1 | Cell *edge() override { return &m_edge; } | |
| 81 | }; | ||
| 82 | |||
| 83 | class QuadrilateralCell : public Cell { | ||
| 84 | private: | ||
| 85 | IntervalCell m_facet; | ||
| 86 | PointCell m_edge; | ||
| 87 | |||
| 88 | public: | ||
| 89 | QuadrilateralCell(); | ||
| 90 | ✗ | Cell *facet() override { return &m_facet; } | |
| 91 | ✗ | Cell *edge() override { return &m_edge; } | |
| 92 | }; | ||
| 93 | |||
| 94 | class TetrahedronCell : public Cell { | ||
| 95 | private: | ||
| 96 | TriangleCell m_facet; | ||
| 97 | IntervalCell m_edge; | ||
| 98 | |||
| 99 | public: | ||
| 100 | TetrahedronCell(); | ||
| 101 | ✗ | Cell *facet() override { return &m_facet; } | |
| 102 | ✗ | Cell *edge() override { return &m_edge; } | |
| 103 | }; | ||
| 104 | |||
| 105 | class HexahedronCell : public Cell { | ||
| 106 | private: | ||
| 107 | QuadrilateralCell m_facet; | ||
| 108 | IntervalCell m_edge; | ||
| 109 | |||
| 110 | public: | ||
| 111 | HexahedronCell(); | ||
| 112 | ✗ | Cell *facet() override { return &m_facet; } | |
| 113 | ✗ | Cell *edge() override { return &m_edge; } | |
| 114 | }; | ||
| 115 | |||
| 116 | CellType get_cell_type(const CellKind cell); | ||
| 117 | |||
| 118 | } // namespace oiseau::mesh | ||
| 119 |