Compare commits

...

13 Commits

Author SHA1 Message Date
e06d350fd3 Расчёт абсолютных погрешностей вычислений темератур 2025-05-16 12:47:30 +03:00
409b3ecd97 Очередная оптимизация 2025-05-16 12:47:02 +03:00
3ed8093481 Изменение индексов граничных условий
Оптимизация кода
2025-05-15 23:26:58 +03:00
5d555820cc Delete .plt tracking 2025-05-15 18:07:15 +03:00
1189fae6e3 Link python script to project 2025-05-15 18:06:57 +03:00
2933868ef9 Python-визуализация сетки 2025-05-15 18:00:18 +03:00
9325bbc747 Here we go again
Или я опять всё напутал в начальных условиях
2025-05-15 15:10:34 +03:00
6482df0727 Renaming 2025-05-15 02:00:37 +03:00
Anton Kamalov
7c53da7199 fix 2025-05-15 01:24:54 +03:00
Anton Kamalov
8811ca5344 Оптимизация пространства 2025-05-15 01:19:28 +03:00
Anton Kamalov
517c551bf5 USTAL 2025-05-15 00:35:37 +03:00
5d1f889a1b Изменение ГУ 2025-05-14 20:25:34 +03:00
2b58527857 Подгонка под вариант
Отмена коммита с перегрузкой оператора -
2025-05-14 19:32:06 +03:00
26 changed files with 427 additions and 387 deletions

2
.gitignore vendored
View File

@@ -10,6 +10,8 @@
*.userosscache
*.sln.docstates
*.txt
*.png
*.plt
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

View File

@@ -0,0 +1,44 @@
import re
def parse_temp_file(temp_file):
node_temps = {}
with open(temp_file, 'r') as f:
for line in f:
match = re.match(r'^\s*(\d+)\s+([\d.]+)\s*$', line.strip())
if match:
node = int(match.group(1))
temp = float(match.group(2))
node_temps[node] = temp
return node_temps
def parse_node_file(node_file):
node_coords = {}
with open(node_file, 'r') as f:
for line in f:
match = re.match(r'^\s*(\d+)\s+([-\d.Ee]+)\s+([-\d.Ee]+)\s+([-\d.Ee]+)\s+[-\d.]+', line.strip())
if match:
node = int(match.group(1))
x = float(match.group(2))
y = float(match.group(3))
node_coords[node] = (x, y)
return node_coords
def process_files(temp_file, node_file, output_file):
node_temps = parse_temp_file(temp_file)
node_coords = parse_node_file(node_file)
with open(output_file, 'w') as f:
for node in node_temps:
if node in node_coords:
x, y = node_coords[node]
temp = node_temps[node]
f.write(f"100 {int(x)} {int(y)} {temp}\n")
else:
print(f"Warning: Node {node} not found in coordinate file")
temp_file = "temp_data.txt"
node_file = "node_data.txt"
output_file = "ansys.txt"
process_files(temp_file, node_file, output_file)
print(f"Output written to {output_file}")

View File

@@ -0,0 +1,60 @@
import math
def read_points(filename):
points = []
with open(filename, 'r') as f:
for line in f:
parts = line.strip().split()
if len(parts) == 4:
try:
x = float(parts[1])
y = float(parts[2])
temp = float(parts[3])
points.append((x, y, temp))
except ValueError:
print(f"Warning: Skipping invalid line in {filename}: {line.strip()}")
return points
def euclidean_distance(p1, p2):
return math.sqrt((p2[0] - p1[0])**2 + (p2[1] - p1[1])**2)
def find_closest_points(myprog_points, ansys_points):
differences = []
for myprog_point in myprog_points:
myprog_x, myprog_y, myprog_temp = myprog_point
min_distance = float('inf')
temp_diff = None
closest_point = None
# Find closest point in ansys.txt
for ansys_point in ansys_points:
ansys_x, ansys_y, ansys_temp = ansys_point
distance = euclidean_distance((myprog_x, myprog_y), (ansys_x, ansys_y))
if distance < min_distance:
min_distance = distance
temp_diff = abs(myprog_temp - ansys_temp)
closest_point = ansys_point
if temp_diff is not None:
differences.append(temp_diff)
print(f"Myprog point ({myprog_x}, {myprog_y}, {myprog_temp}) -> Closest Ansys point ({closest_point[0]}, {closest_point[1]}, {closest_point[2]}) -> Temp diff: {temp_diff}")
return differences
def process_files(myprog_file, ansys_file):
myprog_points = read_points(myprog_file)
ansys_points = read_points(ansys_file)
if not myprog_points or not ansys_points:
print("Error: One or both files are empty or contain no valid data.")
return
differences = find_closest_points(myprog_points, ansys_points)
if differences:
avg_difference = sum(differences) / len(differences)
print(f"\nAverage temperature difference: {avg_difference}")
else:
print("No valid matches found between the files.")
myprog_file = "myprog.txt"
ansys_file = "ansys.txt"
process_files(myprog_file, ansys_file)

View File

@@ -0,0 +1,4 @@
file = open('../implicit10.txt').readlines()
lines = [line for line in file if line.startswith('100')]
open('myprog.txt', 'w').write(''.join(lines))

View File

