From 4724c2070572fbb61c3cb86f583b91c9126bcbaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantin=20Ri=DF?= Date: Sun, 17 Jan 2010 22:09:57 +0100 Subject: kleine aenderung --- DisplayClass.cpp | 2 +- Temparray.cpp | 74 ++++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 54 insertions(+), 22 deletions(-) diff --git a/DisplayClass.cpp b/DisplayClass.cpp index 712251a..b04c11c 100644 --- a/DisplayClass.cpp +++ b/DisplayClass.cpp @@ -75,7 +75,7 @@ void DisplayClass::renderScene(unsigned long delta) { glRotatef(-angle*5, 1.0, 1.0, 1.0); - Temparray temp(20, x, y, z); + static Temparray temp(20, x, y, z); triangles=temp.getTriangles(); temp.calcTemp(); diff --git a/Temparray.cpp b/Temparray.cpp index b47cf4b..5894e63 100644 --- a/Temparray.cpp +++ b/Temparray.cpp @@ -39,10 +39,12 @@ Temparray::Temparray(float initialtemp, int x0, int y0, int z0){ void Temparray::calcTemp(){ float specificconductivity = 0.7; - float areasmall, areabig, distance, capacity, capacity2, volume, thermalresistance, tau12, tau21; + float areasmall, area, areabig, distance, capacity, capacity2, capacity3, volume, thermalresistance, + thermalresistance2, tau12, tau21, tau13, tau31; float meterperunit = 3.0; float width, height, depth, innerwidth, innerdepth; float width2, height2, depth2, innerwidth2, innerdepth2; + float width3, height3, depth3, innerwidth3, innerdepth3; for(int i = 0; i < sx; ++i) { for(int j = 0; j < sy; ++j) { @@ -51,61 +53,91 @@ void Temparray::calcTemp(){ for(int m = 0; m < 4; m++) { width = cubehole(i, j, k, l).getWidth(); width2 = cubehole(i, j, k, l-1).getWidth(); + if(l!=5)width3 = cubehole(i, j, k, l+1).getWidth(); height = cubehole(i, j, k, l).getHeight(); height2 = cubehole(i, j, k, l-1).getHeight(); + if(l!=5)height3 = cubehole(i, j, k, l+1).getHeight(); depth = cubehole(i, j, k, l).getDepth(); depth2 = cubehole(i, j, k, l-1).getDepth(); + if(l!=5)depth3 = cubehole(i, j, k, l+1).getDepth(); innerwidth = cubehole(i, j, k, l).getInnerWidth(); innerwidth2 = cubehole(i, j, k, l-1).getInnerWidth(); + if(l!=5)innerwidth3 = cubehole(i, j, k, l+1).getInnerWidth(); innerdepth = cubehole(i, j, k, l).getInnerDepth(); innerdepth2 = cubehole(i, j, k, l-1).getInnerDepth(); + if(l!=5)innerdepth3 = cubehole(i, j, k, l+1).getInnerDepth(); if(m % 2 == 0) { - areasmall = (((width + innerwidth)/2)*height) / 0.9 * meterperunit; + if(l!=5)areasmall = (((width3 + innerwidth3)/2)*height3) / 0.9 * meterperunit; + area = (((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)); + (specificconductivity * ((area + areabig) / 2)); + if(l!=5)thermalresistance2 = ((depth / 2 - (depth - innerdepth)/4)- + (depth3 / 2 - (depth3 - innerdepth3)/4)) / 0.9 * meterperunit / + (specificconductivity * ((area + areasmall) / 2)); - capacity = specificconductivity *((((width + innerwidth)/2)*height)/0.9*meterperunit); - capacity2 = specificconductivity *((((width2 + innerwidth2)/2)*height2)/0.9*meterperunit); + capacity = specificconductivity *((((depth + innerdepth)/2)*((width + innerwidth)/2)* + height)/0.9*meterperunit); + capacity2 = specificconductivity *((((depth2 + innerdepth2)/2)*((width2 + innerwidth2)/2)* + height2)/0.9*meterperunit); + if(l!=5)capacity3 = specificconductivity *((((depth3 + innerdepth3)/2)*((width3 + innerwidth3)/2)* + height3)/0.9*meterperunit); } else if(m % 2 == 1) { - areasmall = (((depth + innerdepth)/2)*height) / 0.9 * meterperunit; + if(l!=5)areasmall = (((depth3 + innerdepth3)/2)*height3) / 0.9 * meterperunit; + area = (((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)); + (specificconductivity * ((area + areabig) / 2)); + if(l!=5)thermalresistance2 = ((width / 2 - (width - innerwidth)/4) - + (width3 / 2 - (width3 - innerwidth3)/4)) / 0.9 * meterperunit / + (specificconductivity * ((area + areasmall) / 2)); - capacity = specificconductivity *((((depth + innerdepth)/2)*height)/0.9*meterperunit); - capacity2 = specificconductivity *((((depth2 + innerdepth2)/2)*height2)/0.9*meterperunit); + capacity = specificconductivity *((((depth + innerdepth)/2)*((width + innerwidth)/2)* + height)/0.9*meterperunit); + capacity2 = specificconductivity *((((depth2 + innerdepth2)/2)*((width2 + innerwidth2)/2)* + height2)/0.9*meterperunit); + if(l!=5) + capacity3 = specificconductivity *((((depth3 + innerdepth3)/2)*((width3 + innerwidth3)/2)* + height3)/0.9*meterperunit); } tau12 = capacity * thermalresistance; tau21 = capacity2 * thermalresistance; + if(l!=5)tau13 = capacity * thermalresistance; + if(l!=5)tau31 = capacity3 * thermalresistance2; - temperaturenew(i, j, k, l, m) = - temperatureold(i, j, k, l, m) - ((temperatureold(i, j, k, l, m) - - temperatureold(i, j, k, l-1, m))*(1-exp(1/tau12))); - temperaturenew(i, j, k, l-1, m) = - temperatureold(i, j, k, l-1, m) + ((temperatureold(i, j, k, l, m) - - temperatureold(i, j, k, l-1, m))*(1-exp(1/tau21))); - - + temperatureold(i, j, k, l, m) = + temperatureold(i, j, k, l, m) + ((temperatureold(i, j, k, l, m) - + temperatureold(i, j, k, l-1, m))*(-exp(-(1/tau12)))); + temperatureold(i, j, k, l-1, m) = + temperatureold(i, j, k, l-1, m) - ((temperatureold(i, j, k, l, m) - + temperatureold(i, j, k, l-1, m))*(-exp(-(1/tau21)))); + + if(l!=5)temperatureold(i, j, k, l, m) = + temperatureold(i, j, k, l, m) + ((temperatureold(i, j, k, l, m) - + temperatureold(i, j, k, l+1, m))*(-exp(-(1/tau13)))); + if(l!=5)temperatureold(i, j, k, l+1, m) = + temperatureold(i, j, k, l+1, m) - ((temperatureold(i, j, k, l, m) - + temperatureold(i, j, k, l+1, m))*(-exp(-(1/tau31)))); } } } } } - for(int i = 0; i < sx; ++i) { + /*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) { - for(int m = 0; m < 4; m++) {temperatureold(i, j, k, l, m)=temperaturenew(i, j, k, l, m);}}}}} - std::cerr << temperaturenew(2, 2, 2, 2, 2) << std::endl; - std::cerr << temperaturenew(2, 2, 2, 3, 2) << std::endl; + for(int m = 0; m < 4; m++) {temperatureold(i, j, k, l, m)=temperaturenew(i, j, k, l, m);}}}}}*/ + std::cerr << temperatureold(2, 2, 2, 1, 2) << std::endl; + std::cerr << temperatureold(2, 2, 2, 2, 2) << std::endl; + std::cerr << temperatureold(2, 2, 2, 3, 2) << std::endl; } std::list Temparray::getTriangles(){ -- cgit v1.2.3