public double CalcWaterLevel(int t, int j, TwoInOne o) { double l = 0; if(o.type == TwoInOne.Type.UseArray) { //逐點輸入,採用Value欄位 l = o.Array2D()[j, t]; } else { //均一水位,採用Value欄位直接回傳 l = o.Value2D()[0, t]; } return l; }
public double CalcFlowQ(int t, int j, TwoInOne o) { double q = 0; double d0, d1, d; if(!o.check) { //均一流量,採用Value欄位直接回傳 d = Math.Sqrt( Math.Pow(inputGrid.inputCoor[0, 0].x - inputGrid.inputCoor[0, inputGrid.GetJ - 1].x, 2) + Math.Pow(inputGrid.inputCoor[0, 0].y - inputGrid.inputCoor[0, inputGrid.GetJ - 1].y, 2)); q = o.Value2D()[0, t] / d; } else { //逐點輸入,採用Value欄位 * Array欄位百分比,取前後位中位數。 d0 = (j == 0) ? 0 : Math.Sqrt( Math.Pow(inputGrid.inputCoor[0, j].x - inputGrid.inputCoor[0, j - 1].x, 2) + Math.Pow(inputGrid.inputCoor[0, j].y - inputGrid.inputCoor[0, j - 1].y, 2)); d1 = (j == inputGrid.GetJ - 1) ? 0 : Math.Sqrt( Math.Pow(inputGrid.inputCoor[0, j].x - inputGrid.inputCoor[0, j + 1].x, 2) + Math.Pow(inputGrid.inputCoor[0, j].y - inputGrid.inputCoor[0, j + 1].y, 2)); d = d0 / 2 + d1 / 2; q = (o.Value2D()[0, t] * o.Array2D()[j, t] / 100) / d; } return q; }