Merge pull request 'fix' (#2) from fix into master

Reviewed-on: https://git.tjoyspotifylastfm.tech/ParkSuMin/MemMAPR/pulls/2
This commit is contained in:
2025-05-15 00:27:00 +02:00
5 changed files with 24 additions and 33 deletions

View File

@@ -3,9 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.12.35707.178 VisualStudioVersion = 17.12.35707.178
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Main_program", "MemMAPR_winda.vcxproj", "{86DC468D-3A9F-48AB-80FC-059A120499AA}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MemMAPR_main", "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}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution 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|x64.Build.0 = Release|x64
{86DC468D-3A9F-48AB-80FC-059A120499AA}.Release|x86.ActiveCfg = Release|Win32 {86DC468D-3A9F-48AB-80FC-059A120499AA}.Release|x86.ActiveCfg = Release|Win32
{86DC468D-3A9F-48AB-80FC-059A120499AA}.Release|x86.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -111,6 +111,7 @@
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>./include</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>

View File

@@ -6,18 +6,16 @@
class System{ class System{
Object& _obj; Object& _obj;
Mesh _mesh; Mesh _mesh;
double _a1; double _a;
double _a2;
double _step; double _step;
public: 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 DefineBounds(int, int, int, int);
std::vector<std::vector<Node*>>& Nodes(); std::vector<std::vector<Node*>>& Nodes();
std::vector<Node*>& LineX(); std::vector<Node*>& LineX();
std::vector<Node*>& LineY(); std::vector<Node*>& LineY();
double step() const { return _step; } double step() const { return _step; }
double a1() const { return _a1; }; double a() const { return _a; };
double a2() const { return _a2; };
}; };
#endif #endif

View File

@@ -1,6 +1,6 @@
#include "Solver.hpp" #include "Solver.hpp"
void Solver::SolveExplicit(System& program, double tstop) const { void Solver::SolveImplicit(System& program, double tstop) const {
std::ofstream output(filename_expl); std::ofstream output(filename_impl);
//output << "t x y T" << std::endl; //output << "t x y T" << std::endl;
for (double t = 0.0; t < tstop; t += delta) { 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 { void Solver::SolveExplicit(System& sys, double tstop) const {
std::ofstream output(filename_impl); std::ofstream output(filename_expl);
//output << "t x y T" << std::endl; //output << "t x y T" << std::endl;
for (double t = 0.; t < tstop; t += delta) { for (double t = 0.; t < tstop; t += delta) {
@@ -66,7 +66,7 @@ void Solver::SolveImplicit(System& sys, double tstop) const {
double tx = (node->r()->T() - 2 * node->T() + node->l()->T()) / pow(sys.step(), 2); 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 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); node->SetT(t);
} }
} }
@@ -85,17 +85,17 @@ void Solver::SolveLine(System& sys, std::vector<Node*>& n) const {
/* Защита от нуля */ /* Защита от нуля */
if (mu2 == 0.) if (mu2 == 0.)
mu2 = .1; mu2 = .1;
double val2 = -(2 * sys.a1()) / (pow(sys.step(), 2)) - 1 / delta; double val2 = -(2 * sys.a()) / (pow(sys.step(), 2)) - 1 / delta;
double val1 = sys.a1() / (pow(sys.step(), 2)); double val1 = sys.a() / (pow(sys.step(), 2));
std::vector<std::vector<double>> _Temperature(size); std::vector<std::vector<double>> _Temperature(size);
std::vector<double> right(size); std::vector<double> right(size);
for (int i = 0; i < _Temperature.size(); i++) for (int i = 0; i < _Temperature.size(); i++)
_Temperature[i].resize(3, 0.0); _Temperature[i].resize(3, 0.0);
_Temperature[0][0] = -(2 * sys.a1()) / (mu1 * pow(sys.step(), 2)) - 1 / delta; /* Первый узел по X */ _Temperature[0][0] = -(2 * sys.a()) / (mu1 * pow(sys.step(), 2)) - 1 / delta; /* Первый узел по X */
_Temperature[0][1] = (2 * sys.a1()) / ((mu1 + 1) * pow(sys.step(), 2)); /* Первый узел по Y */ _Temperature[0][1] = (2 * sys.a()) / ((mu1 + 1) * pow(sys.step(), 2)); /* Первый узел по Y */
_Temperature.back()[1] = (2 * sys.a1()) / ((mu2 + 1) * pow(sys.step(), 2)); _Temperature.back()[1] = (2 * sys.a()) / ((mu2 + 1) * pow(sys.step(), 2));
_Temperature.back()[2] = -(2 * sys.a1()) / (mu2 * pow(sys.step(), 2)) - 1 / delta; _Temperature.back()[2] = -(2 * sys.a()) / (mu2 * pow(sys.step(), 2)) - 1 / delta;
for (int i = 1; i < size - 1; i++) { for (int i = 1; i < size - 1; i++) {
_Temperature[i][0] = val1; _Temperature[i][0] = val1;
@@ -105,8 +105,8 @@ void Solver::SolveLine(System& sys, std::vector<Node*>& n) const {
for (int i = 0; i < right.size(); i++) for (int i = 0; i < right.size(); i++)
right[i] = -n[i + 1]->T() / delta; right[i] = -n[i + 1]->T() / delta;
right.front() += -(2 * sys.a1() * n.front()->T()) / (mu1 * (mu1 + 1) * pow(sys.step(), 2)); right.front() += -(2 * sys.a() * 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)); right.back() += -(2 * sys.a() * n.back()->T()) / (mu2 * (mu2 + 1) * pow(sys.step(), 2));
std::vector<double> tmps = ThomasMethod(_Temperature, right); std::vector<double> tmps = ThomasMethod(_Temperature, right);
for (int i = 0; i < tmps.size(); i++) for (int i = 0; i < tmps.size(); i++)
n[i + 1]->SetT(tmps[i]); n[i + 1]->SetT(tmps[i]);

View File

@@ -17,7 +17,7 @@
#define HOLE_Y 255. #define HOLE_Y 255.
#define HOLE_RADIUS 50. #define HOLE_RADIUS 50.
#define CONDUCTIVITY 50. // Теплопроводность материала #define CONDUCTIVITY 90. // Теплопроводность материала
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;
@@ -36,12 +36,12 @@ int main()
3 - конвекция 3 - конвекция
4 - отсутствует 4 - отсутствует
*/ */
int left = 3; int left = 1;
int top = 1; int top = 3;
int right = 3; int right = 1;
int bottom = 1; int bottom = 3;
int arc_bound = 3; int arc_bound = 3;
int hole_bound = 1; int hole_bound = 2;
double step_5 = 5; double step_5 = 5;
double step_10 = 10; double step_10 = 10;