Skip to main content

Rocky PrePost scripting 2026 R1

RAGridFunction

Last update: 23.02.2026

class RAGridFunction

Identifies a grid function in the model.

It acts as a handle of the grid function and not the actual grid function, which means that when the time changes, this handle will start returning the values for the grid function at the new time and not at the time where it was requested initially.

I.e.: : GoToFirstTimeStep() grid = GetGrid(‘Main Grid’) gf = grid.GetGridFunction(‘Oil Pressure’) gf.GetMax() #Max value at time 0. GoToNextTimeStep() gf.GetMax() #Max value at time 1.

Although most function also accept passing in the time.

I.e.: : grid = GetGrid(‘Main Grid’) gf = grid.GetGridFunction(‘Oil Pressure’) gf.GetMax(time_step=0) #Max value at time 0. gf.GetMax(time_step=2) #Max value at time 2.

Methods:

Name Description
GetArray([unit, time_step])
GetAverage([unit, time_step])
GetGrid()
GetIsStatic()
GetIsTransient()
GetLimits([unit, time_step])
GetLocation()
GetMax([unit, time_step])
GetMin([unit, time_step])
GetStandardDeviation([unit, time_step])
GetSum([unit, time_step])
GetSumSquared([unit, time_step])
GetTimeStep(time_step[, accept_global]) Get the timestep corresponding to the given time.
GetUnit()
GetValue(i[, j, k, unit, time_step])
GetVariance([unit, time_step])
Modified(*args, **kwargs) Resets all the cache information after a change in the subject being tracked.
SetCurrentTimeStep(time_step) Sets the current time step.

Attributes:

Name
average
is_static
is_transient
limits
max
min
standard_deviation
sum
sum_squared
unit
variance

GetArray(unit=None, time_step='current')

  • Parameters:
    • unit (str) – The unit in which the array should be gotten (if not passed, the default unit is used).

    • time_step (str , ITimeStep or int) –

      Either a string with ‘current’ identifying the current time step

      or an ITimeStep identifying the time to get the limits

      or an int identifying the time step index to be used based on the global time set

  • Return type: numpy array or None
  • Returns: Returns a numpy array representing the passed grid function or None if it couldn’t be found.

GetAverage(unit=None, time_step='current')

  • Parameters:
    • unit (str) – The unit in which the value should be gotten (if not passed, the default unit is used).

    • time_step (str , ITimeStep or int) –

      Either a string with ‘current’ identifying the current time step (note that ‘global’ is NOT accepted for this statistic).

      or an ITimeStep identifying the time to get the limits

      or an int identifying the time step index to be used based on the global time set

  • Return type: float or None
  • Returns: Returns a the average value for the grid function or None if it’s not available for the current time.

GetGrid()

  • Return type: KAGrid
  • Returns: The grid that “owns” the grid function.

GetIsStatic()

  • Return type: bool
  • Returns: Returns whether this grid function is static.

GetIsTransient()

  • Return type: bool
  • Returns: Returns whether this grid function is transient.

GetLimits(unit=None, time_step='current')

  • Parameters:
    • unit (str) – The unit in which the limits should be gotten

    • time_step (str , ITimeStep or int) –

      Either a string with : ’current’ identifying the current time step ‘global’ identifying that the global limits should be gotten

      or an ITimeStep identifying the time to get the limits

      or an int identifying the time step index to be used based on the global time set

  • Return type: list(float, float) or None
  • Returns: Returns a tuple with the min and max value for the limits and None if the limit is not available for the current time.

GetLocation()

  • Return type: [‘cell’, ‘node’]
  • Returns: Returns whether this grid function is a cell or node/vertex grid function.

GetMax(unit=None, time_step='current')

  • Parameters:
    • unit (str) – The unit in which the value should be gotten (if not passed, the default unit is used).

    • time_step (str , ITimeStep or int) –

      Either a string with : ’current’ identifying the current time step ‘global’ identifying that the global limits should be gotten

      or an ITimeStep identifying the time to get the limits

      or an int identifying the time step index to be used based on the global time set

  • Return type: float or None
  • Returns: Returns a the max value or None if it’s not available for the current time.

