iota.mesh

Description

This module provides functionalities to operate with data from the meshes.

CFD mesh class object. This object is returned when getting a mesh from a CFD dataset using Dataset.get_mesh method.

Parameters

  • id: (int) id for the mesh

  • name: (str) name for the mesh

Example

my_mesh = iota.mesh.CFDMesh(0,'my_mesh')

Methods

Add a new cell defined by a list of faces

Parameters

  • type : (CFDMesh.CellType) the type of the cell

  • faces : (list of FaceHandle) a list of faces

Examples

Adding a cell of type hexahedron defined by a list of faces

my_mesh.add_cell_faces(iota.mesh.CellType.HEXAHEDRON,list_of_faces)

Adding a cell of type polyhedron defined by a list of faces

my_mesh.add_cell_faces(iota.mesh.CellType.POLYHEDRON,list_of_faces)

Add a new face defined by a list of vertices

Parameters

  • vertices : (list of VertexHandle) a list of vertices

  • id : (int) identifier of the face

Examples

Adding a cell of type hexahedron defined by a list of faces

my_mesh.add_cell_faces(iota.mesh.CellType.HEXAHEDRON,list_of_faces)

Adding a cell of type polyhedron defined by a list of faces

my_mesh.add_cell_faces(iota.mesh.CellType.POLYHEDRON,list_of_faces)

Add a single new vertex to the mesh

Parameters

  • vertex : (iota.Vector3) vertex position (x,y,z)

  • id : (int) id for the vertex

Example

my_mesh.add_vertex(iota.Vector3(0,0,0), 1)

Add a set of new vertices to the mesh

Parameters

  • vertices : (numpy.ndarray of floats) An array with the position (x,y,z) of the vertices

Example

Adding two new vertices to the mesh

ArrayOfVertices = numpy.array([(0.5,0.5,0.5), (1.3,2.8, 2.9)])
my_mesh.add_vertices(ArrayOfVertices)

Get the id of the vertices of a cell given its id

Parameters

  • id : (int) index of cell

Returns

  • A numpy.ndarray of integers that contains the id of the vertices of the cell

Example

Getting the ids of the vertices of the cell with id = 5

vertices = my_mesh.cell(id=5)
print(vertices)

Get the coordinates of the centre of a cell given its id

Parameters

  • id : (int) index of cell

Returns

  • A numpy.ndarray of floats that contains the position (x,y,z) of the centre of the cell

Example

Getting the coordinates of the centre of the cell with id = 5

cell_centre = my_mesh.cell_center(id=5)
print(cell_centre)

Get the coordinates of the centres of all cells

Returns

  • A numpy.ndarray of floats that contains, per row, the position (x,y,z) of the cells

Example

cell_centres = my_mesh.cell_centers()
print(cell_centres)

Get the id of the faces of a cell given its id

Parameters

  • id : (int) index of cell

Returns

  • A numpy.ndarray of integers that contains the id of the faces of the cell

Example

Getting the id of the faces of the cell with id = 5

faces = my_mesh.cell_face(id=5)
print(faces)

Get the id of the cells in the mesh

Returns

  • A numpy.ndarray of integers that contains the id of cells

Example

id_cells = my_mesh.cell_ids()
print(id_cells)

Get the id of the cells that are neighbors of a cell given its id

Parameters

  • id : (int) index of cell

Returns

  • A numpy.ndarray of integers that contains the id of the cells

Example

Getting the id of the cells that are neighbors of the cell with id = 5

cells_neighbors = my_mesh.cell_neighbours(id=5)
print(cells_neighbors)

Get a list of the cells occupying a particular point in space

Parameters

  • point_coordinates : (iota.Vector3d) coordinates (x,y,z) of the point

  • cell_list : (list of integers) handles of the cells to interrogate (default: all cells)

Returns

  • A list of integers containing the handles of the cells that occupy that point in space

