discretize.base.BaseRectangularMesh.reshape

BaseRectangularMesh.reshape(x, x_type='cell_centers', out_type='cell_centers', format='V', **kwargs)[source]

General reshape method for tensor quantities

Reshape is a quick command that will do its best to reshape discrete quantities living on meshes than inherit the discretize.base_mesh.RectangularMesh class. For example, you may have a 1D array defining a vector on mesh faces, and you would like to extract the x-component and reshaped it to a 3D matrix.

Parameters
xnumpy.ndarray or list of numpy.ndarray

The input quantity. , ndarray (tensor) or a list

x_type{‘CC’, ‘N’, ‘F’, ‘Fx’, ‘Fy’, ‘Fz’, ‘E’, ‘Ex’, ‘Ey’, ‘Ez’}

Defines the locations on the mesh where input parameter x lives.

out_typestr

Defines the output quantity. Choice depends on your input for x_type:

  • x_type = ‘CC’ —> out_type = ‘CC’

  • x_type = ‘N’ —> out_type = ‘N’

  • x_type = ‘F’ —> out_type = {‘F’, ‘Fx’, ‘Fy’, ‘Fz’}

  • x_type = ‘E’ —> out_type = {‘E’, ‘Ex’, ‘Ey’, ‘Ez’}

formatstr

The dimensions of quantity being returned

  • V: return a vector (1D array) or a list of vectors

  • M: return matrix (nD array) or a list of matrices