private void CreateData(object d) { RiverSimulationProfile.TwoInOne o = d as RiverSimulationProfile.TwoInOne; RiverSimulationProfile.TwoInOne _d = null; Debug.Assert(o != null); if (formType == FormType.FlowQuantity || formType == FormType.WaterLevel) { _data = new RiverSimulationProfile.TwoInOne(d as RiverSimulationProfile.TwoInOne); _d = _data as RiverSimulationProfile.TwoInOne; Debug.Assert(_d != null); if (o.ValueNull() || o.ArrayNull() || (o.valueType == RiverSimulationProfile.TwoInOne.ValueType.TwoDim && (o.Value2D().GetLength(0) != colCount || o.Value2D().GetLength(1) != rowCount)) || (o.valueType == RiverSimulationProfile.TwoInOne.ValueType.ThreeDim && (o.Value3D().GetLength(0) != colCount || o.Value3D().GetLength(1) != rowCount))) { //rowCount : Q1 ~ Q5, colCount : J1 ~ J15 //_data = new RiverSimulationProfile.TwoInOne(colCount, rowCount); _d.Create2D(colCount, rowCount); _d.type = RiverSimulationProfile.TwoInOne.Type.UseValue; } } else if (formType == FormType.BottomBedLoadFlux) { _data = new RiverSimulationProfile.TwoInOne(d as RiverSimulationProfile.TwoInOne); _d = _data as RiverSimulationProfile.TwoInOne; Debug.Assert(_d != null); if (o.ValueNull() || o.ArrayNull()) { //rowCount : Q1 ~ Q5, colCount : J1 ~ J15 // _data = new RiverSimulationProfile.TwoInOne(p.boundaryTimeNumber, p.sedimentParticlesNumber, p.inputGrid.GetJ); //[T, K, J] //_data = new RiverSimulationProfile.TwoInOne(p.sedimentParticlesNumber, p.inputGrid.GetJ, p.boundaryTimeNumber); //[K, J, T] //_d.Create3D(p.sedimentParticlesNumber, p.inputGrid.GetJ, p.boundaryTimeNumber); _d.Create3D(p.sedimentParticlesNumber, p.inputGrid.GetJ, rowCount); _d.type = RiverSimulationProfile.TwoInOne.Type.UseValue; } } else if (formType == FormType.DepthAverageConcentration) { _data = new RiverSimulationProfile.TwoInOne(d as RiverSimulationProfile.TwoInOne); _d = _data as RiverSimulationProfile.TwoInOne; Debug.Assert(_d != null); if (o.ValueNull() || o.ArrayNull()) { //rowCount : Q1 ~ Q5, colCount : J1 ~ J15 _d.Create3D(p.sedimentParticlesNumber, p.inputGrid.GetJ, p.inputGrid.GetI); } } }
private bool AlertBoundaryTimeChange(ref RiverSimulationProfile.TwoInOne o) { if (o == null) { return(false); } if (p.IsConstantFlowType()) { //定量流時不檢查 return(true); } if (p.boundaryTime == null || p.boundaryTime.GetLength(0) != p.boundaryTimeNumber) { MessageBox.Show("邊界時間尚未輸入完成", "確認", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (!o.ArrayNull() && o.Array2D().GetLength(1) != p.boundaryTimeNumber) { //邊界時間有輸入,但與邊界時間數目不符合 if (DialogResult.OK == MessageBox.Show("改變過邊界時間數目需要重新輸入所有流況資料,請確認?", "確認", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation)) { RiverSimulationProfile.TwoInOne.Type tp = o.type; RiverSimulationProfile.TwoInOne.ValueType vt = o.valueType; RiverSimulationProfile.TwoInOne.ArrayType at = o.arrayType; o = new RiverSimulationProfile.TwoInOne(vt, at, tp); return(true); } else { p.boundaryTimeNumber = o.Array2D().GetLength(1); boundaryTimeNumberTxt.Text = p.boundaryTimeNumber.ToString(); return(false); } } return(true); }
private void CreateData(object d) { RiverSimulationProfile.TwoInOne o = d as RiverSimulationProfile.TwoInOne; RiverSimulationProfile.TwoInOne _d = null; switch (_inputFormType) { case InputFormType.TwoInOneDouble: case InputFormType.TwoInOneDoubleGreaterThanZero: case InputFormType.TwoInOneDoubleGreaterThanOrEqualZero: Debug.Assert(o != null); _data = new RiverSimulationProfile.TwoInOne(d as RiverSimulationProfile.TwoInOne); _d = _data as RiverSimulationProfile.TwoInOne; Debug.Assert(_d != null); if (o.ValueNull() || o.ArrayNull()) { (_data as RiverSimulationProfile.TwoInOne).CreateDouble2D(colCount, rowCount); } if (_d.Array2D().GetLength(0) != colCount || _d.Array2D().GetLength(1) != rowCount) { Debug.Assert(false); } break; case InputFormType.GenericDouble: case InputFormType.GenericDoubleGreaterThanZero: case InputFormType.GenericDoubleGreaterThanOrEqualZero: case InputFormType.BottomBedParticleSizeRatio: if (d == null) { _data = new double[colCount, rowCount]; } else { _data = (double [, ])(d as double[, ]).Clone(); } break; case InputFormType.SeabedThicknessForm: if (d == null) { _data = new double[rowCount]; } else { _data = (double [])(d as double[]).Clone(); } break; case InputFormType.SedimentCompositionRatioForm: if (d == null) { _data = new double[colCount, rowCount]; } else { _data = (double [, ])(d as double[, ]).Clone(); } break; case InputFormType.SeparateForm: case InputFormType.BoundaryTime: if (d == null) { _data = new double[rowCount]; } else { _data = (double [])(d as double[]).Clone(); } break; case InputFormType.VerticalVelocityDistributionForm: if (d == null) { _data = new double[2, rowCount]; } else { _data = (double [, ])(d as double[, ]).Clone(); } break; case InputFormType.BottomElevationForm: if (d == null) { _data = new CoorPoint[colCount, rowCount]; } else { _data = (CoorPoint[, ])(d as CoorPoint[, ]).Clone(); } break; case InputFormType.FlowConditionsSettingConstant: case InputFormType.FlowConditionsSettingVariable: Debug.Assert(o != null); _data = new RiverSimulationProfile.TwoInOne(d as RiverSimulationProfile.TwoInOne); _d = _data as RiverSimulationProfile.TwoInOne; if (o.ValueNull() || o.ArrayNull()) { //rowCount : Q1 ~ Q5, colCount : J1 ~ J15 _d.CreateDouble2D(colCount, rowCount); // (_data as RiverSimulationProfile.TwoInOne).dataValue = new double[colCount, rowCount]; } break; } }
private void CreateData(Object d) { RiverSimulationProfile p = RiverSimulationProfile.profile; RiverSimulationProfile.TwoInOne o = d as RiverSimulationProfile.TwoInOne; RiverSimulationProfile.TwoInOne _d = null; //第1, 3種:亞臨界流、均一值/逐點給、定量流 if (inputData.criticalFlowType == RiverSimulationProfile.CriticalFlowType.SubCriticalFlow && p.IsConstantFlowType()) { if (d == null) { _data = new RiverSimulationProfile.TwoInOne(RiverSimulationProfile.TwoInOne.ValueType.TwoDim, RiverSimulationProfile.TwoInOne.ArrayType.ThreeDim, RiverSimulationProfile.TwoInOne.Type.UseValue); _d = _data as RiverSimulationProfile.TwoInOne; } else { _data = new RiverSimulationProfile.TwoInOne(o); _d = _data as RiverSimulationProfile.TwoInOne; } if (_d.type == RiverSimulationProfile.TwoInOne.Type.UseValue) { colCount = 2; rowCount = 1; _inputFormType = InputFormType.Type1; tabPage1.Parent = tabControl; tabPage2.Parent = null; tabPage3.Parent = null; tabPage1.Text = ""; if (_d.ValueNull()) { (_data as RiverSimulationProfile.TwoInOne).CreateValue2D(colCount, rowCount); } } else { colCount = inputData.sideFlowPoints.Count; rowCount = 1; _inputFormType = InputFormType.Type3; tabPage1.Parent = tabControl; tabPage2.Parent = tabControl; tabPage3.Parent = null; tabPage1.Text = "主流方向流量(cms)"; tabPage2.Text = "側方向流量(cms)"; if (_d.ArrayNull()) { (_data as RiverSimulationProfile.TwoInOne).CreateArray3D(colCount, rowCount, 2); } } } //第2, 4種:亞臨界流、均一值/逐點給、變量流 else if (inputData.criticalFlowType == RiverSimulationProfile.CriticalFlowType.SubCriticalFlow && p.IsVariableFlowType()) { if (d == null) { _data = new RiverSimulationProfile.TwoInOne(RiverSimulationProfile.TwoInOne.ValueType.ThreeDim, RiverSimulationProfile.TwoInOne.ArrayType.ThreeDim, RiverSimulationProfile.TwoInOne.Type.UseValue); _d = _data as RiverSimulationProfile.TwoInOne; } else { _data = new RiverSimulationProfile.TwoInOne(o); _d = _data as RiverSimulationProfile.TwoInOne; } if (_d.type == RiverSimulationProfile.TwoInOne.Type.UseValue) { colCount = 1; rowCount = p.boundaryTime.Length; _inputFormType = InputFormType.Type2; tabPage1.Parent = tabControl; tabPage2.Parent = tabControl; tabPage3.Parent = null; tabPage1.Text = "主流方向流量(cms)"; tabPage2.Text = "側方向流量(cms)"; if (_d.ValueNull()) { (_data as RiverSimulationProfile.TwoInOne).CreateValue3D(colCount, rowCount, 2); } } else { colCount = inputData.sideFlowPoints.Count; rowCount = p.boundaryTime.Length; _inputFormType = InputFormType.Type4; tabPage1.Parent = tabControl; tabPage2.Parent = tabControl; tabPage3.Parent = null; tabPage1.Text = "主流方向流量(cms)"; tabPage2.Text = "側方向流量(cms)"; if (_d.ArrayNull()) { (_data as RiverSimulationProfile.TwoInOne).CreateArray3D(colCount, rowCount, 2); } } } //第5, 7種:超臨界流、均一值/逐點給、定量流 else if (inputData.criticalFlowType == RiverSimulationProfile.CriticalFlowType.SuperCriticalFlow && p.IsConstantFlowType()) { if (d == null) { _data = new RiverSimulationProfile.TwoInOne(RiverSimulationProfile.TwoInOne.ValueType.TwoDim, RiverSimulationProfile.TwoInOne.ArrayType.ThreeDim, RiverSimulationProfile.TwoInOne.Type.UseValue); _d = _data as RiverSimulationProfile.TwoInOne; } else { _data = new RiverSimulationProfile.TwoInOne(o); _d = _data as RiverSimulationProfile.TwoInOne; } if (_d.type == RiverSimulationProfile.TwoInOne.Type.UseValue) { colCount = 3; rowCount = 1; _inputFormType = InputFormType.Type5; tabPage1.Parent = tabControl; tabPage2.Parent = null; tabPage3.Parent = null; tabPage1.Text = ""; if (_d.ValueNull()) { (_data as RiverSimulationProfile.TwoInOne).CreateValue2D(colCount, rowCount); } } else { colCount = inputData.sideFlowPoints.Count; rowCount = 1; _inputFormType = InputFormType.Type7; tabPage1.Parent = tabControl; tabPage2.Parent = tabControl; tabPage3.Parent = tabControl; tabPage1.Text = "主流方向流量(cms)"; tabPage2.Text = "側方向流量(cms)"; tabPage3.Text = "水位(m)"; if (_d.ArrayNull()) { (_data as RiverSimulationProfile.TwoInOne).CreateArray3D(colCount, rowCount, 3); } } } //第6, 8種:超臨界流、均一值/逐點給、變量流 else if (inputData.criticalFlowType == RiverSimulationProfile.CriticalFlowType.SuperCriticalFlow && p.IsVariableFlowType()) { if (d == null) { _data = new RiverSimulationProfile.TwoInOne(RiverSimulationProfile.TwoInOne.ValueType.ThreeDim, RiverSimulationProfile.TwoInOne.ArrayType.ThreeDim, RiverSimulationProfile.TwoInOne.Type.UseValue); _d = _data as RiverSimulationProfile.TwoInOne; } else { _data = new RiverSimulationProfile.TwoInOne(o); _d = _data as RiverSimulationProfile.TwoInOne; } if (_d.type == RiverSimulationProfile.TwoInOne.Type.UseValue) { colCount = 1; rowCount = p.boundaryTime.Length; _inputFormType = InputFormType.Type6; tabPage1.Parent = tabControl; tabPage2.Parent = tabControl; tabPage3.Parent = tabControl; tabPage1.Text = "主流方向流量(cms)"; tabPage2.Text = "側方向流量(cms)"; tabPage3.Text = "水位(m)"; if (_d.ValueNull()) { (_data as RiverSimulationProfile.TwoInOne).CreateValue3D(colCount, rowCount, 3); } } else { colCount = inputData.sideFlowPoints.Count; rowCount = p.boundaryTime.Length; _inputFormType = InputFormType.Type8; tabPage1.Parent = tabControl; tabPage2.Parent = tabControl; tabPage3.Parent = tabControl; tabPage1.Text = "主流方向流量(cms)"; tabPage2.Text = "側方向流量(cms)"; tabPage3.Text = "水位(m)"; if (_d.ArrayNull()) { (_data as RiverSimulationProfile.TwoInOne).CreateArray3D(colCount, rowCount, 3); } } } }