cell_owners = my_mesh.cell_owners(point_coordinates=iota.Vector3d(0.1, 0.2, 0.3))
print(cell_owners)

Get the number of cells in the mesh

Parameters

  • id : (int) index of cell

Returns

  • A integer that represents number of cells in the mesh

Example

Getting the size of the cells with id = 5

size_of_cell = my_mesh.cell_size(id=5)
print(size_of_cell)

Get the type of a cell given its id

Parameters

  • id : (int) index of cell

Returns

  • A iota.mesh.CellType that represents the type of the cell

Example

Getting the type of the cell with id = 5

type_of_cell = my_mesh.cell_type(id=5)
print(type_of_cell)

Get the volume of a cell given its id

Parameters

  • id : (int) index of cell

Returns

  • A float that represents the volume of the cell

Example

Getting the volume of the cell with id = 5

volume_of_cell = my_mesh.cell_volume(id=5)
print(volume_of_cell)

Get the id of the cells around a vertex given its id

Parameters

  • id : (int) index of the vertex

Returns

  • A numpy.ndarray of integers with the id of the cells

Example

Getting the id of the cells around the vertex with id = 5

id_cells = my_mesh.cells_around_vertex(id=5)
print(id_cells)

Check if the faces of the boundary of the mesh have consistent pointing normal vectors

Returns

  • A tuple of

    • A bool that is True if the faces have consistent pointing normal vectors

    • A bool that is True if the normal vectors point inwards

Example

Getting the id of the cells around the vertex with id = 5

id_cells = my_mesh.cells_around_vertex(id=5)
print(id_cells)

Get the dimension of the mesh

Returns

  • A integer that represents the dimension of the mesh:

    • 0: point mesh

    • 1 : line segments

    • 2 : surface mesh

    • 3 : volume mesh

Example

mesh_dimension = my_mesh.dimension()
print(mesh_dimension)

Get the id of the vertices of an edge given its id

Parameters

  • id : (int) index of edge

Returns

  • A numpy.ndarray of integers that contains the id of the vertices of the edge

Example

Getting the ids of the vertices of the edge with id = 5

vertices_edge = my_mesh.edge(5)
print(vertices_edge)

Get the id of the edges in the mesh

Returns

  • A numpy.ndarray of integers that contains the id of the edges

Example

id_edges = my_mesh.edge_ids()
print(id_edges)

Get the number of edges in the mesh

Returns

  • An integer the corresponds to the number of edges

Example

number_edges = my_mesh.edge_size()
print(number_edges)

Get the number of edges in the mesh

Returns

  • An integer the corresponds to the number of edges

Example

number_edges = my_mesh.edge_size()
print(number_edges)

Get the pair of vertices id for all the edges in the mesh

Returns

  • A numpy.ndarray of integers that contains a pair of vertices id for each edge

Example

id_vertices_edges = my_mesh.edges()
print(id_vertices_edges)

Get the id of the vertices of a face given its id

Parameters

  • id : (int) index of the face

Returns

  • A numpy.ndarray of integers that contains the id of the vertices of the face

Example

Getting the ids of the vertices of the face with id = 5

vertices_face = my_mesh.face(5)
print(vertices_face)

Get the area of a face given its id

Parameters

  • id : (int) index of the face

Returns

  • A float that represents the area of the face

Example

Getting the area of the face with id = 5

area_face = my_mesh.face_area(5)
print(area_face)

Get the cell(s) that limit with a face given its id

Parameters

  • id : (int) index of the face

Returns

  • A list of integers that contains the id of the cells that limit with the face

Example

Getting the cells that limit with the face with id = 5

cell_neighbours = my_mesh.face_cell_neighbour(5)
print(cell_neighbours)

Get the centroid of a face given its id

Parameters

  • id : (int) index of the face

Returns

  • A numpy.ndarray of floats that contains the position (x,y,z) of the centroid of the face

Example

Getting the coordinates of the centroid of the face with id = 5

