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; }
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; }
void DumpTwoInOne(TwoInOne o, ref StringBuilder sb, DumpTwoInOneType t = DumpTwoInOneType.Normal, bool noNewLine = false) { if(o == null || o.type == TwoInOne.Type.None) { if (t != DumpTwoInOneType.OnlyValueOrArray) { sb.AppendFormat("{0,8}", (0).ToString()); if (!noNewLine) { sb.Append("\n"); } } if (t != DumpTwoInOneType.OnlyType) { sb.AppendFormat("{0,8}\n", (0).ToString()); } return; } if(o.type == TwoInOne.Type.UseValue) { if (t != DumpTwoInOneType.OnlyValueOrArray) { sb.AppendFormat("{0,8}", (0).ToString()); if (!noNewLine) { sb.Append("\n"); } } if (t != DumpTwoInOneType.OnlyType) { sb.AppendFormat("{0,8}\n", o.ValueDouble()[0].ToString()); } return; } if (t != DumpTwoInOneType.OnlyValueOrArray) { sb.AppendFormat("{0,8}", (-1).ToString()); if (!noNewLine) { sb.Append("\n"); } } if (t == DumpTwoInOneType.OnlyType) { return; } int count = 0; for (int j = 0; j < o.Array2D().GetLength(1); ++j) { for (int i = 0; i < o.Array2D().GetLength(0); ++i) { if (count == 10) { sb.Append("\n"); count = 0; } sb.AppendFormat("{0,8}", o.Array2D()[i, j].ToString()); ++count; } sb.Append("\n"); count = 0; } }