summaryrefslogtreecommitdiffstats
path: root/Temparray.cpp
diff options
context:
space:
mode:
authorConstantin Riß <constantin.riss@dre.de>2010-02-08 23:07:48 +0100
committerConstantin Riß <constantin.riss@dre.de>2010-02-08 23:07:48 +0100
commit8fd9c234206718b4f3b3b07ac06a47d4d6c90a18 (patch)
tree931050b85a1cdda8bfa6ac34935c9497bb1ed683 /Temparray.cpp
parent3b4db495c6fe7452fddc096d3085e44470830694 (diff)
downloadc3d-8fd9c234206718b4f3b3b07ac06a47d4d6c90a18.tar
c3d-8fd9c234206718b4f3b3b07ac06a47d4d6c90a18.zip
kleinere fehler da...
Diffstat (limited to 'Temparray.cpp')
-rw-r--r--Temparray.cpp81
1 files changed, 66 insertions, 15 deletions
diff --git a/Temparray.cpp b/Temparray.cpp
index ae75583..1d8f8b7 100644
--- a/Temparray.cpp
+++ b/Temparray.cpp
@@ -4,6 +4,7 @@ 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];
+ weight1 = new int[x0*y0*z0];
sx = x0;
sy = y0;
@@ -35,18 +36,7 @@ Temparray::Temparray(float initialtemp, int x0, int y0, int z0){
}
}
}
-/* cubehole(2, 2, 2, 1).setColor(vmml::vec4f(0.0, 0.0, 0.0, 1.0),
- vmml::vec4f(0.0, 0.0, 0.0, 1.0),
- vmml::vec4f(0.0, 0.0, 0.0, 1.0),
- vmml::vec4f(0.0, 0.0, 0.0, 1.0));
- cubehole(2, 2, 2, 2).setColor(vmml::vec4f(1.0, 1.0, 1.0, 1.0),
- vmml::vec4f(1.0, 1.0, 1.0, 1.0),
- vmml::vec4f(1.0, 1.0, 1.0, 1.0),
- vmml::vec4f(1.0, 1.0, 1.0, 1.0));
- cubehole(2, 2, 2, 3).setColor(vmml::vec4f(0.5, 0.5, 0.5, 1.0),
- vmml::vec4f(0.5, 0.5, 0.5, 1.0),
- vmml::vec4f(0.5, 0.5, 0.5, 1.0),
- vmml::vec4f(0.5, 0.5, 0.5, 1.0));*/
+ calcweight();
}
void Temparray::calcTemp(){
@@ -113,7 +103,7 @@ void Temparray::calcTemp(){
}
}
}
- for(int h = 0; h < 10; ++h) {
+ for(int h = 0; h <= maxweight; ++h) {
for(int i = 0; i < sx; ++i) {
for(int j = 0; j < sy; ++j) {
for(int k = 0; k < sz; ++k) {
@@ -147,7 +137,7 @@ void Temparray::calcTemp(){
tau12 = capacity * thermalresistance;
- if(input>=0){
+ if(input>=0 && weight(i, j, k)==h){
if(loadableenergy <= 0)
inputpower = 0;
else if (input >= loadableenergy) {
@@ -165,7 +155,7 @@ void Temparray::calcTemp(){
*thermalresistance*factor*(1-exp(-(1/tau12)));
}
}
- if (input < 0){
+ if (input < 0 && maxweight-weight(i, j, k)==h){
if(unloadableenergy <= 0)
inputpower = 0;
else if (input > unloadableenergy) {
@@ -533,3 +523,64 @@ void Temparray::coloring() {
}
}
}
+
+void Temparray::calcweight() {
+ int dist, disth, disth2, posx, posy, posz, posx2, posy2, posz2;
+ maxweight = 0;
+ for(int i=0; i < sx; ++i) {
+ for(int j=0; j < sy; ++j) {
+ for(int k=0; k < sz; ++k) {
+ dist = 0;
+ if (sx%2 == 0) {
+ posx = sx/2.0-1; posx2 = sx/2.0;
+ disth = abs(posx-i); disth2 = abs(posx2-i);
+ if(disth < disth2) dist += disth; else dist += disth2;
+ if (sy%2 == 0) {
+ posy = sy/2.0-1; posy2 = sy/2.0;
+ disth = abs(posy-j); disth2 = abs(posy2-j);
+ if(disth < disth2) dist += disth; else dist += disth2;
+ }
+ else if (sy%2 == 1) {
+ posy = sy/2.0-0.5;
+ dist += abs(posy-j);
+ if (sz%2 == 0) {
+ posz = sz/2.0-1; posz2 = sz/2.0;
+ disth = abs(posz-k); disth2 = abs(posz2-k);
+ if(disth < disth2) dist += disth; else dist += disth2;
+ }
+ else if (sz%2 == 1) {
+ posz = sz/2.0-0.5;
+ dist += abs(posz-k);
+ }
+ }
+ }
+
+ else if (sx%2 == 1) {
+ posx = sx/2.0-1; posx2 = sx/2.0;
+ disth = abs(posx-i); disth2 = abs(posx2-i);
+ if(disth < disth2) dist += disth; else dist += disth2;
+ if (sy%2 == 0) {
+ posy = sy/2.0-1; posy2 = sy/2.0;
+ disth = abs(posy-j); disth2 = abs(posy2-j);
+ if(disth < disth2) dist += disth; else dist += disth2;
+ }
+ else if (sy%2 == 1) {
+ posy = sy/2.0-0.5;
+ dist += abs(posy-j);
+ if (sz%2 == 0) {
+ posz = sz/2.0-1; posz2 = sz/2.0;
+ disth = abs(posz-k); disth2 = abs(posz2-k);
+ if(disth < disth2) dist += disth; else dist += disth2;
+ }
+ else if (sz%2 == 1) {
+ posz = sz/2.0-0.5;
+ dist += abs(posz-k);
+ }
+ }
+ }
+ weight(i, j, k) = dist;
+ if (dist > maxweight) maxweight = dist;
+ }
+ }
+ }
+}