@@ -3,9 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35707.178
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Main_program", "MemMAPR_winda.vcxproj", "{86DC468D-3A9F-48AB-80FC-059A120499AA}"
EndProject
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "MemMAPR_visual", "..\MemMAPR_visual\MemMAPR_visual.pyproj", "{C56779D9-6429-49A0-8E09-0AE6A666EA21}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MemMAPR_main", "MemMAPR_winda.vcxproj", "{86DC468D-3A9F-48AB-80FC-059A120499AA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -29,12 +27,6 @@ Global
{86DC468D-3A9F-48AB-80FC-059A120499AA}.Release|x64.Build.0 = Release|x64
{86DC468D-3A9F-48AB-80FC-059A120499AA}.Release|x86.ActiveCfg = Release|Win32
{86DC468D-3A9F-48AB-80FC-059A120499AA}.Release|x86.Build.0 = Release|Win32
{C56779D9-6429-49A0-8E09-0AE6A666EA21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C56779D9-6429-49A0-8E09-0AE6A666EA21}.Debug|x64.ActiveCfg = Debug|Any CPU
{C56779D9-6429-49A0-8E09-0AE6A666EA21}.Debug|x86.ActiveCfg = Debug|Any CPU
{C56779D9-6429-49A0-8E09-0AE6A666EA21}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C56779D9-6429-49A0-8E09-0AE6A666EA21}.Release|x64.ActiveCfg = Release|Any CPU
{C56779D9-6429-49A0-8E09-0AE6A666EA21}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -111,6 +111,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>./include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@@ -157,6 +158,7 @@
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="visual_mesh.py" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@@ -68,5 +68,6 @@
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="visual_mesh.py" />
</ItemGroup>
</Project>

View File

@@ -1,10 +0,0 @@
set cbrange [0:100]
set size ratio 0.8
unset key
set palette defined (0 0 0 1, 0.25 0 1 1, 0.5 0 1 0, 0.75 1 1 0, 1 1 0 0)
do for [i=0:99]{
plot 'explicit10.txt' u 1:2:3 index i w points pt 5 palette
pause 1e-09}
pause mouse

10
es5.plt
View File

@@ -1,10 +0,0 @@
set cbrange [0:100]
set size ratio 0.8
unset key
set palette defined (0 0 0 1, 0.25 0 1 1, 0.5 0 1 0, 0.75 1 1 0, 1 1 0 0)
do for [i=0:99]{
plot 'explicit5.txt' u 1:2:3 index i w points pt 5 palette
pause 1e-09}
pause mouse

View File

