Example #1
0
            public override void ExecuteSimple()
            {
                // extract input data
                var startX  = PetrelUnitSystem.ConvertFromUI(Domain.X, arguments.X);
                var startY  = PetrelUnitSystem.ConvertFromUI(Domain.Y, arguments.Y);
                var startZ  = PetrelUnitSystem.ConvertFromUI(Domain.ELEVATION_DEPTH, arguments.Z);
                var spacing = PetrelUnitSystem.ConvertFromUI(Domain.ELEVATION_DEPTH, arguments.Spacing);
                var nLines  = arguments.NLines;
                //
                // define default increments
                double incrementX = 500.0;
                double incrementY = 100.0;
                double incrementZ = 100.0;
                //
                // Create points
                var points = new List <Point3>();

                //
                for (int lineIndex = 0; lineIndex < nLines; lineIndex++)
                {
                    for (int pointIndex = 0; pointIndex < nLines; pointIndex++)
                    {
                        double verticalSpacing = pointIndex * spacing;
                        points.Add(new Point3(startX, startY, startZ + verticalSpacing));
                    }
                    //
                    startX += incrementX;
                    startY += incrementY;
                    startZ += incrementZ;
                }
                //
                // create empty collection
                Collection collection = Collection.NullObject;
                Project    project    = PetrelProject.PrimaryProject;

                //
                using (var transaction = DataManager.NewTransaction())
                {
                    transaction.Lock(project);
                    //
                    collection = project.CreateCollection("My Collection");
                    //
                    var pointSet = collection.CreatePointSet("My point set");
                    //
                    // set point set properties
                    pointSet.Domain = Domain.ELEVATION_DEPTH;
                    pointSet.Points = new Point3Set(points);
                    //
                    // update the output argument
                    arguments.PointSet = pointSet;
                    //
                    transaction.Commit();
                }
            }
