summaryrefslogtreecommitdiffstats
path: root/Temparray.cpp
blob: e7d8b4244421a0637fc708ddfd2af9fa8b88fdda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "Temparray.h"

Temparray::Temparray(float initialtemp, int x0, int y0, int z0){
  temparraynew = new float[x0*y0*z0*6*4];
  temparrayold = new float[x0*y0*z0*6*4];
  cubearray = new Cubehole[x0*y0*z0*6];

  sx = x0;
  sy = y0;
  sz = z0;

  tempInit(initialtemp, x0, y0, z0);

  //  static const float pos[5] = {-2.0, -1.0, 0.0, 1.0, 2.0};
  for(int i = 0; i < x0; ++i) {
    for(int j = 0; j < y0; ++j) {
      for(int k = 0; k < z0; ++k) {
        for(int l = 0; l < 6; ++l) {
          cubehole(i, j, k, l).setSize((6-l)/6.0*0.9, 0.9, (6-l)/6.0*0.9, (5-l)/6.0*0.9, (5-l)/6.0*0.9);

          float x, y, z;
          if(x0 % 2 == 0)      x = -(x0/2)+i+0.5;
          else if(x0 % 2 == 1) x = -(x0-1)/2+i;
          if(y0 % 2 == 0)      y = -(y0/2)+j+0.5;
          else if(y0 % 2 == 1) y = -(y0-1)/2+j;
          if(z0 % 2 == 0)      z = -(z0/2)+k+0.5;
          else if(z0 % 2 == 1) z = -(z0-1)/2+k;
          cubehole(i, j, k, l).setPos(x, y, z);

          cubehole(i, j, k, l).setColor(vmml::vec4f(1.0, 0.5, 1.0, 1.0),
                                        vmml::vec4f(0.5, 0.5, 1.0, 1.0),
                                        vmml::vec4f(1.0, 0.5, 0.0, 1.0),
                                        vmml::vec4f(0.0, 0.5, 0.0, 1.0));
        }
      }
    }
  }
}

void Temparray::calcTemp(){
  float specificconductivity = 0.7;
  float areasmall, areabig, distance, capacity, capacity2, volume, thermalresistance, tau12, tau21;
  float meterperunit = 3.0;
  float width, height, depth, innerwidth, innerdepth;
  float width2, height2, depth2, innerwidth2, innerdepth2;
  
  for(int i = 0; i < sx; ++i) {
    for(int j = 0; j < sy; ++j) {
      for(int k = 0; k < sz; ++k) {
        for(int l = 5; l > 0; --l) {
          for(int m = 0; m < 4; m++) {
            width = cubehole(i, j, k, l).getWidth();
            width2 = cubehole(i, j, k, l-1).getWidth();
            height = cubehole(i, j, k, l).getHeight();
            height2 = cubehole(i, j, k, l-1).getHeight();
            depth = cubehole(i, j, k, l).getDepth();
            depth2 = cubehole(i, j, k, l-1).getDepth();
            innerwidth = cubehole(i, j, k, l).getInnerWidth();
            innerwidth2 = cubehole(i, j, k, l-1).getInnerWidth();
            innerdepth = cubehole(i, j, k, l).getInnerDepth();
            innerdepth2 = cubehole(i, j, k, l-1).getInnerDepth();
            
            if(m % 2 == 0) {
              areasmall = (((width + innerwidth)/2)*height) / 0.9 * meterperunit;
              areabig = (((width2 + innerwidth2)/2)*height2) / 0.9 * meterperunit;

              thermalresistance = ((depth2 / 2 - (depth2 - innerdepth2)/4) -
                                   (depth / 2 - (depth - innerdepth)/4)) / 0.9 * meterperunit /
                                   (specificconductivity * ((areasmall + areabig) / 2));

              capacity = specificconductivity *((((width + innerwidth)/2)*height)/0.9*meterperunit);
              capacity2 = specificconductivity *((((width2 + innerwidth2)/2)*height2)/0.9*meterperunit);
            }
            else if(m % 2 == 1) {
              areasmall = (((depth + innerdepth)/2)*height) / 0.9 * meterperunit;
              areabig = (((depth2 + innerdepth2)/2)*height2) / 0.9 * meterperunit;

              thermalresistance = ((width2 / 2 - (width2 - innerwidth2)/4) -
                                   (width / 2 - (width - innerwidth)/4)) / 0.9 * meterperunit /
                                   (specificconductivity * ((areasmall + areabig) / 2));

              capacity = specificconductivity *((((depth + innerdepth)/2)*height)/0.9*meterperunit);
              capacity2 = specificconductivity *((((depth2 + innerdepth2)/2)*height2)/0.9*meterperunit);
            }
            tau12 = capacity * thermalresistance;
            tau21 = capacity2 * thermalresistance;
            std::cerr << tau12 << "\n" << tau21 << std::endl;
            
            
          }
        }
      }
    }
  }
}

std::list<Triangle> Temparray::getTriangles(){
  std::list<Triangle> triangles;

  for(int i = 0; i < sx; ++i) {
    for(int j = 0; j < sy; ++j) {
      for(int k = 0; k < sz; ++k) {
        for(int l = 0; l < 6; ++l) {
          std::list<Triangle> t = cubehole(i, j, k, l).getTriangles();
          triangles.splice(triangles.end(), t);
        }
      }
    }
  }

  return triangles;
}