SimPEG.utils.index_cube#

SimPEG.utils.index_cube(nodes, grid_shape, n=None)[source]#

Returns the index of nodes on a tensor (or curvilinear) mesh.

For 2D tensor meshes, each cell is defined by nodes A, B, C and D. And for 3D tensor meshes, each cell is defined by nodes A through H (see below). index_cube outputs the indices for the specified node(s) for all cells in the mesh.

TWO DIMENSIONS:

node(i,j+1)      node(i+i,j+1)
     B -------------- C
     |                |
     |    cell(i,j)   |
     |        I       |
     |                |
     A -------------- D
 node(i,j)        node(i+1,j)

THREE DIMENSIONS:

   node(i,j+1,k+1)    node(i+1,j+1,k+1)
           F ---------------- G
          /|                / |
         / |               /  |
        /  |              /   |
node(i,j,k+1)     node(i+1,j,k+1)
      E --------------- H     |
      |    B -----------|---- C
      |   / cell(i,j,k) |   /
      |  /        I     |  /
      | /               | /
      A --------------- D
 node(i,j,k)     node(i+1,j,k)
Parameters
nodesstr

String specifying which nodes to return. For 2D meshes, nodes must be a string containing combinations of the characters ‘A’, ‘B’, ‘C’, or ‘D’. For 3D meshes, nodes can also be ‘E’, ‘F’, ‘G’, or ‘H’. Note that order is preserved. E.g. if we want to return the C, D and A node indices in that particular order, we input nodes = ‘CDA’.

grid_shapelist of int

Number of nodes along the i,j,k directions; e.g. [ni,nj,nk]

nclist of int

Number of cells along the i,j,k directions; e.g. [nci,ncj,nck]

Returns
indextuple of numpy.ndarray

Each entry of the tuple is a 1D numpy.ndarray containing the indices of the nodes specified in the input nodes in the order asked; e.g. if nodes = ‘DCBA’, the tuple returned is ordered (D,C,B,A).

Examples