face_centroid = my_mesh.face_centroid(5)
print(face_centroid)

Get the centroids of all faces

Returns

  • A numpy.ndarray of floats that contains, per row, the position (x,y,z) of the centroids of all the faces

Example

face_centroids = mesh.face_centroids()
print(face_centroids)

Get the id of the faces in the mesh

Returns

  • A numpy.ndarray of integers that contains the id of the faces

Example

id_faces = my_mesh.face_ids()
print(id_faces)

Get the id of the faces that are neighbors of a face given its id

Parameters

  • id : (int) index of the face

Returns

  • A numpy.ndarray of integers that contains the id of the faces

Example

Getting the id of the faces that are neighbors of the face with id = 5

neighbours_face = my_mesh.face_neighbours(5)
print(neighbours_face)

Get the number the faces in the mesh

Returns

  • A integer that represents the number of faces

Example

number_faces = my_mesh.face_size()
print(number_faces)

Get the mesh that represents the isosurface for a constant value of a given an array of values of a variable

Parameters

  • variable : (numpy.ndarray of floats) array of values. Note the that the size of the values of the variable must be equal to the number of vertices of the input CFDMesh.

  • value: (float) constant value of variable for the calculation of the isosurface

Returns

  • A iota.CFDMesh object that contains the mesh that represents the isosurface

Example

Getting the isosurface mesh from the mesh called 'my_mesh' and based on the values of the result-analysis 'PRESSURE'-'phase-1' and a constant value of result equal to 0.0

my_cfd_mesh = my_dataset.get_mesh('my_mesh')
variable_values = my_dataset.get_result(step=0, mesh='my_mesh', result='PRESSURE', analysis='phase-1')
my_cfd_mesh.isosurface(varaibale=variable_values, value=0.0)

Get the mesh that represents the skin of a volume mesh

Returns

  • A iota.CFDMesh object that contains the mesh representing the skin of the volume mesh

Example

Getting the skin of the volume mesh

skin_mesh = my_mesh.skin()

Get a mesh that represents a slice of a volume mesh given the normal vector (nx,ny,nz ) and the position (x,y,z) of the origin that define the slice

Parameters

  • normal: (list of floats) normal vector (nx,ny,nz ) of the slice

  • origin: (list of float) position (x,y,z) of the slice

Returns

  • A iota.CFDMesh object that contains the mesh representing the slice

Example

Getting a slice with normal vector pointing the z-axis and centered at position (0,0,0)

new_slice = my_mesh.slice(normal=[0,0,1], origin=[0,0,0])
print(new_slice)

Get the position (x,y,z) of a vertex given its id

Parameters

  • id: (int) index of the vertex

Returns

  • A numpy.ndarray of floats with the position (x,y,z) of the vertex

Example

Getting the position of the vertex with id=5

vertex_position = my_mesh.vertex(id=5)
print(vertex_position)

Get the id of the all the vertices in the mesh

Returns

  • A numpy.ndarray of integers with the id of the vertices

Example

Getting the id of the vertices of the mesh

vertices_ids = my_mesh.vertex_ids()
print(vertices_ids)

Get the number of vertices in the mesh

Returns

  • An integer that represents the number of vertices in the mesh

Example

Getting the number of the vertices in the mesh

number_vertices = my_mesh.vertex_size()
print(number_vertices)

Get the positions (x,y,z) of all the vertices in the mesh

Returns

  • An numpy.ndarray of floats that contains the positions (x,y,z) of the vertices

Example

Getting the positions of the vertices in 'my_mesh'

vertices_positions = my_mesh.vertices()
print(vertices_positions)

Get the volume/area of a volume/surface mesh.

Returns

  • A float that represents the volume/area of the volume/surface mesh

Example

Getting the volume of a volume mesh

volume = my_volume_mesh.volume()
print(volume)

Getting the area of a surface mesh

area = my_surface_mesh.volume()
print(area)

