# 5.2.2 二维导热算例-迭代计算

```1. packageSoong.Solver
2. {
3.  public class TSolver
4.    {
5.  public var Tlist:Vector.<Node>;
6.
7.  private var xGridNum:uint = 1;//Number of GridAllocated in X Direction
8.  private var yGridNum:uint = 1;//Number of GridAllocated in X Direction
9.
10.  public var dx:Number = 1;//Grid Size in XDirection
11.  public var dy:Number = 1;//Grid Size in YDirection
12.
13.  public var Sx:Number = 0;//Area of HeatInterface in X Direction
14.  public var Sy:Number = 0;//Area of HeatInterface in X Direction
15.
16.  public var cellVol:Number = 0;//Volume ofControl Volume
17.
18.  public var Freezing:Boolean=false;//If Time toFreeze
19.
20.  public functionTSolver(xGridNum:uint,yGridNum:uint,dx:Number,dy:Number)
21.       {
22.  this.xGridNum = xGridNum;
23.  this.yGridNum = yGridNum;
24.
25.  this.dx = dx;
26.  this.dy = dy;
27.
28.  this.Sx = dy * 1;
29.  this.Sy = dx * 1;
30.
31.  this.cellVol = dx * dy * 1;
32.       }
33.
34.  public functionStep(timeStep:Number):void
35.       {
36.  var col:uint = 0;
37.  var row:uint = 0;
38.  var node:Node = null;
39.
40.  for (col = 2; col < xGridNum - 2; col++ )
41.          {
42.  for (row = 2; row < yGridNum-2; row++ )
43.             {
44.                node= Tlist[Index(col, row)] as Node;
45.
46.                CalTnext(timeStep,node,col,row);
47.
48.                node.T0=node.T;
49.             }
50.          }
51.       }
52.
53.  public functionCalTnext(timeStep:Number,node:Node,col:uint,row:uint):void
54.       {
55.  var conner:Boolean=false;
57.
58.  var conductionHeat:Number= 0;
59.
60.  //For Node on/in Connor or Edge
61.  var SxFix:Number=1;//Area Fix Factor For Non-Interior Region in X Direction
62.  var SyFix:Number=1;//Area Fix Factor For Non-Interior Region in Y Direction
63.
64.  var VolFix:Number=1;//Volume Fix Factor For Non-Interior Region in Y Direction
65.
66.  if(((col==2)&&(row==2))||((col==2)&&(row==yGridNum-3))||((col==xGridNum-3)&&(row==2))||((col==xGridNum-3)&&(row==yGridNum-3)))
67.          {
68.             SxFix=1/2.0;
69.             SyFix=1/2.0;
70.
71.             conner=true;
72.          }
73.
74.  if((col==2)||(col==xGridNum-3))
75.          {
76.             VolFix/=2;
77.
78.  if(!conner)
79.             {
80.                SyFix=1/2.0;
81.             }
82.          }
83.
84.  if((row==2)||(row==yGridNum-3))
85.          {
86.             VolFix/=2;
87.
88.  if(!conner)
89.             {
90.                SxFix=1/2.0;
91.             }
92.          }
93.
94.          node_Adj= Tlist[Index(col+1, row)] as Node;
96.
97.          node_Adj= Tlist[Index(col-1, row)] as Node;
99.
100.         node_Adj= Tlist[Index(col, row+1)] as Node;
102.
103.         node_Adj= Tlist[Index(col, row - 1)] as Node;
105.
106. var dT:Number =conductionHeat * timeStep;
107.         dT/= cellVol * VolFix * node.Rho * node.Cp;
108.
109.         node.T= node.T0 + dT;
110.      }
111.
112. public functionLatentHeatRelease(node:Node):void
113.      {
114.
115.      }
116.
117. //Apply the Boundary Condition
118. public functionApplyBC():void
119.      {
120.
121.      }
122.
123. private functionIndex(col:uint=0,row:uint=0):uint
124.      {
125. return row * xGridNum + col;
126.      }
127.   }
128.}```

67 篇文章12 人订阅

0 条评论

## 相关文章

### PTA 7-2 列车调度（25 分）

7-2 列车调度（25 分） 火车站的列车调度铁轨的结构如下图所示。 ? 两端分别是一条入口（Entrance）轨道和一条出口（Exit）轨道，它们之间有N条平...

3109

2746

1.8K5

1652

1163

3007

### 大神洗礼第三讲——接上一讲

Author：bakari                 Date:2012.10.26 这一讲的主要内容和上一讲相同，是上一讲的深入分析。内存对齐涉及内存实...

2108

1865

1847

2967