@@ -7,14 +7,13 @@
class Form {
protected:
static size_t counter_;
size_t id_;
bool excluded_;
static size_t counter;
size_t id;
bool excluded;
int bound_type;
public:
Form();
virtual double Function(double, double);
virtual std::pair<double, double> Second_Deriative(double, double);
virtual bool Inhere(double, double);
virtual std::pair<double, double> missX(double);
virtual std::pair<double, double> missY(double);

View File

@@ -1,16 +1,18 @@
#ifndef MIMAPR_MESH_H
#define MIMAPR_MESH_H
#include <vector>
#include "Object.hpp"
#include "Node.hpp"
#include <vector>
#include <iostream>
#include <fstream>
class Mesh{
std::vector<std::vector<Node*>> _mesh;
std::vector<Node*> _hlines;
std::vector<Node*> _vlines;
Object& _obj;
double _step;
std::vector<std::vector<Node*>> mesh;
std::vector<Node*> hlines;
std::vector<Node*> vlines;
Object& obj;
double step;
void LinkX();
void LinkY();
void Delnode(int, int);
@@ -20,10 +22,11 @@ public:
Mesh(Object&, double);
~Mesh();
//void ShowLinks();
void VisualizeMesh(std::string);
std::vector<std::vector<Node*>>& Nodes() { return _mesh; }
std::vector<Node*>& LineX() { return _hlines; }
std::vector<Node*>& LineY() { return _vlines; }
std::vector<std::vector<Node*>>& Nodes() { return mesh; }
std::vector<Node*>& LineX() { return hlines; }
std::vector<Node*>& LineY() { return vlines; }
};
#endif

View File

@@ -1,26 +1,28 @@
#ifndef MIMAPR_NODE_H
#define MIMAPR_NODE_H
#define T_START 0.
#include <cmath>
class Node{
double _x;
double _y;
double _t;
int _btype;
double x;
double y;
double t;
int btype;
Node* _left;
Node* _right;
Node* _above;
Node* _below;
Node* left;
Node* right;
Node* above;
Node* bellow;
public:
Node(double x = 0., double y = 0., int type = 0., double t = 0.): _x(x), _y(y), _t(t), _left(nullptr), _right(nullptr), _above(nullptr), _below(nullptr), _btype(type) {}
Node(double _x = 0., double _y = 0., int _type = 0., double _t = T_START): x(_x), y(_y), t(_t), left(nullptr), right(nullptr), above(nullptr), bellow(nullptr), btype(_type) {}
double T() const;
double X() const;
double Y() const;
//double Dist(const Node*) const;
double Dist(const Node*) const;
void LinkX(Node*, Node*);
void LinkY(Node*, Node*);
Node*& l();
@@ -30,8 +32,6 @@ public:
void SetT(double);
bool IsBound();
void SetB(int);
double operator-(const Node*) const;
};
#endif

View File

@@ -6,9 +6,9 @@
class Object {
private:
std::vector<Form*> forms_;
double _w;
double _h;
std::vector<Form*> forms;
double w;
double h;
void Updsize();
public:
Object();
@@ -19,8 +19,8 @@ public:
double Height() const;
bool Add_Form(const std::string&, std::map<std::string, double>&, bool, int);
std::pair<double, double> Filly(double, double);
std::pair<double, double> Fillx(double, double);
std::pair<double, double> FillX(double, double);
std::pair<double, double> FillY(double, double);
Form* Who(double, double);
};

View File

@@ -8,14 +8,13 @@
class Rectangle : public Form {
private:
double a_;
double b_;
double h_x_;
double h_y_;
double x;
double y;
double h_x;
double h_y;
public:
Rectangle(double, double, double, double, bool, int);
double Function(double, double) override;
std::pair<double, double> Second_Deriative(double, double) override;
bool Inhere(double, double) override;
std::pair<double, double> missX(double) override;
std::pair<double, double> missY(double) override;
@@ -23,14 +22,13 @@ public:
};
class Circle : public Form {
private:
double a_;
double b_;
double h_x_;
double h_y_;
double x;
double y;
double h_x;
double h_y;
public:
Circle(double, double, double, double, bool, int);
double Function(double, double) override;
std::pair<double, double> Second_Deriative(double, double) override;
bool Inhere(double, double) override;
std::pair<double, double> missX(double) override;
std::pair<double, double> missY(double) override;
@@ -39,14 +37,13 @@ public:
class Arc : public Form {
private:
double a_;
double b_;
double h_x_;
double h_y_;
double x;
double y;
double h_x;
double h_y;
public:
Arc(double, double, double, double, bool, int);
double Function(double, double) override;
std::pair<double, double> Second_Deriative(double, double) override;
std::pair<double, double> missX(double) override;
std::pair<double, double> missY(double) override;
std::pair<double, double> size() override;

View File

@@ -5,19 +5,18 @@
class System{
Object& _obj;
Mesh _mesh;
double _a1;
double _a2;
Mesh mesh;
double _a;
double _step;
public:
System(Object& obj, double step = 10., double a1 = 1., double a2 = 1.): _obj(obj), _mesh(obj, step), _a1(a1), _a2(a2), _step(step) {}
System(Object& obj, double step = 10., double a1 = 1.): _obj(obj), mesh(obj, step), _a(a1), _step(step) {}
void DefineBounds(int, int, int, int);
void export_mesh(std::string);
std::vector<std::vector<Node*>>& Nodes();
std::vector<Node*>& LineX();
std::vector<Node*>& LineY();
double step() const { return _step; }
double a1() const { return _a1; };
double a2() const { return _a2; };
double a() const { return _a; };
};
#endif

View File

@@ -1,10 +0,0 @@
set cbrange [0:100]
set size ratio 0.8
unset key
set palette defined (0 0 0 1, 0.25 0 1 1, 0.5 0 1 0, 0.75 1 1 0, 1 1 0 0)
do for [i=0:99]{
plot 'implicit10.txt' u 1:2:3 index i w points pt 5 palette
pause 1e-09}
pause mouse

10
is5.plt
View File

@@ -1,10 +0,0 @@
set cbrange [0:100]
set size ratio 0.8
unset key
set palette defined (0 0 0 1, 0.25 0 1 1, 0.5 0 1 0, 0.75 1 1 0, 1 1 0 0)
do for [i=0:99]{
plot 'implicit5.txt' u 1:2:3 index i w points pt 5 palette
pause 1e-09}
pause mouse

View File

@@ -1,15 +1,11 @@
#include "Form.hpp"
size_t Form::counter_ = 0;
size_t Form::counter = 0;
double Form::Function(double, double) {
return 0;
}
std::pair<double, double> Form::Second_Deriative(double, double) {
return { 0, 0 };
}
std::pair<double, double> Form::size() {
return { 0, 0 };
}
@@ -27,17 +23,13 @@ std::pair<double, double> Form::missY(double) {
}
Form::Form() {
id_ = counter_++;
excluded_ = false;
id = counter++;
excluded = false;
bound_type = -1;
}
bool Form::Excluded() const {
return excluded_;
return excluded;
}
int Form::GetB() { return bound_type; }
//bool Form::operator==(size_t id) const {
// return id_ == id;
//}
int Form::GetB() { return bound_type; }

View File

@@ -1,13 +1,9 @@
#include "Mesh.hpp"
#include <iostream>
#include <Object.hpp>
Mesh::Mesh(Object& obj, double step) : _obj(obj), _step(step) {
Mesh::Mesh(Object& _obj, double _step) : obj(_obj), step(_step) {
for (double y = 0.0; y <= _obj.Height(); y += _step) {
_mesh.push_back(std::vector<Node*>());
mesh.push_back(std::vector<Node*>());
for (double x = 0.0; x <= _obj.Width(); x += _step) {
_mesh.back().push_back(new Node(x, y));
mesh.back().push_back(new Node(x, y));
}
}
LinkX();
@@ -15,36 +11,48 @@ Mesh::Mesh(Object& obj, double step) : _obj(obj), _step(step) {
Adapt();
}
void Mesh::LinkX() {
void Mesh::VisualizeMesh(std::string name) {
std::ofstream data_file(name);
for (int i = 0; i < _mesh.size(); i++) {
_mesh[i][0]->LinkX(nullptr, _mesh[i][1]);
for (int j = 1; j < _mesh[i].size() - 1; j++)
_mesh[i][j]->LinkX(_mesh[i][j - 1], _mesh[i][j + 1]);
_mesh[i].back()->LinkX(_mesh[i][_mesh[i].size() - 2], nullptr);
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";
}
}
for (int i = 0; i < _mesh.size(); i++)
_hlines.push_back(_mesh[i][0]);
data_file.close();
}
void Mesh::LinkX() {
for (int i = 0; i < mesh.size(); i++) {
mesh[i][0]->LinkX(nullptr, mesh[i][1]);
for (int j = 1; j < mesh[i].size() - 1; j++)
mesh[i][j]->LinkX(mesh[i][j - 1], mesh[i][j + 1]);
mesh[i].back()->LinkX(mesh[i][mesh[i].size() - 2], nullptr);
}
for (int i = 0; i < mesh.size(); i++)
hlines.push_back(mesh[i][0]);
}
void Mesh::LinkY() {
for (int j = 0; j < _mesh[0].size(); j++) {
_mesh[0][j]->LinkY(nullptr, _mesh[1][j]);
for (int i = 1; i < _mesh.size() - 1; i++)
_mesh[i][j]->LinkY(_mesh[i - 1][j], _mesh[i + 1][j]);
_mesh[_mesh.size() - 1][j]->LinkY(_mesh[_mesh.size() - 2][j], nullptr);
for (int j = 0; j < mesh[0].size(); j++) {
mesh[0][j]->LinkY(nullptr, mesh[1][j]);
for (int i = 1; i < mesh.size() - 1; i++)
mesh[i][j]->LinkY(mesh[i - 1][j], mesh[i + 1][j]);
mesh[mesh.size() - 1][j]->LinkY(mesh[mesh.size() - 2][j], nullptr);
}
for (int i = 0; i < _mesh[0].size(); i++)
_vlines.push_back(_mesh[0][i]);
for (int i = 0; i < mesh[0].size(); i++)
vlines.push_back(mesh[0][i]);
}
void Mesh::Adapt() {
for (int i = 0; i < _mesh.size(); i++) {
int s = _mesh[i].size();
for (int i = 0; i < mesh.size(); i++) {
int s = mesh[i].size();
for (int j = 0; j < s; j++) {
if (!_obj.Inhere(_mesh[i][j]->X(), _mesh[i][j]->Y())) {
if (!obj.Inhere(mesh[i][j]->X(), mesh[i][j]->Y())) {
Delnode(i, j);
j--;
s--;
@@ -54,26 +62,32 @@ void Mesh::Adapt() {
}
void Mesh::Delnode(int i, int j) {
Node* node = _mesh[i][j];
double bndX1 = _obj.Fillx(node->X(), node->Y()).first;
double bndX2 = _obj.Fillx(node->X(), node->Y()).second;
double bndY1 = _obj.Filly(node->X(), node->Y()).first;
double bndY2 = _obj.Filly(node->X(), node->Y()).second;
int btype = _obj.Who(node->X(), node->Y())->GetB();
Node* node = mesh[i][j];
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> X <20> Y */
double bndX1 = obj.FillX(node->X(), node->Y()).first;
double bndX2 = obj.FillX(node->X(), node->Y()).second;
double bndY1 = obj.FillY(node->X(), node->Y()).first;
double bndY2 = obj.FillY(node->X(), node->Y()).second;
/* <20><> <20><><EFBFBD><EFBFBD><EFBFBD> */
int btype = obj.Who(node->X(), node->Y())->GetB();
if (node->l()) {
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (node->l()->X() != bndX2 && node->l()->X() != bndX1) {
if (bndX1 != bndX2) {
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> bndX2 <20> bndX1 <20> <20><> btype */
Node* left = new Node(bndX2, node->Y(), btype);
Node* right = new Node(bndX1, node->Y(), btype);
node->l()->r() = left;
if (node->r())
node->r()->l() = right;
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD> X */
left->LinkX(node->l(), right);
right->LinkX(left, node->r());
node->l() = right;
_mesh[i].push_back(left);
_mesh[i].push_back(right);
mesh[i].push_back(left);
mesh[i].push_back(right);
}
/* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> X <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> */
else {
Node* left = new Node(bndX2, node->Y(), btype);
node->l()->r() = left;
@@ -81,12 +95,13 @@ void Mesh::Delnode(int i, int j) {
node->r()->l() = left;
left->LinkX(node->l(), node->r());
node->l() = left;
_mesh[i].push_back(left);
mesh[i].push_back(left);
}
}
/* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
else
node->l()->r() = node->r();
}
} /* <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> */
if (node->r()) {
node->r()->l() = node->l();
}
@@ -101,8 +116,8 @@ void Mesh::Delnode(int i, int j) {
down->LinkY(node->d(), up);
up->LinkY(down, node->u());
node->d() = up;
_mesh[i].push_back(down);
_mesh[i].push_back(up);
mesh[i].push_back(down);
mesh[i].push_back(up);
}
else {
Node* down = new Node(node->X(), bndY2, btype);
@@ -111,7 +126,7 @@ void Mesh::Delnode(int i, int j) {
node->u()->d() = down;
down->LinkY(node->d(), node->u());
node->d() = down;
_mesh[i].push_back(down);
mesh[i].push_back(down);
}
}
else
@@ -120,42 +135,12 @@ void Mesh::Delnode(int i, int j) {
if (node->u()) {
node->u()->d() = node->d();
}
_mesh[i].erase(_mesh[i].begin() + j);
mesh[i].erase(mesh[i].begin() + j);
delete node;
}
Mesh::~Mesh() {
for (auto line : _mesh)
for (auto line : mesh)
for (auto node : line)
delete node;
}
//void Mesh::ShowLinks() {
// for (auto line : _mesh) {
// for (auto node : line) {
// if (node->d())
// std::cout << "| ";
// }
// std::cout << '\n';
// for (auto node : line) {
// if (node->l()) {
// std::cout << '-';
// }
// std::cout << 'N';
// if (node->r()) {
// std::cout << '-';
// }
// else {
// std::cout << '\n';
// }
// }
// for (auto node : line) {
// if (node->u())
// std::cout << "|";
// std::cout << " ";
//
// }
// std::cout << '\n';
// }
//}
}

View File

@@ -1,91 +1,86 @@
#include "Node.hpp"
#include <iostream>
double Node::X() const { return _x; }
double Node::Y() const { return _y; }
double Node::X() const { return x; }
double Node::Y() const { return y; }
double Node::T() const {
if (_btype == 1)
if (btype == 1)
return 100.;
if (_btype == 2) {
if (!_left)
if (_right)
return _right->T();
if (!_right)
if (_left)
return _left->T();
if (!_above)
if (_below)
return _below->T();
if (!_below)
if (_above)
return _above->T();
if (_right && _left) {
if (_right->IsBound())
return _left->T();
return _right->T();
else if (btype == 2) {
if (!left)
if (right)
return right->T() / (1 + Dist(right));
if (!right)
if (left)
return left->T() / (1 + Dist(left));
if (!above)
if (bellow)
return bellow->T() / (1 + Dist(bellow));
if (!bellow)
if (above)
return above->T() / (1 + Dist(above));
if (right && left) {
if (right->IsBound())
return left->T() / (1 + Dist(left));
return right->T() / (1 + Dist(right));
}
if (_above && _below) {
if (_above->IsBound())
return _below->T();
return _above->T();
if (above && bellow) {
if (above->IsBound())
return bellow->T() / (1 + Dist(bellow));
return above->T() / (1 + Dist(above));
}
}
if (_btype == 3) {
if (!_left)
if (_right)
return _right->T() / (1 + this - _right);
if (!_right)
if (_left)
return _left->T() / (1 + this - _left);
if (!_above)
if (_below)
return _below->T() / (1 + this - _below);
if (!_below)
if (_above)
return _above->T() / (1 + this - _above);
if (_right && _left) {
if (_right->IsBound())
return _left->T() / (1 + this - _left);
return _right->T() / (1 + this - _right);
else if (btype == 3) {
if (!left)
if (right)
return right->T();
if (!right)
if (left)
return left->T();
if (!above)
if (bellow)
return bellow->T();
if (!bellow)
if (above)
return above->T();
if (right && left) {
if (right->IsBound())
return left->T();
return right->T();
}
if (_above && _below) {
if (_above->IsBound())
return _below->T() / (1 + this - _below);
return _above->T() / (1 + this - _above);
if (above && bellow) {
if (above->IsBound())
return bellow->T();
return above->T();
}
}
return _t;
return t;
}
double Node::operator-(const Node* to) const {
double Node::Dist(const Node* to) const {
return std::sqrt(pow(X() - to->X(), 2) + pow(Y() - to->Y(), 2));
}
//double Node::Dist(const Node* to) const {
// return std::sqrt(pow(X() - to->X(), 2) + pow(Y() - to->Y(), 2));
//}
Node*& Node::l() { return _left; }
Node*& Node::r() { return _right; }
Node*& Node::u() { return _above; }
Node*& Node::d() { return _below; }
Node*& Node::l() { return left; }
Node*& Node::r() { return right; }
Node*& Node::u() { return above; }
Node*& Node::d() { return bellow; }
void Node::LinkX(Node* l, Node* r) {
_left = l;
_right = r;
left = l;
right = r;
}
void Node::LinkY(Node* d, Node* u) {
_below = d;
_above = u;
bellow = d;
above = u;
}
void Node::SetT(double t) {
_t = t;
void Node::SetT(double _t) {
t = _t;
}
bool Node::IsBound() { return _btype; }
void Node::SetB(int type) { _btype = type; }
bool Node::IsBound() { return btype; }
void Node::SetB(int _type) { btype = _type; }

View File

@@ -1,9 +1,9 @@
#include "Object.hpp"
Object::Object() : _w(0), _h(0) {}
Object::Object() : w(0), h(0) {}
double Object::Inhere(double x, double y) {
for (auto form : forms_) {
for (auto form : forms) {
if (form->Excluded()) {
if (form->Inhere(x, y)) {
return false;
@@ -19,25 +19,25 @@ double Object::Inhere(double x, double y) {
}
void Object::Updsize() {
for (auto form : forms_) {
_w = std::max(_w, form->size().first);
_h = std::max(_h, form->size().second);
for (auto form : forms) {
w = std::max(w, form->size().first);
h = std::max(h, form->size().second);
}
}
bool Object::Add_Form(const std::string& name, std::map<std::string, double>& args, bool excluded, int btype) {
if (name == "Rectangle") {
forms_.push_back(new Rectangle(args["a"], args["b"], args["h_x"], args["h_y"], excluded, btype));
forms.push_back(new Rectangle(args["a"], args["b"], args["h_x"], args["h_y"], excluded, btype));
Updsize();
return true;
}
else if (name == "Circle") {
forms_.push_back(new Circle(args["a"], args["b"], args["h_x"], args["h_y"], excluded, btype));
forms.push_back(new Circle(args["a"], args["b"], args["h_x"], args["h_y"], excluded, btype));
Updsize();
return true;
}
else if (name == "Arc") {
forms_.push_back(new Arc(args["a"], args["b"], args["h_x"], args["h_y"], excluded, btype));
forms.push_back(new Arc(args["a"], args["b"], args["h_x"], args["h_y"], excluded, btype));
Updsize();
return true;
}
@@ -46,8 +46,8 @@ bool Object::Add_Form(const std::string& name, std::map<std::string, double>& ar
std::pair<double, double> Object::Fillx(double x, double y) {
for (auto form : forms_) {
std::pair<double, double> Object::FillX(double x, double y) {
for (auto form : forms) {
if (form->Inhere(x, y)) {
return form->missX(y);
}
@@ -55,8 +55,8 @@ std::pair<double, double> Object::Fillx(double x, double y) {
return { 0, 0 };
}
std::pair<double, double> Object::Filly(double x, double y) {
for (auto form : forms_) {
std::pair<double, double> Object::FillY(double x, double y) {
for (auto form : forms) {
if (form->Inhere(x, y)) {
return form->missY(x);
}
@@ -65,33 +65,24 @@ std::pair<double, double> Object::Filly(double x, double y) {
}
double Object::Width() const {
return _w;
return w;
}
double Object::Height() const {
return _h;
return h;
}
//std::vector<size_t> Object::Get_IDs() {
// std::vector<size_t> ids;
// ids.reserve(forms_.size());
// for (auto form : forms_) {
// ids.push_back(form->Get_ID());
// }
// return ids;
//}
Form* Object::Who(double x, double y) {
for (auto form : forms_) {
for (auto form : forms) {
if (form->Inhere(x, y)) {
return form;
}
}
return forms_.back();
return forms.back();
}
Object::~Object() {
for (auto form : forms_)
for (auto form : forms)
delete form;
}

View File

@@ -1,95 +1,74 @@
#include "Primitives.hpp"
Rectangle::Rectangle(double a, double b, double h_x, double h_y, bool excluded, int btype) : a_(a), b_(b), h_x_(h_x), h_y_(h_y) {
excluded_ = excluded;
bound_type = btype;
Rectangle::Rectangle(double _x, double _y, double _h_x, double _h_y, bool _excluded, int _btype) : x(_x), y(_y), h_x(_h_x), h_y(_h_y) {
excluded = _excluded;
bound_type = _btype;
}
std::pair<double, double> Rectangle::missX(double y) {
return { 0.5 / h_x_ + a_, -0.5 / h_x_ + a_ };
std::pair<double, double> Rectangle::missX(double _y) {
return { 0.5 / h_x + x, -0.5 / h_x + x };
}
std::pair<double, double> Rectangle::missY(double x) {
return { 0.5 / h_y_ + b_, -0.5 / h_y_ + b_ };
std::pair<double, double> Rectangle::missY(double _x) {
return { 0.5 / h_y + y, -0.5 / h_y + y };
}
std::pair<double, double> Rectangle::size() {
return { 1 / h_x_, 1 / h_y_ };
return { 1 / h_x, 1 / h_y };
}
double Rectangle::Function(double x, double y) {
return std::max(h_x_ * std::abs(x - a_), h_y_ * std::abs(y - b_));
}
std::pair<double, double> Rectangle::Second_Deriative(double x, double y) {
return { (h_x_ / 2) * ((x - a_) / std::abs(x - a_)), (h_y_ / 2) * ((y - b_) / std::abs(y - b_)) };
double Rectangle::Function(double _x, double _y) {
return std::max(h_x * std::abs(_x - x), h_y * std::abs(_y - y));
}
bool Rectangle::Inhere(double x, double y) {
return Function(x, y) <= EPS_RECTANGLE;
}
Circle::Circle(double a, double b, double h_x, double h_y, bool excluded, int btype) : a_(a), b_(b), h_x_(h_x), h_y_(h_y) {
excluded_ = excluded;
bound_type = btype;
Circle::Circle(double _x, double _y, double _h_x, double _h_y, bool _excluded, int _btype) : x(_x), y(_y), h_x(_h_x), h_y(_h_y) {
excluded = _excluded;
bound_type = _btype;
}
std::pair<double, double> Circle::missY(double x) {
return { std::sqrt(1 - pow((h_x_ * (x - a_)), 2)) / h_y_ + b_, -std::sqrt(1 - pow((h_x_ * (x - a_)), 2)) / h_y_ + b_ };
std::pair<double, double> Circle::missY(double _x) {
return { std::sqrt(1 - pow((h_x * (_x - x)), 2)) / h_y + y, -std::sqrt(1 - pow((h_x * (_x - x)), 2)) / h_y + y };
}
std::pair<double, double> Circle::missX(double y) {
return { std::sqrt(1 - pow((h_y_ * (y - b_)), 2)) / h_x_ + a_, -std::sqrt(1 - pow((h_y_ * (y - b_)), 2)) / h_x_ + a_ };
std::pair<double, double> Circle::missX(double _y) {
return { std::sqrt(1 - pow((h_y * (_y - y)), 2)) / h_x + x, -std::sqrt(1 - pow((h_y * (_y - y)), 2)) / h_x + x };
}
double Circle::Function(double x, double y) {
return pow(h_x_ * (x - a_), 2) + pow(h_y_ * (y - b_), 2);
}
std::pair<double, double> Circle::Second_Deriative(double x, double y) {
return { 2 * h_x_ * (x - a_), 2 * h_y_ * (y - b_) };
double Circle::Function(double _x, double _y) {
return pow(h_x * (_x - x), 2) + pow(h_y * (_y - y), 2);
}
std::pair<double, double> Circle::size() {
return { 1 / h_x_, 1 / h_y_ };
return { 1 / h_x, 1 / h_y };
}
bool Circle::Inhere(double x, double y) {
return Function(x, y) <= EPS_CIRCLE;
}
Arc::Arc(double a, double b, double h_x, double h_y, bool excluded, int btype) : a_(a), b_(b), h_x_(h_x), h_y_(h_y) {
excluded_ = excluded;
bound_type = btype;
Arc::Arc(double _x, double _y, double _h_x, double _h_y, bool _excluded, int _btype) : x(_x), y(_y), h_x(_h_x), h_y(_h_y) {
excluded = _excluded;
bound_type = _btype;
}
std::pair<double, double> Arc::missY(double x) {
return { std::sqrt(1 - pow((h_x_ * (x - a_)), 2)) / h_y_ + b_, std::sqrt(1 - pow((h_x_ * (x - a_)), 2)) / h_y_ + b_ };
std::pair<double, double> Arc::missY(double _x) {
return { std::sqrt(1 - pow((h_x * (_x - x)), 2)) / h_y + y, std::sqrt(1 - pow((h_x * (_x - x)), 2)) / h_y + y };
}
std::pair<double, double> Arc::missX(double y) {
return { std::sqrt(1 - pow((h_y_ * (y - b_)), 2)) / h_x_ + a_, std::sqrt(1 - pow((h_y_ * (y - b_)), 2)) / h_x_ + a_ };
std::pair<double, double> Arc::missX(double _y) {
return { std::sqrt(1 - pow((h_y * (_y - y)), 2)) / h_x + x, std::sqrt(1 - pow((h_y * (_y - y)), 2)) / h_x + x };
}
double Arc::Function(double x, double y) {
if (x >= a_ && y >= b_) {
return pow(h_x_ * (x - a_), 2) + pow(h_y_ * (y - b_), 2);
double Arc::Function(double _x, double _y) {
if (_x >= x && _y >= y) {
return pow(h_x * (_x - x), 2) + pow(h_y * (_y - y), 2);
}
return -1.0;
}
std::pair<double, double> Arc::Second_Deriative(double x, double y) {
if (x >= a_ && y >= b_) {
return { 2 * h_x_ * (x - a_), 2 * h_y_ * (y - b_) };
}
if (x < a_) {
//std::cout << "x < a\n";
}
if (y < b_) {
//std::cout << "y < b\n";
}
return { -1.0, -1.0 };
}
std::pair<double, double> Arc::size() {
return { 1 / h_x_, 1 / h_y_ };
return { 1 / h_x, 1 / h_y };
}
bool Arc::Inhere(double x, double y) {

View File

@@ -1,6 +1,6 @@
#include "Solver.hpp"
void Solver::SolveExplicit(System& program, double tstop) const {
std::ofstream output(filename_expl);
void Solver::SolveImplicit(System& program, double tstop) const {
std::ofstream output(filename_impl);
//output << "t x y T" << std::endl;
for (double t = 0.0; t < tstop; t += delta) {
@@ -50,8 +50,8 @@ void Solver::SolveExplicit(System& program, double tstop) const {
}
}
void Solver::SolveImplicit(System& sys, double tstop) const {
std::ofstream output(filename_impl);
void Solver::SolveExplicit(System& sys, double tstop) const {
std::ofstream output(filename_expl);
//output << "t x y T" << std::endl;
for (double t = 0.; t < tstop; t += delta) {
@@ -61,12 +61,11 @@ void Solver::SolveImplicit(System& sys, double tstop) const {
if (!node->IsBound()) {
/* Tx = T_right - 2T_current + T_left / delta_x ^ 2 */
/* Ty = T_upper - 2T_current + T_down / delta_y ^ 2*/
/* T_new = delta_t * a * (delta_x + delta_y) + T_current
(для удобства коээфициент a = 1) */
/* T_new = delta_t * a * (delta_x + delta_y) + T_current */
double tx = (node->r()->T() - 2 * node->T() + node->l()->T()) / pow(sys.step(), 2);
double ty = (node->u()->T() - 2 * node->T() + node->d()->T()) / pow(sys.step(), 2);
double t = delta * (tx + ty) + node->T();
double t = delta * (tx + ty) * sys.a() + node->T();
node->SetT(t);
}
}
@@ -80,22 +79,22 @@ void Solver::SolveImplicit(System& sys, double tstop) const {
void Solver::SolveLine(System& sys, std::vector<Node*>& n) const {
int size = n.size() - 2;
double mu1 = (n.front() - n[1]) / sys.step();
double mu2 = (n.back() - n[n.size() - 2]) / sys.step();
double mu1 = n.front()->Dist(n[1]) / sys.step();
double mu2 = n.back()->Dist(n[n.size() - 2]) / sys.step();
/* Защита от нуля */
if (mu2 == 0.)
mu2 = .1;
double val2 = -(2 * sys.a1()) / (pow(sys.step(), 2)) - 1 / delta;
double val1 = sys.a1() / (pow(sys.step(), 2));
double val2 = -(2 * sys.a()) / (pow(sys.step(), 2)) - 1 / delta;
double val1 = sys.a() / (pow(sys.step(), 2));
std::vector<std::vector<double>> _Temperature(size);
std::vector<double> right(size);
for (int i = 0; i < _Temperature.size(); i++)
_Temperature[i].resize(3, 0.0);
_Temperature[0][0] = -(2 * sys.a1()) / (mu1 * pow(sys.step(), 2)) - 1 / delta; /* Первый узел по X */
_Temperature[0][1] = (2 * sys.a1()) / ((mu1 + 1) * pow(sys.step(), 2)); /* Первый узел по Y */
_Temperature.back()[1] = (2 * sys.a1()) / ((mu2 + 1) * pow(sys.step(), 2));
_Temperature.back()[2] = -(2 * sys.a1()) / (mu2 * pow(sys.step(), 2)) - 1 / delta;
_Temperature[0][0] = -(2 * sys.a()) / (mu1 * pow(sys.step(), 2)) - 1 / delta; /* Первый узел по X */
_Temperature[0][1] = (2 * sys.a()) / ((mu1 + 1) * pow(sys.step(), 2)); /* Первый узел по Y */
_Temperature.back()[1] = (2 * sys.a()) / ((mu2 + 1) * pow(sys.step(), 2));
_Temperature.back()[2] = -(2 * sys.a()) / (mu2 * pow(sys.step(), 2)) - 1 / delta;
for (int i = 1; i < size - 1; i++) {
_Temperature[i][0] = val1;
@@ -105,14 +104,14 @@ void Solver::SolveLine(System& sys, std::vector<Node*>& n) const {
for (int i = 0; i < right.size(); i++)
right[i] = -n[i + 1]->T() / delta;
right.front() += -(2 * sys.a1() * n.front()->T()) / (mu1 * (mu1 + 1) * pow(sys.step(), 2));
right.back() += -(2 * sys.a1() * n.back()->T()) / (mu2 * (mu2 + 1) * pow(sys.step(), 2));
std::vector<double> tmps = ThomasMethod(_Temperature, right);
for (int i = 0; i < tmps.size(); i++)
n[i + 1]->SetT(tmps[i]);
right.front() += -(2 * sys.a() * n.front()->T()) / (mu1 * (mu1 + 1) * pow(sys.step(), 2));
right.back() += -(2 * sys.a() * n.back()->T()) / (mu2 * (mu2 + 1) * pow(sys.step(), 2));
std::vector<double> tmp = ThomasMethod(_Temperature, right);
for (int i = 0; i < tmp.size(); i++)
n[i + 1]->SetT(tmp[i]);
}
/* Метод прогонки для численного решения СЛАУ */
std::vector<double> Solver::ThomasMethod(std::vector<std::vector<double>>& A, std::vector<double>& b) const {
int row = b.size() - 1;

View File

@@ -1,30 +1,34 @@
#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();
Node* cur = mesh.LineX().front();
while (cur) {
cur->SetB(b);
cur = cur->r();
}
cur = _mesh.LineX().back();
cur = mesh.LineX().back();
while (cur) {
cur->SetB(t);
cur = cur->r();
}
cur = _mesh.LineY().front();
cur = mesh.LineY().front();
while (cur) {
cur->SetB(l);
cur = cur->u();
}
cur = _mesh.LineY().back();
cur = mesh.LineY().back();
while (cur->u()) {
cur->SetB(r);
cur = cur->u();
}
}
std::vector<std::vector<Node*>>& System::Nodes() { return _mesh.Nodes(); }
std::vector<Node*>& System::LineX() { return _mesh.LineX(); }
std::vector<Node*>& System::LineY() { return _mesh.LineY(); }
std::vector<std::vector<Node*>>& System::Nodes() { return mesh.Nodes(); }
std::vector<Node*>& System::LineX() { return mesh.LineX(); }
std::vector<Node*>& System::LineY() { return mesh.LineY(); }

View File

@@ -2,20 +2,22 @@
#include <fstream>
#include <Solver.hpp>
#define STEP 1
#define WIDTH 500.
#define HEIGHT 400.
#define ARC_RADIUS 150.
//#define SQUARE_X 355.
//#define SQUARE_Y 155.
//#define SQUARE_SIDE 100.
#define SQUARE_X 355.
#define SQUARE_Y 155.
#define SQUARE_SIDE 100.
#define HOLE_X 355.
#define HOLE_Y 155.
#define HOLE_RADIUS 50.
//#define HOLE_X 155.
//#define HOLE_Y 255.
//#define HOLE_RADIUS 50.
#define CONDUCTIVITY 50. // Теплопроводность материала
#define CONDUCTIVITY 100. // Теплопроводность материала
void visualize(std::ofstream& file, std::string filename, int time_end) {
file << "set cbrange [" << 0 << ":" << 100 << "]" << std::endl;
@@ -29,59 +31,66 @@ void visualize(std::ofstream& file, std::string filename, int time_end) {
int main()
{
/* Граничные условия:
1 - нагрев
2 - теплоизоляция
3 - конвекция
4 - отсутствует
1 - нагрев
2 - конвекция
3 - теплоизоляция
0 - отсутствует
*/
int left = 3;
int top = 1;
int right = 3;
int bottom = 1;
int r2 = 3;
int s = 3;
int left = 1;
int top = 2;
int right = 1;
int bottom = 2;
int arc_bound = 2;
int hole_bound = 1;
double step_5 = 5;
double step_10 = 10;
double time_step = 1;
double time_end = 100;
std::map<std::string, double> plate{
{"a", WIDTH / 2}, {"b", HEIGHT / 2}, {"h_x", 1 / WIDTH}, {"h_y", 1 / HEIGHT}
std::map<std::string, double> plate{
{"a", WIDTH / 2}, {"b", HEIGHT / 2}, {"h_x", 1 / WIDTH}, {"h_y", 1 / HEIGHT}
};
std::map<std::string, double> arc{
{"a", WIDTH - ARC_RADIUS}, {"b", HEIGHT - ARC_RADIUS}, {"h_x", 1 / ARC_RADIUS}, {"h_y", 1 / ARC_RADIUS}
{"a", WIDTH - ARC_RADIUS}, {"b", HEIGHT - ARC_RADIUS}, {"h_x", 1 / ARC_RADIUS}, {"h_y", 1 / ARC_RADIUS}
};
std::map<std::string, double> circle{
{"a", HOLE_X}, {"b", HOLE_Y}, {"h_x", 1 / HOLE_RADIUS}, {"h_y", 1 / HOLE_RADIUS}
//std::map<std::string, double> circle{
// {"a", HOLE_X}, {"b", HOLE_Y}, {"h_x", 1 / HOLE_RADIUS}, {"h_y", 1 / HOLE_RADIUS}
//};
std::map<std::string, double> square{
{"a", SQUARE_X}, {"b", SQUARE_Y}, {"h_x", 1 / SQUARE_SIDE}, {"h_y", 1 / SQUARE_SIDE}
};
Object obj;
obj.Add_Form("Circle", circle, true, s);
obj.Add_Form("Arc", arc, true, r2);
obj.Add_Form("Rectangle", square, true, hole_bound);
obj.Add_Form("Arc", arc, true, arc_bound);
obj.Add_Form("Rectangle", plate, false, 1);
System explicit5(obj, step_5, CONDUCTIVITY);
System explicit10(obj, step_10, CONDUCTIVITY);
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);
implicit5.DefineBounds(left, top, right, bottom);
implicit10.DefineBounds(left, top, right, bottom);
Solver slv5("explicit5.txt", "implicit5.txt", time_step);
Solver slv10("explicit10.txt", "implicit10.txt", time_step);
Solver slv5("explicit5.txt", "implicit5.txt", STEP);
Solver slv10("explicit10.txt", "implicit10.txt", STEP);
slv5.SolveExplicit(explicit5, time_end);
slv5.SolveImplicit(implicit5, time_end);
slv10.SolveExplicit(explicit10, time_end);
slv10.SolveImplicit(implicit10, time_end);
std::ofstream script("es10.plt");
visualize(script, "explicit10.txt", time_end);
script.close();
@@ -100,6 +109,3 @@ int main()
return 0;
}
//std::map<std::string, double> square{
// {"a", SQUARE_X}, {"b", SQUARE_Y}, {"h_x", 1 / SQUARE_SIDE}, {"h_y", 1 / SQUARE_SIDE}
//};

26
visual_mesh.py Normal file
View File

@@ -0,0 +1,26 @@
import matplotlib.pyplot as plt
x_coords = []
y_coords = []
try:
filename = input("Input name: ")
with open(f'{filename}', 'r') as file:
lines = file.readlines()
for line in lines[2:]:
if line.strip():
x, y = map(float, line.strip().split())
x_coords.append(x)
y_coords.append(y)
plt.figure(figsize=(10, 6))
plt.scatter(x_coords, y_coords, s=10, c='blue', alpha=0.5)
plt.xlabel('X')
plt.ylabel('Y')
plt.grid(True)
plt.axis('equal')
plt.savefig(f"{filename[:-4]}.png")
plt.show()
except FileNotFoundError:
print(f"{filename} not found. ABORT!")