Get extent of gridpoints

Hi,
any hint for how to get the values for minimum and maximum gp extent via a fish command?
I can read them using the ‘zone list summary’ command

flac3d>zone list summary
    Number of Gps : 336633
Maximum Gp Extent : (4.66635000e+05,6.56261700e+06,-1.20501872e+02)
Minimum Gp Extent : (4.61635000e+05,6.55761700e+06,-3.00000000e+03)
Maximum Gp Displ. : 0.00000000e+00
  Number of Zones : 320000
 Max. Zone Volume : 5.32443736e+05
 Min. Zone Volume : 9.28385223e+03
 Max. Zone Stress : 0.00000000e+00
 Min. Zone Stress : 0.00000000e+00
  Number of Attaches : 0
Number of Interfaces : 0

But would like to get them dynamically.
Thanks,
Julia

Hi @JuDi !

A Fish function relying on gridpoint functions would be:

def get_extent
    local xmin = 1e12 ; A really huge value
    local ymin = xmin 
    local zmin = xmin 
    local xmax = -1e12 ; A really small value
    local ymax = xmax 
    local zmax = xmax 
    loop foreach local gppnt gp.list
        xmin = math.min(xmin, gp.pos(gppnt)->x)
        ymin = math.min(ymin, gp.pos(gppnt)->y)
        zmin = math.min(zmin, gp.pos(gppnt)->z)
        xmax = math.max(xmax, gp.pos(gppnt)->x)
        ymax = math.max(ymax, gp.pos(gppnt)->y)
        zmax = math.max(zmax, gp.pos(gppnt)->z)
    end_loop
    get_extent = list.seq(vector(xmin,ymin,zmin), vector(xmax,ymax,zmax))
end

Then, running the command [extent = get_extent] in Flac3D console will store 2 vectors in the extent variable: extent(1) is the vector with minimum x, y, and z of gridpoints, and extent(2) stores the max values.

Another option would be to use splitting:

def get_extent2
    local extent_min = vector(list.min(gp.pos(::gp.list)->x),list.min(gp.pos(::gp.list)->y),list.min(gp.pos(::gp.list)->z))
    local extent_max = vector(list.max(gp.pos(::gp.list)->x),list.max(gp.pos(::gp.list)->y),list.max(gp.pos(::gp.list)->z))
    get_extent2 = list.seq(extent_min, extent_max)
end

Alternatively, you could take advantage of the Python API. In a Python console, this should do the trick:

import itasca as it

# Contains xmin, ymin, zmin
min_ext = it.gridpointarray.pos().min(axis=0)
# Contains xmax, ymax, zmax
max_ext = it.gridpointarray.pos().max(axis=0)

Cheers!

Théophile

1 Like

Hi Théophile,

very much appreciated. I was hoping for something like the splitting to avoid the looping over all grid points. Great!
Julia

Glad it helped!

Splitting is powerful indeed!
It might not be the fastest one, though, if performance matters (see multithreading section on official page).

Cheers

Théophile