Here we go again

Или я опять всё напутал в начальных условиях
This commit is contained in:
2025-05-15 15:10:34 +03:00
parent 6482df0727
commit 9325bbc747
4 changed files with 31 additions and 27 deletions

View File

@@ -19,8 +19,8 @@ public:
double Height() const; double Height() const;
bool Add_Form(const std::string&, std::map<std::string, double>&, bool, int); 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); Form* Who(double, double);
}; };

View File

@@ -3,7 +3,6 @@
#include <Object.hpp> #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) { 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) { for (double x = 0.0; x <= _obj.Width(); x += _step) {
@@ -16,7 +15,6 @@ Mesh::Mesh(Object& _obj, double _step) : obj(_obj), step(_step) {
} }
void Mesh::LinkX() { void Mesh::LinkX() {
for (int i = 0; i < mesh.size(); i++) { for (int i = 0; i < mesh.size(); i++) {
mesh[i][0]->LinkX(nullptr, mesh[i][1]); mesh[i][0]->LinkX(nullptr, mesh[i][1]);
for (int j = 1; j < mesh[i].size() - 1; j++) for (int j = 1; j < mesh[i].size() - 1; j++)
@@ -27,7 +25,6 @@ void Mesh::LinkX() {
hlines.push_back(mesh[i][0]); hlines.push_back(mesh[i][0]);
} }
void Mesh::LinkY() { void Mesh::LinkY() {
for (int j = 0; j < mesh[0].size(); j++) { for (int j = 0; j < mesh[0].size(); j++) {
mesh[0][j]->LinkY(nullptr, mesh[1][j]); mesh[0][j]->LinkY(nullptr, mesh[1][j]);
@@ -39,7 +36,6 @@ void Mesh::LinkY() {
vlines.push_back(mesh[0][i]); vlines.push_back(mesh[0][i]);
} }
void Mesh::Adapt() { void Mesh::Adapt() {
for (int i = 0; i < mesh.size(); i++) { for (int i = 0; i < mesh.size(); i++) {
int s = mesh[i].size(); int s = mesh[i].size();
@@ -55,25 +51,31 @@ void Mesh::Adapt() {
void Mesh::Delnode(int i, int j) { void Mesh::Delnode(int i, int j) {
Node* node = mesh[i][j]; Node* node = mesh[i][j];
double bndX1 = obj.Fillx(node->X(), node->Y()).first; /* <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 bndX2 = obj.Fillx(node->X(), node->Y()).second; double bndX1 = obj.FillX(node->X(), node->Y()).first;
double bndY1 = obj.Filly(node->X(), node->Y()).first; double bndX2 = obj.FillX(node->X(), node->Y()).second;
double bndY2 = obj.Filly(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(); int btype = obj.Who(node->X(), node->Y())->GetB();
if (node->l()) { 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 (node->l()->X() != bndX2 && node->l()->X() != bndX1) {
if (bndX1 != bndX2) { 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* left = new Node(bndX2, node->Y(), btype);
Node* right = new Node(bndX1, node->Y(), btype); Node* right = new Node(bndX1, node->Y(), btype);
node->l()->r() = left; node->l()->r() = left;
if (node->r()) if (node->r())
node->r()->l() = right; 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); left->LinkX(node->l(), right);
right->LinkX(left, node->r()); right->LinkX(left, node->r());
node->l() = right; node->l() = right;
mesh[i].push_back(left); mesh[i].push_back(left);
mesh[i].push_back(right); 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 { else {
Node* left = new Node(bndX2, node->Y(), btype); Node* left = new Node(bndX2, node->Y(), btype);
node->l()->r() = left; node->l()->r() = left;
@@ -84,9 +86,10 @@ void Mesh::Delnode(int i, int j) {
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 else
node->l()->r() = node->r(); 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()) { if (node->r()) {
node->r()->l() = node->l(); node->r()->l() = node->l();
} }

View File

@@ -46,7 +46,7 @@ bool Object::Add_Form(const std::string& name, std::map<std::string, double>& ar
std::pair<double, double> Object::Fillx(double x, double y) { std::pair<double, double> Object::FillX(double x, double y) {
for (auto form : forms) { for (auto form : forms) {
if (form->Inhere(x, y)) { if (form->Inhere(x, y)) {
return form->missX(y); return form->missX(y);
@@ -55,7 +55,7 @@ std::pair<double, double> Object::Fillx(double x, double y) {
return { 0, 0 }; return { 0, 0 };
} }
std::pair<double, double> Object::Filly(double x, double y) { std::pair<double, double> Object::FillY(double x, double y) {
for (auto form : forms) { for (auto form : forms) {
if (form->Inhere(x, y)) { if (form->Inhere(x, y)) {
return form->missY(x); return form->missY(x);

View File

@@ -9,15 +9,15 @@
#define ARC_RADIUS 150. #define ARC_RADIUS 150.
//#define SQUARE_X 355. #define SQUARE_X 355.
//#define SQUARE_Y 155. #define SQUARE_Y 155.
//#define SQUARE_SIDE 100. #define SQUARE_SIDE 100.
#define HOLE_X 155. //#define HOLE_X 155.
#define HOLE_Y 255. //#define HOLE_Y 255.
#define HOLE_RADIUS 50. //#define HOLE_RADIUS 50.
#define CONDUCTIVITY 90. // Теплопроводность материала #define CONDUCTIVITY 50. // Теплопроводность материала
void visualize(std::ofstream& file, std::string filename, int time_end) { void visualize(std::ofstream& file, std::string filename, int time_end) {
file << "set cbrange [" << 0 << ":" << 100 << "]" << std::endl; file << "set cbrange [" << 0 << ":" << 100 << "]" << std::endl;
@@ -41,7 +41,7 @@ int main()
int right = 1; int right = 1;
int bottom = 3; int bottom = 3;
int arc_bound = 3; int arc_bound = 3;
int hole_bound = 2; int hole_bound = 1;
double step_5 = 5; double step_5 = 5;
double step_10 = 10; double step_10 = 10;
@@ -54,12 +54,16 @@ int main()
std::map<std::string, double> arc{ 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{ //std::map<std::string, double> circle{
{"a", HOLE_X}, {"b", HOLE_Y}, {"h_x", 1 / HOLE_RADIUS}, {"h_y", 1 / HOLE_RADIUS} // {"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; Object obj;
obj.Add_Form("Circle", circle, true, hole_bound); obj.Add_Form("Rectangle", square, true, hole_bound);
obj.Add_Form("Arc", arc, true, arc_bound); obj.Add_Form("Arc", arc, true, arc_bound);
obj.Add_Form("Rectangle", plate, false, 1); obj.Add_Form("Rectangle", plate, false, 1);
@@ -101,6 +105,3 @@ int main()
return 0; return 0;
} }
//std::map<std::string, double> square{
// {"a", SQUARE_X}, {"b", SQUARE_Y}, {"h_x", 1 / SQUARE_SIDE}, {"h_y", 1 / SQUARE_SIDE}
//};