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; }