Python-визуализация сетки

This commit is contained in:
2025-05-15 18:00:18 +03:00
parent 9325bbc747
commit 2933868ef9
6 changed files with 52 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
#include "Mesh.hpp"
#include <iostream>
#include <fstream>
#include <Object.hpp>
Mesh::Mesh(Object& _obj, double _step) : obj(_obj), step(_step) {
@@ -14,6 +15,21 @@ Mesh::Mesh(Object& _obj, double _step) : obj(_obj), step(_step) {
Adapt();
}
void Mesh::VisualizeMesh(std::string name) {
std::ofstream data_file(name);
data_file << "# Coordinates\n";
data_file << "# Format: x y\n";
for (const auto& row : mesh) {
for (const auto& node : row) {
data_file << node->X() << " " << node->Y() << "\n";
}
}
data_file.close();
}
void Mesh::LinkX() {
for (int i = 0; i < mesh.size(); i++) {
mesh[i][0]->LinkX(nullptr, mesh[i][1]);

View File

@@ -1,5 +1,9 @@
#include "System.hpp"
void System::export_mesh(std::string name) {
mesh.VisualizeMesh(name);
}
void System::DefineBounds(int l, int t, int r, int b) {
Node* cur = mesh.LineX().front();
while (cur) {

View File

@@ -73,6 +73,10 @@ int main()
System implicit5(obj, step_5, CONDUCTIVITY);
System implicit10(obj, step_10, CONDUCTIVITY);
/* Экспорт сеток */
explicit5.export_mesh("mesh5.txt");
explicit10.export_mesh("mesh10.txt");
explicit5.DefineBounds(left, top, right, bottom);
explicit10.DefineBounds(left, top, right, bottom);