Example #2
0
            public override void ExecuteSimple()
            {
                // extract input time value
                var displayTimeValue = arguments.DisplayUnitValue;
                //
                // find time measurment
                var timeMeasurement = PetrelProject.WellKnownTemplates.GeometricalGroup.TimeOneWay.UnitMeasurement;
                //
                // find core and ui units
                var displayUnit   = PetrelUnitSystem.GetDisplayUnit(timeMeasurement);
                var invariantUnit = PetrelUnitSystem.GetInvariantUnit(timeMeasurement);
                //
                // do the real conversion
                var invariantTimeValue = PetrelUnitSystem.ConvertFromUI(timeMeasurement, displayTimeValue);

                //
                // update the argument package
                arguments.SIUnitValue = invariantTimeValue;
                arguments.DisplayUnit = displayUnit.DisplaySymbol;
                arguments.SIUnit      = invariantUnit.DisplaySymbol;
            }
            public override void ExecuteSimple()
            {
                // extract input data
                var grid         = arguments.Grid;
                var contactDepth = arguments.ContactDepth;

                //
                if (grid == null)
                {
                    PetrelLogger.ErrorStatus("CreateDistanceAboveContactPropertyWorkstep: Must provide input grid");
                    return;
                }
                //
                PropertyCollection properties           = grid.PropertyCollection;
                PropertyCollection oceanProperties      = FindOrCreatePropertyCollection("Ocean Properties", grid);;
                Property           property             = Property.NullObject;
                Template           aboveContactTemplate = PetrelProject.WellKnownTemplates.GeometricalGroup.AboveContact;

                //
                using (var transaction = DataManager.NewTransaction())
                {
                    transaction.Lock(oceanProperties);
                    //
                    property      = oceanProperties.CreateProperty(aboveContactTemplate);
                    property.Name = "Above Contact " + contactDepth;
                    //
                    // we are computing the difference from the constant contact and the grid.Z value
                    double constantDepth = PetrelUnitSystem.ConvertFromUI(grid.Domain, contactDepth);
                    //
                    // set data on the property for all the cells in the grid
                    double cellCenterDepth = double.NaN;
                    double propertyValue   = double.NaN;
                    Index3 currentCell     = new Index3();
                    //
                    for (int i = 0; i < grid.NumCellsIJK.I; i++)
                    {
                        for (int j = 0; j < grid.NumCellsIJK.J; j++)
                        {
                            for (int k = 0; k < grid.NumCellsIJK.K; k++)
                            {
                                currentCell.I = i;
                                currentCell.J = j;
                                currentCell.K = k;
                                //
                                // if the cell is defined and has volume, set property value
                                if (grid.IsCellDefined(currentCell) && grid.HasCellVolume(currentCell))
                                {
                                    // get cell center depth, Z value
                                    cellCenterDepth = grid.GetCellCenter(currentCell).Z;
                                    //
                                    // if the cell center is above the constant depth, set the property value as the difference
                                    propertyValue = cellCenterDepth > constantDepth
                                        ? cellCenterDepth - constantDepth
                                        : 0.0;
                                    //
                                    property[currentCell] = (float)propertyValue;
                                }
                            }
                        }
                    }
                    //
                    transaction.Commit();
                }
                //
                // update output arguments
                arguments.AboveContact = property;
            }
            public override void ExecuteSimple()
            {
                // extract input data
                var grid = arguments.Grid;

                if (grid == null)
                {
                    PetrelLogger.ErrorStatus("HelloGridWorkstep: Grid argument cannot be empty");
                    return;
                }
                //
                // get total number of cells in the grid
                Index3 numCells = grid.NumCellsIJK;

                arguments.NumCells = numCells.I * numCells.J * numCells.K;
                //
                // get cell and volume
                double px = PetrelUnitSystem.ConvertFromUI(Domain.X, arguments.PointX);
                double py = PetrelUnitSystem.ConvertFromUI(Domain.Y, arguments.PointY);
                double pz = PetrelUnitSystem.ConvertFromUI(grid.Domain, arguments.PointZ);
                //
                Point3 point = new Point3(px, py, pz);
                //
                Index3 cellIndex = grid.GetCellAtPoint(point);

                //
                arguments.CellVolume = Double.NaN;
                if (cellIndex != null && grid.HasCellVolume(cellIndex))
                {
                    arguments.CellVolume = grid.GetCellVolume(cellIndex);
                }
                //
                // get cell corners
                PetrelLogger.InfoOutputWindow("The corner points of the cell are: ");
                foreach (Point3 cellCorner in grid.GetCellCorners(cellIndex, CellCornerSet.All))
                {
                    double x = PetrelUnitSystem.ConvertToUI(Domain.X, cellCorner.X);
                    double y = PetrelUnitSystem.ConvertToUI(Domain.Y, cellCorner.Y);
                    double z = PetrelUnitSystem.ConvertToUI(grid.Domain, cellCorner.Z);
                    //
                    PetrelLogger.InfoOutputWindow($"X = {x}, Y = {y}, Z = {z}");
                }
                //
                // check to see if node is defined at (10,10,10)
                Index3    nodeIndex3 = new Index3(10, 10, 10);
                Direction direction  = Direction.NorthEast;

                if (grid.IsNodeDefined(nodeIndex3, direction))
                {
                    PetrelLogger.InfoOutputWindow("The node is defined at 10, 10, 10 with NorthWest direction");
                }
                //
                // check to see if node is faulted at 10, 10
                Index2 nodeIndex2 = new Index2(10, 10);

                if (grid.IsNodeFaulted(nodeIndex2))
                {
                    // then get faults at the given node
                    foreach (PillarFault fault in grid.GetPillarFaultsAtNode(nodeIndex2))
                    {
                        PetrelLogger.InfoOutputWindow("The fault name at node is " + fault.Description.Name);
                    }
                }
                //
                // get all the horizons in the grid and output each one's name, type, and K index
                PetrelLogger.InfoOutputWindow("\nThere are " + grid.HorizonCount + " horizons in the grid, and their names are:");
                foreach (Horizon hz in grid.Horizons)
                {
                    PetrelLogger.InfoOutputWindow(hz.Name + " is of type " + hz.HorizonType.ToString() + " and is at K index " + hz.K);
                }
                //
                // get all the zones in grid and output their names; these are hierachical
                PetrelLogger.InfoOutputWindow("\nThere are " + grid.ZoneCount + " zones in the grid, and their names are:");
                foreach (Zone z in grid.Zones)
                {
                    PetrelLogger.InfoOutputWindow(z.Name + " has a zone count of " + z.ZoneCount + " and contains these zones:");
                    foreach (Zone subZone in z.Zones)
                    {
                        PetrelLogger.InfoOutputWindow(subZone.Name);
                    }
                }
                //
                //
                PrintPillarFaultsInCollection(grid.FaultCollection);
                //
                // get all the segments in the grid and output their names and cell count
                PetrelLogger.InfoOutputWindow("\nThere are " + grid.SegmentCount + " segments in the grid, and their names are:");
                foreach (Segment seg in grid.Segments)
                {
                    PetrelLogger.InfoOutputWindow(seg.Name + " has a cell count of " + seg.CellCount);
                }
            }