Load a mesh list from file

*Returns a list of meshes

Arguments

  • filename: (str) file containing the meshes to me readed

  • split: (bool) split meshes by connectivities (default: True)

Example

meshes = iota.mesh.load(
    filename = 'my_username',
    split = True
)
print(meshes)

Export a mesh to file

Arguments

  • mesh: (iota.mesh.Mesh) mesh object to be exported

  • filename: (str) file to write the mesh

  • format: (iota.mesh.export_format) mesh format for to written (default: P4S)

Example

status = iota.mesh.export(
    mesh = myMesh,
    filename = '/file/to/write/the/mesh/mesh.meta',
    format = iota.mesh.export_format.P4S
)
print('mesh is ok: ',status)

Create a linear mesh of edges

Arguments

  • start: (iota.Vector3d) point representing the origin of the line

  • end: (iota.Vector3d) point representing the end of the line

  • element_size: (float) size of the triangular elements

  • name: (str) name of the mesh (default: 'line')

Example

line = iota.mesh.create_line(
    start = iota.Vector3d(0,0,0),
    end = iota.Vector3d(1,1,0),
    element_size = 0.1,
    name = 'my_linear_mesh'
)

Create a circular mesh of triangles

Arguments

  • centre: (iota.Vector3d) point representing the centre of the circle

  • radius: (float) radius of the circle

  • normal: (iota.Vector3d) normal vector representing the plane of the circle

  • element_size: (float) size of the triangular elements

  • name: (str) name of the mesh (default: 'circle')

Example

circle = iota.mesh.create_circle(
    centre = iota.Vector3d(0,0,0),
    radius = 1.0,
    normal = iota.Vector3d(0,0,1),
    element_size = 0.1,
    name = 'my_circle'
)

Create a rectangular mesh of triangles

Arguments

  • origin: (iota.Vector3d) point representing the origin of the rectangle

  • normal: (iota.Vector3d) normal vector representing the plane of the rectangle

  • length: (float) length of the rectangle

  • width: (float) width of the rectangle

  • element_size: (float) size of the triangular elements

  • name: (str) name of the mesh (default: 'rectangle')

Example

rectangle = iota.mesh.create_rectangle(
    origin = iota.Vector3d(0,0,0),
    normal = iota.Vector3d(0,0,1),
    length = 1.0,
    width = 1.0,
    element_size = 0.1,
    name = 'my_rectangle'
)

Create a cuboid mesh of tetrahedra

Arguments

  • origin: (iota.Vector3d) point representing the origin of the cuboid

  • up: (iota.Vector3d) vector representing the up direction of the cuboid

  • length: (float) length of the cuboid

  • width: (float) width of the cuboid

  • height: (float) height of the cuboid

  • element_size: (float) size of the elements

  • name: (str) name of the mesh (default: 'cuboid')

  • skin: (bool) generate the surface instead of volume (default: False)

Example

cuboid = iota.mesh.create_cuboid(
    origin = iota.Vector3d(0,0,0),
    up = iota.Vector3d(0,0,1),
    length = 1.0,
    width = 1.0,
    height = 1.0,
    element_size = 0.1,
    name = 'my_cuboid'
)

Create a cylinder mesh of tetrahedra

Arguments

  • origin: (iota.Vector3d) point representing the origin of the cylinder

  • up: (iota.Vector3d) vector representing the up direction of the cylinder

  • radius: (float) radius of the cylinder

  • height: (float) height of the cylinder

  • element_size: (float) size of the elements

  • name: (str) name of the mesh (default: 'cylinder')

  • skin: (bool) generate the surface instead of volume (default: False)

Example

cylinder = iota.mesh.create_cylinder(
    origin = iota.Vector3d(0,0,0),
    up = iota.Vector3d(0,0,1),
    radius = 1.0,
    height = 1.0,
    element_size = 0.1,
    name = 'my_cylinder'
)

Last updated