GetMin(unit=None, time_step='current')

  • Parameters:
    • unit (str) – The unit in which the value should be gotten (if not passed, the default unit is used).

    • time_step (str , ITimeStep or int) –

      Either a string with : ’current’ identifying the current time step ‘global’ identifying that the global limits should be gotten

      or an ITimeStep identifying the time to get the limits

      or an int identifying the time step index to be used based on the global time set

  • Return type: float or None
  • Returns: Returns a the min value or None if it’s not available for the current time.

GetStandardDeviation(unit=None, time_step='current')

  • Parameters:
    • unit (str) – The unit in which the value should be gotten (if not passed, the default unit is used).

    • time_step (str , ITimeStep or int) –

      Either a string with ‘current’ identifying the current time step (note that ‘global’ is NOT accepted for this statistic).

      or an ITimeStep identifying the time to get the limits

      or an int identifying the time step index to be used based on the global time set

  • Return type: float or None
  • Returns: Returns a the standard deviation of the grid function or None if it’s not available for the current time.

GetSum(unit=None, time_step='current')

  • Parameters:
    • unit (str) – The unit in which the value should be gotten (if not passed, the default unit is used).

    • time_step (str , ITimeStep or int) –

      Either a string with ‘current’ identifying the current time step (note that ‘global’ is NOT accepted for this statistic).

      or an ITimeStep identifying the time to get the limits

      or an int identifying the time step index to be used based on the global time set

  • Return type: float or None
  • Returns: Returns a the sum of all values in the grid function or None if it’s not available for the current time.

GetSumSquared(unit=None, time_step='current')

  • Parameters:
    • unit (str) – The unit in which the value should be gotten (if not passed, the default unit is used).

    • time_step (str , ITimeStep or int) –

      Either a string with ‘current’ identifying the current time step (note that ‘global’ is NOT accepted for this statistic).

      or an ITimeStep identifying the time to get the limits

      or an int identifying the time step index to be used based on the global time set

  • Return type: float or None
  • Returns: Returns a the sum squared considering all values in the grid function or None if it’s not available for the current time.

GetTimeStep(time_step, accept_global=False)

Get the timestep corresponding to the given time.

  • Parameters:
    • time_step (unicode , ITimeStep or int) –

      Either a string with : ’current’ identifying the current time step ‘global’ identifying that the global limits should be gotten (note that if accept_global=False and ‘global’ is passed, an error is raised).

      or an ITimeStep identifying the time to get the limits

      or an int identifying the time step index to be used based on the global time set

    • accept_global (bool) – If True, a global time step is accepted (and returns None), otherwise, an error is raised if ‘global’ is passed.

  • Return type: ITimeStep
  • Returns: Returns the time step to be used or None if accept_global == True and the time step passed is ‘global’.

GetUnit()

  • Return type: str
  • Returns: Returns the default unit for the grid function.

GetValue(i, j=None, k=None, unit=None, time_step='current')

  • Parameters:
    • i (int) – The topological I cell index or the grid cell handle

    • j (int) – The topological J cell index

    • k (int) – The topological K cell index

    • unit (str) – The unit in which the array should be gotten (if not passed, the default unit is used).

    • time_step (str , ITimeStep or int) –

      Either a string with ‘current’ identifying the current time step

      or an ITimeStep identifying the time to get the limits

      or an int identifying the time step index to be used based on the global time set

  • Return type: float
  • Returns: Returns the grid function value for the given cell

GetVariance(unit=None, time_step='current')

  • Parameters:
    • unit (str) – The unit in which the value should be gotten (if not passed, the default unit is used).

    • time_step (str , ITimeStep or int) –

      Either a string with ‘current’ identifying the current time step (note that ‘global’ is NOT accepted for this statistic).

      or an ITimeStep identifying the time to get the limits

      or an int identifying the time step index to be used based on the global time set

  • Return type: float or None
  • Returns: Returns a the variance of the grid function or None if it’s not available for the current time.

Modified(*args, **kwargs)

Resets all the cache information after a change in the subject being tracked.

SetCurrentTimeStep(time_step)

Sets the current time step.

  • Parameters: time_step (ITimeStep) – The time step to be considered the ‘current’ time step.

