Loading Grid
ReservoirGrid requires JCarnac3D scenegraph.
Instantiation of the grid requires only the loaded file path :
Sample Code
// Locate File to load
File reservoirGridFile;
JFileChooser chooser = new JFileChooser("./");
chooser.setFileFilter(new FileNameExtensionFilter("Reservoir grid files", "resqml", "grdecl", cgNameConstants.HEADER_FILE_NAME_EXTENSION));
reservoirGridFile= chooser.getSelectedFile();
// create correct file reader
cgReservoirGridReader reader;
if (reservoirGridFile.getAbsolutePath().toLowerCase().endsWith("resqml")) {
reader = new cgRESQMLReader(reservoirGridFile, false);
} else if (reservoirGridFile.getAbsolutePath().toLowerCase().endsWith("grdecl")) {
reader= new cgRESQMLReader(reservoirGridFile, false);
}
cgUserManageableReservoir grid = new cgJOGLSimpleReservoirNode(reader.createReservoirGrid(0));
// Then add the grid to rendering scenegraph
The node supports several rendering options on Outline. Those options are color of the outline color and size, and outline rendering on/off.
Sample code
// Setting new outline color
Color color = Color.RED; // Any color
cgAttribute attribute = _gridNode.getAttribute();
attribute.setLineColor(c); // Set new color on attribute
gridNode.setAttribute(attr); // Update grid node
// Setting outline Size
float size = 1.0f;
attribute = _reservoirNode.getAttribute();
attr.setLineWidth(size);
gridNode.setAttribute(attr);
// Setting outline rendering enable true or false
boolean enable = true; // or false
gridNode.setOutlineRenderingEnabled(enable);
IJK FILTERS
We provide an example of a IJK filter with range filters.
Based on two classes, FilterIJKDialog and IJKRangeSlider, it allows you to choose 3 ranges to filter the rendering.
IJKRangeSlider provides the example to correctly apply a filter on the grid.
Sample Code
// Create filter and get sliders from dialog (current example)
cgReservoirIJKFilter newFilter = new cgReservoirIJKFilter();
IJKRangeSlider rangeSliderI = _parentFilter.getRangeSliderI();
IJKRangeSlider rangeSliderJ = _parentFilter.getRangeSliderJ();
IJKRangeSlider rangeSliderK = _parentFilter.getRangeSliderK();
// set the values on filter, current example get values from sliders
newFilter.setMinI(rangeSliderI.getLowValue());
newFilter.setMaxI(rangeSliderI.getHighValue());
newFilter.setMinJ(rangeSliderJ.getLowValue());
newFilter.setMaxJ(rangeSliderJ.getHighValue());
newFilter.setMinK(rangeSliderK.getLowValue());
newFilter.setMaxK(rangeSliderK.getHighValue());
// Remove the values from the grid node
cgManageableNodifiedReservoirGrid reservoirNode = (cgManageableNodifiedReservoirGrid)_parentFilter.getNode();
for (cgReservoirGridFilter oldFilter : reservoirNode.getFilters()) {
if (oldFilter instanceof cgReservoirIJKFilter) {
reservoirNode.removeFilter(oldFilter);
}
}
// Add the new filer to the grid node
reservoirNode.addFilter(newFilter);
PROPERTY FILTER
The grid rendering can also be filtered through attached properties.
If the loaded file contains any properties, you can choose to display any of it.
Sample code
cgUserManageableReservoir gridNode = ... ; // loaded node
// Iterator on loaded properties directly through the reservoir node
Iterator<PropertyKey> properties = node.getAvailableProperties();
PropertyKey activeProperty = node.getActiveProperty();
// Iterate keys and do your selection
while (properties.hasNext()) {
final PropertyKey propertyKey = properties.next();
// With the key ou can get to the property
cgReservoirGridProperty property = grid.getProperty(propertyKey);
// You can also set it as active
node.setActiveProperty(propertyKey);
// If you need to activate, set the correct bounds to the property values
float minPropertyValue, maxPropertyValue;
maxPropertyValue = gridNode.getPropertyExtentMaxValue();
minPropertyValue = gridNode.getPropertyExtentMinValue();
// Create property Filter to be applied on grid
cgReservoirGridPropertyFilter filter = new cgReservoirPropertyFilter(property, gridNode.getIJKBoundingBox().getNbI(),
gridNode.getIJKBoundingBox().getNbJ());
filter.setMinFilteredValue(minPropertyValue);
filter.setMaxFilteredValue(maxPropertyValue);
// remove old filter
cgManageableNodifiedReservoirGrid reservoirNode = (cgManageableNodifiedReservoirGrid) gridNode;
for (cgReservoirGridFilter oldFilter : reservoirNode.getFilters()) {
if (!(oldFilter instanceof cgReservoirIJKFilter)) {
reservoirNode.removeFilter(oldFilter);
break;
}
}
// Add new property Filter
reservoirNode.addFilter(filter);
}
Once you chose a property, you can also apply a specific color map to display it.
sample code
// Dont forget to correctly set the range to the filter before you set the color map, as seen previously
filter.setMinFilteredValue(minValue);
filter.setMaxFilteredValue(maxValue);
// Add a color map as a Color[]
gridNode.setColorMap(new Color[] {Color.red, Color.BLACK,... });
You can then filter the values to display only some cells depending on properties values. You need to change value to the created Property Filter
Sample Code
// If you need to activate, set the correct bounds to the property values
float minPropertyValue, maxPropertyValue;
maxPropertyValue = customMaxValue // <= gridNode.getPropertyExtentMaxValue();
minPropertyValue = custom Min Value // >= gridNode.getPropertyExtentMinValue();
// Create property Filter to be applied on grid
cgReservoirGridPropertyFilter filter = new cgReservoirPropertyFilter(property, gridNode.getIJKBoundingBox().getNbI(),
gridNode.getIJKBoundingBox().getNbJ());
filter.setMinFilteredValue(minPropertyValue);
filter.setMaxFilteredValue(maxPropertyValue);