Mesh

class ESMF.Mesh(*args, **kwargs)
__del__()

Release the memory associated with a Mesh.

Required Arguments:

None

Optional Arguments:

None

Returns:

None
__init__(*args, **kwargs)

Create an unstructured Mesh. This can be done two different ways, as a Mesh in memory, or from a SCRIP formatted or CF compliant UGRID file. The argument for each type of Mesh creation are outlined below.

Mesh in memory:

The in-memory Mesh can be created manually in 3 steps:

  1. create the Mesh (specifying parametric_dim and spatial_dim),
  2. add nodes,
  3. add elements.

Required arguments for a Mesh in memory:

parametric_dim: the dimension of the topology of the Mesh (e.g. a Mesh composed of squares would have a parametric dimension of 2 and a Mesh composed of cubes would have a parametric dimension of 3).

spatial_dim: the number of coordinate dimensions needed to describe the locations of the nodes making up the Mesh. For a manifold the spatial dimension can be larger than the parametric dimension (e.g. the 2D surface of a sphere in 3D space), but it cannot be smaller.

Optional arguments for creating a Mesh in memory:

None

Mesh from file:

Note that Meshes created from file do not have the parametric_dim and spatial dim set. Required arguments for creating a Mesh from file:

filename: the name of NetCDF file containing the Mesh.

filetype: the input file type of the Mesh.

Argument values are:

FileFormat.SCRIP

FileFormat.ESMFMESH

FileFormat.UGRID

Optional arguments for creating a Mesh from file:

convert_to_dual: a boolean value to specify if the dual
Mesh should be calculated. Defaults to True. This argument is only supported with filetype FileFormat.SCRIP.
add_user_area: a boolean value to specify if an area
property should be added to the mesh. This argument is only supported for filetype FileFormat.SCRIP or FileFormat.ESMFMESH. Defaults to False.
meshname: a string value specifying the name of the
Mesh metadata variable in a UGRID file. This argument is only supported with filetype FileFormat.UGRID. Defaults to the empty string.
add_mask: a boolean value to specify if a mask in a UGRID file
should be added to the Mesh. This argument is only supported with filetype FileFormat.UGRID. Defaults to False.
varname: a string to specify a variable name for the mask in a
UGRID file if add_mask is True. This argument is only supported for filetype FileFormat.UGRID. Defaults to the empty string.

Returns:

Mesh
add_elements(element_count, element_ids, element_types, element_conn, element_mask=None, element_area=None)

Add elements to a Mesh, this must be done after adding nodes.

Required Arguments:

element_count: the number of elements to add to the Mesh.

element_ids: a numpy array (internally cast to

dtype=numpy.int32) to specify the element_ids.

type: numpy.array

shape: (element_count, 1)

element_types: a numpy array (internally cast to

dtype=numpy.int32) to specify the element_types.

type: numpy.array

shape: (element_count, 1)

Argument values are:

MeshElemType.TRI

MeshElemType.QUAD

MeshElemType.TETRA

MeshElemType.HEX

element_conn: a numpy array (internally cast to

dtype=numpy.int32) to specify the connectivity of the Mesh. The connectivity array is constructed by concatenating the tuples that correspond to the element_ids. The connectivity tuples are constructed by listing the node_ids of each element in COUNTERCLOCKWISE order.

type: numpy.array

shape: (sum(element_types[:], 1)

Optional Arguments:

element_mask: a numpy array (internally cast to

dtype=numpy.int32) containing integer values to specify masked elements. The specific values that are masked are specified in the Regrid() constructor.

type: numpy.array

shape: (element_count, 1)

element_area: a numpy array (internally cast to

dtype=numpy.float64) to specify the areas of the elements.

type: numpy.array

shape: (element_count, 1)

Returns:

None
add_nodes(node_count, node_ids, node_coords, node_owners)

Add nodes to a Mesh, this must be done before adding elements.

Required Arguments:

node_count: the number of nodes to add to the Mesh.

node_ids: a numpy array (internally cast to

dtype=numpy.int32) to specify the node_ids.

type: numpy.array

shape: (node_count, 1)

node_coords: a numpy array (internally cast to

dtype=numpy.float64) to specify the coordinates of the Mesh. The array should be constructed by concatenating the coordinate tuples into a numpy array that correspond to node_ids.

type: numpy.array

shape: (spatial_dim*node_count, 1)

node_owners: a numpy array (internally cast to

dtype=numpy.int32) to specify the rank of the processor that owns each node.

type: numpy.array

shape: (node_count, 1)

Optional Arguments:

None

Returns:

None
free_memory()

Free memory associated with the creation of a Mesh which is no longer needed.

Required Arguments:

None

Optional Arguments:

None

Returns:

None
get_coords(coord_dim, meshloc=0)

Return a numpy array of coordinates at a specified Mesh location (coordinates can only be returned for the Mesh NODES at this time). The returned array is NOT a copy, it is directly aliased to the underlying memory allocated by ESMF.

Required Arguments:

coord_dim: the dimension number of the coordinates to return:
e.g. [x, y, z] = (0, 1, 2), or [lat, lon] = (0, 1)

Optional Arguments:

meshloc: the mesh location of the coordinates.

Argument values are:

node=0 (default)

element=1 (not implemented)

Returns:

None

This Page