112 lines
3.0 KiB
C++
112 lines
3.0 KiB
C++
#include <iostream>
|
|
#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 HOLE_X 155.
|
|
//#define HOLE_Y 255.
|
|
//#define HOLE_RADIUS 50.
|
|
|
|
#define CONDUCTIVITY 100. // Теплопроводность материала
|
|
|
|
void visualize(std::ofstream& file, std::string filename, int time_end) {
|
|
file << "set cbrange [" << 0 << ":" << 100 << "]" << std::endl;
|
|
file << "set size ratio " << float(400) / 500 << "\nunset key\n" << "\nset 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)\n" << std::endl;
|
|
file << "do for [i=0:" << time_end - 1 << "]{" << std::endl;
|
|
file << "plot '" << filename << "' u 2:3:4 index i w points pt 5 palette" << std::endl;
|
|
file << "pause " << 0.000000001 << "}" << std::endl;
|
|
file << "pause mouse";
|
|
}
|
|
|
|
int main()
|
|
{
|
|
/* Граничные условия:
|
|
1 - нагрев
|
|
2 - конвекция
|
|
3 - теплоизоляция
|
|
0 - отсутствует
|
|
*/
|
|
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_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> arc{
|
|
{"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> square{
|
|
{"a", SQUARE_X}, {"b", SQUARE_Y}, {"h_x", 1 / SQUARE_SIDE}, {"h_y", 1 / SQUARE_SIDE}
|
|
};
|
|
|
|
Object obj;
|
|
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", 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();
|
|
|
|
script.open("is10.plt");
|
|
visualize(script, "implicit10.txt", time_end);
|
|
script.close();
|
|
|
|
script.open("es5.plt");
|
|
visualize(script, "explicit5.txt", time_end);
|
|
script.close();
|
|
|
|
script.open("is5.plt");
|
|
visualize(script, "implicit5.txt", time_end);
|
|
script.close();
|
|
return 0;
|
|
}
|
|
|