Ejemplo n.º 1
0
        public void DistributeIntakesOnLayers()
        {
            //Reset Layers
            foreach (Layer L in Layers)
            {
                L.Intakes.Clear();
                L.OriginalIntakes.Clear();
                L.IntakesMoved.Clear();
                L.IntakesAllowed = true;
            }


            //Distribute the intakes
            foreach (IWell W in Wells)
            {
                int col;
                int row;

                if (!MShe.GridInfo.TryGetIndex(W.X, W.Y, out col, out row))
                {
                    WellsOutSideModelDomain.Add(W);
                }
                else
                {
                    //Well has no terrain. Use model topography
                    if (W.Terrain < 0)
                    {
                        W.Terrain = MShe.GridInfo.SurfaceTopography.Data[row, col];
                    }

                    foreach (IIntake I in W.Intakes)
                    {
                        foreach (Screen S in I.Screens)
                        {
                            //Missing screen info
                            if (S.TopAsKote < -990 || S.BottomAsKote < -990 || S.DepthToBottom < -990 || S.DepthToTop < -990)
                            {
                                ScreensWithMissingDepths.Add(S);
                            }
                            else
                            {
                                int TopLayer    = MShe.GridInfo.GetLayer(col, row, S.TopAsKote.Value);
                                int BottomLayer = MShe.GridInfo.GetLayer(col, row, S.BottomAsKote.Value);

                                //Above terrain
                                if (BottomLayer == -1)
                                {
                                    ScreensAboveTerrain.Add(S);
                                }
                                //Below bottom
                                else if (TopLayer == -2)
                                {
                                    ScreensBelowBottom.Add(S);
                                }
                                else
                                {
                                    BottomLayer = Math.Max(0, BottomLayer);
                                    if (TopLayer == -1)
                                    {
                                        TopLayer = MShe.GridInfo.NumberOfLayers - 1;
                                    }

                                    for (int i = BottomLayer; i <= TopLayer; i++)
                                    {
                                        //Prevent adding the same intake twice if has two screens in the same layer
                                        if (I.Screens.Count > 1)
                                        {
                                            if (!Layers[i].Intakes.Contains(I))
                                            {
                                                Layers[i].Intakes.Add(I);
                                                Layers[i].OriginalIntakes.Add(I);
                                            }
                                        }
                                        else
                                        {
                                            Layers[i].Intakes.Add(I);
                                            Layers[i].OriginalIntakes.Add(I);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }