public List <Cell3D> SearchGroup(ref Cell3D startCell) { List <Cell3D> group = new List <Cell3D>(); group.Add(startCell); List <Cell3D> queue = new List <Cell3D>();//BFS queue.Add(startCell); startCell.IsChecked = true; while (queue.Count > 0) { Cell3D c = queue[0]; queue.RemoveAt(0); List <Cell3D> neighbour = c.Neighbour; foreach (Cell3D nc in neighbour) { if (nc.IsChecked == false) { if ((startCell.Phase > 0 && nc.Phase > 0) || //gas (startCell.Phase == 0 && nc.Phase == 0)) //liquid { nc.IsChecked = true; queue.Add(nc); group.Add(nc); } } } } return(group); }
private int InterfaceAction(Interface3D itf) { Cell3D liquidCell = itf.LiquidCell; Cell3D gasCell = itf.GasCell; double liquidPressure = DropList[liquidCell.Index].Pressure; double gasVolume = BubbleList[gasCell.Index].BubbleVolume; double gasAmount = BubbleList[gasCell.Index].BubbleGasAmount; //double gasPressure = BubbleList[gasCell.index].Pressure; int action = 0; if (gasVolume > 1 && liquidPressure >= gasAmount / (gasVolume - 1)) { action = 1; } else if (liquidPressure < gasAmount / gasVolume) { action = -1; foreach (Source3D s in SourceList) { if (s.SourceCell == liquidCell) { action = 0; } } } else if (gasVolume == 1 && liquidPressure >= gasAmount * 1.5) { action = 2;//小气泡消失 } return(action); }
public List <GH_Mesh> DisplayMeshColored() { List <GH_Mesh> Display = new List <GH_Mesh>(); Point3d min = new Point3d(0, 0, 0); Point3d max = new Point3d(1, 1, 1); BoundingBox box = new BoundingBox(min, max); Mesh baseMesh = Mesh.CreateFromBox(box, 1, 1, 1); for (int i = 0; i < VesselCellCount; i++) { Cell3D currentCell = VesselCellList[i]; Mesh newMesh = baseMesh.DuplicateMesh(); newMesh.Translate(currentCell.X_coor * Step, currentCell.Y_coor * Step, currentCell.Z_coor * Step); if (currentCell.Phase > 0) { newMesh.VertexColors.CreateMonotoneMesh(Color.FromArgb(40, 255, 255, 255)); } else { newMesh.VertexColors.CreateMonotoneMesh(Color.FromArgb(100, 0, 0, 255)); } Display.Add(new GH_Mesh(newMesh)); } return(Display); }
public Source3D(Cell3D c, double p) { SourceCell = new Cell3D(0, 0, 0); SourceCell = c; SourcePressure = p; SourceCell.Phase = 0; SourceCell.Volume = 1; }
public Interface3D(Cell3D liquidCell, Cell3D gasCell) { LiquidCell = new Cell3D(0, 0, 0); GasCell = new Cell3D(0, 0, 0); LiquidCell = liquidCell; GasCell = gasCell; DropIndex = liquidCell.Index; BubbleIndex = gasCell.Index; }
private void TakeAction(Interface3D itf, int action) { Cell3D gasCell = itf.GasCell; Cell3D liquidCell = itf.LiquidCell; if (action == 1) { List <Cell3D> neighbour = gasCell.Neighbour; List <Cell3D> gasNeighbour = new List <Cell3D>();//gasCell的gas邻域 foreach (Cell3D nc in neighbour) { if (nc.Phase > 0) { gasNeighbour.Add(nc); } } if (gasNeighbour.Count > 0) { double addtion = gasCell.Phase / gasNeighbour.Count; foreach (Cell3D gnc in gasNeighbour) { gnc.Phase += addtion; } gasCell.Phase = 0;//update phase } } else if (action == -1) { liquidCell.Phase += gasCell.Phase / 2;//update phase gasCell.Phase -= gasCell.Phase / 2; } else if (action == 2) { gasCell.Phase = 0;//直接消失 } }
public void ReadMesh() { for (int i = 0; i < VesselCellCount; i++) { VesselCellList[i].IsChecked = false; } BubbleList.Clear(); DropList.Clear(); foreach (Source3D source in SourceList) { Cell3D currentCell = source.SourceCell; List <Cell3D> cellGroup = SearchGroup(ref currentCell); DropList.Add(new Drop3D(cellGroup, source.SourcePressure)); } for (int i = 0; i < VesselCellCount; i++) { Cell3D currentCell = VesselCellList[i]; if (currentCell.IsChecked == false) { List <Cell3D> cellGroup = SearchGroup(ref currentCell); if (currentCell.Phase > 0) {//gas BubbleList.Add(new Bubble3D(cellGroup)); } else {//drop DropList.Add(new Drop3D(cellGroup)); } } } SumGasAmount = AnalyzeBubles(); AnalyzeDrops(); }
private void AnalyzeDrops() { int numberOfDrops = DropList.Count; for (int j = 0; j < numberOfDrops; j++) { Drop3D currentDrop = DropList[j]; int n = currentDrop.CellList.Count; double pressure = 0; for (int i = 0; i < n; i++) { Cell3D c = currentDrop.CellList[i]; c.Index = j;//update index for every cell List <Cell3D> neighbour = c.Neighbour; foreach (Cell3D nc in neighbour) { if (nc.Phase > 0) { //气液界面 Interface3D interf = new Interface3D(c, nc); //(liquid, gas) currentDrop.InterfaceList.Add(interf); if (BubbleList[nc.Index].Pressure > pressure) {//获得与该drop接触的bubble中最大的气压值 pressure = BubbleList[nc.Index].Pressure; } //pressure += BubbleList[nc.index].Pressure; } } } //气液界面按照bubble体积降序排列 int numberOfInterface = currentDrop.InterfaceList.Count; List <Interface3D> orderedInterfaceList = new List <Interface3D>(); List <bool> isOrdered = new List <bool>(); for (int i = 0; i < numberOfInterface; i++) { isOrdered.Add(false); } for (int i = 0; i < numberOfInterface; i++) { double maxV = 0; int maxIndex = 0; for (int k = 0; k < numberOfInterface; k++) { Interface3D currentItf = currentDrop.InterfaceList[k]; double v = BubbleList[currentItf.BubbleIndex].BubbleVolume; if (v > maxV && isOrdered[k] == false) { maxV = v; maxIndex = k; } } isOrdered[maxIndex] = true; orderedInterfaceList.Add(currentDrop.InterfaceList[maxIndex]); } currentDrop.InterfaceList = orderedInterfaceList; if (!currentDrop.isSource && currentDrop.InterfaceList.Count != 0) { //pressure /= currentDrop.InterfaceList.Count; //currentDrop.Pressure = pressure; currentDrop.Pressure = pressure * 0.95;//最大气压的0.95 } } }