property average

  • Parameters:
    • unit (str) – The unit in which the value should be gotten (if not passed, the default unit is used).

    • time_step (str , ITimeStep or int) –

      Either a string with ‘current’ identifying the current time step (note that ‘global’ is NOT accepted for this statistic).

      or an ITimeStep identifying the time to get the limits

      or an int identifying the time step index to be used based on the global time set

  • Return type: float or None
  • Returns: Returns a the average value for the grid function or None if it’s not available for the current time.

property is_static

  • Return type: bool
  • Returns: Returns whether this grid function is static.

property is_transient

  • Return type: bool
  • Returns: Returns whether this grid function is transient.

property limits

  • Parameters:
    • unit (str) – The unit in which the limits should be gotten

    • time_step (str , ITimeStep or int) –

      Either a string with : ’current’ identifying the current time step ‘global’ identifying that the global limits should be gotten

      or an ITimeStep identifying the time to get the limits

      or an int identifying the time step index to be used based on the global time set

  • Return type: list(float, float) or None
  • Returns: Returns a tuple with the min and max value for the limits and None if the limit is not available for the current time.

property max

  • Parameters:
    • unit (str) – The unit in which the value should be gotten (if not passed, the default unit is used).

    • time_step (str , ITimeStep or int) –

      Either a string with : ’current’ identifying the current time step ‘global’ identifying that the global limits should be gotten

      or an ITimeStep identifying the time to get the limits

      or an int identifying the time step index to be used based on the global time set

  • Return type: float or None
  • Returns: Returns a the max value or None if it’s not available for the current time.

property min

  • Parameters:
    • unit (str) – The unit in which the value should be gotten (if not passed, the default unit is used).

    • time_step (str , ITimeStep or int) –

      Either a string with : ’current’ identifying the current time step ‘global’ identifying that the global limits should be gotten

      or an ITimeStep identifying the time to get the limits

      or an int identifying the time step index to be used based on the global time set

  • Return type: float or None
  • Returns: Returns a the min value or None if it’s not available for the current time.

property standard_deviation

  • Parameters:
    • unit (str) – The unit in which the value should be gotten (if not passed, the default unit is used).

    • time_step (str , ITimeStep or int) –

      Either a string with ‘current’ identifying the current time step (note that ‘global’ is NOT accepted for this statistic).

      or an ITimeStep identifying the time to get the limits

      or an int identifying the time step index to be used based on the global time set

  • Return type: float or None
  • Returns: Returns a the standard deviation of the grid function or None if it’s not available for the current time.

property sum

  • Parameters:
    • unit (str) – The unit in which the value should be gotten (if not passed, the default unit is used).

    • time_step (str , ITimeStep or int) –

      Either a string with ‘current’ identifying the current time step (note that ‘global’ is NOT accepted for this statistic).

      or an ITimeStep identifying the time to get the limits

      or an int identifying the time step index to be used based on the global time set

  • Return type: float or None
  • Returns: Returns a the sum of all values in the grid function or None if it’s not available for the current time.

property sum_squared

  • Parameters:
    • unit (str) – The unit in which the value should be gotten (if not passed, the default unit is used).

    • time_step (str , ITimeStep or int) –

      Either a string with ‘current’ identifying the current time step (note that ‘global’ is NOT accepted for this statistic).

      or an ITimeStep identifying the time to get the limits

      or an int identifying the time step index to be used based on the global time set

  • Return type: float or None
  • Returns: Returns a the sum squared considering all values in the grid function or None if it’s not available for the current time.

property unit

  • Return type: str
  • Returns: Returns the default unit for the grid function.

property variance

  • Parameters:
    • unit (str) – The unit in which the value should be gotten (if not passed, the default unit is used).

    • time_step (str , ITimeStep or int) –

      Either a string with ‘current’ identifying the current time step (note that ‘global’ is NOT accepted for this statistic).

      or an ITimeStep identifying the time to get the limits

      or an int identifying the time step index to be used based on the global time set

  • Return type: float or None
  • Returns: Returns a the variance of the grid function or None if it’s not available for the current time.

Connect with Ansys