| 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 | #include "oiseau/plotting/triplot.hpp" | ||
| 8 | |||
| 9 | #include <pybind11/cast.h> | ||
| 10 | |||
| 11 | #include <algorithm> | ||
| 12 | #include <cstddef> | ||
| 13 | #include <vector> | ||
| 14 | #include <xtensor/containers/xadapt.hpp> | ||
| 15 | #include <xtensor/containers/xbuffer_adaptor.hpp> | ||
| 16 | #include <xtensor/views/xslice.hpp> | ||
| 17 | #include <xtensor/views/xview.hpp> | ||
| 18 | |||
| 19 | #include "oiseau/mesh/mesh.hpp" | ||
| 20 | |||
| 21 | namespace oiseau::plotting { | ||
| 22 | |||
| 23 | ✗ | void triplot(plt::AxesSubPlot &ax, oiseau::mesh::Mesh &mesh) { | |
| 24 | ✗ | auto topology = mesh.topology(); | |
| 25 | ✗ | auto geometry = mesh.geometry(); | |
| 26 | ✗ | auto connectivity = topology.conn(); | |
| 27 | ✗ | auto x = geometry.x(); | |
| 28 | |||
| 29 | ✗ | std::vector<std::size_t> shape = {x.size() / geometry.dim(), geometry.dim()}; | |
| 30 | ✗ | auto coords = xt::adapt(x.data(), x.size(), xt::no_ownership(), shape); | |
| 31 | |||
| 32 | ✗ | for (std::size_t i = 0; i < connectivity.size(); ++i) { | |
| 33 | ✗ | auto cell = topology.cell_types()[i]; | |
| 34 | ✗ | auto conn = connectivity[i]; | |
| 35 | |||
| 36 | ✗ | auto face_vertices = cell->get_entity_vertices(1); | |
| 37 | ✗ | for (const auto &face_vertice : face_vertices) { | |
| 38 | ✗ | std::vector<std::size_t> temp(face_vertice.size()); | |
| 39 | ✗ | std::ranges::transform(face_vertice, temp.begin(), | |
| 40 | ✗ | [&conn](std::size_t idx) { return conn[idx]; }); | |
| 41 | |||
| 42 | ✗ | auto co = xt::view(coords, xt::keep(temp)); | |
| 43 | ✗ | auto xx = xt::col(co, 0); | |
| 44 | ✗ | auto yy = xt::col(co, 1); | |
| 45 | ✗ | ax.plot(xx, yy, "color"_a = "k"); | |
| 46 | ✗ | } | |
| 47 | ✗ | } | |
| 48 | ✗ | } | |
| 49 | |||
| 50 | } // namespace oiseau::plotting | ||
| 51 |